xref: /aoo42x/main/sc/source/ui/view/output3.cxx (revision 77bc49c4)
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 //==================================================================
49 
50 // #i72502#
PrePrintDrawingLayer(long nLogStX,long nLogStY)51 Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY )
52 {
53 	Rectangle aRect;
54 	SCCOL nCol;
55 	Point aOffset;
56 	long nLayoutSign(bLayoutRTL ? -1 : 1);
57 
58 	for (nCol=0; nCol<nX1; nCol++)
59 		aOffset.X() -= pDoc->GetColWidth( nCol, nTab ) * nLayoutSign;
60     aOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nTab );
61 
62 	long nDataWidth = 0;
63 	long nDataHeight = 0;
64 	for (nCol=nX1; nCol<=nX2; nCol++)
65 		nDataWidth += pDoc->GetColWidth( nCol, nTab );
66     nDataHeight += pDoc->GetRowHeight( nY1, nY2, nTab );
67 
68 	if ( bLayoutRTL )
69 		aOffset.X() += nDataWidth;
70 
71 	aRect.Left() = aRect.Right()  = -aOffset.X();
72 	aRect.Top()  = aRect.Bottom() = -aOffset.Y();
73 
74 	Point aMMOffset( aOffset );
75 	aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
76 	aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
77 
78 	if (!bMetaFile)
79 		aMMOffset += Point( nLogStX, nLogStY );
80 
81 	for (nCol=nX1; nCol<=nX2; nCol++)
82 		aRect.Right() += pDoc->GetColWidth( nCol, nTab );
83     aRect.Bottom() += pDoc->GetRowHeight( nY1, nY2, nTab );
84 
85 	aRect.Left()   = (long) (aRect.Left()   * HMM_PER_TWIPS);
86 	aRect.Top()    = (long) (aRect.Top()    * HMM_PER_TWIPS);
87 	aRect.Right()  = (long) (aRect.Right()  * HMM_PER_TWIPS);
88 	aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS);
89 
90 	if(pViewShell || pDrawView)
91 	{
92 		SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
93 
94 		if(pLocalDrawView)
95 		{
96             // #i76114# MapMode has to be set because BeginDrawLayers uses GetPaintRegion
97             MapMode aOldMode = pDev->GetMapMode();
98             if (!bMetaFile)
99                 pDev->SetMapMode( MapMode( MAP_100TH_MM, aMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
100 
101 			// #i74769# work with SdrPaintWindow directly
102             // #i76114# pass bDisableIntersect = true, because the intersection of the table area
103             // with the Window's paint region can be empty
104 			Region aRectRegion(aRect);
105             mpTargetPaintWindow = pLocalDrawView->BeginDrawLayers(pDev, aRectRegion, true);
106 			OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
107 
108             if (!bMetaFile)
109                 pDev->SetMapMode( aOldMode );
110 		}
111 	}
112 
113 	return aMMOffset;
114 }
115 
116 // #i72502#
PostPrintDrawingLayer(const Point & rMMOffset)117 void ScOutputData::PostPrintDrawingLayer(const Point& rMMOffset) // #i74768#
118 {
119 	// #i74768# just use offset as in PrintDrawingLayer() to also get the form controls
120 	// painted with offset
121 	MapMode aOldMode = pDev->GetMapMode();
122 
123 	if (!bMetaFile)
124 	{
125 		pDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
126 	}
127 
128 	if(pViewShell || pDrawView)
129 	{
130 		SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
131 
132 		if(pLocalDrawView)
133 		{
134 			// #i74769# work with SdrPaintWindow directly
135 			pLocalDrawView->EndDrawLayers(*mpTargetPaintWindow, true);
136 			mpTargetPaintWindow = 0;
137 		}
138 	}
139 
140 	// #i74768#
141 	if (!bMetaFile)
142 	{
143 		pDev->SetMapMode( aOldMode );
144 	}
145 }
146 
147 // #i72502#
PrintDrawingLayer(const sal_uInt16 nLayer,const Point & rMMOffset)148 void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset)
149 {
150     bool bHideAllDrawingLayer(false);
151 
152 	if(pViewShell || pDrawView)
153 	{
154 		SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
155 
156 		if(pLocalDrawView)
157 		{
158             bHideAllDrawingLayer = pLocalDrawView->getHideOle() && pLocalDrawView->getHideChart()
159                     && pLocalDrawView->getHideDraw() && pLocalDrawView->getHideFormControl();
160         }
161     }
162 
163 	// #109985#
164 	if(bHideAllDrawingLayer || (!pDoc->GetDrawLayer()))
165 	{
166 		return;
167 	}
168 
169 	MapMode aOldMode = pDev->GetMapMode();
170 
171 	if (!bMetaFile)
172 	{
173 		pDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
174 	}
175 
176 	// #109985#
177 	DrawSelectiveObjects( nLayer );
178 
179 	if (!bMetaFile)
180 	{
181 		pDev->SetMapMode( aOldMode );
182 	}
183 }
184 
185 // #109985#
DrawSelectiveObjects(const sal_uInt16 nLayer)186 void ScOutputData::DrawSelectiveObjects(const sal_uInt16 nLayer)
187 {
188 	ScDrawLayer* pModel = pDoc->GetDrawLayer();
189 	if (!pModel)
190 		return;
191 
192     //  #i46362# high contrast mode (and default text direction) must be handled
193     //  by the application, so it's still needed when using DrawLayer().
194 
195     SdrOutliner& rOutl = pModel->GetDrawOutliner();
196     rOutl.EnableAutoColor( bUseStyleColor );
197     rOutl.SetDefaultHorizontalTextDirection(
198                 (EEHorizontalTextDirection)pDoc->GetEditTextDirection( nTab ) );
199 
200     //  #i69767# The hyphenator must be set (used to be before drawing a text shape with hyphenation).
201     //  LinguMgr::GetHyphenator (EditEngine) uses a wrapper now that creates the real hyphenator on demand,
202     //  so it's not a performance problem to call UseHyphenator even when it's not needed.
203 
204     pModel->UseHyphenator();
205 
206     sal_uLong nOldDrawMode = pDev->GetDrawMode();
207     if ( bUseStyleColor && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
208     {
209         pDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
210                             DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
211     }
212 
213 	// #109985#
214 	if(pViewShell || pDrawView)
215 	{
216 		SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
217 
218 		if(pLocalDrawView)
219 		{
220 			SdrPageView* pPageView = pLocalDrawView->GetSdrPageView();
221 
222 			if(pPageView)
223 			{
224                 pPageView->DrawLayer(sal::static_int_cast<SdrLayerID>(nLayer), pDev);
225 			}
226 		}
227 	}
228 
229     pDev->SetDrawMode(nOldDrawMode);
230 
231 	// #109985#
232 	return;
233 }
234 
235 //	Teile nur fuer Bildschirm
236 
237 // #109985#
DrawingSingle(const sal_uInt16 nLayer)238 void ScOutputData::DrawingSingle(const sal_uInt16 nLayer)
239 {
240 	sal_Bool	bHad	= sal_False;
241 	long	nPosY	= nScrY;
242 	SCSIZE	nArrY;
243 	for (nArrY=1; nArrY+1<nArrCount; nArrY++)
244 	{
245 		RowInfo* pThisRowInfo = &pRowInfo[nArrY];
246 
247 		if ( pThisRowInfo->bChanged )
248 		{
249 			if (!bHad)
250 			{
251 				bHad = sal_True;
252 			}
253 		}
254 		else if (bHad)
255 		{
256 			DrawSelectiveObjects( nLayer );
257 			bHad = sal_False;
258 		}
259 		nPosY += pRowInfo[nArrY].nHeight;
260 	}
261 
262 	if (bHad)
263 		DrawSelectiveObjects( nLayer );
264 }
265 
266 
267 
268 
269