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