xref: /aoo41x/main/sc/source/ui/view/output3.cxx (revision b3f79822)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 // INCLUDE ---------------------------------------------------------------
30 
31 #include <editeng/eeitem.hxx>
32 #include <svx/svdograf.hxx>
33 #include <svx/svdoole2.hxx>
34 #include <svx/svdoutl.hxx>
35 #include <svx/svdpage.hxx>
36 #include <svx/svdpagv.hxx>
37 #include <svx/svdview.hxx>
38 #include <vcl/svapp.hxx>
39 
40 #include "output.hxx"
41 #include "drwlayer.hxx"
42 #include "document.hxx"
43 #include "tabvwsh.hxx"
44 #include "fillinfo.hxx"
45 
46 #include <svx/fmview.hxx>
47 
48 // STATIC DATA -----------------------------------------------------------
49 
50 SdrObject* pSkipPaintObj = NULL;
51 
52 //==================================================================
53 
54 // #i72502#
55 Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY )
56 {
57 	Rectangle aRect;
58 	SCCOL nCol;
59 	Point aOffset;
60 	long nLayoutSign(bLayoutRTL ? -1 : 1);
61 
62 	for (nCol=0; nCol<nX1; nCol++)
63 		aOffset.X() -= pDoc->GetColWidth( nCol, nTab ) * nLayoutSign;
64     aOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nTab );
65 
66 	long nDataWidth = 0;
67 	long nDataHeight = 0;
68 	for (nCol=nX1; nCol<=nX2; nCol++)
69 		nDataWidth += pDoc->GetColWidth( nCol, nTab );
70     nDataHeight += pDoc->GetRowHeight( nY1, nY2, nTab );
71 
72 	if ( bLayoutRTL )
73 		aOffset.X() += nDataWidth;
74 
75 	aRect.Left() = aRect.Right()  = -aOffset.X();
76 	aRect.Top()  = aRect.Bottom() = -aOffset.Y();
77 
78 	Point aMMOffset( aOffset );
79 	aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
80 	aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
81 
82 	if (!bMetaFile)
83 		aMMOffset += Point( nLogStX, nLogStY );
84 
85 	for (nCol=nX1; nCol<=nX2; nCol++)
86 		aRect.Right() += pDoc->GetColWidth( nCol, nTab );
87     aRect.Bottom() += pDoc->GetRowHeight( nY1, nY2, nTab );
88 
89 	aRect.Left()   = (long) (aRect.Left()   * HMM_PER_TWIPS);
90 	aRect.Top()    = (long) (aRect.Top()    * HMM_PER_TWIPS);
91 	aRect.Right()  = (long) (aRect.Right()  * HMM_PER_TWIPS);
92 	aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS);
93 
94 	if(pViewShell || pDrawView)
95 	{
96 		SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
97 
98 		if(pLocalDrawView)
99 		{
100             // #i76114# MapMode has to be set because BeginDrawLayers uses GetPaintRegion
101             MapMode aOldMode = pDev->GetMapMode();
102             if (!bMetaFile)
103                 pDev->SetMapMode( MapMode( MAP_100TH_MM, aMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
104 
105 			// #i74769# work with SdrPaintWindow directly
106             // #i76114# pass bDisableIntersect = true, because the intersection of the table area
107             // with the Window's paint region can be empty
108 			Region aRectRegion(aRect);
109             mpTargetPaintWindow = pLocalDrawView->BeginDrawLayers(pDev, aRectRegion, true);
110 			OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
111 
112             if (!bMetaFile)
113                 pDev->SetMapMode( aOldMode );
114 		}
115 	}
116 
117 	return aMMOffset;
118 }
119 
120 // #i72502#
121 void ScOutputData::PostPrintDrawingLayer(const Point& rMMOffset) // #i74768#
122 {
123 	// #i74768# just use offset as in PrintDrawingLayer() to also get the form controls
124 	// painted with offset
125 	MapMode aOldMode = pDev->GetMapMode();
126 
127 	if (!bMetaFile)
128 	{
129 		pDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
130 	}
131 
132 	if(pViewShell || pDrawView)
133 	{
134 		SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
135 
136 		if(pLocalDrawView)
137 		{
138 			// #i74769# work with SdrPaintWindow directly
139 			pLocalDrawView->EndDrawLayers(*mpTargetPaintWindow, true);
140 			mpTargetPaintWindow = 0;
141 		}
142 	}
143 
144 	// #i74768#
145 	if (!bMetaFile)
146 	{
147 		pDev->SetMapMode( aOldMode );
148 	}
149 }
150 
151 // #i72502#
152 void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset)
153 {
154     bool bHideAllDrawingLayer(false);
155 
156 	if(pViewShell || pDrawView)
157 	{
158 		SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
159 
160 		if(pLocalDrawView)
161 		{
162             bHideAllDrawingLayer = pLocalDrawView->getHideOle() && pLocalDrawView->getHideChart()
163                     && pLocalDrawView->getHideDraw() && pLocalDrawView->getHideFormControl();
164         }
165     }
166 
167 	// #109985#
168 	if(bHideAllDrawingLayer || (!pDoc->GetDrawLayer()))
169 	{
170 		return;
171 	}
172 
173 	MapMode aOldMode = pDev->GetMapMode();
174 
175 	if (!bMetaFile)
176 	{
177 		pDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
178 	}
179 
180 	// #109985#
181 	DrawSelectiveObjects( nLayer );
182 
183 	if (!bMetaFile)
184 	{
185 		pDev->SetMapMode( aOldMode );
186 	}
187 }
188 
189 // #109985#
190 void ScOutputData::DrawSelectiveObjects(const sal_uInt16 nLayer)
191 {
192 	ScDrawLayer* pModel = pDoc->GetDrawLayer();
193 	if (!pModel)
194 		return;
195 
196     //  #i46362# high contrast mode (and default text direction) must be handled
197     //  by the application, so it's still needed when using DrawLayer().
198 
199     SdrOutliner& rOutl = pModel->GetDrawOutliner();
200     rOutl.EnableAutoColor( bUseStyleColor );
201     rOutl.SetDefaultHorizontalTextDirection(
202                 (EEHorizontalTextDirection)pDoc->GetEditTextDirection( nTab ) );
203 
204     //  #i69767# The hyphenator must be set (used to be before drawing a text shape with hyphenation).
205     //  LinguMgr::GetHyphenator (EditEngine) uses a wrapper now that creates the real hyphenator on demand,
206     //  so it's not a performance problem to call UseHyphenator even when it's not needed.
207 
208     pModel->UseHyphenator();
209 
210     sal_uLong nOldDrawMode = pDev->GetDrawMode();
211     if ( bUseStyleColor && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
212     {
213         pDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
214                             DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
215     }
216 
217 	// #109985#
218 	if(pViewShell || pDrawView)
219 	{
220 		SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
221 
222 		if(pLocalDrawView)
223 		{
224 			SdrPageView* pPageView = pLocalDrawView->GetSdrPageView();
225 
226 			if(pPageView)
227 			{
228                 pPageView->DrawLayer(sal::static_int_cast<SdrLayerID>(nLayer), pDev);
229 			}
230 		}
231 	}
232 
233     pDev->SetDrawMode(nOldDrawMode);
234 
235 	// #109985#
236 	return;
237 }
238 
239 //	Teile nur fuer Bildschirm
240 
241 // #109985#
242 void ScOutputData::DrawingSingle(const sal_uInt16 nLayer)
243 {
244 	sal_Bool	bHad	= sal_False;
245 	long	nPosY	= nScrY;
246 	SCSIZE	nArrY;
247 	for (nArrY=1; nArrY+1<nArrCount; nArrY++)
248 	{
249 		RowInfo* pThisRowInfo = &pRowInfo[nArrY];
250 
251 		if ( pThisRowInfo->bChanged )
252 		{
253 			if (!bHad)
254 			{
255 				bHad = sal_True;
256 			}
257 		}
258 		else if (bHad)
259 		{
260 			DrawSelectiveObjects( nLayer );
261 			bHad = sal_False;
262 		}
263 		nPosY += pRowInfo[nArrY].nHeight;
264 	}
265 
266 	if (bHad)
267 		DrawSelectiveObjects( nLayer );
268 }
269 
270 
271 
272 
273