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