xref: /AOO41X/main/sc/source/ui/view/printfun.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 // INCLUDE ---------------------------------------------------------------
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "scitems.hxx"
34*cdf0e10cSrcweir #include <editeng/eeitem.hxx>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include "printfun.hxx"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <svx/svxids.hrc>
39*cdf0e10cSrcweir #include <editeng/adjitem.hxx>
40*cdf0e10cSrcweir #include <editeng/boxitem.hxx>
41*cdf0e10cSrcweir #include <editeng/brshitem.hxx>
42*cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
43*cdf0e10cSrcweir #include <editeng/editstat.hxx>		// EE_CNTRL_RTFSTYLESHEETS
44*cdf0e10cSrcweir #include <svx/fmview.hxx>
45*cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
46*cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
47*cdf0e10cSrcweir #include <editeng/paperinf.hxx>
48*cdf0e10cSrcweir #include <editeng/pbinitem.hxx>
49*cdf0e10cSrcweir #include <editeng/shaditem.hxx>
50*cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
51*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
52*cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
53*cdf0e10cSrcweir #include <sfx2/app.hxx>
54*cdf0e10cSrcweir #include <sfx2/printer.hxx>
55*cdf0e10cSrcweir #include <tools/multisel.hxx>
56*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
57*cdf0e10cSrcweir #include <tools/urlobj.hxx>
58*cdf0e10cSrcweir #include <svx/xoutbmp.hxx>
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir #include "editutil.hxx"
61*cdf0e10cSrcweir #include "docsh.hxx"
62*cdf0e10cSrcweir #include "output.hxx"
63*cdf0e10cSrcweir #include "viewdata.hxx"
64*cdf0e10cSrcweir #include "viewopti.hxx"
65*cdf0e10cSrcweir #include "stlpool.hxx"
66*cdf0e10cSrcweir #include "pagepar.hxx"
67*cdf0e10cSrcweir #include "attrib.hxx"
68*cdf0e10cSrcweir #include "patattr.hxx"
69*cdf0e10cSrcweir #include "docpool.hxx"
70*cdf0e10cSrcweir #include "dociter.hxx"
71*cdf0e10cSrcweir #include "cell.hxx"
72*cdf0e10cSrcweir #include "drawutil.hxx"
73*cdf0e10cSrcweir #include "globstr.hrc"
74*cdf0e10cSrcweir #include "scresid.hxx"
75*cdf0e10cSrcweir #include "sc.hrc"
76*cdf0e10cSrcweir #include "pagedata.hxx"
77*cdf0e10cSrcweir #include "printopt.hxx"
78*cdf0e10cSrcweir #include "prevloc.hxx"
79*cdf0e10cSrcweir #include "scmod.hxx"
80*cdf0e10cSrcweir #include "drwlayer.hxx"
81*cdf0e10cSrcweir #include "fillinfo.hxx"
82*cdf0e10cSrcweir #include "postit.hxx"
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir #include <vcl/lineinfo.hxx>
85*cdf0e10cSrcweir #include <tools/pstm.hxx>
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir #define ZOOM_MIN	10
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir #define GET_BOOL(set,which)   ((const SfxBoolItem&)(set)->Get((which))).GetValue()
92*cdf0e10cSrcweir #define GET_USHORT(set,which) ((const SfxUInt16Item&)(set)->Get((which))).GetValue()
93*cdf0e10cSrcweir #define GET_SHOW(set,which)   ( VOBJ_MODE_SHOW == ScVObjMode( ((const ScViewObjectModeItem&)(set)->Get((which))).GetValue()) )
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir //------------------------------------------------------------------------
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir ScPageRowEntry::ScPageRowEntry(const ScPageRowEntry& r)
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir 	nStartRow = r.nStartRow;
100*cdf0e10cSrcweir 	nEndRow	  = r.nEndRow;
101*cdf0e10cSrcweir 	nPagesX   = r.nPagesX;
102*cdf0e10cSrcweir 	if (r.pHidden && nPagesX)
103*cdf0e10cSrcweir 	{
104*cdf0e10cSrcweir 		pHidden = new sal_Bool[nPagesX];
105*cdf0e10cSrcweir 		memcpy( pHidden, r.pHidden, nPagesX * sizeof(sal_Bool) );
106*cdf0e10cSrcweir 	}
107*cdf0e10cSrcweir 	else
108*cdf0e10cSrcweir 		pHidden = NULL;
109*cdf0e10cSrcweir }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir const ScPageRowEntry& ScPageRowEntry::operator=(const ScPageRowEntry& r)
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir 	delete[] pHidden;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	nStartRow = r.nStartRow;
116*cdf0e10cSrcweir 	nEndRow	  = r.nEndRow;
117*cdf0e10cSrcweir 	nPagesX   = r.nPagesX;
118*cdf0e10cSrcweir 	if (r.pHidden && nPagesX)
119*cdf0e10cSrcweir 	{
120*cdf0e10cSrcweir 		pHidden = new sal_Bool[nPagesX];
121*cdf0e10cSrcweir 		memcpy( pHidden, r.pHidden, nPagesX * sizeof(sal_Bool) );
122*cdf0e10cSrcweir 	}
123*cdf0e10cSrcweir 	else
124*cdf0e10cSrcweir 		pHidden = NULL;
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	return *this;
127*cdf0e10cSrcweir }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir void ScPageRowEntry::SetPagesX(size_t nNew)
130*cdf0e10cSrcweir {
131*cdf0e10cSrcweir 	if (pHidden)
132*cdf0e10cSrcweir 	{
133*cdf0e10cSrcweir 		DBG_ERROR("SetPagesX nicht nach SetHidden");
134*cdf0e10cSrcweir 		delete[] pHidden;
135*cdf0e10cSrcweir 		pHidden = NULL;
136*cdf0e10cSrcweir 	}
137*cdf0e10cSrcweir 	nPagesX = nNew;
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir void ScPageRowEntry::SetHidden(size_t nX)
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir 	if ( nX < nPagesX )
143*cdf0e10cSrcweir 	{
144*cdf0e10cSrcweir 		if ( nX+1 == nPagesX )	// letzte Seite?
145*cdf0e10cSrcweir 			--nPagesX;
146*cdf0e10cSrcweir 		else
147*cdf0e10cSrcweir 		{
148*cdf0e10cSrcweir 			if (!pHidden)
149*cdf0e10cSrcweir 			{
150*cdf0e10cSrcweir 				pHidden = new sal_Bool[nPagesX];
151*cdf0e10cSrcweir 				memset( pHidden, sal_False, nPagesX * sizeof(sal_Bool) );
152*cdf0e10cSrcweir 			}
153*cdf0e10cSrcweir 			pHidden[nX] = sal_True;
154*cdf0e10cSrcweir 		}
155*cdf0e10cSrcweir 	}
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir sal_Bool ScPageRowEntry::IsHidden(size_t nX) const
159*cdf0e10cSrcweir {
160*cdf0e10cSrcweir 	return nX>=nPagesX || ( pHidden && pHidden[nX] );		//! inline?
161*cdf0e10cSrcweir }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir size_t ScPageRowEntry::CountVisible() const
164*cdf0e10cSrcweir {
165*cdf0e10cSrcweir 	if ( pHidden )
166*cdf0e10cSrcweir 	{
167*cdf0e10cSrcweir 		size_t nVis = 0;
168*cdf0e10cSrcweir 		for (size_t i=0; i<nPagesX; i++)
169*cdf0e10cSrcweir 			if (!pHidden[i])
170*cdf0e10cSrcweir 				++nVis;
171*cdf0e10cSrcweir 		return nVis;
172*cdf0e10cSrcweir 	}
173*cdf0e10cSrcweir 	else
174*cdf0e10cSrcweir 		return nPagesX;
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir //------------------------------------------------------------------------
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir long lcl_LineTotal(const SvxBorderLine* pLine)
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir 	return pLine ? ( pLine->GetOutWidth() + pLine->GetInWidth() + pLine->GetDistance() ) : 0;
182*cdf0e10cSrcweir }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir void ScPrintFunc::Construct( const ScPrintOptions* pOptions )
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir     pDocShell->UpdatePendingRowHeights( nPrintTab );
187*cdf0e10cSrcweir 	pDoc = pDocShell->GetDocument();
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	SfxPrinter* pDocPrinter = pDoc->GetPrinter();	// auch fuer Preview den Drucker nehmen
190*cdf0e10cSrcweir 	if (pDocPrinter)
191*cdf0e10cSrcweir 		aOldPrinterMode = pDocPrinter->GetMapMode();
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	//	einheitlicher MapMode ueber alle Aufrufe (z.B. Repaint !!!),
194*cdf0e10cSrcweir 	//	weil die EditEngine sonst unterschiedliche Texthoehen liefert
195*cdf0e10cSrcweir 	pDev->SetMapMode(MAP_PIXEL);
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 	pPageEndX = NULL;
198*cdf0e10cSrcweir 	pPageEndY = NULL;
199*cdf0e10cSrcweir 	pPageRows = NULL;
200*cdf0e10cSrcweir 	pBorderItem = NULL;
201*cdf0e10cSrcweir 	pBackgroundItem = NULL;
202*cdf0e10cSrcweir 	pShadowItem = NULL;
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 	pEditEngine = NULL;
205*cdf0e10cSrcweir 	pEditDefaults = NULL;
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	ScStyleSheetPool* pStylePool	= pDoc->GetStyleSheetPool();
208*cdf0e10cSrcweir 	SfxStyleSheetBase* pStyleSheet  = pStylePool->Find(
209*cdf0e10cSrcweir 											pDoc->GetPageStyle( nPrintTab ),
210*cdf0e10cSrcweir 											SFX_STYLE_FAMILY_PAGE );
211*cdf0e10cSrcweir 	if (pStyleSheet)
212*cdf0e10cSrcweir 		pParamSet = &pStyleSheet->GetItemSet();
213*cdf0e10cSrcweir 	else
214*cdf0e10cSrcweir 	{
215*cdf0e10cSrcweir 		DBG_ERROR("Seitenvorlage nicht gefunden" );
216*cdf0e10cSrcweir 		pParamSet = NULL;
217*cdf0e10cSrcweir 	}
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	if (!bState)
220*cdf0e10cSrcweir 		nZoom = 100;
221*cdf0e10cSrcweir 	nManualZoom = 100;
222*cdf0e10cSrcweir 	bClearWin = sal_False;
223*cdf0e10cSrcweir 	bUseStyleColor = sal_False;
224*cdf0e10cSrcweir 	bIsRender = sal_False;
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 	InitParam(pOptions);
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	pPageData = NULL;		// wird nur zur Initialisierung gebraucht
229*cdf0e10cSrcweir }
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
232*cdf0e10cSrcweir 							long nPage, long nDocP, const ScRange* pArea,
233*cdf0e10cSrcweir 							const ScPrintOptions* pOptions,
234*cdf0e10cSrcweir 							ScPageBreakData* pData )
235*cdf0e10cSrcweir 	:	pDocShell			( pShell ),
236*cdf0e10cSrcweir 		pPrinter			( pNewPrinter ),
237*cdf0e10cSrcweir 		pDrawView			( NULL ),
238*cdf0e10cSrcweir 		nPrintTab			( nTab ),
239*cdf0e10cSrcweir 		nPageStart			( nPage ),
240*cdf0e10cSrcweir 		nDocPages			( nDocP ),
241*cdf0e10cSrcweir 		pUserArea			( pArea ),
242*cdf0e10cSrcweir 		bState				( sal_False ),
243*cdf0e10cSrcweir 		bSourceRangeValid	( sal_False ),
244*cdf0e10cSrcweir 		bPrintCurrentTable	( sal_False ),
245*cdf0e10cSrcweir 		bMultiArea			( sal_False ),
246*cdf0e10cSrcweir 		nTabPages			( 0 ),
247*cdf0e10cSrcweir 		nTotalPages			( 0 ),
248*cdf0e10cSrcweir 		pPageData			( pData )
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir 	pDev = pPrinter;
251*cdf0e10cSrcweir 	aSrcOffset = pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), MAP_100TH_MM );
252*cdf0e10cSrcweir 	Construct( pOptions );
253*cdf0e10cSrcweir }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
256*cdf0e10cSrcweir 							long nPage, long nDocP, const ScRange* pArea,
257*cdf0e10cSrcweir 							const ScPrintOptions* pOptions )
258*cdf0e10cSrcweir 	:	pDocShell			( pShell ),
259*cdf0e10cSrcweir 		pPrinter			( NULL ),
260*cdf0e10cSrcweir 		pDrawView			( NULL ),
261*cdf0e10cSrcweir 		nPrintTab			( nTab ),
262*cdf0e10cSrcweir 		nPageStart			( nPage ),
263*cdf0e10cSrcweir 		nDocPages			( nDocP ),
264*cdf0e10cSrcweir 		pUserArea			( pArea ),
265*cdf0e10cSrcweir 		bState				( sal_False ),
266*cdf0e10cSrcweir 		bSourceRangeValid	( sal_False ),
267*cdf0e10cSrcweir 		bPrintCurrentTable	( sal_False ),
268*cdf0e10cSrcweir 		bMultiArea			( sal_False ),
269*cdf0e10cSrcweir 		nTabPages			( 0 ),
270*cdf0e10cSrcweir 		nTotalPages			( 0 ),
271*cdf0e10cSrcweir 		pPageData			( NULL )
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir 	pDev = pOutDev;
274*cdf0e10cSrcweir 	Construct( pOptions );
275*cdf0e10cSrcweir }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
278*cdf0e10cSrcweir 							 const ScPrintState& rState, const ScPrintOptions* pOptions )
279*cdf0e10cSrcweir 	:	pDocShell			( pShell ),
280*cdf0e10cSrcweir 		pPrinter			( NULL ),
281*cdf0e10cSrcweir 		pDrawView			( NULL ),
282*cdf0e10cSrcweir 		pUserArea			( NULL ),
283*cdf0e10cSrcweir 		bSourceRangeValid	( sal_False ),
284*cdf0e10cSrcweir 		bPrintCurrentTable	( sal_False ),
285*cdf0e10cSrcweir 		bMultiArea			( sal_False ),
286*cdf0e10cSrcweir 		pPageData			( NULL )
287*cdf0e10cSrcweir {
288*cdf0e10cSrcweir 	pDev = pOutDev;
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 	nPrintTab	= rState.nPrintTab;
291*cdf0e10cSrcweir 	nStartCol	= rState.nStartCol;
292*cdf0e10cSrcweir 	nStartRow	= rState.nStartRow;
293*cdf0e10cSrcweir 	nEndCol		= rState.nEndCol;
294*cdf0e10cSrcweir 	nEndRow		= rState.nEndRow;
295*cdf0e10cSrcweir 	nZoom		= rState.nZoom;
296*cdf0e10cSrcweir 	nPagesX		= rState.nPagesX;
297*cdf0e10cSrcweir 	nPagesY		= rState.nPagesY;
298*cdf0e10cSrcweir 	nTabPages	= rState.nTabPages;
299*cdf0e10cSrcweir 	nTotalPages	= rState.nTotalPages;
300*cdf0e10cSrcweir 	nPageStart	= rState.nPageStart;
301*cdf0e10cSrcweir 	nDocPages	= rState.nDocPages;
302*cdf0e10cSrcweir 	bState		= sal_True;
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir 	Construct( pOptions );
305*cdf0e10cSrcweir }
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir void ScPrintFunc::GetPrintState( ScPrintState& rState )
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir 	rState.nPrintTab	= nPrintTab;
310*cdf0e10cSrcweir 	rState.nStartCol	= nStartCol;
311*cdf0e10cSrcweir 	rState.nStartRow	= nStartRow;
312*cdf0e10cSrcweir 	rState.nEndCol		= nEndCol;
313*cdf0e10cSrcweir 	rState.nEndRow		= nEndRow;
314*cdf0e10cSrcweir 	rState.nZoom		= nZoom;
315*cdf0e10cSrcweir 	rState.nPagesX		= nPagesX;
316*cdf0e10cSrcweir 	rState.nPagesY		= nPagesY;
317*cdf0e10cSrcweir 	rState.nTabPages	= nTabPages;
318*cdf0e10cSrcweir 	rState.nTotalPages	= nTotalPages;
319*cdf0e10cSrcweir 	rState.nPageStart	= nPageStart;
320*cdf0e10cSrcweir 	rState.nDocPages	= nDocPages;
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir sal_Bool ScPrintFunc::GetLastSourceRange( ScRange& rRange ) const
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir 	rRange = aLastSourceRange;
326*cdf0e10cSrcweir 	return bSourceRangeValid;
327*cdf0e10cSrcweir }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir void ScPrintFunc::FillPageData()
330*cdf0e10cSrcweir {
331*cdf0e10cSrcweir 	if (pPageData)
332*cdf0e10cSrcweir 	{
333*cdf0e10cSrcweir         sal_uInt16 nCount = sal::static_int_cast<sal_uInt16>( pPageData->GetCount() );
334*cdf0e10cSrcweir 		ScPrintRangeData& rData = pPageData->GetData(nCount);		// hochzaehlen
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 		rData.SetPrintRange( ScRange( nStartCol, nStartRow, nPrintTab,
337*cdf0e10cSrcweir 										nEndCol, nEndRow, nPrintTab ) );
338*cdf0e10cSrcweir 		rData.SetPagesX( nPagesX, pPageEndX );
339*cdf0e10cSrcweir 		rData.SetPagesY( nTotalY, pPageEndY );
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 		//	Einstellungen
342*cdf0e10cSrcweir 		rData.SetTopDown( aTableParam.bTopDown );
343*cdf0e10cSrcweir 		rData.SetAutomatic( !aAreaParam.bPrintArea );
344*cdf0e10cSrcweir 	}
345*cdf0e10cSrcweir }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir ScPrintFunc::~ScPrintFunc()
348*cdf0e10cSrcweir {
349*cdf0e10cSrcweir 	ScAddress* pTripel = (ScAddress*) aNotePosList.First();
350*cdf0e10cSrcweir 	while (pTripel)
351*cdf0e10cSrcweir 	{
352*cdf0e10cSrcweir 		delete pTripel;
353*cdf0e10cSrcweir 		pTripel = (ScAddress*) aNotePosList.Next();
354*cdf0e10cSrcweir 	}
355*cdf0e10cSrcweir 	aNotePosList.Clear();
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir 	delete[] pPageEndX;
358*cdf0e10cSrcweir 	delete[] pPageEndY;
359*cdf0e10cSrcweir 	delete[] pPageRows;
360*cdf0e10cSrcweir 	delete pEditDefaults;
361*cdf0e10cSrcweir 	delete pEditEngine;
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 	//	Druckereinstellungen werden jetzt von aussen wiederhergestellt
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 	//	#64294# Fuer DrawingLayer/Charts muss der MapMode am Drucker (RefDevice) immer stimmen
366*cdf0e10cSrcweir 	SfxPrinter* pDocPrinter = pDoc->GetPrinter();	// auch fuer Preview den Drucker nehmen
367*cdf0e10cSrcweir 	if (pDocPrinter)
368*cdf0e10cSrcweir 		pDocPrinter->SetMapMode(aOldPrinterMode);
369*cdf0e10cSrcweir }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir void ScPrintFunc::SetDrawView( FmFormView* pNew )
372*cdf0e10cSrcweir {
373*cdf0e10cSrcweir 	pDrawView = pNew;
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir void lcl_HidePrint( ScTableInfo& rTabInfo, SCCOL nX1, SCCOL nX2 )
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir     for (SCSIZE nArrY=1; nArrY+1<rTabInfo.mnArrCount; nArrY++)
379*cdf0e10cSrcweir 	{
380*cdf0e10cSrcweir         RowInfo* pThisRowInfo = &rTabInfo.mpRowInfo[nArrY];
381*cdf0e10cSrcweir 		for (SCCOL nX=nX1; nX<=nX2; nX++)
382*cdf0e10cSrcweir 		{
383*cdf0e10cSrcweir 			const CellInfo& rCellInfo = pThisRowInfo->pCellInfo[nX+1];
384*cdf0e10cSrcweir 			if (!rCellInfo.bEmptyCellText)
385*cdf0e10cSrcweir 				if (((const ScProtectionAttr&)rCellInfo.pPatternAttr->
386*cdf0e10cSrcweir 							GetItem(ATTR_PROTECTION, rCellInfo.pConditionSet)).GetHidePrint())
387*cdf0e10cSrcweir 				{
388*cdf0e10cSrcweir 					pThisRowInfo->pCellInfo[nX+1].pCell			 = NULL;
389*cdf0e10cSrcweir 					pThisRowInfo->pCellInfo[nX+1].bEmptyCellText = sal_True;
390*cdf0e10cSrcweir 				}
391*cdf0e10cSrcweir 		}
392*cdf0e10cSrcweir 	}
393*cdf0e10cSrcweir }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir //
396*cdf0e10cSrcweir //			Ausgabe auf Device (static)
397*cdf0e10cSrcweir //
398*cdf0e10cSrcweir //		wird benutzt fuer:
399*cdf0e10cSrcweir //		-	Clipboard/Bitmap
400*cdf0e10cSrcweir //		-	Ole-Object (DocShell::Draw)
401*cdf0e10cSrcweir //		-	Vorschau bei Vorlagen
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPrintFactor */,
404*cdf0e10cSrcweir 							const Rectangle& rBound, ScViewData* pViewData, sal_Bool bMetaFile )
405*cdf0e10cSrcweir {
406*cdf0e10cSrcweir 	//!	nPrintFactor auswerten !!!
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir 	SCTAB nTab = 0;
409*cdf0e10cSrcweir 	if (pViewData)
410*cdf0e10cSrcweir 		nTab = pViewData->GetTabNo();
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir 	sal_Bool bDoGrid, bNullVal, bFormula;
413*cdf0e10cSrcweir 	ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
414*cdf0e10cSrcweir 	SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE );
415*cdf0e10cSrcweir 	if (pStyleSheet)
416*cdf0e10cSrcweir 	{
417*cdf0e10cSrcweir 		SfxItemSet& rSet = pStyleSheet->GetItemSet();
418*cdf0e10cSrcweir 		bDoGrid  = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_GRID)).GetValue();
419*cdf0e10cSrcweir 		bNullVal = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_NULLVALS)).GetValue();
420*cdf0e10cSrcweir 		bFormula = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_FORMULAS)).GetValue();
421*cdf0e10cSrcweir 	}
422*cdf0e10cSrcweir 	else
423*cdf0e10cSrcweir 	{
424*cdf0e10cSrcweir 		const ScViewOptions& rOpt = pDoc->GetViewOptions();
425*cdf0e10cSrcweir 		bDoGrid  = rOpt.GetOption(VOPT_GRID);
426*cdf0e10cSrcweir 		bNullVal = rOpt.GetOption(VOPT_NULLVALS);
427*cdf0e10cSrcweir 		bFormula = rOpt.GetOption(VOPT_FORMULAS);
428*cdf0e10cSrcweir 	}
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir 	MapMode aMode = pDev->GetMapMode();
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 	Rectangle aRect = rBound;
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir 	if (aRect.Right() < aRect.Left() || aRect.Bottom() < aRect.Top())
435*cdf0e10cSrcweir 		aRect = Rectangle( Point(), pDev->GetOutputSize() );
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir 	SCCOL nX1 = 0;
438*cdf0e10cSrcweir 	SCROW nY1 = 0;
439*cdf0e10cSrcweir 	SCCOL nX2 = OLE_STD_CELLS_X - 1;
440*cdf0e10cSrcweir 	SCROW nY2 = OLE_STD_CELLS_Y - 1;
441*cdf0e10cSrcweir 	if (bMetaFile)
442*cdf0e10cSrcweir 	{
443*cdf0e10cSrcweir 		ScRange aRange = pDoc->GetRange( nTab, rBound );
444*cdf0e10cSrcweir 		nX1 = aRange.aStart.Col();
445*cdf0e10cSrcweir 		nY1 = aRange.aStart.Row();
446*cdf0e10cSrcweir 		nX2 = aRange.aEnd.Col();
447*cdf0e10cSrcweir 		nY2 = aRange.aEnd.Row();
448*cdf0e10cSrcweir 	}
449*cdf0e10cSrcweir 	else if (pViewData)
450*cdf0e10cSrcweir 	{
451*cdf0e10cSrcweir 		ScSplitPos eWhich = pViewData->GetActivePart();
452*cdf0e10cSrcweir 		ScHSplitPos eHWhich = WhichH(eWhich);
453*cdf0e10cSrcweir 		ScVSplitPos eVWhich = WhichV(eWhich);
454*cdf0e10cSrcweir 		nX1 = pViewData->GetPosX(eHWhich);
455*cdf0e10cSrcweir 		nY1 = pViewData->GetPosY(eVWhich);
456*cdf0e10cSrcweir 		nX2 = nX1 + pViewData->VisibleCellsX(eHWhich);
457*cdf0e10cSrcweir 		if (nX2>nX1) --nX2;
458*cdf0e10cSrcweir 		nY2 = nY1 + pViewData->VisibleCellsY(eVWhich);
459*cdf0e10cSrcweir 		if (nY2>nY1) --nY2;
460*cdf0e10cSrcweir 	}
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir 	if (nX1 > MAXCOL) nX1 = MAXCOL;
463*cdf0e10cSrcweir 	if (nX2 > MAXCOL) nX2 = MAXCOL;
464*cdf0e10cSrcweir 	if (nY1 > MAXROW) nY1 = MAXROW;
465*cdf0e10cSrcweir 	if (nY2 > MAXROW) nY2 = MAXROW;
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir 	long nDevSizeX = aRect.Right()-aRect.Left()+1;
468*cdf0e10cSrcweir 	long nDevSizeY = aRect.Bottom()-aRect.Top()+1;
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir 	Rectangle aLines;
471*cdf0e10cSrcweir 	ScRange aRange( nX1,nY1,nTab, nX2,nY2,nTab );
472*cdf0e10cSrcweir //    sal_Bool bAddLines = pDoc->HasLines( aRange, aLines );
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 	long nTwipsSizeX = 0;
475*cdf0e10cSrcweir 	for (SCCOL i=nX1; i<=nX2; i++)
476*cdf0e10cSrcweir 		nTwipsSizeX += pDoc->GetColWidth( i, nTab );
477*cdf0e10cSrcweir 	long nTwipsSizeY = (long) pDoc->GetRowHeight( nY1, nY2, nTab );
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir 	//	wenn keine Linien, dann trotzdem Platz fuer den Aussenrahmen (20 Twips = 1pt)
480*cdf0e10cSrcweir 	//	(HasLines initalisiert aLines auf 0,0,0,0)
481*cdf0e10cSrcweir 	nTwipsSizeX += aLines.Left() + Max( aLines.Right(), 20L );
482*cdf0e10cSrcweir 	nTwipsSizeY += aLines.Top() +  Max( aLines.Bottom(), 20L );
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir 	double nScaleX = (double) nDevSizeX / nTwipsSizeX;
485*cdf0e10cSrcweir 	double nScaleY = (double) nDevSizeY / nTwipsSizeY;
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir 							//!		Flag bei FillInfo uebergeben !!!!!
488*cdf0e10cSrcweir     ScRange aERange;
489*cdf0e10cSrcweir 	sal_Bool bEmbed = pDoc->IsEmbedded();
490*cdf0e10cSrcweir 	if (bEmbed)
491*cdf0e10cSrcweir 	{
492*cdf0e10cSrcweir 		pDoc->GetEmbedded(aERange);
493*cdf0e10cSrcweir 		pDoc->ResetEmbedded();
494*cdf0e10cSrcweir 	}
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir 	//	Daten zusammenstellen
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir     ScTableInfo aTabInfo;
499*cdf0e10cSrcweir     pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab,
500*cdf0e10cSrcweir 										nScaleX, nScaleY, sal_False, bFormula );
501*cdf0e10cSrcweir     lcl_HidePrint( aTabInfo, nX1, nX2 );
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir 	if (bEmbed)
504*cdf0e10cSrcweir 		pDoc->SetEmbedded(aERange);
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir /*	if (!bMetaFile)
507*cdf0e10cSrcweir 		pDev->SetMapMode(MAP_PIXEL);
508*cdf0e10cSrcweir */
509*cdf0e10cSrcweir 	long nScrX = aRect.Left();
510*cdf0e10cSrcweir 	long nScrY = aRect.Top();
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir 	//	Wenn keine Linien, trotzdem Platz fuer Gitterlinien lassen
513*cdf0e10cSrcweir 	//	(werden sonst abgeschnitten)
514*cdf0e10cSrcweir 	long nAddX = (long)( aLines.Left() * nScaleX );
515*cdf0e10cSrcweir 	nScrX += ( nAddX ? nAddX : 1 );
516*cdf0e10cSrcweir 	long nAddY = (long)( aLines.Top() * nScaleY );
517*cdf0e10cSrcweir 	nScrY += ( nAddY ? nAddY : 1 );
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir     ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pDoc, nTab,
520*cdf0e10cSrcweir 								nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY );
521*cdf0e10cSrcweir 	aOutputData.SetMetaFileMode(bMetaFile);
522*cdf0e10cSrcweir 	aOutputData.SetShowNullValues(bNullVal);
523*cdf0e10cSrcweir 	aOutputData.SetShowFormulas(bFormula);
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir 	// #114135#
526*cdf0e10cSrcweir 	ScDrawLayer* pModel = pDoc->GetDrawLayer();
527*cdf0e10cSrcweir 	FmFormView* pDrawView = NULL;
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir 	if( pModel )
530*cdf0e10cSrcweir 	{
531*cdf0e10cSrcweir 		pDrawView = new FmFormView( pModel, pDev );
532*cdf0e10cSrcweir 		pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
533*cdf0e10cSrcweir 		pDrawView->SetPrintPreview( sal_True );
534*cdf0e10cSrcweir 		aOutputData.SetDrawView( pDrawView );
535*cdf0e10cSrcweir 	}
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir 	//!	SetUseStyleColor ??
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir 	if ( bMetaFile && pDev->GetOutDevType() == OUTDEV_VIRDEV )
540*cdf0e10cSrcweir 		aOutputData.SetSnapPixel();
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 	Point aLogStart = pDev->PixelToLogic( Point(nScrX,nScrY), MAP_100TH_MM );
543*cdf0e10cSrcweir 	long nLogStX = aLogStart.X();
544*cdf0e10cSrcweir 	long nLogStY = aLogStart.Y();
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir 	//!		nZoom fuer GetFont in OutputData ???
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir 	if (!bMetaFile && pViewData)
549*cdf0e10cSrcweir 		pDev->SetMapMode(pViewData->GetLogicMode(pViewData->GetActivePart()));
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir 	// #i72502#
552*cdf0e10cSrcweir 	const Point aMMOffset(aOutputData.PrePrintDrawingLayer(nLogStX, nLogStY));
553*cdf0e10cSrcweir 	aOutputData.PrintDrawingLayer(SC_LAYER_BACK, aMMOffset);
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir 	if (!bMetaFile && pViewData)
556*cdf0e10cSrcweir 		pDev->SetMapMode(aMode);
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir 	aOutputData.DrawBackground();
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir #ifdef OS2
561*cdf0e10cSrcweir 	if (bMetaFile && !bDoGrid)
562*cdf0e10cSrcweir 	{
563*cdf0e10cSrcweir 					// unter OS2 fuer Metafiles gesamte Flaeche benutzen,
564*cdf0e10cSrcweir 					// weil sonst die Groesse nicht erkannt wird
565*cdf0e10cSrcweir 		pDev->SetLineColor();
566*cdf0e10cSrcweir 		pDev->SetFillColor();
567*cdf0e10cSrcweir 		pDev->DrawRect( Rectangle( nScrX,nScrY,
568*cdf0e10cSrcweir 						nScrX+aOutputData.GetScrW(), nScrY+aOutputData.GetScrH() ) );
569*cdf0e10cSrcweir 	}
570*cdf0e10cSrcweir #endif
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir 	aOutputData.DrawShadow();
573*cdf0e10cSrcweir 	aOutputData.DrawFrame();
574*cdf0e10cSrcweir 	aOutputData.DrawStrings();
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir 	if (!bMetaFile && pViewData)
577*cdf0e10cSrcweir 		pDev->SetMapMode(pViewData->GetLogicMode(pViewData->GetActivePart()));
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir 	aOutputData.DrawEdit(!bMetaFile);
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir 	if (bDoGrid)
582*cdf0e10cSrcweir 	{
583*cdf0e10cSrcweir 		if (!bMetaFile && pViewData)
584*cdf0e10cSrcweir 			pDev->SetMapMode(aMode);
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir 		aOutputData.DrawGrid( sal_True, sal_False );	// keine Seitenumbrueche
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir 		pDev->SetLineColor( COL_BLACK );
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir 		Size aOne = pDev->PixelToLogic( Size(1,1) );
591*cdf0e10cSrcweir 		if (bMetaFile)
592*cdf0e10cSrcweir 			aOne = Size(1,1);	// compatible with DrawGrid
593*cdf0e10cSrcweir 		long nRight = nScrX + aOutputData.GetScrW() - aOne.Width();
594*cdf0e10cSrcweir 		long nBottom = nScrY + aOutputData.GetScrH() - aOne.Height();
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir 		sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir 		// extra line at the left edge for left-to-right, right for right-to-left
599*cdf0e10cSrcweir 		if ( bLayoutRTL )
600*cdf0e10cSrcweir 			pDev->DrawLine( Point(nRight,nScrY), Point(nRight,nBottom) );
601*cdf0e10cSrcweir 		else
602*cdf0e10cSrcweir 			pDev->DrawLine( Point(nScrX,nScrY), Point(nScrX,nBottom) );
603*cdf0e10cSrcweir 		// extra line at the top in both cases
604*cdf0e10cSrcweir 		pDev->DrawLine( Point(nScrX,nScrY), Point(nRight,nScrY) );
605*cdf0e10cSrcweir 	}
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir 	// #i72502#
608*cdf0e10cSrcweir 	aOutputData.PrintDrawingLayer(SC_LAYER_FRONT, aMMOffset);
609*cdf0e10cSrcweir 	aOutputData.PrintDrawingLayer(SC_LAYER_INTERN, aMMOffset);
610*cdf0e10cSrcweir 	aOutputData.PostPrintDrawingLayer(aMMOffset); // #i74768#
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir 	// #114135#
613*cdf0e10cSrcweir 	delete pDrawView;
614*cdf0e10cSrcweir }
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir //
617*cdf0e10cSrcweir //			Drucken
618*cdf0e10cSrcweir //
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir void lcl_FillHFParam( ScPrintHFParam& rParam, const SfxItemSet* pHFSet )
621*cdf0e10cSrcweir {
622*cdf0e10cSrcweir 	//	nDistance muss vorher unterschiedlich initalisiert sein
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir 	if ( pHFSet == NULL )
625*cdf0e10cSrcweir 	{
626*cdf0e10cSrcweir 		rParam.bEnable	= sal_False;
627*cdf0e10cSrcweir 		rParam.pBorder	= NULL;
628*cdf0e10cSrcweir 		rParam.pBack	= NULL;
629*cdf0e10cSrcweir 		rParam.pShadow	= NULL;
630*cdf0e10cSrcweir 	}
631*cdf0e10cSrcweir 	else
632*cdf0e10cSrcweir 	{
633*cdf0e10cSrcweir 		rParam.bEnable	= ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_ON)).GetValue();
634*cdf0e10cSrcweir 		rParam.bDynamic	= ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_DYNAMIC)).GetValue();
635*cdf0e10cSrcweir 		rParam.bShared	= ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_SHARED)).GetValue();
636*cdf0e10cSrcweir 		rParam.nHeight	= ((const SvxSizeItem&) pHFSet->Get(ATTR_PAGE_SIZE)).GetSize().Height();
637*cdf0e10cSrcweir 		const SvxLRSpaceItem* pHFLR = &(const SvxLRSpaceItem&) pHFSet->Get(ATTR_LRSPACE);
638*cdf0e10cSrcweir 		long nTmp;
639*cdf0e10cSrcweir 		nTmp = pHFLR->GetLeft();
640*cdf0e10cSrcweir 		rParam.nLeft = nTmp < 0 ? 0 : sal_uInt16(nTmp);
641*cdf0e10cSrcweir 		nTmp = pHFLR->GetRight();
642*cdf0e10cSrcweir 		rParam.nRight = nTmp < 0 ? 0 : sal_uInt16(nTmp);
643*cdf0e10cSrcweir 		rParam.pBorder	= (const SvxBoxItem*)   &pHFSet->Get(ATTR_BORDER);
644*cdf0e10cSrcweir 		rParam.pBack	= (const SvxBrushItem*) &pHFSet->Get(ATTR_BACKGROUND);
645*cdf0e10cSrcweir 		rParam.pShadow	= (const SvxShadowItem*)&pHFSet->Get(ATTR_SHADOW);;
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir //	jetzt doch wieder schon im Dialog:
648*cdf0e10cSrcweir //		rParam.nHeight += rParam.nDistance;				// nicht mehr im Dialog ???
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir 		if (rParam.pBorder)
651*cdf0e10cSrcweir 			rParam.nHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) +
652*cdf0e10cSrcweir 							  lcl_LineTotal( rParam.pBorder->GetBottom() );
653*cdf0e10cSrcweir 
654*cdf0e10cSrcweir 		rParam.nManHeight = rParam.nHeight;
655*cdf0e10cSrcweir 	}
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir 	if (!rParam.bEnable)
658*cdf0e10cSrcweir 		rParam.nHeight = 0;
659*cdf0e10cSrcweir }
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir //	bNew = TRUE:	benutzten Bereich aus dem Dokument suchen
662*cdf0e10cSrcweir //	bNew = FALSE:	nur ganze Zeilen/Spalten begrenzen
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir sal_Bool ScPrintFunc::AdjustPrintArea( sal_Bool bNew )
665*cdf0e10cSrcweir {
666*cdf0e10cSrcweir 	SCCOL nOldEndCol = nEndCol;	// nur wichtig bei !bNew
667*cdf0e10cSrcweir 	SCROW nOldEndRow = nEndRow;
668*cdf0e10cSrcweir 	sal_Bool bChangeCol = sal_True;			// bei bNew werden beide angepasst
669*cdf0e10cSrcweir 	sal_Bool bChangeRow = sal_True;
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir 	sal_Bool bNotes = aTableParam.bNotes;
672*cdf0e10cSrcweir 	if ( bNew )
673*cdf0e10cSrcweir 	{
674*cdf0e10cSrcweir 		nStartCol = 0;
675*cdf0e10cSrcweir 		nStartRow = 0;
676*cdf0e10cSrcweir 		if (!pDoc->GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes ))
677*cdf0e10cSrcweir 			return sal_False;	// nix
678*cdf0e10cSrcweir 	}
679*cdf0e10cSrcweir 	else
680*cdf0e10cSrcweir 	{
681*cdf0e10cSrcweir 		sal_Bool bFound = sal_True;
682*cdf0e10cSrcweir 		bChangeCol = ( nStartCol == 0 && nEndCol == MAXCOL );
683*cdf0e10cSrcweir 		bChangeRow = ( nStartRow == 0 && nEndRow == MAXROW );
684*cdf0e10cSrcweir         sal_Bool bForcedChangeRow = sal_False;
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir         // #i53558# Crop entire column of old row limit to real print area with
687*cdf0e10cSrcweir         // some fuzzyness.
688*cdf0e10cSrcweir         if (!bChangeRow && nStartRow == 0)
689*cdf0e10cSrcweir         {
690*cdf0e10cSrcweir             SCROW nPAEndRow;
691*cdf0e10cSrcweir             bFound = pDoc->GetPrintAreaVer( nPrintTab, nStartCol, nEndCol, nPAEndRow, bNotes );
692*cdf0e10cSrcweir             // Say we don't want to print more than ~1000 empty rows, which are
693*cdf0e10cSrcweir             // about 14 pages intentionally left blank..
694*cdf0e10cSrcweir             const SCROW nFuzzy = 23*42;
695*cdf0e10cSrcweir             if (nPAEndRow + nFuzzy < nEndRow)
696*cdf0e10cSrcweir             {
697*cdf0e10cSrcweir                 bForcedChangeRow = sal_True;
698*cdf0e10cSrcweir                 nEndRow = nPAEndRow;
699*cdf0e10cSrcweir             }
700*cdf0e10cSrcweir             else
701*cdf0e10cSrcweir                 bFound = sal_True;  // user seems to _want_ to print some empty rows
702*cdf0e10cSrcweir         }
703*cdf0e10cSrcweir         // TODO: in case we extend the number of columns we may have to do the
704*cdf0e10cSrcweir         // same for horizontal cropping.
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir 		if ( bChangeCol && bChangeRow )
707*cdf0e10cSrcweir 			bFound = pDoc->GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes );
708*cdf0e10cSrcweir 		else if ( bChangeCol )
709*cdf0e10cSrcweir 			bFound = pDoc->GetPrintAreaHor( nPrintTab, nStartRow, nEndRow, nEndCol, bNotes );
710*cdf0e10cSrcweir 		else if ( bChangeRow )
711*cdf0e10cSrcweir 			bFound = pDoc->GetPrintAreaVer( nPrintTab, nStartCol, nEndCol, nEndRow, bNotes );
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir 		if (!bFound)
714*cdf0e10cSrcweir 			return sal_False;	// leer
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir         if (bForcedChangeRow)
717*cdf0e10cSrcweir             bChangeRow = sal_True;
718*cdf0e10cSrcweir 	}
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir 	pDoc->ExtendMerge( nStartCol,nStartRow, nEndCol,nEndRow, nPrintTab,
721*cdf0e10cSrcweir 						sal_False, sal_True );		// kein Refresh, incl. Attrs
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir 	if ( bChangeCol )
724*cdf0e10cSrcweir 	{
725*cdf0e10cSrcweir 		OutputDevice* pRefDev = pDoc->GetPrinter();		// auch fuer Preview den Drucker nehmen
726*cdf0e10cSrcweir 		pRefDev->SetMapMode( MAP_PIXEL );				// wichtig fuer GetNeededSize
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir 		pDoc->ExtendPrintArea( pRefDev,
729*cdf0e10cSrcweir 							nPrintTab, nStartCol, nStartRow, nEndCol, nEndRow );
730*cdf0e10cSrcweir 		//	nEndCol wird veraendert
731*cdf0e10cSrcweir 	}
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir 	if ( nEndCol < MAXCOL && pDoc->HasAttrib(
734*cdf0e10cSrcweir 					nEndCol,nStartRow,nPrintTab, nEndCol,nEndRow,nPrintTab, HASATTR_SHADOW_RIGHT ) )
735*cdf0e10cSrcweir 		++nEndCol;
736*cdf0e10cSrcweir 	if ( nEndRow < MAXROW && pDoc->HasAttrib(
737*cdf0e10cSrcweir 					nStartCol,nEndRow,nPrintTab, nEndCol,nEndRow,nPrintTab, HASATTR_SHADOW_DOWN ) )
738*cdf0e10cSrcweir 		++nEndRow;
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir 	if (!bChangeCol) nEndCol = nOldEndCol;
741*cdf0e10cSrcweir 	if (!bChangeRow) nEndRow = nOldEndRow;
742*cdf0e10cSrcweir 
743*cdf0e10cSrcweir 	return sal_True;
744*cdf0e10cSrcweir }
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir long ScPrintFunc::TextHeight( const EditTextObject* pObject )
747*cdf0e10cSrcweir {
748*cdf0e10cSrcweir 	if (!pObject)
749*cdf0e10cSrcweir 		return 0;
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir //	pEditEngine->SetPageNo( nTotalPages );
752*cdf0e10cSrcweir 	pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, sal_False );
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir 	return (long) pEditEngine->GetTextHeight();
755*cdf0e10cSrcweir }
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir //	nZoom muss gesetzt sein !!!
758*cdf0e10cSrcweir //	und der entsprechende Twip-MapMode eingestellt
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir void ScPrintFunc::UpdateHFHeight( ScPrintHFParam& rParam )
761*cdf0e10cSrcweir {
762*cdf0e10cSrcweir 	DBG_ASSERT( aPageSize.Width(), "UpdateHFHeight ohne aPageSize");
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir 	if (rParam.bEnable && rParam.bDynamic)
765*cdf0e10cSrcweir 	{
766*cdf0e10cSrcweir 		//	nHeight aus Inhalten berechnen
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir 		MakeEditEngine();
769*cdf0e10cSrcweir 		long nPaperWidth = ( aPageSize.Width() - nLeftMargin - nRightMargin -
770*cdf0e10cSrcweir 								rParam.nLeft - rParam.nRight ) * 100 / nZoom;
771*cdf0e10cSrcweir 		if (rParam.pBorder)
772*cdf0e10cSrcweir 			nPaperWidth -= ( rParam.pBorder->GetDistance(BOX_LINE_LEFT) +
773*cdf0e10cSrcweir 							 rParam.pBorder->GetDistance(BOX_LINE_RIGHT) +
774*cdf0e10cSrcweir 							 lcl_LineTotal(rParam.pBorder->GetLeft()) +
775*cdf0e10cSrcweir 							 lcl_LineTotal(rParam.pBorder->GetRight()) ) * 100 / nZoom;
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir 		if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
778*cdf0e10cSrcweir 			nPaperWidth -= ( rParam.pShadow->CalcShadowSpace(SHADOW_LEFT) +
779*cdf0e10cSrcweir 							 rParam.pShadow->CalcShadowSpace(SHADOW_RIGHT) ) * 100L / nZoom;
780*cdf0e10cSrcweir 
781*cdf0e10cSrcweir 		pEditEngine->SetPaperSize( Size( nPaperWidth, 10000 ) );
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir 		long nMaxHeight = 0;
784*cdf0e10cSrcweir 		if ( rParam.pLeft )
785*cdf0e10cSrcweir 		{
786*cdf0e10cSrcweir 			nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetLeftArea() ) );
787*cdf0e10cSrcweir 			nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetCenterArea() ) );
788*cdf0e10cSrcweir 			nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetRightArea() ) );
789*cdf0e10cSrcweir 		}
790*cdf0e10cSrcweir 		if ( rParam.pRight )
791*cdf0e10cSrcweir 		{
792*cdf0e10cSrcweir 			nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetLeftArea() ) );
793*cdf0e10cSrcweir 			nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetCenterArea() ) );
794*cdf0e10cSrcweir 			nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetRightArea() ) );
795*cdf0e10cSrcweir 		}
796*cdf0e10cSrcweir 
797*cdf0e10cSrcweir 		rParam.nHeight = nMaxHeight + rParam.nDistance;
798*cdf0e10cSrcweir 		if (rParam.pBorder)
799*cdf0e10cSrcweir 			rParam.nHeight += rParam.pBorder->GetDistance(BOX_LINE_TOP) +
800*cdf0e10cSrcweir 							  rParam.pBorder->GetDistance(BOX_LINE_BOTTOM) +
801*cdf0e10cSrcweir 							  lcl_LineTotal( rParam.pBorder->GetTop() ) +
802*cdf0e10cSrcweir 							  lcl_LineTotal( rParam.pBorder->GetBottom() );
803*cdf0e10cSrcweir 		if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
804*cdf0e10cSrcweir 			rParam.nHeight += rParam.pShadow->CalcShadowSpace(SHADOW_TOP) +
805*cdf0e10cSrcweir 							  rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM);
806*cdf0e10cSrcweir 
807*cdf0e10cSrcweir 		if (rParam.nHeight < rParam.nManHeight)
808*cdf0e10cSrcweir 			rParam.nHeight = rParam.nManHeight;			// eingestelltes Minimum
809*cdf0e10cSrcweir 	}
810*cdf0e10cSrcweir }
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
813*cdf0e10cSrcweir {
814*cdf0e10cSrcweir 	if (!pParamSet)
815*cdf0e10cSrcweir 		return;
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir 								// TabPage "Seite"
818*cdf0e10cSrcweir 	const SvxLRSpaceItem* pLRItem = (const SvxLRSpaceItem*) &pParamSet->Get( ATTR_LRSPACE );
819*cdf0e10cSrcweir 	long nTmp;
820*cdf0e10cSrcweir 	nTmp = pLRItem->GetLeft();
821*cdf0e10cSrcweir 	nLeftMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
822*cdf0e10cSrcweir 	nTmp = pLRItem->GetRight();
823*cdf0e10cSrcweir 	nRightMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
824*cdf0e10cSrcweir 	const SvxULSpaceItem* pULItem = (const SvxULSpaceItem*) &pParamSet->Get( ATTR_ULSPACE );
825*cdf0e10cSrcweir 	nTopMargin    = pULItem->GetUpper();
826*cdf0e10cSrcweir 	nBottomMargin = pULItem->GetLower();
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir 	const SvxPageItem* pPageItem = (const SvxPageItem*) &pParamSet->Get( ATTR_PAGE );
829*cdf0e10cSrcweir 	nPageUsage			= pPageItem->GetPageUsage();
830*cdf0e10cSrcweir 	bLandscape			= pPageItem->IsLandscape();
831*cdf0e10cSrcweir 	aFieldData.eNumType	= pPageItem->GetNumType();
832*cdf0e10cSrcweir 
833*cdf0e10cSrcweir 	bCenterHor = ((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_HORCENTER)).GetValue();
834*cdf0e10cSrcweir 	bCenterVer = ((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_VERCENTER)).GetValue();
835*cdf0e10cSrcweir 
836*cdf0e10cSrcweir 	aPageSize = ((const SvxSizeItem&) pParamSet->Get(ATTR_PAGE_SIZE)).GetSize();
837*cdf0e10cSrcweir 	if ( !aPageSize.Width() || !aPageSize.Height() )
838*cdf0e10cSrcweir 	{
839*cdf0e10cSrcweir 		DBG_ERROR("PageSize Null ?!?!?");
840*cdf0e10cSrcweir 		aPageSize = SvxPaperInfo::GetPaperSize( PAPER_A4 );
841*cdf0e10cSrcweir 	}
842*cdf0e10cSrcweir 
843*cdf0e10cSrcweir 	pBorderItem		= (const SvxBoxItem*)    &pParamSet->Get(ATTR_BORDER);
844*cdf0e10cSrcweir 	pBackgroundItem	= (const SvxBrushItem*)	 &pParamSet->Get(ATTR_BACKGROUND);
845*cdf0e10cSrcweir 	pShadowItem		= (const SvxShadowItem*) &pParamSet->Get(ATTR_SHADOW);
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir 								// TabPage "Kopfzeile"
848*cdf0e10cSrcweir 
849*cdf0e10cSrcweir 	aHdr.pLeft		= (const ScPageHFItem*)	&pParamSet->Get(ATTR_PAGE_HEADERLEFT);		// Inhalt
850*cdf0e10cSrcweir 	aHdr.pRight		= (const ScPageHFItem*)	&pParamSet->Get(ATTR_PAGE_HEADERRIGHT);
851*cdf0e10cSrcweir 
852*cdf0e10cSrcweir 	const SvxSetItem* pHeaderSetItem;
853*cdf0e10cSrcweir 	const SfxItemSet* pHeaderSet = NULL;
854*cdf0e10cSrcweir 	if ( pParamSet->GetItemState( ATTR_PAGE_HEADERSET, sal_False,
855*cdf0e10cSrcweir 							(const SfxPoolItem**)&pHeaderSetItem ) == SFX_ITEM_SET )
856*cdf0e10cSrcweir 	{
857*cdf0e10cSrcweir 		pHeaderSet = &pHeaderSetItem->GetItemSet();
858*cdf0e10cSrcweir 														// Kopfzeile hat unteren Abstand
859*cdf0e10cSrcweir 		aHdr.nDistance	= ((const SvxULSpaceItem&) pHeaderSet->Get(ATTR_ULSPACE)).GetLower();
860*cdf0e10cSrcweir 	}
861*cdf0e10cSrcweir 	lcl_FillHFParam( aHdr, pHeaderSet );
862*cdf0e10cSrcweir 
863*cdf0e10cSrcweir 								// TabPage "Fusszeile"
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir 	aFtr.pLeft		= (const ScPageHFItem*)	&pParamSet->Get(ATTR_PAGE_FOOTERLEFT);		// Inhalt
866*cdf0e10cSrcweir 	aFtr.pRight		= (const ScPageHFItem*)	&pParamSet->Get(ATTR_PAGE_FOOTERRIGHT);
867*cdf0e10cSrcweir 
868*cdf0e10cSrcweir 	const SvxSetItem* pFooterSetItem;
869*cdf0e10cSrcweir 	const SfxItemSet* pFooterSet = NULL;
870*cdf0e10cSrcweir 	if ( pParamSet->GetItemState( ATTR_PAGE_FOOTERSET, sal_False,
871*cdf0e10cSrcweir 							(const SfxPoolItem**)&pFooterSetItem ) == SFX_ITEM_SET )
872*cdf0e10cSrcweir 	{
873*cdf0e10cSrcweir 		pFooterSet = &pFooterSetItem->GetItemSet();
874*cdf0e10cSrcweir 														// Fusszeile hat oberen Abstand
875*cdf0e10cSrcweir 		aFtr.nDistance	= ((const SvxULSpaceItem&) pFooterSet->Get(ATTR_ULSPACE)).GetUpper();
876*cdf0e10cSrcweir 	}
877*cdf0e10cSrcweir 	lcl_FillHFParam( aFtr, pFooterSet );
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir 	//------------------------------------------------------
880*cdf0e10cSrcweir 	// Table-/Area-Params aus einzelnen Items zusammenbauen:
881*cdf0e10cSrcweir 	//------------------------------------------------------
882*cdf0e10cSrcweir 	// TabPage "Tabelle"
883*cdf0e10cSrcweir 
884*cdf0e10cSrcweir     const SfxUInt16Item*     pScaleItem          = NULL;
885*cdf0e10cSrcweir     const ScPageScaleToItem* pScaleToItem        = NULL;
886*cdf0e10cSrcweir     const SfxUInt16Item*     pScaleToPagesItem   = NULL;
887*cdf0e10cSrcweir     SfxItemState             eState;
888*cdf0e10cSrcweir 
889*cdf0e10cSrcweir 	eState = pParamSet->GetItemState( ATTR_PAGE_SCALE, sal_False,
890*cdf0e10cSrcweir 									  (const SfxPoolItem**)&pScaleItem );
891*cdf0e10cSrcweir 	if ( SFX_ITEM_DEFAULT == eState )
892*cdf0e10cSrcweir 		pScaleItem = (const SfxUInt16Item*)
893*cdf0e10cSrcweir                     &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALE );
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir     eState = pParamSet->GetItemState( ATTR_PAGE_SCALETO, sal_False,
896*cdf0e10cSrcweir                                       (const SfxPoolItem**)&pScaleToItem );
897*cdf0e10cSrcweir     if ( SFX_ITEM_DEFAULT == eState )
898*cdf0e10cSrcweir         pScaleToItem = (const ScPageScaleToItem*)
899*cdf0e10cSrcweir                     &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALETO );
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir 	eState = pParamSet->GetItemState( ATTR_PAGE_SCALETOPAGES, sal_False,
902*cdf0e10cSrcweir 									  (const SfxPoolItem**)&pScaleToPagesItem );
903*cdf0e10cSrcweir 	if ( SFX_ITEM_DEFAULT == eState )
904*cdf0e10cSrcweir 		pScaleToPagesItem = (const SfxUInt16Item*)
905*cdf0e10cSrcweir                     &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALETOPAGES );
906*cdf0e10cSrcweir 
907*cdf0e10cSrcweir     DBG_ASSERT( pScaleItem && pScaleToItem && pScaleToPagesItem, "Missing ScaleItem! :-/" );
908*cdf0e10cSrcweir 
909*cdf0e10cSrcweir     aTableParam.bCellContent    = sal_True;
910*cdf0e10cSrcweir 	aTableParam.bNotes			= GET_BOOL(pParamSet,ATTR_PAGE_NOTES);
911*cdf0e10cSrcweir 	aTableParam.bGrid			= GET_BOOL(pParamSet,ATTR_PAGE_GRID);
912*cdf0e10cSrcweir 	aTableParam.bHeaders		= GET_BOOL(pParamSet,ATTR_PAGE_HEADERS);
913*cdf0e10cSrcweir 	aTableParam.bFormulas		= GET_BOOL(pParamSet,ATTR_PAGE_FORMULAS);
914*cdf0e10cSrcweir 	aTableParam.bNullVals		= GET_BOOL(pParamSet,ATTR_PAGE_NULLVALS);
915*cdf0e10cSrcweir 	aTableParam.bCharts			= GET_SHOW(pParamSet,ATTR_PAGE_CHARTS);
916*cdf0e10cSrcweir 	aTableParam.bObjects		= GET_SHOW(pParamSet,ATTR_PAGE_OBJECTS);
917*cdf0e10cSrcweir 	aTableParam.bDrawings		= GET_SHOW(pParamSet,ATTR_PAGE_DRAWINGS);
918*cdf0e10cSrcweir 	aTableParam.bTopDown		= GET_BOOL(pParamSet,ATTR_PAGE_TOPDOWN);
919*cdf0e10cSrcweir 	aTableParam.bLeftRight		= !aTableParam.bLeftRight;
920*cdf0e10cSrcweir 	aTableParam.nFirstPageNo	= GET_USHORT(pParamSet,ATTR_PAGE_FIRSTPAGENO);
921*cdf0e10cSrcweir 	if (!aTableParam.nFirstPageNo)
922*cdf0e10cSrcweir 		aTableParam.nFirstPageNo = (sal_uInt16) nPageStart;		// von vorheriger Tabelle
923*cdf0e10cSrcweir 
924*cdf0e10cSrcweir     if ( pScaleItem && pScaleToItem && pScaleToPagesItem )
925*cdf0e10cSrcweir 	{
926*cdf0e10cSrcweir 		sal_uInt16	nScaleAll     = pScaleItem->GetValue();
927*cdf0e10cSrcweir 		sal_uInt16	nScaleToPages = pScaleToPagesItem->GetValue();
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir 		aTableParam.bScaleNone		= (nScaleAll     == 100);
930*cdf0e10cSrcweir 		aTableParam.bScaleAll		= (nScaleAll      > 0  );
931*cdf0e10cSrcweir         aTableParam.bScaleTo        = pScaleToItem->IsValid();
932*cdf0e10cSrcweir 		aTableParam.bScalePageNum	= (nScaleToPages  > 0  );
933*cdf0e10cSrcweir 		aTableParam.nScaleAll		= nScaleAll;
934*cdf0e10cSrcweir         aTableParam.nScaleWidth     = pScaleToItem->GetWidth();
935*cdf0e10cSrcweir         aTableParam.nScaleHeight    = pScaleToItem->GetHeight();
936*cdf0e10cSrcweir 		aTableParam.nScalePageNum	= nScaleToPages;
937*cdf0e10cSrcweir 	}
938*cdf0e10cSrcweir 	else
939*cdf0e10cSrcweir 	{
940*cdf0e10cSrcweir 		aTableParam.bScaleNone		= sal_True;
941*cdf0e10cSrcweir 		aTableParam.bScaleAll		= sal_False;
942*cdf0e10cSrcweir         aTableParam.bScaleTo        = sal_False;
943*cdf0e10cSrcweir 		aTableParam.bScalePageNum	= sal_False;
944*cdf0e10cSrcweir 		aTableParam.nScaleAll		= 0;
945*cdf0e10cSrcweir         aTableParam.nScaleWidth     = 0;
946*cdf0e10cSrcweir         aTableParam.nScaleHeight    = 0;
947*cdf0e10cSrcweir 		aTableParam.nScalePageNum	= 0;
948*cdf0e10cSrcweir 	}
949*cdf0e10cSrcweir 
950*cdf0e10cSrcweir 	//	skip empty pages only if options with that flag are passed
951*cdf0e10cSrcweir 	aTableParam.bSkipEmpty = pOptions && pOptions->GetSkipEmpty();
952*cdf0e10cSrcweir 	if ( pPageData )
953*cdf0e10cSrcweir 		aTableParam.bSkipEmpty = sal_False;
954*cdf0e10cSrcweir 	// Wenn pPageData gesetzt ist, interessieren fuer die Umbruch-Vorschau
955*cdf0e10cSrcweir 	// nur die Umbrueche, leere Seiten werden nicht speziell behandelt
956*cdf0e10cSrcweir 
957*cdf0e10cSrcweir 	//------------------------------------------------------
958*cdf0e10cSrcweir 	// TabPage "Bereiche":
959*cdf0e10cSrcweir 	//------------------------------------------------------
960*cdf0e10cSrcweir 
961*cdf0e10cSrcweir 	//!	alle PrintAreas der Tabelle durchgehen !!!
962*cdf0e10cSrcweir 	const ScRange*	pPrintArea = pDoc->GetPrintRange( nPrintTab, 0 );
963*cdf0e10cSrcweir 	const ScRange*	pRepeatCol = pDoc->GetRepeatColRange( nPrintTab );
964*cdf0e10cSrcweir 	const ScRange*	pRepeatRow = pDoc->GetRepeatRowRange( nPrintTab );
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir 	//	ATTR_PAGE_PRINTTABLES wird ignoriert
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir 	if ( pUserArea )				// UserArea (Selektion) hat Vorrang
969*cdf0e10cSrcweir 	{
970*cdf0e10cSrcweir 		bPrintCurrentTable    =
971*cdf0e10cSrcweir 		aAreaParam.bPrintArea = sal_True;					// Selektion
972*cdf0e10cSrcweir 		aAreaParam.aPrintArea = *pUserArea;
973*cdf0e10cSrcweir 
974*cdf0e10cSrcweir 		//	Die Tabellen-Abfrage ist schon in DocShell::Print, hier immer
975*cdf0e10cSrcweir 		aAreaParam.aPrintArea.aStart.SetTab(nPrintTab);
976*cdf0e10cSrcweir 		aAreaParam.aPrintArea.aEnd.SetTab(nPrintTab);
977*cdf0e10cSrcweir 
978*cdf0e10cSrcweir //		lcl_LimitRange( aAreaParam.aPrintArea, nPrintTab );			// ganze Zeilen/Spalten...
979*cdf0e10cSrcweir 	}
980*cdf0e10cSrcweir 	else if ( pDoc->HasPrintRange() )
981*cdf0e10cSrcweir 	{
982*cdf0e10cSrcweir 		if ( pPrintArea )								// mindestens eine gesetzt ?
983*cdf0e10cSrcweir 		{
984*cdf0e10cSrcweir 			bPrintCurrentTable    =
985*cdf0e10cSrcweir 			aAreaParam.bPrintArea = sal_True;
986*cdf0e10cSrcweir 			aAreaParam.aPrintArea = *pPrintArea;
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir 			bMultiArea = ( pDoc->GetPrintRangeCount(nPrintTab) > 1 );
989*cdf0e10cSrcweir 		}
990*cdf0e10cSrcweir 		else
991*cdf0e10cSrcweir 		{
992*cdf0e10cSrcweir             // do not print hidden sheets with "Print entire sheet" flag
993*cdf0e10cSrcweir             bPrintCurrentTable = pDoc->IsPrintEntireSheet( nPrintTab ) && pDoc->IsVisible( nPrintTab );
994*cdf0e10cSrcweir             aAreaParam.bPrintArea = !bPrintCurrentTable;    // otherwise the table is always counted
995*cdf0e10cSrcweir 		}
996*cdf0e10cSrcweir 	}
997*cdf0e10cSrcweir 	else
998*cdf0e10cSrcweir 	{
999*cdf0e10cSrcweir 		//	#74834# don't print hidden tables if there's no print range defined there
1000*cdf0e10cSrcweir 		if ( pDoc->IsVisible( nPrintTab ) )
1001*cdf0e10cSrcweir 		{
1002*cdf0e10cSrcweir 			aAreaParam.bPrintArea = sal_False;
1003*cdf0e10cSrcweir 			bPrintCurrentTable = sal_True;
1004*cdf0e10cSrcweir 		}
1005*cdf0e10cSrcweir 		else
1006*cdf0e10cSrcweir 		{
1007*cdf0e10cSrcweir 			aAreaParam.bPrintArea = sal_True;	// otherwise the table is always counted
1008*cdf0e10cSrcweir 			bPrintCurrentTable = sal_False;
1009*cdf0e10cSrcweir 		}
1010*cdf0e10cSrcweir 	}
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir 	if ( pRepeatCol )
1013*cdf0e10cSrcweir 	{
1014*cdf0e10cSrcweir 		aAreaParam.bRepeatCol = sal_True;
1015*cdf0e10cSrcweir 		aAreaParam.aRepeatCol = *pRepeatCol;
1016*cdf0e10cSrcweir 		nRepeatStartCol	= pRepeatCol->aStart.Col();
1017*cdf0e10cSrcweir 		nRepeatEndCol	= pRepeatCol->aEnd  .Col();
1018*cdf0e10cSrcweir 	}
1019*cdf0e10cSrcweir 	else
1020*cdf0e10cSrcweir 	{
1021*cdf0e10cSrcweir 		aAreaParam.bRepeatCol = sal_False;
1022*cdf0e10cSrcweir 		nRepeatStartCol = nRepeatEndCol = SCCOL_REPEAT_NONE;
1023*cdf0e10cSrcweir 	}
1024*cdf0e10cSrcweir 
1025*cdf0e10cSrcweir 	if ( pRepeatRow )
1026*cdf0e10cSrcweir 	{
1027*cdf0e10cSrcweir 		aAreaParam.bRepeatRow = sal_True;
1028*cdf0e10cSrcweir 		aAreaParam.aRepeatRow = *pRepeatRow;
1029*cdf0e10cSrcweir 		nRepeatStartRow	= pRepeatRow->aStart.Row();
1030*cdf0e10cSrcweir 		nRepeatEndRow	= pRepeatRow->aEnd  .Row();
1031*cdf0e10cSrcweir 	}
1032*cdf0e10cSrcweir 	else
1033*cdf0e10cSrcweir 	{
1034*cdf0e10cSrcweir 		aAreaParam.bRepeatRow = sal_False;
1035*cdf0e10cSrcweir 		nRepeatStartRow = nRepeatEndRow = SCROW_REPEAT_NONE;
1036*cdf0e10cSrcweir 	}
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir 			//
1039*cdf0e10cSrcweir 			//	Seiten aufteilen
1040*cdf0e10cSrcweir 			//
1041*cdf0e10cSrcweir 
1042*cdf0e10cSrcweir 	if (!bState)
1043*cdf0e10cSrcweir 	{
1044*cdf0e10cSrcweir 		nTabPages = CountPages();									// berechnet auch Zoom
1045*cdf0e10cSrcweir 		nTotalPages = nTabPages;
1046*cdf0e10cSrcweir 		nTotalPages += CountNotePages();
1047*cdf0e10cSrcweir 	}
1048*cdf0e10cSrcweir 	else
1049*cdf0e10cSrcweir 	{
1050*cdf0e10cSrcweir 		CalcPages();			// nur Umbrueche suchen
1051*cdf0e10cSrcweir 		CountNotePages();		// Notizen zaehlen, auch wenn Seitenzahl schon bekannt
1052*cdf0e10cSrcweir 	}
1053*cdf0e10cSrcweir 
1054*cdf0e10cSrcweir 	if (nDocPages)
1055*cdf0e10cSrcweir 		aFieldData.nTotalPages = nDocPages;
1056*cdf0e10cSrcweir 	else
1057*cdf0e10cSrcweir 		aFieldData.nTotalPages = nTotalPages;
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir 	SetDateTime( Date(), Time() );
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir 	aFieldData.aTitle		= pDocShell->GetTitle();
1062*cdf0e10cSrcweir 	const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
1063*cdf0e10cSrcweir 	aFieldData.aLongDocName	= rURLObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
1064*cdf0e10cSrcweir 	if ( aFieldData.aLongDocName.Len() )
1065*cdf0e10cSrcweir 		aFieldData.aShortDocName = rURLObj.GetName( INetURLObject::DECODE_UNAMBIGUOUS );
1066*cdf0e10cSrcweir 	else
1067*cdf0e10cSrcweir 		aFieldData.aShortDocName = aFieldData.aLongDocName = aFieldData.aTitle;
1068*cdf0e10cSrcweir 
1069*cdf0e10cSrcweir 	//	Druckereinstellungen (Orientation, Paper) jetzt erst bei DoPrint
1070*cdf0e10cSrcweir }
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir Size ScPrintFunc::GetDataSize() const
1073*cdf0e10cSrcweir {
1074*cdf0e10cSrcweir 	Size aSize = aPageSize;
1075*cdf0e10cSrcweir 	aSize.Width()  -= nLeftMargin + nRightMargin;
1076*cdf0e10cSrcweir 	aSize.Height() -= nTopMargin + nBottomMargin;
1077*cdf0e10cSrcweir 	aSize.Height() -= aHdr.nHeight + aFtr.nHeight;
1078*cdf0e10cSrcweir 	return aSize;
1079*cdf0e10cSrcweir }
1080*cdf0e10cSrcweir 
1081*cdf0e10cSrcweir void ScPrintFunc::GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr )
1082*cdf0e10cSrcweir {
1083*cdf0e10cSrcweir 	rPhysSize = aPageSize;
1084*cdf0e10cSrcweir 	rPhysSize.Width()  -= nLeftMargin + nRightMargin;
1085*cdf0e10cSrcweir 	rPhysSize.Height() -= nTopMargin + nBottomMargin;
1086*cdf0e10cSrcweir 
1087*cdf0e10cSrcweir 	rDocHdr = aHdr.nHeight;
1088*cdf0e10cSrcweir 	rDocFtr = aFtr.nHeight;
1089*cdf0e10cSrcweir }
1090*cdf0e10cSrcweir 
1091*cdf0e10cSrcweir void ScPrintFunc::SetDateTime( const Date& rDate, const Time& rTime )
1092*cdf0e10cSrcweir {
1093*cdf0e10cSrcweir 	aFieldData.aDate = rDate;
1094*cdf0e10cSrcweir 	aFieldData.aTime = rTime;
1095*cdf0e10cSrcweir }
1096*cdf0e10cSrcweir 
1097*cdf0e10cSrcweir void lcl_DrawGraphic( const Graphic &rGraphic, OutputDevice *pOut,
1098*cdf0e10cSrcweir                       const Rectangle &rGrf, const Rectangle &rOut )
1099*cdf0e10cSrcweir {
1100*cdf0e10cSrcweir     const FASTBOOL bNotInside = !rOut.IsInside( rGrf );
1101*cdf0e10cSrcweir     if ( bNotInside )
1102*cdf0e10cSrcweir     {
1103*cdf0e10cSrcweir         pOut->Push();
1104*cdf0e10cSrcweir         pOut->IntersectClipRegion( rOut );
1105*cdf0e10cSrcweir     }
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir     ((Graphic&)rGraphic).Draw( pOut, rGrf.TopLeft(), rGrf.GetSize() );
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir     if ( bNotInside )
1110*cdf0e10cSrcweir         pOut->Pop();
1111*cdf0e10cSrcweir }
1112*cdf0e10cSrcweir 
1113*cdf0e10cSrcweir void lcl_DrawGraphic( const SvxBrushItem &rBrush, OutputDevice *pOut, OutputDevice* pRefDev,
1114*cdf0e10cSrcweir 						const Rectangle &rOrg, const Rectangle &rOut )
1115*cdf0e10cSrcweir {
1116*cdf0e10cSrcweir 	Size aGrfSize(0,0);
1117*cdf0e10cSrcweir 	const Graphic *pGraphic = rBrush.GetGraphic();
1118*cdf0e10cSrcweir 	SvxGraphicPosition ePos;
1119*cdf0e10cSrcweir 	if ( pGraphic && pGraphic->IsSupportedGraphic() )
1120*cdf0e10cSrcweir 	{
1121*cdf0e10cSrcweir 		const MapMode aMapMM( MAP_100TH_MM );
1122*cdf0e10cSrcweir 		if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
1123*cdf0e10cSrcweir 			aGrfSize = pRefDev->PixelToLogic( pGraphic->GetPrefSize(), aMapMM );
1124*cdf0e10cSrcweir 		else
1125*cdf0e10cSrcweir 			aGrfSize = OutputDevice::LogicToLogic( pGraphic->GetPrefSize(),
1126*cdf0e10cSrcweir 									pGraphic->GetPrefMapMode(), aMapMM );
1127*cdf0e10cSrcweir 		ePos = rBrush.GetGraphicPos();
1128*cdf0e10cSrcweir 	}
1129*cdf0e10cSrcweir 	else
1130*cdf0e10cSrcweir 		ePos = GPOS_NONE;
1131*cdf0e10cSrcweir 
1132*cdf0e10cSrcweir 	Point aPos;
1133*cdf0e10cSrcweir 	Size aDrawSize = aGrfSize;
1134*cdf0e10cSrcweir 
1135*cdf0e10cSrcweir 	FASTBOOL bDraw = sal_True;
1136*cdf0e10cSrcweir //	FASTBOOL bRetouche = sal_True;
1137*cdf0e10cSrcweir 	switch ( ePos )
1138*cdf0e10cSrcweir 	{
1139*cdf0e10cSrcweir 		case GPOS_LT: aPos = rOrg.TopLeft();
1140*cdf0e10cSrcweir 					  break;
1141*cdf0e10cSrcweir 		case GPOS_MT: aPos.Y() = rOrg.Top();
1142*cdf0e10cSrcweir 					  aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2;
1143*cdf0e10cSrcweir 					  break;
1144*cdf0e10cSrcweir 		case GPOS_RT: aPos.Y() = rOrg.Top();
1145*cdf0e10cSrcweir 					  aPos.X() = rOrg.Right() - aGrfSize.Width();
1146*cdf0e10cSrcweir 					  break;
1147*cdf0e10cSrcweir 
1148*cdf0e10cSrcweir 		case GPOS_LM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2;
1149*cdf0e10cSrcweir 					  aPos.X() = rOrg.Left();
1150*cdf0e10cSrcweir 					  break;
1151*cdf0e10cSrcweir 		case GPOS_MM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2;
1152*cdf0e10cSrcweir 					  aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2;
1153*cdf0e10cSrcweir 					  break;
1154*cdf0e10cSrcweir 		case GPOS_RM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2;
1155*cdf0e10cSrcweir 					  aPos.X() = rOrg.Right() - aGrfSize.Width();
1156*cdf0e10cSrcweir 					  break;
1157*cdf0e10cSrcweir 
1158*cdf0e10cSrcweir 		case GPOS_LB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height();
1159*cdf0e10cSrcweir 					  aPos.X() = rOrg.Left();
1160*cdf0e10cSrcweir 					  break;
1161*cdf0e10cSrcweir 		case GPOS_MB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height();
1162*cdf0e10cSrcweir 					  aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2;
1163*cdf0e10cSrcweir 					  break;
1164*cdf0e10cSrcweir 		case GPOS_RB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height();
1165*cdf0e10cSrcweir 					  aPos.X() = rOrg.Right() - aGrfSize.Width();
1166*cdf0e10cSrcweir 					  break;
1167*cdf0e10cSrcweir 
1168*cdf0e10cSrcweir 		case GPOS_AREA:
1169*cdf0e10cSrcweir 					  aPos = rOrg.TopLeft();
1170*cdf0e10cSrcweir 					  aDrawSize = rOrg.GetSize();
1171*cdf0e10cSrcweir //					  bRetouche = sal_False;
1172*cdf0e10cSrcweir 					  break;
1173*cdf0e10cSrcweir 		case GPOS_TILED:
1174*cdf0e10cSrcweir 					{
1175*cdf0e10cSrcweir 						//	#104004# use GraphicObject::DrawTiled instead of an own loop
1176*cdf0e10cSrcweir 						//	(pixel rounding is handled correctly, and a very small bitmap
1177*cdf0e10cSrcweir 						//	is duplicated into a bigger one for better performance)
1178*cdf0e10cSrcweir 
1179*cdf0e10cSrcweir 						GraphicObject aObject( *pGraphic );
1180*cdf0e10cSrcweir 
1181*cdf0e10cSrcweir                         if( pOut->GetPDFWriter() &&
1182*cdf0e10cSrcweir                             (aObject.GetType() == GRAPHIC_BITMAP || aObject.GetType() == GRAPHIC_DEFAULT) )
1183*cdf0e10cSrcweir                         {
1184*cdf0e10cSrcweir                             // #104004# For PDF export, every draw
1185*cdf0e10cSrcweir                             // operation for bitmaps takes a noticeable
1186*cdf0e10cSrcweir                             // amount of place (~50 characters). Thus,
1187*cdf0e10cSrcweir                             // optimize between tile bitmap size and
1188*cdf0e10cSrcweir                             // number of drawing operations here.
1189*cdf0e10cSrcweir                             //
1190*cdf0e10cSrcweir                             //                  A_out
1191*cdf0e10cSrcweir                             // n_chars = k1 *  ---------- + k2 * A_bitmap
1192*cdf0e10cSrcweir                             //                  A_bitmap
1193*cdf0e10cSrcweir                             //
1194*cdf0e10cSrcweir                             // minimum n_chars is obtained for (derive for
1195*cdf0e10cSrcweir                             // A_bitmap, set to 0, take positive
1196*cdf0e10cSrcweir                             // solution):
1197*cdf0e10cSrcweir                             //                   k1
1198*cdf0e10cSrcweir                             // A_bitmap = Sqrt( ---- A_out )
1199*cdf0e10cSrcweir                             //                   k2
1200*cdf0e10cSrcweir                             //
1201*cdf0e10cSrcweir                             // where k1 is the number of chars per draw
1202*cdf0e10cSrcweir                             // operation, and k2 is the number of chars
1203*cdf0e10cSrcweir                             // per bitmap pixel. This is approximately 50
1204*cdf0e10cSrcweir                             // and 7 for current PDF writer, respectively.
1205*cdf0e10cSrcweir                             //
1206*cdf0e10cSrcweir                             const double	k1( 50 );
1207*cdf0e10cSrcweir                             const double	k2( 7 );
1208*cdf0e10cSrcweir                             const Size 		aSize( rOrg.GetSize() );
1209*cdf0e10cSrcweir                             const double 	Abitmap( k1/k2 * aSize.Width()*aSize.Height() );
1210*cdf0e10cSrcweir 
1211*cdf0e10cSrcweir                             aObject.DrawTiled( pOut, rOrg, aGrfSize, Size(0,0),
1212*cdf0e10cSrcweir                                                NULL, GRFMGR_DRAW_STANDARD,
1213*cdf0e10cSrcweir                                                ::std::max( 128, static_cast<int>( sqrt(sqrt( Abitmap)) + .5 ) ) );
1214*cdf0e10cSrcweir                         }
1215*cdf0e10cSrcweir                         else
1216*cdf0e10cSrcweir                         {
1217*cdf0e10cSrcweir                             aObject.DrawTiled( pOut, rOrg, aGrfSize, Size(0,0) );
1218*cdf0e10cSrcweir                         }
1219*cdf0e10cSrcweir 
1220*cdf0e10cSrcweir 						bDraw = sal_False;
1221*cdf0e10cSrcweir //						bRetouche = sal_False;
1222*cdf0e10cSrcweir 					}
1223*cdf0e10cSrcweir 					break;
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir 		case GPOS_NONE:
1226*cdf0e10cSrcweir 					  bDraw = sal_False;
1227*cdf0e10cSrcweir 					  break;
1228*cdf0e10cSrcweir 
1229*cdf0e10cSrcweir 		default: DBG_ASSERT( !pOut, "new Graphic position?" );
1230*cdf0e10cSrcweir 	}
1231*cdf0e10cSrcweir 	Rectangle aGrf( aPos,aDrawSize );
1232*cdf0e10cSrcweir 	if ( bDraw && aGrf.IsOver( rOut ) )
1233*cdf0e10cSrcweir 	{
1234*cdf0e10cSrcweir 		lcl_DrawGraphic( *pGraphic, pOut, aGrf, rOut );
1235*cdf0e10cSrcweir 	}
1236*cdf0e10cSrcweir }
1237*cdf0e10cSrcweir 
1238*cdf0e10cSrcweir //	Rahmen wird nach innen gezeichnet
1239*cdf0e10cSrcweir 
1240*cdf0e10cSrcweir void ScPrintFunc::DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
1241*cdf0e10cSrcweir 								const SvxBoxItem* pBorderData, const SvxBrushItem* pBackground,
1242*cdf0e10cSrcweir 								const SvxShadowItem* pShadow )
1243*cdf0e10cSrcweir {
1244*cdf0e10cSrcweir 	//!		direkte Ausgabe aus SvxBoxItem !!!
1245*cdf0e10cSrcweir 
1246*cdf0e10cSrcweir 	if (pBorderData)
1247*cdf0e10cSrcweir 		if ( !pBorderData->GetTop() && !pBorderData->GetBottom() && !pBorderData->GetLeft() &&
1248*cdf0e10cSrcweir 										!pBorderData->GetRight() )
1249*cdf0e10cSrcweir 			pBorderData = NULL;
1250*cdf0e10cSrcweir 
1251*cdf0e10cSrcweir 	if (!pBorderData && !pBackground && !pShadow)
1252*cdf0e10cSrcweir 		return;										// nichts zu tun
1253*cdf0e10cSrcweir 
1254*cdf0e10cSrcweir 	long nLeft   = 0;
1255*cdf0e10cSrcweir 	long nRight  = 0;
1256*cdf0e10cSrcweir 	long nTop    = 0;
1257*cdf0e10cSrcweir 	long nBottom = 0;
1258*cdf0e10cSrcweir 
1259*cdf0e10cSrcweir 	//	aFrameRect - aussen um die Umrandung, ohne Schatten
1260*cdf0e10cSrcweir 	if ( pShadow && pShadow->GetLocation() != SVX_SHADOW_NONE )
1261*cdf0e10cSrcweir 	{
1262*cdf0e10cSrcweir 		nLeft	+= (long) ( pShadow->CalcShadowSpace(SHADOW_LEFT)	* nScaleX );
1263*cdf0e10cSrcweir 		nRight	+= (long) ( pShadow->CalcShadowSpace(SHADOW_RIGHT)	* nScaleX );
1264*cdf0e10cSrcweir 		nTop	+= (long) ( pShadow->CalcShadowSpace(SHADOW_TOP)	* nScaleY );
1265*cdf0e10cSrcweir 		nBottom	+= (long) ( pShadow->CalcShadowSpace(SHADOW_BOTTOM)	* nScaleY );
1266*cdf0e10cSrcweir 	}
1267*cdf0e10cSrcweir 	Rectangle aFrameRect( Point(nScrX+nLeft, nScrY+nTop),
1268*cdf0e10cSrcweir 						  Size(nScrW-nLeft-nRight, nScrH-nTop-nBottom) );
1269*cdf0e10cSrcweir 
1270*cdf0e10cSrcweir 	//	Mitte der Umrandung, um Linien ueber OutputData zu zeichnen:
1271*cdf0e10cSrcweir 	if (pBorderData)
1272*cdf0e10cSrcweir 	{
1273*cdf0e10cSrcweir 		nLeft   += (long) ( lcl_LineTotal(pBorderData->GetLeft())   * nScaleX / 2 );
1274*cdf0e10cSrcweir 		nRight  += (long) ( lcl_LineTotal(pBorderData->GetRight())  * nScaleX / 2 );
1275*cdf0e10cSrcweir 		nTop    += (long) ( lcl_LineTotal(pBorderData->GetTop())    * nScaleY / 2 );
1276*cdf0e10cSrcweir 		nBottom += (long) ( lcl_LineTotal(pBorderData->GetBottom()) * nScaleY / 2 );
1277*cdf0e10cSrcweir 	}
1278*cdf0e10cSrcweir 	long nEffHeight = nScrH - nTop - nBottom;
1279*cdf0e10cSrcweir 	long nEffWidth = nScrW - nLeft - nRight;
1280*cdf0e10cSrcweir 	if (nEffHeight<=0 || nEffWidth<=0)
1281*cdf0e10cSrcweir 		return;											// leer
1282*cdf0e10cSrcweir 
1283*cdf0e10cSrcweir 	//	#105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed sal_True)
1284*cdf0e10cSrcweir 	sal_Bool bCellContrast = bUseStyleColor &&
1285*cdf0e10cSrcweir 			Application::GetSettings().GetStyleSettings().GetHighContrastMode();
1286*cdf0e10cSrcweir 
1287*cdf0e10cSrcweir 	if ( pBackground && !bCellContrast )
1288*cdf0e10cSrcweir 	{
1289*cdf0e10cSrcweir //		Rectangle aBackRect( Point(nScrX+nLeft, nScrY+nTop), Size(nEffWidth,nEffHeight) );
1290*cdf0e10cSrcweir 		if (pBackground->GetGraphicPos() != GPOS_NONE)
1291*cdf0e10cSrcweir 		{
1292*cdf0e10cSrcweir 			OutputDevice* pRefDev;
1293*cdf0e10cSrcweir 			if ( bIsRender )
1294*cdf0e10cSrcweir 				pRefDev = pDev;					// don't use printer for PDF
1295*cdf0e10cSrcweir 			else
1296*cdf0e10cSrcweir 				pRefDev = pDoc->GetPrinter();	// use printer also for preview
1297*cdf0e10cSrcweir 
1298*cdf0e10cSrcweir 			lcl_DrawGraphic( *pBackground, pDev, pRefDev, aFrameRect, aFrameRect );
1299*cdf0e10cSrcweir 		}
1300*cdf0e10cSrcweir 		else
1301*cdf0e10cSrcweir 		{
1302*cdf0e10cSrcweir 			pDev->SetFillColor(pBackground->GetColor());
1303*cdf0e10cSrcweir 			pDev->SetLineColor();
1304*cdf0e10cSrcweir 			pDev->DrawRect(aFrameRect);
1305*cdf0e10cSrcweir 		}
1306*cdf0e10cSrcweir 	}
1307*cdf0e10cSrcweir 
1308*cdf0e10cSrcweir 	if ( pShadow && pShadow->GetLocation() != SVX_SHADOW_NONE )
1309*cdf0e10cSrcweir 	{
1310*cdf0e10cSrcweir 		if ( bCellContrast )
1311*cdf0e10cSrcweir             pDev->SetFillColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
1312*cdf0e10cSrcweir 		else
1313*cdf0e10cSrcweir 			pDev->SetFillColor(pShadow->GetColor());
1314*cdf0e10cSrcweir 		pDev->SetLineColor();
1315*cdf0e10cSrcweir 		long nShadowX = (long) ( pShadow->GetWidth() * nScaleX );
1316*cdf0e10cSrcweir 		long nShadowY = (long) ( pShadow->GetWidth() * nScaleY );
1317*cdf0e10cSrcweir 		switch (pShadow->GetLocation())
1318*cdf0e10cSrcweir 		{
1319*cdf0e10cSrcweir 			case SVX_SHADOW_TOPLEFT:
1320*cdf0e10cSrcweir 				pDev->DrawRect( Rectangle(
1321*cdf0e10cSrcweir 						aFrameRect.Left()-nShadowX, aFrameRect.Top()-nShadowY,
1322*cdf0e10cSrcweir 						aFrameRect.Right()-nShadowX, aFrameRect.Top() ) );
1323*cdf0e10cSrcweir 				pDev->DrawRect( Rectangle(
1324*cdf0e10cSrcweir 						aFrameRect.Left()-nShadowX, aFrameRect.Top()-nShadowY,
1325*cdf0e10cSrcweir 						aFrameRect.Left(), aFrameRect.Bottom()-nShadowY ) );
1326*cdf0e10cSrcweir 				break;
1327*cdf0e10cSrcweir 			case SVX_SHADOW_TOPRIGHT:
1328*cdf0e10cSrcweir 				pDev->DrawRect( Rectangle(
1329*cdf0e10cSrcweir 						aFrameRect.Left()+nShadowX, aFrameRect.Top()-nShadowY,
1330*cdf0e10cSrcweir 						aFrameRect.Right()+nShadowX, aFrameRect.Top() ) );
1331*cdf0e10cSrcweir 				pDev->DrawRect( Rectangle(
1332*cdf0e10cSrcweir 						aFrameRect.Right(), aFrameRect.Top()-nShadowY,
1333*cdf0e10cSrcweir 						aFrameRect.Right()+nShadowX, aFrameRect.Bottom()-nShadowY ) );
1334*cdf0e10cSrcweir 				break;
1335*cdf0e10cSrcweir 			case SVX_SHADOW_BOTTOMLEFT:
1336*cdf0e10cSrcweir 				pDev->DrawRect( Rectangle(
1337*cdf0e10cSrcweir 						aFrameRect.Left()-nShadowX, aFrameRect.Bottom(),
1338*cdf0e10cSrcweir 						aFrameRect.Right()-nShadowX, aFrameRect.Bottom()+nShadowY ) );
1339*cdf0e10cSrcweir 				pDev->DrawRect( Rectangle(
1340*cdf0e10cSrcweir 						aFrameRect.Left()-nShadowX, aFrameRect.Top()+nShadowY,
1341*cdf0e10cSrcweir 						aFrameRect.Left(), aFrameRect.Bottom()+nShadowY ) );
1342*cdf0e10cSrcweir 				break;
1343*cdf0e10cSrcweir 			case SVX_SHADOW_BOTTOMRIGHT:
1344*cdf0e10cSrcweir 				pDev->DrawRect( Rectangle(
1345*cdf0e10cSrcweir 						aFrameRect.Left()+nShadowX, aFrameRect.Bottom(),
1346*cdf0e10cSrcweir 						aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) );
1347*cdf0e10cSrcweir 				pDev->DrawRect( Rectangle(
1348*cdf0e10cSrcweir 						aFrameRect.Right(), aFrameRect.Top()+nShadowY,
1349*cdf0e10cSrcweir 						aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) );
1350*cdf0e10cSrcweir 				break;
1351*cdf0e10cSrcweir             default:
1352*cdf0e10cSrcweir             {
1353*cdf0e10cSrcweir                 // added to avoid warnings
1354*cdf0e10cSrcweir             }
1355*cdf0e10cSrcweir 		}
1356*cdf0e10cSrcweir 	}
1357*cdf0e10cSrcweir 
1358*cdf0e10cSrcweir 	if (pBorderData)
1359*cdf0e10cSrcweir 	{
1360*cdf0e10cSrcweir 		ScDocument* pBorderDoc = new ScDocument( SCDOCMODE_UNDO );
1361*cdf0e10cSrcweir 		pBorderDoc->InitUndo( pDoc, 0,0, sal_True,sal_True );
1362*cdf0e10cSrcweir 		if (pBorderData)
1363*cdf0e10cSrcweir 			pBorderDoc->ApplyAttr( 0,0,0, *pBorderData );
1364*cdf0e10cSrcweir 
1365*cdf0e10cSrcweir         ScTableInfo aTabInfo;
1366*cdf0e10cSrcweir         pBorderDoc->FillInfo( aTabInfo, 0,0, 0,0, 0,
1367*cdf0e10cSrcweir 											nScaleX, nScaleY, sal_False, sal_False );
1368*cdf0e10cSrcweir         DBG_ASSERT(aTabInfo.mnArrCount,"nArrCount == 0");
1369*cdf0e10cSrcweir 
1370*cdf0e10cSrcweir         aTabInfo.mpRowInfo[1].nHeight = (sal_uInt16) nEffHeight;
1371*cdf0e10cSrcweir         aTabInfo.mpRowInfo[0].pCellInfo[1].nWidth =
1372*cdf0e10cSrcweir             aTabInfo.mpRowInfo[1].pCellInfo[1].nWidth = (sal_uInt16) nEffWidth;
1373*cdf0e10cSrcweir 
1374*cdf0e10cSrcweir         ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pBorderDoc, 0,
1375*cdf0e10cSrcweir 									nScrX+nLeft, nScrY+nTop, 0,0, 0,0, nScaleX, nScaleY );
1376*cdf0e10cSrcweir 		aOutputData.SetUseStyleColor( bUseStyleColor );
1377*cdf0e10cSrcweir 
1378*cdf0e10cSrcweir //		pDev->SetMapMode(aTwipMode);
1379*cdf0e10cSrcweir 
1380*cdf0e10cSrcweir 		if (pBorderData)
1381*cdf0e10cSrcweir 			aOutputData.DrawFrame();
1382*cdf0e10cSrcweir 
1383*cdf0e10cSrcweir 		delete pBorderDoc;
1384*cdf0e10cSrcweir 	}
1385*cdf0e10cSrcweir }
1386*cdf0e10cSrcweir 
1387*cdf0e10cSrcweir void ScPrintFunc::PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY )
1388*cdf0e10cSrcweir {
1389*cdf0e10cSrcweir 	sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
1390*cdf0e10cSrcweir 	long nLayoutSign = bLayoutRTL ? -1 : 1;
1391*cdf0e10cSrcweir 
1392*cdf0e10cSrcweir 	Size aOnePixel = pDev->PixelToLogic(Size(1,1));
1393*cdf0e10cSrcweir 	long nOneX = aOnePixel.Width();
1394*cdf0e10cSrcweir 	long nOneY = aOnePixel.Height();
1395*cdf0e10cSrcweir 	SCCOL nCol;
1396*cdf0e10cSrcweir 
1397*cdf0e10cSrcweir 	long nHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY);
1398*cdf0e10cSrcweir 	long nEndY = nScrY + nHeight - nOneY;
1399*cdf0e10cSrcweir 
1400*cdf0e10cSrcweir 	long nPosX = nScrX;
1401*cdf0e10cSrcweir 	if ( bLayoutRTL )
1402*cdf0e10cSrcweir 	{
1403*cdf0e10cSrcweir 		for (nCol=nX1; nCol<=nX2; nCol++)
1404*cdf0e10cSrcweir 			nPosX += (long)( pDoc->GetColWidth( nCol, nPrintTab ) * nScaleX );
1405*cdf0e10cSrcweir 	}
1406*cdf0e10cSrcweir 	else
1407*cdf0e10cSrcweir 		nPosX -= nOneX;
1408*cdf0e10cSrcweir 	long nPosY = nScrY - nOneY;
1409*cdf0e10cSrcweir 	String aText;
1410*cdf0e10cSrcweir 
1411*cdf0e10cSrcweir 	for (nCol=nX1; nCol<=nX2; nCol++)
1412*cdf0e10cSrcweir 	{
1413*cdf0e10cSrcweir 		sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nPrintTab );
1414*cdf0e10cSrcweir 		if (nDocW)
1415*cdf0e10cSrcweir 		{
1416*cdf0e10cSrcweir 			long nWidth = (long) (nDocW * nScaleX);
1417*cdf0e10cSrcweir 			long nEndX = nPosX + nWidth * nLayoutSign;
1418*cdf0e10cSrcweir 
1419*cdf0e10cSrcweir 			pDev->DrawRect( Rectangle( nPosX,nPosY,nEndX,nEndY ) );
1420*cdf0e10cSrcweir 
1421*cdf0e10cSrcweir             aText = ::ScColToAlpha( nCol);
1422*cdf0e10cSrcweir 			long nTextWidth = pDev->GetTextWidth(aText);
1423*cdf0e10cSrcweir 			long nTextHeight = pDev->GetTextHeight();
1424*cdf0e10cSrcweir 			long nAddX = ( nWidth  - nTextWidth  ) / 2;
1425*cdf0e10cSrcweir 			long nAddY = ( nHeight - nTextHeight ) / 2;
1426*cdf0e10cSrcweir 			long nTextPosX = nPosX+nAddX;
1427*cdf0e10cSrcweir 			if ( bLayoutRTL )
1428*cdf0e10cSrcweir 				nTextPosX -= nWidth;
1429*cdf0e10cSrcweir 			pDev->DrawText( Point( nTextPosX,nPosY+nAddY ), aText );
1430*cdf0e10cSrcweir 
1431*cdf0e10cSrcweir 			nPosX = nEndX;
1432*cdf0e10cSrcweir 		}
1433*cdf0e10cSrcweir 	}
1434*cdf0e10cSrcweir }
1435*cdf0e10cSrcweir 
1436*cdf0e10cSrcweir void ScPrintFunc::PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY )
1437*cdf0e10cSrcweir {
1438*cdf0e10cSrcweir 	Size aOnePixel = pDev->PixelToLogic(Size(1,1));
1439*cdf0e10cSrcweir 	long nOneX = aOnePixel.Width();
1440*cdf0e10cSrcweir 	long nOneY = aOnePixel.Height();
1441*cdf0e10cSrcweir 
1442*cdf0e10cSrcweir 	sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
1443*cdf0e10cSrcweir 
1444*cdf0e10cSrcweir 	long nWidth = (long) (PRINT_HEADER_WIDTH * nScaleX);
1445*cdf0e10cSrcweir 	long nEndX = nScrX + nWidth;
1446*cdf0e10cSrcweir 	long nPosX = nScrX;
1447*cdf0e10cSrcweir 	if ( !bLayoutRTL )
1448*cdf0e10cSrcweir 	{
1449*cdf0e10cSrcweir 		nEndX -= nOneX;
1450*cdf0e10cSrcweir 		nPosX -= nOneX;
1451*cdf0e10cSrcweir 	}
1452*cdf0e10cSrcweir 	long nPosY = nScrY - nOneY;
1453*cdf0e10cSrcweir 	String aText;
1454*cdf0e10cSrcweir 
1455*cdf0e10cSrcweir 	for (SCROW nRow=nY1; nRow<=nY2; nRow++)
1456*cdf0e10cSrcweir 	{
1457*cdf0e10cSrcweir 		sal_uInt16 nDocH = pDoc->GetRowHeight( nRow, nPrintTab );
1458*cdf0e10cSrcweir 		if (nDocH)
1459*cdf0e10cSrcweir 		{
1460*cdf0e10cSrcweir 			long nHeight = (long) (nDocH * nScaleY);
1461*cdf0e10cSrcweir 			long nEndY = nPosY + nHeight;
1462*cdf0e10cSrcweir 
1463*cdf0e10cSrcweir 			pDev->DrawRect( Rectangle( nPosX,nPosY,nEndX,nEndY ) );
1464*cdf0e10cSrcweir 
1465*cdf0e10cSrcweir 			aText = String::CreateFromInt32( nRow+1 );
1466*cdf0e10cSrcweir 			long nTextWidth = pDev->GetTextWidth(aText);
1467*cdf0e10cSrcweir 			long nTextHeight = pDev->GetTextHeight();
1468*cdf0e10cSrcweir 			long nAddX = ( nWidth  - nTextWidth  ) / 2;
1469*cdf0e10cSrcweir 			long nAddY = ( nHeight - nTextHeight ) / 2;
1470*cdf0e10cSrcweir 			pDev->DrawText( Point( nPosX+nAddX,nPosY+nAddY ), aText );
1471*cdf0e10cSrcweir 
1472*cdf0e10cSrcweir 			nPosY = nEndY;
1473*cdf0e10cSrcweir 		}
1474*cdf0e10cSrcweir 	}
1475*cdf0e10cSrcweir }
1476*cdf0e10cSrcweir 
1477*cdf0e10cSrcweir void ScPrintFunc::LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
1478*cdf0e10cSrcweir 								sal_Bool bRepCol, ScPreviewLocationData& rLocationData )
1479*cdf0e10cSrcweir {
1480*cdf0e10cSrcweir 	Size aOnePixel = pDev->PixelToLogic(Size(1,1));
1481*cdf0e10cSrcweir 	long nOneX = aOnePixel.Width();
1482*cdf0e10cSrcweir 	long nOneY = aOnePixel.Height();
1483*cdf0e10cSrcweir 
1484*cdf0e10cSrcweir 	long nHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY);
1485*cdf0e10cSrcweir 	long nEndY = nScrY + nHeight - nOneY;
1486*cdf0e10cSrcweir 
1487*cdf0e10cSrcweir 	long nPosX = nScrX - nOneX;
1488*cdf0e10cSrcweir 	for (SCCOL nCol=nX1; nCol<=nX2; nCol++)
1489*cdf0e10cSrcweir 	{
1490*cdf0e10cSrcweir 		sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nPrintTab );
1491*cdf0e10cSrcweir 		if (nDocW)
1492*cdf0e10cSrcweir 			nPosX += (long) (nDocW * nScaleX);
1493*cdf0e10cSrcweir 	}
1494*cdf0e10cSrcweir 	Rectangle aCellRect( nScrX, nScrY, nPosX, nEndY );
1495*cdf0e10cSrcweir 	rLocationData.AddColHeaders( aCellRect, nX1, nX2, bRepCol );
1496*cdf0e10cSrcweir }
1497*cdf0e10cSrcweir 
1498*cdf0e10cSrcweir void ScPrintFunc::LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
1499*cdf0e10cSrcweir 								sal_Bool bRepRow, ScPreviewLocationData& rLocationData )
1500*cdf0e10cSrcweir {
1501*cdf0e10cSrcweir 	Size aOnePixel = pDev->PixelToLogic(Size(1,1));
1502*cdf0e10cSrcweir 	long nOneX = aOnePixel.Width();
1503*cdf0e10cSrcweir 	long nOneY = aOnePixel.Height();
1504*cdf0e10cSrcweir 
1505*cdf0e10cSrcweir 	sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
1506*cdf0e10cSrcweir 
1507*cdf0e10cSrcweir 	long nWidth = (long) (PRINT_HEADER_WIDTH * nScaleX);
1508*cdf0e10cSrcweir 	long nEndX = nScrX + nWidth;
1509*cdf0e10cSrcweir 	if ( !bLayoutRTL )
1510*cdf0e10cSrcweir 		nEndX -= nOneX;
1511*cdf0e10cSrcweir 
1512*cdf0e10cSrcweir 	long nPosY = nScrY - nOneY;
1513*cdf0e10cSrcweir     nPosY += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY);
1514*cdf0e10cSrcweir 	Rectangle aCellRect( nScrX, nScrY, nEndX, nPosY );
1515*cdf0e10cSrcweir 	rLocationData.AddRowHeaders( aCellRect, nY1, nY2, bRepRow );
1516*cdf0e10cSrcweir }
1517*cdf0e10cSrcweir 
1518*cdf0e10cSrcweir void ScPrintFunc::LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
1519*cdf0e10cSrcweir 								long nScrX, long nScrY, sal_Bool bRepCol, sal_Bool bRepRow,
1520*cdf0e10cSrcweir 								ScPreviewLocationData& rLocationData )
1521*cdf0e10cSrcweir {
1522*cdf0e10cSrcweir 	//	get MapMode for drawing objects (same MapMode as in ScOutputData::PrintDrawingLayer)
1523*cdf0e10cSrcweir 
1524*cdf0e10cSrcweir 	Point aLogPos = OutputDevice::LogicToLogic(Point(nScrX,nScrY), aOffsetMode, aLogicMode);
1525*cdf0e10cSrcweir 	long nLogStX = aLogPos.X();
1526*cdf0e10cSrcweir 	long nLogStY = aLogPos.Y();
1527*cdf0e10cSrcweir 
1528*cdf0e10cSrcweir 	SCCOL nCol;
1529*cdf0e10cSrcweir 	Point aTwipOffset;
1530*cdf0e10cSrcweir 	for (nCol=0; nCol<nX1; nCol++)
1531*cdf0e10cSrcweir 		aTwipOffset.X() -= pDoc->GetColWidth( nCol, nPrintTab );
1532*cdf0e10cSrcweir     aTwipOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nPrintTab );
1533*cdf0e10cSrcweir 
1534*cdf0e10cSrcweir 	Point aMMOffset( aTwipOffset );
1535*cdf0e10cSrcweir 	aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
1536*cdf0e10cSrcweir 	aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
1537*cdf0e10cSrcweir 	aMMOffset += Point( nLogStX, nLogStY );
1538*cdf0e10cSrcweir 	MapMode aDrawMapMode( MAP_100TH_MM, aMMOffset, aLogicMode.GetScaleX(), aLogicMode.GetScaleY() );
1539*cdf0e10cSrcweir 
1540*cdf0e10cSrcweir 	//	get pixel rectangle
1541*cdf0e10cSrcweir 
1542*cdf0e10cSrcweir 	Size aOnePixel = pDev->PixelToLogic(Size(1,1));
1543*cdf0e10cSrcweir 	long nOneX = aOnePixel.Width();
1544*cdf0e10cSrcweir 	long nOneY = aOnePixel.Height();
1545*cdf0e10cSrcweir 
1546*cdf0e10cSrcweir 	long nPosX = nScrX - nOneX;
1547*cdf0e10cSrcweir 	for (nCol=nX1; nCol<=nX2; nCol++)
1548*cdf0e10cSrcweir 	{
1549*cdf0e10cSrcweir 		sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nPrintTab );
1550*cdf0e10cSrcweir 		if (nDocW)
1551*cdf0e10cSrcweir 			nPosX += (long) (nDocW * nScaleX);
1552*cdf0e10cSrcweir 	}
1553*cdf0e10cSrcweir 
1554*cdf0e10cSrcweir 	long nPosY = nScrY - nOneY;
1555*cdf0e10cSrcweir     nPosY += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY);
1556*cdf0e10cSrcweir 	Rectangle aCellRect( nScrX, nScrY, nPosX, nPosY );
1557*cdf0e10cSrcweir 	rLocationData.AddCellRange( aCellRect, ScRange( nX1,nY1,nPrintTab, nX2,nY2,nPrintTab ),
1558*cdf0e10cSrcweir 								bRepCol, bRepRow, aDrawMapMode );
1559*cdf0e10cSrcweir }
1560*cdf0e10cSrcweir 
1561*cdf0e10cSrcweir void ScPrintFunc::PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
1562*cdf0e10cSrcweir 								long nScrX, long nScrY,
1563*cdf0e10cSrcweir 								sal_Bool bShLeft, sal_Bool bShTop, sal_Bool bShRight, sal_Bool bShBottom )
1564*cdf0e10cSrcweir {
1565*cdf0e10cSrcweir     // #i47547# nothing to do if the end of the print area is before the end of
1566*cdf0e10cSrcweir     // the repeat columns/rows (don't use negative size for ScOutputData)
1567*cdf0e10cSrcweir     if ( nX2 < nX1 || nY2 < nY1 )
1568*cdf0e10cSrcweir         return;
1569*cdf0e10cSrcweir 
1570*cdf0e10cSrcweir 							//!		Flag bei FillInfo uebergeben !!!!!
1571*cdf0e10cSrcweir     ScRange aERange;
1572*cdf0e10cSrcweir 	sal_Bool bEmbed = pDoc->IsEmbedded();
1573*cdf0e10cSrcweir 	if (bEmbed)
1574*cdf0e10cSrcweir 	{
1575*cdf0e10cSrcweir 		pDoc->GetEmbedded(aERange);
1576*cdf0e10cSrcweir 		pDoc->ResetEmbedded();
1577*cdf0e10cSrcweir 	}
1578*cdf0e10cSrcweir 
1579*cdf0e10cSrcweir 	Point aPos = OutputDevice::LogicToLogic(Point(nScrX,nScrY), aOffsetMode, aLogicMode);
1580*cdf0e10cSrcweir 	long nLogStX = aPos.X();
1581*cdf0e10cSrcweir 	long nLogStY = aPos.Y();
1582*cdf0e10cSrcweir 
1583*cdf0e10cSrcweir 					//	Daten zusammenstellen
1584*cdf0e10cSrcweir 
1585*cdf0e10cSrcweir     ScTableInfo aTabInfo;
1586*cdf0e10cSrcweir     pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nPrintTab,
1587*cdf0e10cSrcweir 										nScaleX, nScaleY, sal_True, aTableParam.bFormulas );
1588*cdf0e10cSrcweir     lcl_HidePrint( aTabInfo, nX1, nX2 );
1589*cdf0e10cSrcweir 
1590*cdf0e10cSrcweir 	if (bEmbed)
1591*cdf0e10cSrcweir 		pDoc->SetEmbedded(aERange);
1592*cdf0e10cSrcweir 
1593*cdf0e10cSrcweir     ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pDoc, nPrintTab,
1594*cdf0e10cSrcweir 								nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY );
1595*cdf0e10cSrcweir 
1596*cdf0e10cSrcweir 	// #114135#
1597*cdf0e10cSrcweir 	aOutputData.SetDrawView( pDrawView );
1598*cdf0e10cSrcweir 
1599*cdf0e10cSrcweir 	// test if all paint parts are hidden, then a paint is not necessary at all
1600*cdf0e10cSrcweir 	const Point aMMOffset(aOutputData.PrePrintDrawingLayer(nLogStX, nLogStY));
1601*cdf0e10cSrcweir     const bool bHideAllDrawingLayer( pDrawView && pDrawView->getHideOle() && pDrawView->getHideChart()
1602*cdf0e10cSrcweir             && pDrawView->getHideDraw() && pDrawView->getHideFormControl() );
1603*cdf0e10cSrcweir 
1604*cdf0e10cSrcweir     if(!bHideAllDrawingLayer)
1605*cdf0e10cSrcweir 	{
1606*cdf0e10cSrcweir 		pDev->SetMapMode(aLogicMode);
1607*cdf0e10cSrcweir 		//	hier kein Clipping setzen (Mapmode wird verschoben)
1608*cdf0e10cSrcweir 
1609*cdf0e10cSrcweir 		// #i72502#
1610*cdf0e10cSrcweir 		aOutputData.PrintDrawingLayer(SC_LAYER_BACK, aMMOffset);
1611*cdf0e10cSrcweir 	}
1612*cdf0e10cSrcweir 
1613*cdf0e10cSrcweir 	pDev->SetMapMode(aOffsetMode);
1614*cdf0e10cSrcweir 
1615*cdf0e10cSrcweir 	aOutputData.SetShowFormulas( aTableParam.bFormulas );
1616*cdf0e10cSrcweir 	aOutputData.SetShowNullValues( aTableParam.bNullVals );
1617*cdf0e10cSrcweir 	aOutputData.SetUseStyleColor( bUseStyleColor );
1618*cdf0e10cSrcweir 
1619*cdf0e10cSrcweir 	Color aGridColor( COL_BLACK );
1620*cdf0e10cSrcweir 	if ( bUseStyleColor )
1621*cdf0e10cSrcweir         aGridColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
1622*cdf0e10cSrcweir 	aOutputData.SetGridColor( aGridColor );
1623*cdf0e10cSrcweir 
1624*cdf0e10cSrcweir 	if ( !pPrinter )
1625*cdf0e10cSrcweir 	{
1626*cdf0e10cSrcweir 		OutputDevice* pRefDev = pDoc->GetPrinter();		// auch fuer Preview den Drucker nehmen
1627*cdf0e10cSrcweir 		Fraction aPrintFrac( nZoom, 100 );				// ohne nManualZoom
1628*cdf0e10cSrcweir 		//	MapMode, wie er beim Drucken herauskommen wuerde:
1629*cdf0e10cSrcweir 		pRefDev->SetMapMode( MapMode( MAP_100TH_MM, Point(), aPrintFrac, aPrintFrac ) );
1630*cdf0e10cSrcweir 
1631*cdf0e10cSrcweir 		//	when rendering (PDF), don't use printer as ref device, but printer's MapMode
1632*cdf0e10cSrcweir 		//	has to be set anyway, as charts still use it (#106409#)
1633*cdf0e10cSrcweir 		if ( !bIsRender )
1634*cdf0e10cSrcweir 			aOutputData.SetRefDevice( pRefDev );
1635*cdf0e10cSrcweir 	}
1636*cdf0e10cSrcweir 
1637*cdf0e10cSrcweir //	aOutputData.SetMetaFileMode(sal_True);
1638*cdf0e10cSrcweir     if( aTableParam.bCellContent )
1639*cdf0e10cSrcweir 	    aOutputData.DrawBackground();
1640*cdf0e10cSrcweir 
1641*cdf0e10cSrcweir 	pDev->SetClipRegion( Rectangle( aPos, Size( aOutputData.GetScrW(), aOutputData.GetScrH() ) ) );
1642*cdf0e10cSrcweir 	pDev->SetClipRegion();
1643*cdf0e10cSrcweir 
1644*cdf0e10cSrcweir //	aOutputData.SetMetaFileMode(sal_False);
1645*cdf0e10cSrcweir     if( aTableParam.bCellContent )
1646*cdf0e10cSrcweir     {
1647*cdf0e10cSrcweir 	    aOutputData.DrawExtraShadow( bShLeft, bShTop, bShRight, bShBottom );
1648*cdf0e10cSrcweir 	    aOutputData.DrawFrame();
1649*cdf0e10cSrcweir 	    aOutputData.DrawStrings();
1650*cdf0e10cSrcweir 
1651*cdf0e10cSrcweir     //	pDev->SetMapMode(aLogicMode);
1652*cdf0e10cSrcweir 	    aOutputData.DrawEdit(sal_False);
1653*cdf0e10cSrcweir     }
1654*cdf0e10cSrcweir 
1655*cdf0e10cSrcweir //	pDev->SetMapMode(aOffsetMode);
1656*cdf0e10cSrcweir 	if (aTableParam.bGrid)
1657*cdf0e10cSrcweir 		aOutputData.DrawGrid( sal_True, sal_False );	// keine Seitenumbrueche
1658*cdf0e10cSrcweir 
1659*cdf0e10cSrcweir /*!!!!!!!!!!!		Notizen in Tabelle markieren ??????????????????????????
1660*cdf0e10cSrcweir 
1661*cdf0e10cSrcweir 	if (aTableParam.bNotes)
1662*cdf0e10cSrcweir 	{
1663*cdf0e10cSrcweir 		pDev->SetMapMode(aOffsetMode);
1664*cdf0e10cSrcweir 		aOutputData.PrintNoteMarks(aNotePosList);
1665*cdf0e10cSrcweir 		pDev->SetMapMode(aLogicMode);
1666*cdf0e10cSrcweir 	}
1667*cdf0e10cSrcweir */
1668*cdf0e10cSrcweir 
1669*cdf0e10cSrcweir     aOutputData.AddPDFNotes();      // has no effect if not rendering PDF with notes enabled
1670*cdf0e10cSrcweir 
1671*cdf0e10cSrcweir //	pDev->SetMapMode(aDrawMode);
1672*cdf0e10cSrcweir 
1673*cdf0e10cSrcweir 	// test if all paint parts are hidden, then a paint is not necessary at all
1674*cdf0e10cSrcweir 	if(!bHideAllDrawingLayer)
1675*cdf0e10cSrcweir 	{
1676*cdf0e10cSrcweir 		// #i72502#
1677*cdf0e10cSrcweir 		aOutputData.PrintDrawingLayer(SC_LAYER_FRONT, aMMOffset);
1678*cdf0e10cSrcweir 	}
1679*cdf0e10cSrcweir 
1680*cdf0e10cSrcweir 	// #i72502#
1681*cdf0e10cSrcweir 	aOutputData.PrintDrawingLayer(SC_LAYER_INTERN, aMMOffset);
1682*cdf0e10cSrcweir 	aOutputData.PostPrintDrawingLayer(aMMOffset); // #i74768#
1683*cdf0e10cSrcweir }
1684*cdf0e10cSrcweir 
1685*cdf0e10cSrcweir sal_Bool ScPrintFunc::IsMirror( long nPageNo )			// Raender spiegeln ?
1686*cdf0e10cSrcweir {
1687*cdf0e10cSrcweir 	SvxPageUsage eUsage = (SvxPageUsage) ( nPageUsage & 0x000f );
1688*cdf0e10cSrcweir 	return ( eUsage == SVX_PAGE_MIRROR && (nPageNo & 1) );
1689*cdf0e10cSrcweir }
1690*cdf0e10cSrcweir 
1691*cdf0e10cSrcweir sal_Bool ScPrintFunc::IsLeft( long nPageNo )			// linke Fussnoten ?
1692*cdf0e10cSrcweir {
1693*cdf0e10cSrcweir 	SvxPageUsage eUsage = (SvxPageUsage) ( nPageUsage & 0x000f );
1694*cdf0e10cSrcweir 	sal_Bool bLeft;
1695*cdf0e10cSrcweir 	if (eUsage == SVX_PAGE_LEFT)
1696*cdf0e10cSrcweir 		bLeft = sal_True;
1697*cdf0e10cSrcweir 	else if (eUsage == SVX_PAGE_RIGHT)
1698*cdf0e10cSrcweir 		bLeft = sal_False;
1699*cdf0e10cSrcweir 	else
1700*cdf0e10cSrcweir 		bLeft = (nPageNo & 1) != 0;
1701*cdf0e10cSrcweir 	return bLeft;
1702*cdf0e10cSrcweir }
1703*cdf0e10cSrcweir 
1704*cdf0e10cSrcweir void ScPrintFunc::MakeTableString()
1705*cdf0e10cSrcweir {
1706*cdf0e10cSrcweir 	pDoc->GetName( nPrintTab, aFieldData.aTabName );
1707*cdf0e10cSrcweir }
1708*cdf0e10cSrcweir 
1709*cdf0e10cSrcweir void ScPrintFunc::MakeEditEngine()
1710*cdf0e10cSrcweir {
1711*cdf0e10cSrcweir 	if (!pEditEngine)
1712*cdf0e10cSrcweir 	{
1713*cdf0e10cSrcweir 		//	can't use document's edit engine pool here,
1714*cdf0e10cSrcweir 		//	because pool must have twips as default metric
1715*cdf0e10cSrcweir 		pEditEngine = new ScHeaderEditEngine( EditEngine::CreatePool(), sal_True );
1716*cdf0e10cSrcweir 
1717*cdf0e10cSrcweir 		pEditEngine->EnableUndo(sal_False);
1718*cdf0e10cSrcweir 		pEditEngine->SetRefDevice( pDev );
1719*cdf0e10cSrcweir 		pEditEngine->SetWordDelimiters(
1720*cdf0e10cSrcweir 				ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
1721*cdf0e10cSrcweir 		pEditEngine->SetControlWord( pEditEngine->GetControlWord() & ~EE_CNTRL_RTFSTYLESHEETS );
1722*cdf0e10cSrcweir         pDoc->ApplyAsianEditSettings( *pEditEngine );
1723*cdf0e10cSrcweir 		pEditEngine->EnableAutoColor( bUseStyleColor );
1724*cdf0e10cSrcweir 
1725*cdf0e10cSrcweir 		//	Default-Set fuer Ausrichtung
1726*cdf0e10cSrcweir 		pEditDefaults = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
1727*cdf0e10cSrcweir 
1728*cdf0e10cSrcweir 		const ScPatternAttr& rPattern = (const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN);
1729*cdf0e10cSrcweir 		rPattern.FillEditItemSet( pEditDefaults );
1730*cdf0e10cSrcweir 		//	FillEditItemSet adjusts font height to 1/100th mm,
1731*cdf0e10cSrcweir 		//	but for header/footer twips is needed, as in the PatternAttr:
1732*cdf0e10cSrcweir 		pEditDefaults->Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
1733*cdf0e10cSrcweir 		pEditDefaults->Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
1734*cdf0e10cSrcweir 		pEditDefaults->Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
1735*cdf0e10cSrcweir 		//	#69193# dont use font color, because background color is not used
1736*cdf0e10cSrcweir 		//!	there's no way to set the background for note pages
1737*cdf0e10cSrcweir 		pEditDefaults->ClearItem( EE_CHAR_COLOR );
1738*cdf0e10cSrcweir 		if (ScGlobal::IsSystemRTL())
1739*cdf0e10cSrcweir 			pEditDefaults->Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
1740*cdf0e10cSrcweir 	}
1741*cdf0e10cSrcweir 
1742*cdf0e10cSrcweir 	pEditEngine->SetData( aFieldData );		// Seitennummer etc. setzen
1743*cdf0e10cSrcweir }
1744*cdf0e10cSrcweir 
1745*cdf0e10cSrcweir //	nStartY = logic
1746*cdf0e10cSrcweir void ScPrintFunc::PrintHF( long nPageNo, sal_Bool bHeader, long nStartY,
1747*cdf0e10cSrcweir 							sal_Bool bDoPrint, ScPreviewLocationData* pLocationData )
1748*cdf0e10cSrcweir {
1749*cdf0e10cSrcweir 	const ScPrintHFParam& rParam = bHeader ? aHdr : aFtr;
1750*cdf0e10cSrcweir 
1751*cdf0e10cSrcweir 	pDev->SetMapMode( aTwipMode );			// Kopf-/Fusszeilen in Twips
1752*cdf0e10cSrcweir 
1753*cdf0e10cSrcweir 	sal_Bool bLeft = IsLeft(nPageNo) && !rParam.bShared;
1754*cdf0e10cSrcweir 	const ScPageHFItem* pHFItem = bLeft ? rParam.pLeft : rParam.pRight;
1755*cdf0e10cSrcweir 
1756*cdf0e10cSrcweir 	long nLineStartX = aPageRect.Left()  + rParam.nLeft;
1757*cdf0e10cSrcweir 	long nLineEndX	 = aPageRect.Right() - rParam.nRight;
1758*cdf0e10cSrcweir 	long nLineWidth  = nLineEndX - nLineStartX + 1;
1759*cdf0e10cSrcweir 
1760*cdf0e10cSrcweir 	//	Edit-Engine
1761*cdf0e10cSrcweir 
1762*cdf0e10cSrcweir 	Point aStart( nLineStartX, nStartY );
1763*cdf0e10cSrcweir 	Size aPaperSize( nLineWidth, rParam.nHeight-rParam.nDistance );
1764*cdf0e10cSrcweir 	if ( rParam.pBorder )
1765*cdf0e10cSrcweir 	{
1766*cdf0e10cSrcweir 		long nLeft = lcl_LineTotal( rParam.pBorder->GetLeft() ) + rParam.pBorder->GetDistance(BOX_LINE_LEFT);
1767*cdf0e10cSrcweir 		long nTop = lcl_LineTotal( rParam.pBorder->GetTop() ) + rParam.pBorder->GetDistance(BOX_LINE_TOP);
1768*cdf0e10cSrcweir 		aStart.X() += nLeft;
1769*cdf0e10cSrcweir 		aStart.Y() += nTop;
1770*cdf0e10cSrcweir 		aPaperSize.Width() -= nLeft + lcl_LineTotal( rParam.pBorder->GetRight() ) + rParam.pBorder->GetDistance(BOX_LINE_RIGHT);
1771*cdf0e10cSrcweir 		aPaperSize.Height() -= nTop + lcl_LineTotal( rParam.pBorder->GetBottom() ) + rParam.pBorder->GetDistance(BOX_LINE_BOTTOM);
1772*cdf0e10cSrcweir 	}
1773*cdf0e10cSrcweir 
1774*cdf0e10cSrcweir 	if ( rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE )
1775*cdf0e10cSrcweir 	{
1776*cdf0e10cSrcweir 		long nLeft	= rParam.pShadow->CalcShadowSpace(SHADOW_LEFT);
1777*cdf0e10cSrcweir 		long nTop	= rParam.pShadow->CalcShadowSpace(SHADOW_TOP);
1778*cdf0e10cSrcweir 		aStart.X() += nLeft;
1779*cdf0e10cSrcweir 		aStart.Y() += nTop;
1780*cdf0e10cSrcweir 		aPaperSize.Width() -= nLeft + rParam.pShadow->CalcShadowSpace(SHADOW_RIGHT);
1781*cdf0e10cSrcweir 		aPaperSize.Height() -= nTop + rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM);
1782*cdf0e10cSrcweir 	}
1783*cdf0e10cSrcweir 
1784*cdf0e10cSrcweir 	aFieldData.nPageNo = nPageNo+aTableParam.nFirstPageNo;
1785*cdf0e10cSrcweir 	MakeEditEngine();
1786*cdf0e10cSrcweir 
1787*cdf0e10cSrcweir 	pEditEngine->SetPaperSize(aPaperSize);
1788*cdf0e10cSrcweir 	const EditTextObject* pObject;
1789*cdf0e10cSrcweir 
1790*cdf0e10cSrcweir 	//	Rahmen / Hintergrund
1791*cdf0e10cSrcweir 
1792*cdf0e10cSrcweir 	Point aBorderStart( nLineStartX, nStartY );
1793*cdf0e10cSrcweir 	Size aBorderSize( nLineWidth, rParam.nHeight-rParam.nDistance );
1794*cdf0e10cSrcweir 	if ( rParam.bDynamic )
1795*cdf0e10cSrcweir 	{
1796*cdf0e10cSrcweir 		//	hier nochmal anpassen, wegen geraden/ungeraden Kopf/Fusszeilen
1797*cdf0e10cSrcweir 		//	und evtl. anderen Umbruechen durch Variablen (Seitennummer etc.)
1798*cdf0e10cSrcweir 
1799*cdf0e10cSrcweir 		long nMaxHeight = 0;
1800*cdf0e10cSrcweir 		nMaxHeight = Max( nMaxHeight, TextHeight( pHFItem->GetLeftArea() ) );
1801*cdf0e10cSrcweir 		nMaxHeight = Max( nMaxHeight, TextHeight( pHFItem->GetCenterArea() ) );
1802*cdf0e10cSrcweir 		nMaxHeight = Max( nMaxHeight, TextHeight( pHFItem->GetRightArea() ) );
1803*cdf0e10cSrcweir 		if (rParam.pBorder)
1804*cdf0e10cSrcweir 			nMaxHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) +
1805*cdf0e10cSrcweir 						  lcl_LineTotal( rParam.pBorder->GetBottom() ) +
1806*cdf0e10cSrcweir 									rParam.pBorder->GetDistance(BOX_LINE_TOP) +
1807*cdf0e10cSrcweir 									rParam.pBorder->GetDistance(BOX_LINE_BOTTOM);
1808*cdf0e10cSrcweir 		if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
1809*cdf0e10cSrcweir 			nMaxHeight += rParam.pShadow->CalcShadowSpace(SHADOW_TOP) +
1810*cdf0e10cSrcweir 						  rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM);
1811*cdf0e10cSrcweir 
1812*cdf0e10cSrcweir 		if (nMaxHeight < rParam.nManHeight-rParam.nDistance)
1813*cdf0e10cSrcweir 			nMaxHeight = rParam.nManHeight-rParam.nDistance;		// eingestelltes Minimum
1814*cdf0e10cSrcweir 
1815*cdf0e10cSrcweir 		aBorderSize.Height() = nMaxHeight;
1816*cdf0e10cSrcweir 	}
1817*cdf0e10cSrcweir 
1818*cdf0e10cSrcweir 	if ( bDoPrint )
1819*cdf0e10cSrcweir 	{
1820*cdf0e10cSrcweir 		double nOldScaleX = nScaleX;
1821*cdf0e10cSrcweir 		double nOldScaleY = nScaleY;
1822*cdf0e10cSrcweir 		nScaleX = nScaleY = 1.0;			// direkt in Twips ausgeben
1823*cdf0e10cSrcweir 		DrawBorder( aBorderStart.X(), aBorderStart.Y(), aBorderSize.Width(), aBorderSize.Height(),
1824*cdf0e10cSrcweir 						rParam.pBorder, rParam.pBack, rParam.pShadow );
1825*cdf0e10cSrcweir 		nScaleX = nOldScaleX;
1826*cdf0e10cSrcweir 		nScaleY = nOldScaleY;
1827*cdf0e10cSrcweir 
1828*cdf0e10cSrcweir 		//	Clipping fuer Text
1829*cdf0e10cSrcweir 
1830*cdf0e10cSrcweir 		pDev->SetClipRegion( Rectangle( aStart, aPaperSize ) );
1831*cdf0e10cSrcweir 
1832*cdf0e10cSrcweir 		//	links
1833*cdf0e10cSrcweir 
1834*cdf0e10cSrcweir 		pObject = pHFItem->GetLeftArea();
1835*cdf0e10cSrcweir 		if (pObject)
1836*cdf0e10cSrcweir 		{
1837*cdf0e10cSrcweir 			pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
1838*cdf0e10cSrcweir 			pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, sal_False );
1839*cdf0e10cSrcweir 			Point aDraw = aStart;
1840*cdf0e10cSrcweir 			long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight();
1841*cdf0e10cSrcweir 			if (nDif > 0)
1842*cdf0e10cSrcweir 				aDraw.Y() += nDif / 2;
1843*cdf0e10cSrcweir 			pEditEngine->Draw( pDev, aDraw, 0 );
1844*cdf0e10cSrcweir 		}
1845*cdf0e10cSrcweir 
1846*cdf0e10cSrcweir 		//	Mitte
1847*cdf0e10cSrcweir 
1848*cdf0e10cSrcweir 		pObject = pHFItem->GetCenterArea();
1849*cdf0e10cSrcweir 		if (pObject)
1850*cdf0e10cSrcweir 		{
1851*cdf0e10cSrcweir 			pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
1852*cdf0e10cSrcweir 			pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, sal_False );
1853*cdf0e10cSrcweir 			Point aDraw = aStart;
1854*cdf0e10cSrcweir 			long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight();
1855*cdf0e10cSrcweir 			if (nDif > 0)
1856*cdf0e10cSrcweir 				aDraw.Y() += nDif / 2;
1857*cdf0e10cSrcweir 			pEditEngine->Draw( pDev, aDraw, 0 );
1858*cdf0e10cSrcweir 		}
1859*cdf0e10cSrcweir 
1860*cdf0e10cSrcweir 		//	rechts
1861*cdf0e10cSrcweir 
1862*cdf0e10cSrcweir 		pObject = pHFItem->GetRightArea();
1863*cdf0e10cSrcweir 		if (pObject)
1864*cdf0e10cSrcweir 		{
1865*cdf0e10cSrcweir 			pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
1866*cdf0e10cSrcweir 			pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, sal_False );
1867*cdf0e10cSrcweir 			Point aDraw = aStart;
1868*cdf0e10cSrcweir 			long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight();
1869*cdf0e10cSrcweir 			if (nDif > 0)
1870*cdf0e10cSrcweir 				aDraw.Y() += nDif / 2;
1871*cdf0e10cSrcweir 			pEditEngine->Draw( pDev, aDraw, 0 );
1872*cdf0e10cSrcweir 		}
1873*cdf0e10cSrcweir 
1874*cdf0e10cSrcweir 		pDev->SetClipRegion();
1875*cdf0e10cSrcweir 	}
1876*cdf0e10cSrcweir 
1877*cdf0e10cSrcweir 	if ( pLocationData )
1878*cdf0e10cSrcweir 	{
1879*cdf0e10cSrcweir 		Rectangle aHeaderRect( aBorderStart, aBorderSize );
1880*cdf0e10cSrcweir 		pLocationData->AddHeaderFooter( aHeaderRect, bHeader, bLeft );
1881*cdf0e10cSrcweir 	}
1882*cdf0e10cSrcweir }
1883*cdf0e10cSrcweir 
1884*cdf0e10cSrcweir long ScPrintFunc::DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData )
1885*cdf0e10cSrcweir {
1886*cdf0e10cSrcweir 	if (bDoPrint)
1887*cdf0e10cSrcweir 		pDev->SetMapMode(aTwipMode);
1888*cdf0e10cSrcweir 
1889*cdf0e10cSrcweir 	MakeEditEngine();
1890*cdf0e10cSrcweir 	pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
1891*cdf0e10cSrcweir 	pEditEngine->SetDefaults( *pEditDefaults );
1892*cdf0e10cSrcweir 
1893*cdf0e10cSrcweir 	Font aMarkFont;
1894*cdf0e10cSrcweir 	ScAutoFontColorMode eColorMode = bUseStyleColor ? SC_AUTOCOL_DISPLAY : SC_AUTOCOL_PRINT;
1895*cdf0e10cSrcweir 	((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).GetFont( aMarkFont, eColorMode );
1896*cdf0e10cSrcweir //?	aMarkFont.SetWeight( WEIGHT_BOLD );
1897*cdf0e10cSrcweir 	pDev->SetFont( aMarkFont );
1898*cdf0e10cSrcweir 	long nMarkLen = pDev->GetTextWidth(
1899*cdf0e10cSrcweir 			String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("GW99999:")));
1900*cdf0e10cSrcweir 	// ohne Space, weil's eh selten so weit kommt
1901*cdf0e10cSrcweir 
1902*cdf0e10cSrcweir 	Size aDataSize = aPageRect.GetSize();
1903*cdf0e10cSrcweir 	if ( nMarkLen > aDataSize.Width() / 2 )		// alles viel zu klein?
1904*cdf0e10cSrcweir 		nMarkLen = aDataSize.Width() / 2;		// Seite bruederlich aufteilen
1905*cdf0e10cSrcweir 	aDataSize.Width() -= nMarkLen;
1906*cdf0e10cSrcweir 
1907*cdf0e10cSrcweir 	pEditEngine->SetPaperSize( aDataSize );
1908*cdf0e10cSrcweir 	long nPosX = aPageRect.Left() + nMarkLen;
1909*cdf0e10cSrcweir 	long nPosY = aPageRect.Top();
1910*cdf0e10cSrcweir 
1911*cdf0e10cSrcweir 	long nCount = 0;
1912*cdf0e10cSrcweir 	sal_Bool bOk;
1913*cdf0e10cSrcweir 	do
1914*cdf0e10cSrcweir 	{
1915*cdf0e10cSrcweir 		bOk = sal_False;
1916*cdf0e10cSrcweir 		ScAddress* pPos = (ScAddress*) aNotePosList.GetObject( nNoteStart+nCount );
1917*cdf0e10cSrcweir 		if (pPos)
1918*cdf0e10cSrcweir 		{
1919*cdf0e10cSrcweir 			ScBaseCell* pCell = pDoc->GetCell( *pPos);
1920*cdf0e10cSrcweir             if( const ScPostIt* pNote = pCell->GetNote() )
1921*cdf0e10cSrcweir 			{
1922*cdf0e10cSrcweir 				if(const EditTextObject *pEditText = pNote->GetEditTextObject())
1923*cdf0e10cSrcweir 				    pEditEngine->SetText(*pEditText);
1924*cdf0e10cSrcweir 				long nTextHeight = pEditEngine->GetTextHeight();
1925*cdf0e10cSrcweir 				if ( nPosY + nTextHeight < aPageRect.Bottom() )
1926*cdf0e10cSrcweir 				{
1927*cdf0e10cSrcweir 					if (bDoPrint)
1928*cdf0e10cSrcweir 					{
1929*cdf0e10cSrcweir 						pEditEngine->Draw( pDev, Point( nPosX, nPosY ), 0 );
1930*cdf0e10cSrcweir 
1931*cdf0e10cSrcweir 						String aMarkStr;
1932*cdf0e10cSrcweir 						pPos->Format( aMarkStr, SCA_VALID, pDoc, pDoc->GetAddressConvention() );
1933*cdf0e10cSrcweir 						aMarkStr += ':';
1934*cdf0e10cSrcweir 
1935*cdf0e10cSrcweir 						//	Zellposition auch per EditEngine, damit die Position stimmt
1936*cdf0e10cSrcweir 						pEditEngine->SetText(aMarkStr);
1937*cdf0e10cSrcweir 						pEditEngine->Draw( pDev, Point( aPageRect.Left(), nPosY ), 0 );
1938*cdf0e10cSrcweir 					}
1939*cdf0e10cSrcweir 
1940*cdf0e10cSrcweir 					if ( pLocationData )
1941*cdf0e10cSrcweir 					{
1942*cdf0e10cSrcweir 						Rectangle aTextRect( Point( nPosX, nPosY ), Size( aDataSize.Width(), nTextHeight ) );
1943*cdf0e10cSrcweir 						pLocationData->AddNoteText( aTextRect, *pPos );
1944*cdf0e10cSrcweir 						Rectangle aMarkRect( Point( aPageRect.Left(), nPosY ), Size( nMarkLen, nTextHeight ) );
1945*cdf0e10cSrcweir 						pLocationData->AddNoteMark( aMarkRect, *pPos );
1946*cdf0e10cSrcweir 					}
1947*cdf0e10cSrcweir 
1948*cdf0e10cSrcweir 					nPosY += nTextHeight;
1949*cdf0e10cSrcweir 					nPosY += 200;					// Abstand
1950*cdf0e10cSrcweir 					++nCount;
1951*cdf0e10cSrcweir 					bOk = sal_True;
1952*cdf0e10cSrcweir 				}
1953*cdf0e10cSrcweir 			}
1954*cdf0e10cSrcweir 		}
1955*cdf0e10cSrcweir 	}
1956*cdf0e10cSrcweir 	while (bOk);
1957*cdf0e10cSrcweir 
1958*cdf0e10cSrcweir 	return nCount;
1959*cdf0e10cSrcweir }
1960*cdf0e10cSrcweir 
1961*cdf0e10cSrcweir long ScPrintFunc::PrintNotes( long nPageNo, long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData )
1962*cdf0e10cSrcweir {
1963*cdf0e10cSrcweir 	if ( nNoteStart >= (long) aNotePosList.Count() || !aTableParam.bNotes )
1964*cdf0e10cSrcweir 		return 0;
1965*cdf0e10cSrcweir 
1966*cdf0e10cSrcweir 	if ( bDoPrint && bClearWin )
1967*cdf0e10cSrcweir 	{
1968*cdf0e10cSrcweir 		//!	mit PrintPage zusammenfassen !!!
1969*cdf0e10cSrcweir 
1970*cdf0e10cSrcweir 		Color aBackgroundColor( COL_WHITE );
1971*cdf0e10cSrcweir 		if ( bUseStyleColor )
1972*cdf0e10cSrcweir             aBackgroundColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
1973*cdf0e10cSrcweir 
1974*cdf0e10cSrcweir 		pDev->SetMapMode(aOffsetMode);
1975*cdf0e10cSrcweir 		pDev->SetLineColor();
1976*cdf0e10cSrcweir 		pDev->SetFillColor(aBackgroundColor);
1977*cdf0e10cSrcweir 		pDev->DrawRect(Rectangle(Point(),
1978*cdf0e10cSrcweir 				Size((long)(aPageSize.Width() * nScaleX * 100 / nZoom),
1979*cdf0e10cSrcweir 					 (long)(aPageSize.Height() * nScaleY * 100 / nZoom))));
1980*cdf0e10cSrcweir 	}
1981*cdf0e10cSrcweir 
1982*cdf0e10cSrcweir 
1983*cdf0e10cSrcweir 	//		aPageRect auf linke / rechte Seiten anpassen
1984*cdf0e10cSrcweir 
1985*cdf0e10cSrcweir 	Rectangle aTempRect = Rectangle( Point(), aPageSize );
1986*cdf0e10cSrcweir 	if (IsMirror(nPageNo))
1987*cdf0e10cSrcweir 	{
1988*cdf0e10cSrcweir 		aPageRect.Left()  = ( aTempRect.Left()  + nRightMargin ) * 100 / nZoom;
1989*cdf0e10cSrcweir 		aPageRect.Right() = ( aTempRect.Right() - nLeftMargin  ) * 100 / nZoom;
1990*cdf0e10cSrcweir 	}
1991*cdf0e10cSrcweir 	else
1992*cdf0e10cSrcweir 	{
1993*cdf0e10cSrcweir 		aPageRect.Left()  = ( aTempRect.Left()  + nLeftMargin  ) * 100 / nZoom;
1994*cdf0e10cSrcweir 		aPageRect.Right() = ( aTempRect.Right() - nRightMargin ) * 100 / nZoom;
1995*cdf0e10cSrcweir 	}
1996*cdf0e10cSrcweir 
1997*cdf0e10cSrcweir 	if ( pPrinter && bDoPrint )
1998*cdf0e10cSrcweir     {
1999*cdf0e10cSrcweir         DBG_ERROR( "StartPage does not exist anymore" );
2000*cdf0e10cSrcweir 		// pPrinter->StartPage();
2001*cdf0e10cSrcweir     }
2002*cdf0e10cSrcweir 
2003*cdf0e10cSrcweir 	if ( bDoPrint || pLocationData )
2004*cdf0e10cSrcweir 	{
2005*cdf0e10cSrcweir 		//	Kopf- und Fusszeilen
2006*cdf0e10cSrcweir 
2007*cdf0e10cSrcweir 		if (aHdr.bEnable)
2008*cdf0e10cSrcweir 		{
2009*cdf0e10cSrcweir 			long nHeaderY = aPageRect.Top()-aHdr.nHeight;
2010*cdf0e10cSrcweir 			PrintHF( nPageNo, sal_True, nHeaderY, bDoPrint, pLocationData );
2011*cdf0e10cSrcweir 		}
2012*cdf0e10cSrcweir 		if (aFtr.bEnable)
2013*cdf0e10cSrcweir 		{
2014*cdf0e10cSrcweir 			long nFooterY = aPageRect.Bottom()+aFtr.nDistance;
2015*cdf0e10cSrcweir 			PrintHF( nPageNo, sal_False, nFooterY, bDoPrint, pLocationData );
2016*cdf0e10cSrcweir 		}
2017*cdf0e10cSrcweir 	}
2018*cdf0e10cSrcweir 
2019*cdf0e10cSrcweir 	long nCount = DoNotes( nNoteStart, bDoPrint, pLocationData );
2020*cdf0e10cSrcweir 
2021*cdf0e10cSrcweir 	if ( pPrinter && bDoPrint )
2022*cdf0e10cSrcweir     {
2023*cdf0e10cSrcweir         DBG_ERROR( "EndPage does not exist anymore" );
2024*cdf0e10cSrcweir 		// pPrinter->EndPage();
2025*cdf0e10cSrcweir     }
2026*cdf0e10cSrcweir 
2027*cdf0e10cSrcweir 	return nCount;
2028*cdf0e10cSrcweir }
2029*cdf0e10cSrcweir 
2030*cdf0e10cSrcweir void ScPrintFunc::PrintPage( long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
2031*cdf0e10cSrcweir 								sal_Bool bDoPrint, ScPreviewLocationData* pLocationData )
2032*cdf0e10cSrcweir {
2033*cdf0e10cSrcweir 	sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
2034*cdf0e10cSrcweir 	long nLayoutSign = bLayoutRTL ? -1 : 1;
2035*cdf0e10cSrcweir 
2036*cdf0e10cSrcweir 	//	nPageNo is the page number within all sheets of one "start page" setting
2037*cdf0e10cSrcweir 
2038*cdf0e10cSrcweir 	if ( bClearWin && bDoPrint )
2039*cdf0e10cSrcweir 	{
2040*cdf0e10cSrcweir 		//	muss genau zum Zeichnen des Rahmens in preview.cxx passen !!!
2041*cdf0e10cSrcweir 
2042*cdf0e10cSrcweir 		Color aBackgroundColor( COL_WHITE );
2043*cdf0e10cSrcweir 		if ( bUseStyleColor )
2044*cdf0e10cSrcweir             aBackgroundColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
2045*cdf0e10cSrcweir 
2046*cdf0e10cSrcweir 		pDev->SetMapMode(aOffsetMode);
2047*cdf0e10cSrcweir 		pDev->SetLineColor();
2048*cdf0e10cSrcweir 		pDev->SetFillColor(aBackgroundColor);
2049*cdf0e10cSrcweir 		pDev->DrawRect(Rectangle(Point(),
2050*cdf0e10cSrcweir 				Size((long)(aPageSize.Width() * nScaleX * 100 / nZoom),
2051*cdf0e10cSrcweir 					 (long)(aPageSize.Height() * nScaleY * 100 / nZoom))));
2052*cdf0e10cSrcweir 	}
2053*cdf0e10cSrcweir 
2054*cdf0e10cSrcweir 
2055*cdf0e10cSrcweir 	//		aPageRect auf linke / rechte Seiten anpassen
2056*cdf0e10cSrcweir 
2057*cdf0e10cSrcweir 	Rectangle aTempRect = Rectangle( Point(), aPageSize );
2058*cdf0e10cSrcweir 	if (IsMirror(nPageNo))
2059*cdf0e10cSrcweir 	{
2060*cdf0e10cSrcweir 		aPageRect.Left()  = ( aTempRect.Left()  + nRightMargin ) * 100 / nZoom;
2061*cdf0e10cSrcweir 		aPageRect.Right() = ( aTempRect.Right() - nLeftMargin  ) * 100 / nZoom;
2062*cdf0e10cSrcweir 	}
2063*cdf0e10cSrcweir 	else
2064*cdf0e10cSrcweir 	{
2065*cdf0e10cSrcweir 		aPageRect.Left()  = ( aTempRect.Left()  + nLeftMargin  ) * 100 / nZoom;
2066*cdf0e10cSrcweir 		aPageRect.Right() = ( aTempRect.Right() - nRightMargin ) * 100 / nZoom;
2067*cdf0e10cSrcweir 	}
2068*cdf0e10cSrcweir 
2069*cdf0e10cSrcweir 	if ( aAreaParam.bRepeatCol )
2070*cdf0e10cSrcweir 		if ( nX1 > nRepeatStartCol && nX1 <= nRepeatEndCol )
2071*cdf0e10cSrcweir 			nX1 = nRepeatEndCol + 1;
2072*cdf0e10cSrcweir 	sal_Bool bDoRepCol = (aAreaParam.bRepeatCol && nX1 > nRepeatEndCol);
2073*cdf0e10cSrcweir 	if ( aAreaParam.bRepeatRow )
2074*cdf0e10cSrcweir 		if ( nY1 > nRepeatStartRow && nY1 <= nRepeatEndRow )
2075*cdf0e10cSrcweir 			nY1 = nRepeatEndRow + 1;
2076*cdf0e10cSrcweir 	sal_Bool bDoRepRow = (aAreaParam.bRepeatRow && nY1 > nRepeatEndRow);
2077*cdf0e10cSrcweir 
2078*cdf0e10cSrcweir     // use new object hide flags in SdrPaintView
2079*cdf0e10cSrcweir     if(pDrawView)
2080*cdf0e10cSrcweir     {
2081*cdf0e10cSrcweir         pDrawView->setHideOle(!aTableParam.bObjects);
2082*cdf0e10cSrcweir         pDrawView->setHideChart(!aTableParam.bCharts);
2083*cdf0e10cSrcweir         pDrawView->setHideDraw(!aTableParam.bDrawings);
2084*cdf0e10cSrcweir         pDrawView->setHideFormControl(!aTableParam.bDrawings);
2085*cdf0e10cSrcweir     }
2086*cdf0e10cSrcweir 
2087*cdf0e10cSrcweir 	if ( pPrinter && bDoPrint )
2088*cdf0e10cSrcweir     {
2089*cdf0e10cSrcweir         DBG_ERROR( "StartPage does not exist anymore" );
2090*cdf0e10cSrcweir 		// pPrinter->StartPage();
2091*cdf0e10cSrcweir     }
2092*cdf0e10cSrcweir 
2093*cdf0e10cSrcweir 	//	Kopf- und Fusszeilen (ohne Zentrierung)
2094*cdf0e10cSrcweir 
2095*cdf0e10cSrcweir 	if (aHdr.bEnable)
2096*cdf0e10cSrcweir 	{
2097*cdf0e10cSrcweir 		long nHeaderY = aPageRect.Top()-aHdr.nHeight;
2098*cdf0e10cSrcweir 		PrintHF( nPageNo, sal_True, nHeaderY, bDoPrint, pLocationData );
2099*cdf0e10cSrcweir 	}
2100*cdf0e10cSrcweir 	if (aFtr.bEnable)
2101*cdf0e10cSrcweir 	{
2102*cdf0e10cSrcweir 		long nFooterY = aPageRect.Bottom()+aFtr.nDistance;
2103*cdf0e10cSrcweir 		PrintHF( nPageNo, sal_False, nFooterY, bDoPrint, pLocationData );
2104*cdf0e10cSrcweir 	}
2105*cdf0e10cSrcweir 
2106*cdf0e10cSrcweir 	//	Position ( Raender / zentrieren )
2107*cdf0e10cSrcweir 
2108*cdf0e10cSrcweir 	long nLeftSpace = aPageRect.Left();		// Document-Twips
2109*cdf0e10cSrcweir 	long nTopSpace  = aPageRect.Top();
2110*cdf0e10cSrcweir 	if ( bCenterHor || bLayoutRTL )
2111*cdf0e10cSrcweir 	{
2112*cdf0e10cSrcweir 		long nDataWidth = 0;
2113*cdf0e10cSrcweir         SCCOL i;
2114*cdf0e10cSrcweir 		for (i=nX1; i<=nX2; i++)
2115*cdf0e10cSrcweir 			nDataWidth += pDoc->GetColWidth( i,nPrintTab );
2116*cdf0e10cSrcweir 		if (bDoRepCol)
2117*cdf0e10cSrcweir 			for (i=nRepeatStartCol; i<=nRepeatEndCol; i++)
2118*cdf0e10cSrcweir 				nDataWidth += pDoc->GetColWidth( i,nPrintTab );
2119*cdf0e10cSrcweir 		if (aTableParam.bHeaders)
2120*cdf0e10cSrcweir 			nDataWidth += (long) PRINT_HEADER_WIDTH;
2121*cdf0e10cSrcweir 		if (pBorderItem)
2122*cdf0e10cSrcweir 			nDataWidth += pBorderItem->GetDistance(BOX_LINE_LEFT) +
2123*cdf0e10cSrcweir 						   pBorderItem->GetDistance(BOX_LINE_RIGHT);		//! Line width?
2124*cdf0e10cSrcweir 		if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
2125*cdf0e10cSrcweir 			nDataWidth += pShadowItem->CalcShadowSpace(SHADOW_LEFT) +
2126*cdf0e10cSrcweir 						   pShadowItem->CalcShadowSpace(SHADOW_RIGHT);
2127*cdf0e10cSrcweir 		if ( bCenterHor )
2128*cdf0e10cSrcweir 		{
2129*cdf0e10cSrcweir 			nLeftSpace += ( aPageRect.GetWidth() - nDataWidth ) / 2;		// LTR or RTL
2130*cdf0e10cSrcweir 			if (pBorderItem)
2131*cdf0e10cSrcweir 				nLeftSpace -= lcl_LineTotal(pBorderItem->GetLeft());
2132*cdf0e10cSrcweir 		}
2133*cdf0e10cSrcweir 		else if ( bLayoutRTL )
2134*cdf0e10cSrcweir 			nLeftSpace += aPageRect.GetWidth() - nDataWidth;				// align to the right edge of the page
2135*cdf0e10cSrcweir 	}
2136*cdf0e10cSrcweir 	if ( bCenterVer )
2137*cdf0e10cSrcweir 	{
2138*cdf0e10cSrcweir         long nDataHeight = pDoc->GetRowHeight( nY1, nY2, nPrintTab);
2139*cdf0e10cSrcweir 		if (bDoRepRow)
2140*cdf0e10cSrcweir             nDataHeight += pDoc->GetRowHeight( nRepeatStartRow,
2141*cdf0e10cSrcweir                     nRepeatEndRow, nPrintTab);
2142*cdf0e10cSrcweir 		if (aTableParam.bHeaders)
2143*cdf0e10cSrcweir 			nDataHeight += (long) PRINT_HEADER_HEIGHT;
2144*cdf0e10cSrcweir 		if (pBorderItem)
2145*cdf0e10cSrcweir 			nDataHeight += pBorderItem->GetDistance(BOX_LINE_TOP) +
2146*cdf0e10cSrcweir 						   pBorderItem->GetDistance(BOX_LINE_BOTTOM);		//! Line width?
2147*cdf0e10cSrcweir 		if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
2148*cdf0e10cSrcweir 			nDataHeight += pShadowItem->CalcShadowSpace(SHADOW_TOP) +
2149*cdf0e10cSrcweir 						   pShadowItem->CalcShadowSpace(SHADOW_BOTTOM);
2150*cdf0e10cSrcweir 		nTopSpace += ( aPageRect.GetHeight() - nDataHeight ) / 2;
2151*cdf0e10cSrcweir 		if (pBorderItem)
2152*cdf0e10cSrcweir 			nTopSpace -= lcl_LineTotal(pBorderItem->GetTop());
2153*cdf0e10cSrcweir 	}
2154*cdf0e10cSrcweir 
2155*cdf0e10cSrcweir 	//	calculate sizes of the elements for partitioning
2156*cdf0e10cSrcweir 	//	(header, repeat, data)
2157*cdf0e10cSrcweir 
2158*cdf0e10cSrcweir 	long nHeaderWidth   = 0;
2159*cdf0e10cSrcweir 	long nHeaderHeight  = 0;
2160*cdf0e10cSrcweir 	long nRepeatWidth   = 0;
2161*cdf0e10cSrcweir 	long nRepeatHeight  = 0;
2162*cdf0e10cSrcweir 	long nContentWidth  = 0;		// scaled - not the same as nDataWidth above
2163*cdf0e10cSrcweir 	long nContentHeight = 0;
2164*cdf0e10cSrcweir 	if (aTableParam.bHeaders)
2165*cdf0e10cSrcweir 	{
2166*cdf0e10cSrcweir 		nHeaderWidth  = (long) (PRINT_HEADER_WIDTH * nScaleX);
2167*cdf0e10cSrcweir 		nHeaderHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY);
2168*cdf0e10cSrcweir 	}
2169*cdf0e10cSrcweir 	if (bDoRepCol)
2170*cdf0e10cSrcweir 		for (SCCOL i=nRepeatStartCol; i<=nRepeatEndCol; i++)
2171*cdf0e10cSrcweir 			nRepeatWidth += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX);
2172*cdf0e10cSrcweir 	if (bDoRepRow)
2173*cdf0e10cSrcweir         nRepeatHeight += pDoc->GetScaledRowHeight( nRepeatStartRow,
2174*cdf0e10cSrcweir                 nRepeatEndRow, nPrintTab, nScaleY);
2175*cdf0e10cSrcweir 	for (SCCOL i=nX1; i<=nX2; i++)
2176*cdf0e10cSrcweir 		nContentWidth += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX);
2177*cdf0e10cSrcweir     nContentHeight += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab,
2178*cdf0e10cSrcweir             nScaleY);
2179*cdf0e10cSrcweir 
2180*cdf0e10cSrcweir 	//	partition the page
2181*cdf0e10cSrcweir 
2182*cdf0e10cSrcweir 	long nStartX = ((long) ( nLeftSpace * nScaleX ));
2183*cdf0e10cSrcweir 	long nStartY = ((long) ( nTopSpace  * nScaleY ));
2184*cdf0e10cSrcweir //		nStartX -= aOffset.X();			// schon im MapMode
2185*cdf0e10cSrcweir //		nStartY -= aOffset.Y();
2186*cdf0e10cSrcweir 
2187*cdf0e10cSrcweir 	long nInnerStartX = nStartX;
2188*cdf0e10cSrcweir 	long nInnerStartY = nStartY;
2189*cdf0e10cSrcweir 	if (pBorderItem)
2190*cdf0e10cSrcweir 	{
2191*cdf0e10cSrcweir 		nInnerStartX += (long) ( ( lcl_LineTotal(pBorderItem->GetLeft()) +
2192*cdf0e10cSrcweir 									pBorderItem->GetDistance(BOX_LINE_LEFT) ) * nScaleX );
2193*cdf0e10cSrcweir 		nInnerStartY += (long) ( ( lcl_LineTotal(pBorderItem->GetTop()) +
2194*cdf0e10cSrcweir 									pBorderItem->GetDistance(BOX_LINE_TOP) ) * nScaleY );
2195*cdf0e10cSrcweir 	}
2196*cdf0e10cSrcweir 	if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
2197*cdf0e10cSrcweir 	{
2198*cdf0e10cSrcweir 		nInnerStartX += (long) ( pShadowItem->CalcShadowSpace(SHADOW_LEFT) * nScaleX );
2199*cdf0e10cSrcweir 		nInnerStartY += (long) ( pShadowItem->CalcShadowSpace(SHADOW_TOP) * nScaleY );
2200*cdf0e10cSrcweir 	}
2201*cdf0e10cSrcweir 
2202*cdf0e10cSrcweir 	if ( bLayoutRTL )
2203*cdf0e10cSrcweir 	{
2204*cdf0e10cSrcweir 		//	arrange elements starting from the right edge
2205*cdf0e10cSrcweir 		nInnerStartX += nHeaderWidth + nRepeatWidth + nContentWidth;
2206*cdf0e10cSrcweir 
2207*cdf0e10cSrcweir 		//	make rounding easier so the elements are really next to each other in preview
2208*cdf0e10cSrcweir 		Size aOffsetOnePixel = pDev->PixelToLogic( Size(1,1), aOffsetMode );
2209*cdf0e10cSrcweir 		long nOffsetOneX = aOffsetOnePixel.Width();
2210*cdf0e10cSrcweir 		nInnerStartX += nOffsetOneX / 2;
2211*cdf0e10cSrcweir 	}
2212*cdf0e10cSrcweir 
2213*cdf0e10cSrcweir 	long nFrameStartX = nInnerStartX;
2214*cdf0e10cSrcweir 	long nFrameStartY = nInnerStartY;
2215*cdf0e10cSrcweir 
2216*cdf0e10cSrcweir 	long nRepStartX = nInnerStartX + nHeaderWidth * nLayoutSign;	// widths/heights are 0 if not used
2217*cdf0e10cSrcweir 	long nRepStartY = nInnerStartY + nHeaderHeight;
2218*cdf0e10cSrcweir 	long nDataX = nRepStartX + nRepeatWidth * nLayoutSign;
2219*cdf0e10cSrcweir 	long nDataY = nRepStartY + nRepeatHeight;
2220*cdf0e10cSrcweir 	long nEndX = nDataX + nContentWidth * nLayoutSign;
2221*cdf0e10cSrcweir 	long nEndY = nDataY + nContentHeight;
2222*cdf0e10cSrcweir 	long nFrameEndX = nEndX;
2223*cdf0e10cSrcweir 	long nFrameEndY = nEndY;
2224*cdf0e10cSrcweir 
2225*cdf0e10cSrcweir 	if ( bLayoutRTL )
2226*cdf0e10cSrcweir 	{
2227*cdf0e10cSrcweir 		//	each element's start position is its left edge
2228*cdf0e10cSrcweir 		//!	subtract one pixel less?
2229*cdf0e10cSrcweir 		nInnerStartX -= nHeaderWidth;		// used for header
2230*cdf0e10cSrcweir 		nRepStartX   -= nRepeatWidth;
2231*cdf0e10cSrcweir 		nDataX       -= nContentWidth;
2232*cdf0e10cSrcweir 
2233*cdf0e10cSrcweir 		//	continue right of the main elements again
2234*cdf0e10cSrcweir 		nEndX += nHeaderWidth + nRepeatWidth + nContentWidth;
2235*cdf0e10cSrcweir 	}
2236*cdf0e10cSrcweir 
2237*cdf0e10cSrcweir 	//	Seiten-Rahmen / Hintergrund
2238*cdf0e10cSrcweir 
2239*cdf0e10cSrcweir 	//!	nEndX/Y anpassen
2240*cdf0e10cSrcweir 
2241*cdf0e10cSrcweir 	long nBorderEndX = nEndX;
2242*cdf0e10cSrcweir 	long nBorderEndY = nEndY;
2243*cdf0e10cSrcweir 	if (pBorderItem)
2244*cdf0e10cSrcweir 	{
2245*cdf0e10cSrcweir 		nBorderEndX += (long) ( ( lcl_LineTotal(pBorderItem->GetRight()) +
2246*cdf0e10cSrcweir 									pBorderItem->GetDistance(BOX_LINE_RIGHT) ) * nScaleX );
2247*cdf0e10cSrcweir 		nBorderEndY += (long) ( ( lcl_LineTotal(pBorderItem->GetBottom()) +
2248*cdf0e10cSrcweir 									pBorderItem->GetDistance(BOX_LINE_BOTTOM) ) * nScaleY );
2249*cdf0e10cSrcweir 	}
2250*cdf0e10cSrcweir 	if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
2251*cdf0e10cSrcweir 	{
2252*cdf0e10cSrcweir 		nBorderEndX += (long) ( pShadowItem->CalcShadowSpace(SHADOW_RIGHT) * nScaleX );
2253*cdf0e10cSrcweir 		nBorderEndY += (long) ( pShadowItem->CalcShadowSpace(SHADOW_BOTTOM) * nScaleY );
2254*cdf0e10cSrcweir 	}
2255*cdf0e10cSrcweir 
2256*cdf0e10cSrcweir 	if ( bDoPrint )
2257*cdf0e10cSrcweir 	{
2258*cdf0e10cSrcweir 		pDev->SetMapMode( aOffsetMode );
2259*cdf0e10cSrcweir 		DrawBorder( nStartX, nStartY, nBorderEndX-nStartX, nBorderEndY-nStartY,
2260*cdf0e10cSrcweir 						pBorderItem, pBackgroundItem, pShadowItem );
2261*cdf0e10cSrcweir 
2262*cdf0e10cSrcweir 		pDev->SetMapMode( aTwipMode );
2263*cdf0e10cSrcweir 	}
2264*cdf0e10cSrcweir 
2265*cdf0e10cSrcweir 	pDev->SetMapMode( aOffsetMode );
2266*cdf0e10cSrcweir 
2267*cdf0e10cSrcweir 	//	Wiederholungszeilen/Spalten ausgeben
2268*cdf0e10cSrcweir 
2269*cdf0e10cSrcweir 	if (bDoRepCol && bDoRepRow)
2270*cdf0e10cSrcweir 	{
2271*cdf0e10cSrcweir 		if ( bDoPrint )
2272*cdf0e10cSrcweir 			PrintArea( nRepeatStartCol,nRepeatStartRow, nRepeatEndCol,nRepeatEndRow,
2273*cdf0e10cSrcweir 							nRepStartX,nRepStartY, sal_True,sal_True,sal_False,sal_False );
2274*cdf0e10cSrcweir 		if ( pLocationData )
2275*cdf0e10cSrcweir 			LocateArea( nRepeatStartCol,nRepeatStartRow, nRepeatEndCol,nRepeatEndRow,
2276*cdf0e10cSrcweir 							nRepStartX,nRepStartY, sal_True,sal_True, *pLocationData );
2277*cdf0e10cSrcweir 	}
2278*cdf0e10cSrcweir 	if (bDoRepCol)
2279*cdf0e10cSrcweir 	{
2280*cdf0e10cSrcweir 		if ( bDoPrint )
2281*cdf0e10cSrcweir 			PrintArea( nRepeatStartCol,nY1, nRepeatEndCol,nY2, nRepStartX,nDataY,
2282*cdf0e10cSrcweir 						sal_True,!bDoRepRow,sal_False,sal_True );
2283*cdf0e10cSrcweir 		if ( pLocationData )
2284*cdf0e10cSrcweir 			LocateArea( nRepeatStartCol,nY1, nRepeatEndCol,nY2, nRepStartX,nDataY, sal_True,sal_False, *pLocationData );
2285*cdf0e10cSrcweir 	}
2286*cdf0e10cSrcweir 	if (bDoRepRow)
2287*cdf0e10cSrcweir 	{
2288*cdf0e10cSrcweir 		if ( bDoPrint )
2289*cdf0e10cSrcweir 			PrintArea( nX1,nRepeatStartRow, nX2,nRepeatEndRow, nDataX,nRepStartY,
2290*cdf0e10cSrcweir 						!bDoRepCol,sal_True,sal_True,sal_False );
2291*cdf0e10cSrcweir 		if ( pLocationData )
2292*cdf0e10cSrcweir 			LocateArea( nX1,nRepeatStartRow, nX2,nRepeatEndRow, nDataX,nRepStartY, sal_False,sal_True, *pLocationData );
2293*cdf0e10cSrcweir 	}
2294*cdf0e10cSrcweir 
2295*cdf0e10cSrcweir 	//	Daten ausgeben
2296*cdf0e10cSrcweir 
2297*cdf0e10cSrcweir 	if ( bDoPrint )
2298*cdf0e10cSrcweir 		PrintArea( nX1,nY1, nX2,nY2, nDataX,nDataY, !bDoRepCol,!bDoRepRow,sal_True,sal_True );
2299*cdf0e10cSrcweir 	if ( pLocationData )
2300*cdf0e10cSrcweir 		LocateArea( nX1,nY1, nX2,nY2, nDataX,nDataY, sal_False,sal_False, *pLocationData );
2301*cdf0e10cSrcweir 
2302*cdf0e10cSrcweir 	//	Spalten-/Zeilenkoepfe ausgeben
2303*cdf0e10cSrcweir 	//	nach den Daten (ueber evtl. weitergezeichneten Schatten)
2304*cdf0e10cSrcweir 
2305*cdf0e10cSrcweir 	Color aGridColor( COL_BLACK );
2306*cdf0e10cSrcweir 	if ( bUseStyleColor )
2307*cdf0e10cSrcweir         aGridColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
2308*cdf0e10cSrcweir 
2309*cdf0e10cSrcweir 	if (aTableParam.bHeaders)
2310*cdf0e10cSrcweir 	{
2311*cdf0e10cSrcweir 		if ( bDoPrint )
2312*cdf0e10cSrcweir 		{
2313*cdf0e10cSrcweir 			pDev->SetLineColor( aGridColor );
2314*cdf0e10cSrcweir 			pDev->SetFillColor();
2315*cdf0e10cSrcweir 			pDev->SetMapMode(aOffsetMode);
2316*cdf0e10cSrcweir 		}
2317*cdf0e10cSrcweir 
2318*cdf0e10cSrcweir 		ScPatternAttr aPattern( pDoc->GetPool() );
2319*cdf0e10cSrcweir 		Font aFont;
2320*cdf0e10cSrcweir 		ScAutoFontColorMode eColorMode = bUseStyleColor ? SC_AUTOCOL_DISPLAY : SC_AUTOCOL_PRINT;
2321*cdf0e10cSrcweir 		aPattern.GetFont( aFont, eColorMode, pDev );
2322*cdf0e10cSrcweir 		pDev->SetFont( aFont );
2323*cdf0e10cSrcweir 
2324*cdf0e10cSrcweir 		if (bDoRepCol)
2325*cdf0e10cSrcweir 		{
2326*cdf0e10cSrcweir 			if ( bDoPrint )
2327*cdf0e10cSrcweir 				PrintColHdr( nRepeatStartCol,nRepeatEndCol, nRepStartX,nInnerStartY );
2328*cdf0e10cSrcweir 			if ( pLocationData )
2329*cdf0e10cSrcweir 				LocateColHdr( nRepeatStartCol,nRepeatEndCol, nRepStartX,nInnerStartY, sal_True, *pLocationData );
2330*cdf0e10cSrcweir 		}
2331*cdf0e10cSrcweir 		if ( bDoPrint )
2332*cdf0e10cSrcweir 			PrintColHdr( nX1,nX2, nDataX,nInnerStartY );
2333*cdf0e10cSrcweir 		if ( pLocationData )
2334*cdf0e10cSrcweir 			LocateColHdr( nX1,nX2, nDataX,nInnerStartY, sal_False, *pLocationData );
2335*cdf0e10cSrcweir 		if (bDoRepRow)
2336*cdf0e10cSrcweir 		{
2337*cdf0e10cSrcweir 			if ( bDoPrint )
2338*cdf0e10cSrcweir 				PrintRowHdr( nRepeatStartRow,nRepeatEndRow, nInnerStartX,nRepStartY );
2339*cdf0e10cSrcweir 			if ( pLocationData )
2340*cdf0e10cSrcweir 				LocateRowHdr( nRepeatStartRow,nRepeatEndRow, nInnerStartX,nRepStartY, sal_True, *pLocationData );
2341*cdf0e10cSrcweir 		}
2342*cdf0e10cSrcweir 		if ( bDoPrint )
2343*cdf0e10cSrcweir 			PrintRowHdr( nY1,nY2, nInnerStartX,nDataY );
2344*cdf0e10cSrcweir 		if ( pLocationData )
2345*cdf0e10cSrcweir 			LocateRowHdr( nY1,nY2, nInnerStartX,nDataY, sal_False, *pLocationData );
2346*cdf0e10cSrcweir 	}
2347*cdf0e10cSrcweir 
2348*cdf0e10cSrcweir 	//	einfacher Rahmen
2349*cdf0e10cSrcweir 
2350*cdf0e10cSrcweir 	if ( bDoPrint && ( aTableParam.bGrid || aTableParam.bHeaders ) )
2351*cdf0e10cSrcweir 	{
2352*cdf0e10cSrcweir 		Size aOnePixel = pDev->PixelToLogic(Size(1,1));
2353*cdf0e10cSrcweir 		long nOneX = aOnePixel.Width();
2354*cdf0e10cSrcweir 		long nOneY = aOnePixel.Height();
2355*cdf0e10cSrcweir 
2356*cdf0e10cSrcweir 		long nLeftX   = nFrameStartX;
2357*cdf0e10cSrcweir 		long nTopY    = nFrameStartY - nOneY;
2358*cdf0e10cSrcweir 		long nRightX  = nFrameEndX;
2359*cdf0e10cSrcweir 		long nBottomY = nFrameEndY - nOneY;
2360*cdf0e10cSrcweir 		if ( !bLayoutRTL )
2361*cdf0e10cSrcweir 		{
2362*cdf0e10cSrcweir 			nLeftX   -= nOneX;
2363*cdf0e10cSrcweir 			nRightX  -= nOneX;
2364*cdf0e10cSrcweir 		}
2365*cdf0e10cSrcweir 		pDev->SetMapMode(aOffsetMode);
2366*cdf0e10cSrcweir 		pDev->SetLineColor( aGridColor );
2367*cdf0e10cSrcweir 		pDev->SetFillColor();
2368*cdf0e10cSrcweir 		pDev->DrawRect( Rectangle( nLeftX, nTopY, nRightX, nBottomY ) );
2369*cdf0e10cSrcweir 		//	nEndX/Y ohne Rahmen-Anpassung
2370*cdf0e10cSrcweir 	}
2371*cdf0e10cSrcweir 
2372*cdf0e10cSrcweir 	if ( pPrinter && bDoPrint )
2373*cdf0e10cSrcweir     {
2374*cdf0e10cSrcweir         DBG_ERROR( "EndPage does not exist anymore" );
2375*cdf0e10cSrcweir 		// pPrinter->EndPage();
2376*cdf0e10cSrcweir     }
2377*cdf0e10cSrcweir 
2378*cdf0e10cSrcweir 	aLastSourceRange = ScRange( nX1, nY1, nPrintTab, nX2, nY2, nPrintTab );
2379*cdf0e10cSrcweir 	bSourceRangeValid = sal_True;
2380*cdf0e10cSrcweir }
2381*cdf0e10cSrcweir 
2382*cdf0e10cSrcweir void ScPrintFunc::SetOffset( const Point& rOfs )
2383*cdf0e10cSrcweir {
2384*cdf0e10cSrcweir 	aSrcOffset = rOfs;
2385*cdf0e10cSrcweir }
2386*cdf0e10cSrcweir 
2387*cdf0e10cSrcweir void ScPrintFunc::SetManualZoom( sal_uInt16 nNewZoom )
2388*cdf0e10cSrcweir {
2389*cdf0e10cSrcweir 	nManualZoom = nNewZoom;
2390*cdf0e10cSrcweir }
2391*cdf0e10cSrcweir 
2392*cdf0e10cSrcweir void ScPrintFunc::SetClearFlag( sal_Bool bFlag )
2393*cdf0e10cSrcweir {
2394*cdf0e10cSrcweir 	bClearWin = bFlag;
2395*cdf0e10cSrcweir }
2396*cdf0e10cSrcweir 
2397*cdf0e10cSrcweir void ScPrintFunc::SetUseStyleColor( sal_Bool bFlag )
2398*cdf0e10cSrcweir {
2399*cdf0e10cSrcweir 	bUseStyleColor = bFlag;
2400*cdf0e10cSrcweir 	if (pEditEngine)
2401*cdf0e10cSrcweir 		pEditEngine->EnableAutoColor( bUseStyleColor );
2402*cdf0e10cSrcweir }
2403*cdf0e10cSrcweir 
2404*cdf0e10cSrcweir void ScPrintFunc::SetRenderFlag( sal_Bool bFlag )
2405*cdf0e10cSrcweir {
2406*cdf0e10cSrcweir 	bIsRender = bFlag;		// set when using XRenderable (PDF)
2407*cdf0e10cSrcweir }
2408*cdf0e10cSrcweir 
2409*cdf0e10cSrcweir void ScPrintFunc::SetExclusivelyDrawOleAndDrawObjects()
2410*cdf0e10cSrcweir {
2411*cdf0e10cSrcweir     aTableParam.bCellContent = false;
2412*cdf0e10cSrcweir     aTableParam.bNotes = false;
2413*cdf0e10cSrcweir     aTableParam.bGrid = false;
2414*cdf0e10cSrcweir     aTableParam.bHeaders = false;
2415*cdf0e10cSrcweir     aTableParam.bFormulas = false;
2416*cdf0e10cSrcweir     aTableParam.bNullVals = false;
2417*cdf0e10cSrcweir }
2418*cdf0e10cSrcweir 
2419*cdf0e10cSrcweir //
2420*cdf0e10cSrcweir //	UpdatePages wird nur von aussen gerufen, um die Umbrueche fuer die Anzeige
2421*cdf0e10cSrcweir //	richtig zu setzen - immer ohne UserArea
2422*cdf0e10cSrcweir //
2423*cdf0e10cSrcweir 
2424*cdf0e10cSrcweir sal_Bool ScPrintFunc::UpdatePages()
2425*cdf0e10cSrcweir {
2426*cdf0e10cSrcweir 	if (!pParamSet)
2427*cdf0e10cSrcweir 		return sal_False;
2428*cdf0e10cSrcweir 
2429*cdf0e10cSrcweir 	//	Zoom
2430*cdf0e10cSrcweir 
2431*cdf0e10cSrcweir 	nZoom = 100;
2432*cdf0e10cSrcweir     if (aTableParam.bScalePageNum || aTableParam.bScaleTo)
2433*cdf0e10cSrcweir 		nZoom = ZOOM_MIN;						// stimmt fuer Umbrueche
2434*cdf0e10cSrcweir 	else if (aTableParam.bScaleAll)
2435*cdf0e10cSrcweir 	{
2436*cdf0e10cSrcweir 		nZoom = aTableParam.nScaleAll;
2437*cdf0e10cSrcweir 		if ( nZoom <= ZOOM_MIN )
2438*cdf0e10cSrcweir 			nZoom = ZOOM_MIN;
2439*cdf0e10cSrcweir 	}
2440*cdf0e10cSrcweir 
2441*cdf0e10cSrcweir 	String aName = pDoc->GetPageStyle( nPrintTab );
2442*cdf0e10cSrcweir 	SCTAB nTabCount = pDoc->GetTableCount();
2443*cdf0e10cSrcweir 	for (SCTAB nTab=0; nTab<nTabCount; nTab++)
2444*cdf0e10cSrcweir 		if ( nTab==nPrintTab || pDoc->GetPageStyle(nTab)==aName )
2445*cdf0e10cSrcweir 		{
2446*cdf0e10cSrcweir 			//	Wiederholungszeilen / Spalten
2447*cdf0e10cSrcweir 			pDoc->SetRepeatArea( nTab, nRepeatStartCol,nRepeatEndCol, nRepeatStartRow,nRepeatEndRow );
2448*cdf0e10cSrcweir 
2449*cdf0e10cSrcweir 			//	Umbrueche setzen
2450*cdf0e10cSrcweir 			ResetBreaks(nTab);
2451*cdf0e10cSrcweir 			pDocShell->PostPaint(0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID);
2452*cdf0e10cSrcweir 		}
2453*cdf0e10cSrcweir 
2454*cdf0e10cSrcweir 	return sal_True;
2455*cdf0e10cSrcweir }
2456*cdf0e10cSrcweir 
2457*cdf0e10cSrcweir long ScPrintFunc::CountPages()							// setzt auch nPagesX, nPagesY
2458*cdf0e10cSrcweir {
2459*cdf0e10cSrcweir 	sal_Bool bAreaOk = sal_False;
2460*cdf0e10cSrcweir 
2461*cdf0e10cSrcweir 	if (pDoc->HasTable( nPrintTab ))
2462*cdf0e10cSrcweir 	{
2463*cdf0e10cSrcweir 		if (aAreaParam.bPrintArea)							// Druckbereich angegeben?
2464*cdf0e10cSrcweir 		{
2465*cdf0e10cSrcweir 			if ( bPrintCurrentTable )
2466*cdf0e10cSrcweir 			{
2467*cdf0e10cSrcweir 				ScRange& rRange = aAreaParam.aPrintArea;
2468*cdf0e10cSrcweir 
2469*cdf0e10cSrcweir 				//	hier kein Vergleich der Tabellen mehr, die Area gilt immer fuer diese Tabelle
2470*cdf0e10cSrcweir 				//	wenn hier verglichen werden soll, muss die Tabelle der Druckbereiche beim
2471*cdf0e10cSrcweir 				//	Einfuegen von Tabellen etc. angepasst werden !
2472*cdf0e10cSrcweir 
2473*cdf0e10cSrcweir 				nStartCol = rRange.aStart.Col();
2474*cdf0e10cSrcweir 				nStartRow = rRange.aStart.Row();
2475*cdf0e10cSrcweir 				nEndCol   = rRange.aEnd  .Col();
2476*cdf0e10cSrcweir 				nEndRow   = rRange.aEnd  .Row();
2477*cdf0e10cSrcweir 				bAreaOk   = AdjustPrintArea(sal_False);			// begrenzen
2478*cdf0e10cSrcweir 			}
2479*cdf0e10cSrcweir 			else
2480*cdf0e10cSrcweir 				bAreaOk = sal_False;
2481*cdf0e10cSrcweir 		}
2482*cdf0e10cSrcweir 		else												// aus Dokument suchen
2483*cdf0e10cSrcweir 			bAreaOk = AdjustPrintArea(sal_True);
2484*cdf0e10cSrcweir 	}
2485*cdf0e10cSrcweir 
2486*cdf0e10cSrcweir 	if (bAreaOk)
2487*cdf0e10cSrcweir 	{
2488*cdf0e10cSrcweir 		long nPages = 0;
2489*cdf0e10cSrcweir 		size_t nY;
2490*cdf0e10cSrcweir 		if (bMultiArea)
2491*cdf0e10cSrcweir 		{
2492*cdf0e10cSrcweir 			sal_uInt16 nRCount = pDoc->GetPrintRangeCount( nPrintTab );
2493*cdf0e10cSrcweir 			for (sal_uInt16 i=0; i<nRCount; i++)
2494*cdf0e10cSrcweir 			{
2495*cdf0e10cSrcweir 				CalcZoom(i);
2496*cdf0e10cSrcweir 				if ( aTableParam.bSkipEmpty )
2497*cdf0e10cSrcweir 					for (nY=0; nY<nPagesY; nY++)
2498*cdf0e10cSrcweir 						nPages += pPageRows[nY].CountVisible();
2499*cdf0e10cSrcweir 				else
2500*cdf0e10cSrcweir 					nPages += ((long) nPagesX) * nPagesY;
2501*cdf0e10cSrcweir 				if ( pPageData )
2502*cdf0e10cSrcweir 					FillPageData();
2503*cdf0e10cSrcweir 			}
2504*cdf0e10cSrcweir 		}
2505*cdf0e10cSrcweir 		else
2506*cdf0e10cSrcweir 		{
2507*cdf0e10cSrcweir 			CalcZoom(RANGENO_NORANGE);						// Zoom berechnen
2508*cdf0e10cSrcweir 			if ( aTableParam.bSkipEmpty )
2509*cdf0e10cSrcweir 				for (nY=0; nY<nPagesY; nY++)
2510*cdf0e10cSrcweir 					nPages += pPageRows[nY].CountVisible();
2511*cdf0e10cSrcweir 			else
2512*cdf0e10cSrcweir 				nPages += ((long) nPagesX) * nPagesY;
2513*cdf0e10cSrcweir 			if ( pPageData )
2514*cdf0e10cSrcweir 				FillPageData();
2515*cdf0e10cSrcweir 		}
2516*cdf0e10cSrcweir 		return nPages;
2517*cdf0e10cSrcweir 	}
2518*cdf0e10cSrcweir 	else
2519*cdf0e10cSrcweir 	{
2520*cdf0e10cSrcweir //		nZoom = 100;						// nZoom auf letztem Wert stehenlassen !!!
2521*cdf0e10cSrcweir 		nPagesX = nPagesY = nTotalY = 0;
2522*cdf0e10cSrcweir 		return 0;
2523*cdf0e10cSrcweir 	}
2524*cdf0e10cSrcweir }
2525*cdf0e10cSrcweir 
2526*cdf0e10cSrcweir long ScPrintFunc::CountNotePages()
2527*cdf0e10cSrcweir {
2528*cdf0e10cSrcweir 	if ( !aTableParam.bNotes || !bPrintCurrentTable )
2529*cdf0e10cSrcweir 		return 0;
2530*cdf0e10cSrcweir 
2531*cdf0e10cSrcweir 	long nCount=0;
2532*cdf0e10cSrcweir 	SCCOL nCol;
2533*cdf0e10cSrcweir 	SCROW nRow;
2534*cdf0e10cSrcweir 
2535*cdf0e10cSrcweir 	sal_Bool bError = sal_False;
2536*cdf0e10cSrcweir 	if (!aAreaParam.bPrintArea)
2537*cdf0e10cSrcweir 		bError = !AdjustPrintArea(sal_True);			// komplett aus Dok suchen
2538*cdf0e10cSrcweir 
2539*cdf0e10cSrcweir 	sal_uInt16 nRepeats = 1;							// wie oft durchgehen ?
2540*cdf0e10cSrcweir 	if (bMultiArea)
2541*cdf0e10cSrcweir 		nRepeats = pDoc->GetPrintRangeCount(nPrintTab);
2542*cdf0e10cSrcweir 	if (bError)
2543*cdf0e10cSrcweir 		nRepeats = 0;
2544*cdf0e10cSrcweir 
2545*cdf0e10cSrcweir 	for (sal_uInt16 nStep=0; nStep<nRepeats; nStep++)
2546*cdf0e10cSrcweir 	{
2547*cdf0e10cSrcweir 		sal_Bool bDoThis = sal_True;
2548*cdf0e10cSrcweir 		if (bMultiArea)				// alle Areas durchgehen
2549*cdf0e10cSrcweir 		{
2550*cdf0e10cSrcweir 			const ScRange* pThisRange = pDoc->GetPrintRange( nPrintTab, nStep );
2551*cdf0e10cSrcweir 			if ( pThisRange )
2552*cdf0e10cSrcweir 			{
2553*cdf0e10cSrcweir 				nStartCol = pThisRange->aStart.Col();
2554*cdf0e10cSrcweir 				nStartRow = pThisRange->aStart.Row();
2555*cdf0e10cSrcweir 				nEndCol   = pThisRange->aEnd  .Col();
2556*cdf0e10cSrcweir 				nEndRow   = pThisRange->aEnd  .Row();
2557*cdf0e10cSrcweir 				bDoThis = AdjustPrintArea(sal_False);
2558*cdf0e10cSrcweir 			}
2559*cdf0e10cSrcweir 		}
2560*cdf0e10cSrcweir 
2561*cdf0e10cSrcweir 		if (bDoThis)
2562*cdf0e10cSrcweir 		{
2563*cdf0e10cSrcweir 			ScHorizontalCellIterator aIter( pDoc, nPrintTab, nStartCol,nStartRow, nEndCol,nEndRow );
2564*cdf0e10cSrcweir 			ScBaseCell* pCell = aIter.GetNext( nCol, nRow );
2565*cdf0e10cSrcweir 			while (pCell)
2566*cdf0e10cSrcweir 			{
2567*cdf0e10cSrcweir                 if (pCell->HasNote())
2568*cdf0e10cSrcweir 				{
2569*cdf0e10cSrcweir 					aNotePosList.Insert( new ScAddress( nCol,nRow,nPrintTab ), LIST_APPEND );
2570*cdf0e10cSrcweir 					++nCount;
2571*cdf0e10cSrcweir 				}
2572*cdf0e10cSrcweir 
2573*cdf0e10cSrcweir 				pCell = aIter.GetNext( nCol, nRow );
2574*cdf0e10cSrcweir 			}
2575*cdf0e10cSrcweir 		}
2576*cdf0e10cSrcweir 	}
2577*cdf0e10cSrcweir 
2578*cdf0e10cSrcweir 	long nPages = 0;
2579*cdf0e10cSrcweir 	long nNoteNr = 0;
2580*cdf0e10cSrcweir 	long nNoteAdd;
2581*cdf0e10cSrcweir 	do
2582*cdf0e10cSrcweir 	{
2583*cdf0e10cSrcweir 		nNoteAdd = PrintNotes( nPages, nNoteNr, sal_False, NULL );
2584*cdf0e10cSrcweir 		if (nNoteAdd)
2585*cdf0e10cSrcweir 		{
2586*cdf0e10cSrcweir 			nNoteNr += nNoteAdd;
2587*cdf0e10cSrcweir 			++nPages;
2588*cdf0e10cSrcweir 		}
2589*cdf0e10cSrcweir 	}
2590*cdf0e10cSrcweir 	while (nNoteAdd);
2591*cdf0e10cSrcweir 
2592*cdf0e10cSrcweir 	return nPages;
2593*cdf0e10cSrcweir }
2594*cdf0e10cSrcweir 
2595*cdf0e10cSrcweir void ScPrintFunc::InitModes()				// aus nZoom etc. die MapModes setzen
2596*cdf0e10cSrcweir {
2597*cdf0e10cSrcweir 	aOffset = Point( aSrcOffset.X()*100/nZoom, aSrcOffset.Y()*100/nZoom );
2598*cdf0e10cSrcweir 
2599*cdf0e10cSrcweir 	long nEffZoom = nZoom * (long) nManualZoom;
2600*cdf0e10cSrcweir 
2601*cdf0e10cSrcweir //	nScaleX = nScaleY = 1.0;			// Ausgabe in Twips
2602*cdf0e10cSrcweir 	nScaleX = nScaleY = HMM_PER_TWIPS;	// Ausgabe in 1/100 mm
2603*cdf0e10cSrcweir 
2604*cdf0e10cSrcweir 	Fraction aZoomFract( nEffZoom,10000 );
2605*cdf0e10cSrcweir 	Fraction aHorFract = aZoomFract;
2606*cdf0e10cSrcweir 
2607*cdf0e10cSrcweir 	if ( !pPrinter && !bIsRender )							// adjust scale for preview
2608*cdf0e10cSrcweir 	{
2609*cdf0e10cSrcweir 		double nFact = pDocShell->GetOutputFactor();
2610*cdf0e10cSrcweir 		aHorFract = Fraction( (long)( nEffZoom / nFact ), 10000 );
2611*cdf0e10cSrcweir 	}
2612*cdf0e10cSrcweir 
2613*cdf0e10cSrcweir 	aLogicMode = MapMode( MAP_100TH_MM, Point(), aHorFract, aZoomFract );
2614*cdf0e10cSrcweir 
2615*cdf0e10cSrcweir 	Point aLogicOfs( -aOffset.X(), -aOffset.Y() );
2616*cdf0e10cSrcweir 	aOffsetMode = MapMode( MAP_100TH_MM, aLogicOfs, aHorFract, aZoomFract );
2617*cdf0e10cSrcweir 
2618*cdf0e10cSrcweir 	Point aTwipsOfs( (long) ( -aOffset.X() / nScaleX + 0.5 ), (long) ( -aOffset.Y() / nScaleY + 0.5 ) );
2619*cdf0e10cSrcweir 	aTwipMode = MapMode( MAP_TWIP, aTwipsOfs, aHorFract, aZoomFract );
2620*cdf0e10cSrcweir }
2621*cdf0e10cSrcweir 
2622*cdf0e10cSrcweir //--------------------------------------------------------------------
2623*cdf0e10cSrcweir 
2624*cdf0e10cSrcweir void ScPrintFunc::ApplyPrintSettings()
2625*cdf0e10cSrcweir {
2626*cdf0e10cSrcweir 	if ( pPrinter )
2627*cdf0e10cSrcweir 	{
2628*cdf0e10cSrcweir 		//
2629*cdf0e10cSrcweir 		//	Printer zum Drucken umstellen
2630*cdf0e10cSrcweir 		//
2631*cdf0e10cSrcweir 
2632*cdf0e10cSrcweir 		Size aEnumSize = aPageSize;
2633*cdf0e10cSrcweir 
2634*cdf0e10cSrcweir 
2635*cdf0e10cSrcweir         pPrinter->SetOrientation( bLandscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT );
2636*cdf0e10cSrcweir         if ( bLandscape )
2637*cdf0e10cSrcweir         {
2638*cdf0e10cSrcweir                 // landscape is always interpreted as a rotation by 90 degrees !
2639*cdf0e10cSrcweir                 // this leads to non WYSIWIG but at least it prints!
2640*cdf0e10cSrcweir                 // #i21775#
2641*cdf0e10cSrcweir                 long nTemp = aEnumSize.Width();
2642*cdf0e10cSrcweir                 aEnumSize.Width() = aEnumSize.Height();
2643*cdf0e10cSrcweir                 aEnumSize.Height() = nTemp;
2644*cdf0e10cSrcweir         }
2645*cdf0e10cSrcweir         Paper ePaper = SvxPaperInfo::GetSvxPaper( aEnumSize, MAP_TWIP, sal_True );
2646*cdf0e10cSrcweir 		sal_uInt16 nPaperBin = ((const SvxPaperBinItem&)pParamSet->Get(ATTR_PAGE_PAPERBIN)).GetValue();
2647*cdf0e10cSrcweir 
2648*cdf0e10cSrcweir         pPrinter->SetPaper( ePaper );
2649*cdf0e10cSrcweir         if ( PAPER_USER == ePaper )
2650*cdf0e10cSrcweir         {
2651*cdf0e10cSrcweir 		    MapMode aPrinterMode = pPrinter->GetMapMode();
2652*cdf0e10cSrcweir 		    MapMode aLocalMode( MAP_TWIP );
2653*cdf0e10cSrcweir 		    pPrinter->SetMapMode( aLocalMode );
2654*cdf0e10cSrcweir 		    pPrinter->SetPaperSizeUser( aEnumSize );
2655*cdf0e10cSrcweir 		    pPrinter->SetMapMode( aPrinterMode );
2656*cdf0e10cSrcweir         }
2657*cdf0e10cSrcweir 
2658*cdf0e10cSrcweir 		pPrinter->SetPaperBin( nPaperBin );
2659*cdf0e10cSrcweir 	}
2660*cdf0e10cSrcweir }
2661*cdf0e10cSrcweir 
2662*cdf0e10cSrcweir //--------------------------------------------------------------------
2663*cdf0e10cSrcweir //	rPageRanges   = Range fuer alle Tabellen
2664*cdf0e10cSrcweir //	nStartPage	  = in rPageRanges beginnen bei nStartPage
2665*cdf0e10cSrcweir //	nDisplayStart = lfd. Nummer fuer Anzeige der Seitennummer
2666*cdf0e10cSrcweir 
2667*cdf0e10cSrcweir long ScPrintFunc::DoPrint( const MultiSelection& rPageRanges,
2668*cdf0e10cSrcweir 								long nStartPage, long nDisplayStart, sal_Bool bDoPrint,
2669*cdf0e10cSrcweir                                 ScPreviewLocationData* pLocationData )
2670*cdf0e10cSrcweir {
2671*cdf0e10cSrcweir 	DBG_ASSERT(pDev,"Device == NULL");
2672*cdf0e10cSrcweir 	if (!pParamSet)
2673*cdf0e10cSrcweir 		return 0;
2674*cdf0e10cSrcweir 
2675*cdf0e10cSrcweir 	if ( pPrinter && bDoPrint )
2676*cdf0e10cSrcweir 		ApplyPrintSettings();
2677*cdf0e10cSrcweir 
2678*cdf0e10cSrcweir 	//--------------------------------------------------------------------
2679*cdf0e10cSrcweir 
2680*cdf0e10cSrcweir 	InitModes();
2681*cdf0e10cSrcweir 	if ( pLocationData )
2682*cdf0e10cSrcweir 	{
2683*cdf0e10cSrcweir 		pLocationData->SetCellMapMode( aOffsetMode );
2684*cdf0e10cSrcweir 		pLocationData->SetPrintTab( nPrintTab );
2685*cdf0e10cSrcweir 	}
2686*cdf0e10cSrcweir 
2687*cdf0e10cSrcweir 	MakeTableString();
2688*cdf0e10cSrcweir 
2689*cdf0e10cSrcweir 	//--------------------------------------------------------------------
2690*cdf0e10cSrcweir 
2691*cdf0e10cSrcweir 	long nPageNo = 0;
2692*cdf0e10cSrcweir 	long nPrinted = 0;
2693*cdf0e10cSrcweir 	long nEndPage = rPageRanges.GetTotalRange().Max();
2694*cdf0e10cSrcweir 
2695*cdf0e10cSrcweir 	sal_uInt16 nRepeats = 1;					// wie oft durchgehen ?
2696*cdf0e10cSrcweir 	if (bMultiArea)
2697*cdf0e10cSrcweir 		nRepeats = pDoc->GetPrintRangeCount(nPrintTab);
2698*cdf0e10cSrcweir 	for (sal_uInt16 nStep=0; nStep<nRepeats; nStep++)
2699*cdf0e10cSrcweir 	{
2700*cdf0e10cSrcweir 		if (bMultiArea)						// Bereich neu belegen ?
2701*cdf0e10cSrcweir 		{
2702*cdf0e10cSrcweir 			CalcZoom(nStep);				// setzt auch nStartCol etc. neu
2703*cdf0e10cSrcweir 			InitModes();
2704*cdf0e10cSrcweir 		}
2705*cdf0e10cSrcweir 
2706*cdf0e10cSrcweir 		SCCOL nX1;
2707*cdf0e10cSrcweir 		SCROW nY1;
2708*cdf0e10cSrcweir 		SCCOL nX2;
2709*cdf0e10cSrcweir 		SCROW nY2;
2710*cdf0e10cSrcweir 		size_t nCountX;
2711*cdf0e10cSrcweir 		size_t nCountY;
2712*cdf0e10cSrcweir 
2713*cdf0e10cSrcweir 		if (aTableParam.bTopDown)							// von oben nach unten
2714*cdf0e10cSrcweir 		{
2715*cdf0e10cSrcweir 			nX1 = nStartCol;
2716*cdf0e10cSrcweir 			for (nCountX=0; nCountX<nPagesX; nCountX++)
2717*cdf0e10cSrcweir 			{
2718*cdf0e10cSrcweir 				nX2 = pPageEndX[nCountX];
2719*cdf0e10cSrcweir 				for (nCountY=0; nCountY<nPagesY; nCountY++)
2720*cdf0e10cSrcweir 				{
2721*cdf0e10cSrcweir 					nY1 = pPageRows[nCountY].GetStartRow();
2722*cdf0e10cSrcweir 					nY2 = pPageRows[nCountY].GetEndRow();
2723*cdf0e10cSrcweir 					if ( !aTableParam.bSkipEmpty || !pPageRows[nCountY].IsHidden(nCountX) )
2724*cdf0e10cSrcweir 					{
2725*cdf0e10cSrcweir 						if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) )
2726*cdf0e10cSrcweir 						{
2727*cdf0e10cSrcweir 							PrintPage( nPageNo+nDisplayStart, nX1, nY1, nX2, nY2,
2728*cdf0e10cSrcweir 										bDoPrint, pLocationData );
2729*cdf0e10cSrcweir 							++nPrinted;
2730*cdf0e10cSrcweir 						}
2731*cdf0e10cSrcweir 						++nPageNo;
2732*cdf0e10cSrcweir 					}
2733*cdf0e10cSrcweir 				}
2734*cdf0e10cSrcweir 				nX1 = nX2 + 1;
2735*cdf0e10cSrcweir 			}
2736*cdf0e10cSrcweir 		}
2737*cdf0e10cSrcweir 		else												// von links nach rechts
2738*cdf0e10cSrcweir 		{
2739*cdf0e10cSrcweir 			for (nCountY=0; nCountY<nPagesY; nCountY++)
2740*cdf0e10cSrcweir 			{
2741*cdf0e10cSrcweir 				nY1 = pPageRows[nCountY].GetStartRow();
2742*cdf0e10cSrcweir 				nY2 = pPageRows[nCountY].GetEndRow();
2743*cdf0e10cSrcweir 				nX1 = nStartCol;
2744*cdf0e10cSrcweir 				for (nCountX=0; nCountX<nPagesX; nCountX++)
2745*cdf0e10cSrcweir 				{
2746*cdf0e10cSrcweir 					nX2 = pPageEndX[nCountX];
2747*cdf0e10cSrcweir 					if ( !aTableParam.bSkipEmpty || !pPageRows[nCountY].IsHidden(nCountX) )
2748*cdf0e10cSrcweir 					{
2749*cdf0e10cSrcweir 						if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) )
2750*cdf0e10cSrcweir 						{
2751*cdf0e10cSrcweir 							PrintPage( nPageNo+nDisplayStart, nX1, nY1, nX2, nY2,
2752*cdf0e10cSrcweir 										bDoPrint, pLocationData );
2753*cdf0e10cSrcweir 							++nPrinted;
2754*cdf0e10cSrcweir 						}
2755*cdf0e10cSrcweir 						++nPageNo;
2756*cdf0e10cSrcweir 					}
2757*cdf0e10cSrcweir 					nX1 = nX2 + 1;
2758*cdf0e10cSrcweir 				}
2759*cdf0e10cSrcweir 			}
2760*cdf0e10cSrcweir 		}
2761*cdf0e10cSrcweir 	}
2762*cdf0e10cSrcweir 
2763*cdf0e10cSrcweir 	aFieldData.aTabName = ScGlobal::GetRscString( STR_NOTES );
2764*cdf0e10cSrcweir 
2765*cdf0e10cSrcweir 	long nNoteNr = 0;
2766*cdf0e10cSrcweir 	long nNoteAdd;
2767*cdf0e10cSrcweir 	do
2768*cdf0e10cSrcweir 	{
2769*cdf0e10cSrcweir 		if ( nPageNo+nStartPage <= nEndPage )
2770*cdf0e10cSrcweir 		{
2771*cdf0e10cSrcweir 			sal_Bool bPageSelected = rPageRanges.IsSelected( nPageNo+nStartPage+1 );
2772*cdf0e10cSrcweir 			nNoteAdd = PrintNotes( nPageNo+nStartPage, nNoteNr, bDoPrint && bPageSelected,
2773*cdf0e10cSrcweir 									( bPageSelected ? pLocationData : NULL ) );
2774*cdf0e10cSrcweir 			if ( nNoteAdd )
2775*cdf0e10cSrcweir 			{
2776*cdf0e10cSrcweir 				nNoteNr += nNoteAdd;
2777*cdf0e10cSrcweir 				if (bPageSelected)
2778*cdf0e10cSrcweir 				{
2779*cdf0e10cSrcweir 					++nPrinted;
2780*cdf0e10cSrcweir 					bSourceRangeValid = sal_False;		// last page was no cell range
2781*cdf0e10cSrcweir 				}
2782*cdf0e10cSrcweir 				++nPageNo;
2783*cdf0e10cSrcweir 			}
2784*cdf0e10cSrcweir 		}
2785*cdf0e10cSrcweir 		else
2786*cdf0e10cSrcweir 			nNoteAdd = 0;
2787*cdf0e10cSrcweir 	}
2788*cdf0e10cSrcweir 	while (nNoteAdd);
2789*cdf0e10cSrcweir 
2790*cdf0e10cSrcweir 	if ( bMultiArea )
2791*cdf0e10cSrcweir 		ResetBreaks(nPrintTab);							// Breaks fuer Anzeige richtig
2792*cdf0e10cSrcweir 
2793*cdf0e10cSrcweir 	return nPrinted;
2794*cdf0e10cSrcweir }
2795*cdf0e10cSrcweir 
2796*cdf0e10cSrcweir void ScPrintFunc::CalcZoom( sal_uInt16 nRangeNo )						// Zoom berechnen
2797*cdf0e10cSrcweir {
2798*cdf0e10cSrcweir 	sal_uInt16 nRCount = pDoc->GetPrintRangeCount( nPrintTab );
2799*cdf0e10cSrcweir 	const ScRange* pThisRange = NULL;
2800*cdf0e10cSrcweir 	if ( nRangeNo != RANGENO_NORANGE || nRangeNo < nRCount )
2801*cdf0e10cSrcweir 		pThisRange = pDoc->GetPrintRange( nPrintTab, nRangeNo );
2802*cdf0e10cSrcweir 	if ( pThisRange )
2803*cdf0e10cSrcweir 	{
2804*cdf0e10cSrcweir 		nStartCol = pThisRange->aStart.Col();
2805*cdf0e10cSrcweir 		nStartRow = pThisRange->aStart.Row();
2806*cdf0e10cSrcweir 		nEndCol   = pThisRange->aEnd  .Col();
2807*cdf0e10cSrcweir 		nEndRow   = pThisRange->aEnd  .Row();
2808*cdf0e10cSrcweir 	}
2809*cdf0e10cSrcweir 
2810*cdf0e10cSrcweir 	if (!AdjustPrintArea(sal_False))						// leer
2811*cdf0e10cSrcweir 	{
2812*cdf0e10cSrcweir 		nZoom = 100;
2813*cdf0e10cSrcweir 		nPagesX = nPagesY = nTotalY = 0;
2814*cdf0e10cSrcweir 		return;
2815*cdf0e10cSrcweir 	}
2816*cdf0e10cSrcweir 
2817*cdf0e10cSrcweir 	pDoc->SetRepeatArea( nPrintTab, nRepeatStartCol,nRepeatEndCol, nRepeatStartRow,nRepeatEndRow );
2818*cdf0e10cSrcweir 
2819*cdf0e10cSrcweir 	if (aTableParam.bScalePageNum)
2820*cdf0e10cSrcweir 	{
2821*cdf0e10cSrcweir 		nZoom = 100;
2822*cdf0e10cSrcweir 		sal_uInt16 nPagesToFit = aTableParam.nScalePageNum;
2823*cdf0e10cSrcweir 
2824*cdf0e10cSrcweir         sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
2825*cdf0e10cSrcweir         while (true)
2826*cdf0e10cSrcweir         {
2827*cdf0e10cSrcweir             if (nZoom <= ZOOM_MIN)
2828*cdf0e10cSrcweir                 break;
2829*cdf0e10cSrcweir 
2830*cdf0e10cSrcweir             CalcPages();
2831*cdf0e10cSrcweir             bool bFitsPage = (nPagesX * nPagesY <= nPagesToFit);
2832*cdf0e10cSrcweir 
2833*cdf0e10cSrcweir             if (bFitsPage)
2834*cdf0e10cSrcweir             {
2835*cdf0e10cSrcweir                 if (nZoom == 100)
2836*cdf0e10cSrcweir                     // If it fits at 100 %, it's good enough for me.
2837*cdf0e10cSrcweir                     break;
2838*cdf0e10cSrcweir 
2839*cdf0e10cSrcweir                 nLastFitZoom = nZoom;
2840*cdf0e10cSrcweir                 nZoom = (nLastNonFitZoom + nZoom) / 2;
2841*cdf0e10cSrcweir 
2842*cdf0e10cSrcweir                 if (nLastFitZoom == nZoom)
2843*cdf0e10cSrcweir                     // It converged.  Use this zoom level.
2844*cdf0e10cSrcweir                     break;
2845*cdf0e10cSrcweir             }
2846*cdf0e10cSrcweir             else
2847*cdf0e10cSrcweir             {
2848*cdf0e10cSrcweir                 if (nZoom - nLastFitZoom <= 1)
2849*cdf0e10cSrcweir                 {
2850*cdf0e10cSrcweir                     nZoom = nLastFitZoom;
2851*cdf0e10cSrcweir                     CalcPages();
2852*cdf0e10cSrcweir                     break;
2853*cdf0e10cSrcweir                 }
2854*cdf0e10cSrcweir 
2855*cdf0e10cSrcweir                 nLastNonFitZoom = nZoom;
2856*cdf0e10cSrcweir                 nZoom = (nLastFitZoom + nZoom) / 2;
2857*cdf0e10cSrcweir             }
2858*cdf0e10cSrcweir         }
2859*cdf0e10cSrcweir 	}
2860*cdf0e10cSrcweir     else if (aTableParam.bScaleTo)
2861*cdf0e10cSrcweir     {
2862*cdf0e10cSrcweir         nZoom = 100;
2863*cdf0e10cSrcweir         sal_uInt16 nW = aTableParam.nScaleWidth;
2864*cdf0e10cSrcweir         sal_uInt16 nH = aTableParam.nScaleHeight;
2865*cdf0e10cSrcweir 
2866*cdf0e10cSrcweir         sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
2867*cdf0e10cSrcweir         while (true)
2868*cdf0e10cSrcweir         {
2869*cdf0e10cSrcweir             if (nZoom <= ZOOM_MIN)
2870*cdf0e10cSrcweir                 break;
2871*cdf0e10cSrcweir 
2872*cdf0e10cSrcweir             CalcPages();
2873*cdf0e10cSrcweir             bool bFitsPage = ((!nW || (nPagesX <= nW)) && (!nH || (nPagesY <= nH)));
2874*cdf0e10cSrcweir 
2875*cdf0e10cSrcweir             if (bFitsPage)
2876*cdf0e10cSrcweir             {
2877*cdf0e10cSrcweir                 if (nZoom == 100)
2878*cdf0e10cSrcweir                     // If it fits at 100 %, it's good enough for me.
2879*cdf0e10cSrcweir                     break;
2880*cdf0e10cSrcweir 
2881*cdf0e10cSrcweir                 nLastFitZoom = nZoom;
2882*cdf0e10cSrcweir                 nZoom = (nLastNonFitZoom + nZoom) / 2;
2883*cdf0e10cSrcweir 
2884*cdf0e10cSrcweir                 if (nLastFitZoom == nZoom)
2885*cdf0e10cSrcweir                     // It converged.  Use this zoom level.
2886*cdf0e10cSrcweir                     break;
2887*cdf0e10cSrcweir             }
2888*cdf0e10cSrcweir             else
2889*cdf0e10cSrcweir             {
2890*cdf0e10cSrcweir                 if (nZoom - nLastFitZoom <= 1)
2891*cdf0e10cSrcweir                 {
2892*cdf0e10cSrcweir                     nZoom = nLastFitZoom;
2893*cdf0e10cSrcweir                     CalcPages();
2894*cdf0e10cSrcweir                     break;
2895*cdf0e10cSrcweir                 }
2896*cdf0e10cSrcweir 
2897*cdf0e10cSrcweir                 nLastNonFitZoom = nZoom;
2898*cdf0e10cSrcweir                 nZoom = (nLastFitZoom + nZoom) / 2;
2899*cdf0e10cSrcweir             }
2900*cdf0e10cSrcweir         }
2901*cdf0e10cSrcweir     }
2902*cdf0e10cSrcweir 	else if (aTableParam.bScaleAll)
2903*cdf0e10cSrcweir 	{
2904*cdf0e10cSrcweir 		nZoom = aTableParam.nScaleAll;
2905*cdf0e10cSrcweir 		if ( nZoom <= ZOOM_MIN )
2906*cdf0e10cSrcweir 			nZoom = ZOOM_MIN;
2907*cdf0e10cSrcweir 		CalcPages();
2908*cdf0e10cSrcweir 	}
2909*cdf0e10cSrcweir 	else
2910*cdf0e10cSrcweir 	{
2911*cdf0e10cSrcweir 		DBG_ASSERT( aTableParam.bScaleNone, "kein Scale-Flag gesetzt" );
2912*cdf0e10cSrcweir 		nZoom = 100;
2913*cdf0e10cSrcweir 		CalcPages();
2914*cdf0e10cSrcweir 	}
2915*cdf0e10cSrcweir }
2916*cdf0e10cSrcweir 
2917*cdf0e10cSrcweir Size ScPrintFunc::GetDocPageSize()
2918*cdf0e10cSrcweir {
2919*cdf0e10cSrcweir 						// Hoehe Kopf-/Fusszeile anpassen
2920*cdf0e10cSrcweir 
2921*cdf0e10cSrcweir 	InitModes();							// aTwipMode aus nZoom initialisieren
2922*cdf0e10cSrcweir 	pDev->SetMapMode( aTwipMode );			// Kopf-/Fusszeilen in Twips
2923*cdf0e10cSrcweir 	UpdateHFHeight( aHdr );
2924*cdf0e10cSrcweir 	UpdateHFHeight( aFtr );
2925*cdf0e10cSrcweir 
2926*cdf0e10cSrcweir 						// Seitengroesse in Document-Twips
2927*cdf0e10cSrcweir 						// 	Berechnung Left / Right auch in PrintPage
2928*cdf0e10cSrcweir 
2929*cdf0e10cSrcweir 	aPageRect = Rectangle( Point(), aPageSize );
2930*cdf0e10cSrcweir 	aPageRect.Left()   = ( aPageRect.Left()   + nLeftMargin					 ) * 100 / nZoom;
2931*cdf0e10cSrcweir 	aPageRect.Right()  = ( aPageRect.Right()  - nRightMargin				 ) * 100 / nZoom;
2932*cdf0e10cSrcweir 	aPageRect.Top()    = ( aPageRect.Top()    + nTopMargin    ) * 100 / nZoom + aHdr.nHeight;
2933*cdf0e10cSrcweir 	aPageRect.Bottom() = ( aPageRect.Bottom() - nBottomMargin ) * 100 / nZoom - aFtr.nHeight;
2934*cdf0e10cSrcweir 
2935*cdf0e10cSrcweir 	Size aDocPageSize = aPageRect.GetSize();
2936*cdf0e10cSrcweir 	if (aTableParam.bHeaders)
2937*cdf0e10cSrcweir 	{
2938*cdf0e10cSrcweir 		aDocPageSize.Width()  -= (long) PRINT_HEADER_WIDTH;
2939*cdf0e10cSrcweir 		aDocPageSize.Height() -= (long) PRINT_HEADER_HEIGHT;
2940*cdf0e10cSrcweir 	}
2941*cdf0e10cSrcweir 	if (pBorderItem)
2942*cdf0e10cSrcweir 	{
2943*cdf0e10cSrcweir 		aDocPageSize.Width()  -= lcl_LineTotal(pBorderItem->GetLeft()) +
2944*cdf0e10cSrcweir 								 lcl_LineTotal(pBorderItem->GetRight()) +
2945*cdf0e10cSrcweir 								 pBorderItem->GetDistance(BOX_LINE_LEFT) +
2946*cdf0e10cSrcweir 								 pBorderItem->GetDistance(BOX_LINE_RIGHT);
2947*cdf0e10cSrcweir 		aDocPageSize.Height() -= lcl_LineTotal(pBorderItem->GetTop()) +
2948*cdf0e10cSrcweir 								 lcl_LineTotal(pBorderItem->GetBottom()) +
2949*cdf0e10cSrcweir 								 pBorderItem->GetDistance(BOX_LINE_TOP) +
2950*cdf0e10cSrcweir 								 pBorderItem->GetDistance(BOX_LINE_BOTTOM);
2951*cdf0e10cSrcweir 	}
2952*cdf0e10cSrcweir 	if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
2953*cdf0e10cSrcweir 	{
2954*cdf0e10cSrcweir 		aDocPageSize.Width()  -= pShadowItem->CalcShadowSpace(SHADOW_LEFT) +
2955*cdf0e10cSrcweir 								 pShadowItem->CalcShadowSpace(SHADOW_RIGHT);
2956*cdf0e10cSrcweir 		aDocPageSize.Height() -= pShadowItem->CalcShadowSpace(SHADOW_TOP) +
2957*cdf0e10cSrcweir 								 pShadowItem->CalcShadowSpace(SHADOW_BOTTOM);
2958*cdf0e10cSrcweir 	}
2959*cdf0e10cSrcweir 	return aDocPageSize;
2960*cdf0e10cSrcweir }
2961*cdf0e10cSrcweir 
2962*cdf0e10cSrcweir void ScPrintFunc::ResetBreaks( SCTAB nTab )			// Breaks fuer Anzeige richtig setzen
2963*cdf0e10cSrcweir {
2964*cdf0e10cSrcweir 	pDoc->SetPageSize( nTab, GetDocPageSize() );
2965*cdf0e10cSrcweir 	pDoc->UpdatePageBreaks( nTab, NULL );
2966*cdf0e10cSrcweir }
2967*cdf0e10cSrcweir 
2968*cdf0e10cSrcweir void lcl_SetHidden( ScDocument* pDoc, SCTAB nPrintTab, ScPageRowEntry& rPageRowEntry,
2969*cdf0e10cSrcweir 					SCCOL nStartCol, const SCCOL* pPageEndX )
2970*cdf0e10cSrcweir {
2971*cdf0e10cSrcweir 	size_t nPagesX   = rPageRowEntry.GetPagesX();
2972*cdf0e10cSrcweir 	SCROW nStartRow = rPageRowEntry.GetStartRow();
2973*cdf0e10cSrcweir 	SCROW nEndRow   = rPageRowEntry.GetEndRow();
2974*cdf0e10cSrcweir 
2975*cdf0e10cSrcweir 	sal_Bool bLeftIsEmpty = sal_False;
2976*cdf0e10cSrcweir 	ScRange aTempRange;
2977*cdf0e10cSrcweir 	Rectangle aTempRect = pDoc->GetMMRect( 0,0, 0,0, 0 );
2978*cdf0e10cSrcweir 
2979*cdf0e10cSrcweir 	for (size_t i=0; i<nPagesX; i++)
2980*cdf0e10cSrcweir 	{
2981*cdf0e10cSrcweir 		SCCOL nEndCol = pPageEndX[i];
2982*cdf0e10cSrcweir 		if ( pDoc->IsPrintEmpty( nPrintTab, nStartCol, nStartRow, nEndCol, nEndRow,
2983*cdf0e10cSrcweir 									bLeftIsEmpty, &aTempRange, &aTempRect ) )
2984*cdf0e10cSrcweir 		{
2985*cdf0e10cSrcweir 			rPageRowEntry.SetHidden(i);
2986*cdf0e10cSrcweir 			bLeftIsEmpty = sal_True;
2987*cdf0e10cSrcweir 		}
2988*cdf0e10cSrcweir 		else
2989*cdf0e10cSrcweir 			bLeftIsEmpty = sal_False;
2990*cdf0e10cSrcweir 
2991*cdf0e10cSrcweir 		nStartCol = nEndCol+1;
2992*cdf0e10cSrcweir 	}
2993*cdf0e10cSrcweir }
2994*cdf0e10cSrcweir 
2995*cdf0e10cSrcweir void ScPrintFunc::CalcPages()               // berechnet aPageRect und Seiten aus nZoom
2996*cdf0e10cSrcweir {
2997*cdf0e10cSrcweir     if (!pPageEndX) pPageEndX = new SCCOL[MAXCOL+1];
2998*cdf0e10cSrcweir     if (!pPageEndY) pPageEndY = new SCROW[MAXROW+1];
2999*cdf0e10cSrcweir     if (!pPageRows) pPageRows = new ScPageRowEntry[MAXROW+1];   //! vorher zaehlen !!!!
3000*cdf0e10cSrcweir 
3001*cdf0e10cSrcweir     pDoc->SetPageSize( nPrintTab, GetDocPageSize() );
3002*cdf0e10cSrcweir     if (aAreaParam.bPrintArea)
3003*cdf0e10cSrcweir     {
3004*cdf0e10cSrcweir         ScRange aRange( nStartCol, nStartRow, nPrintTab, nEndCol, nEndRow, nPrintTab );
3005*cdf0e10cSrcweir         pDoc->UpdatePageBreaks( nPrintTab, &aRange );
3006*cdf0e10cSrcweir     }
3007*cdf0e10cSrcweir     else
3008*cdf0e10cSrcweir         pDoc->UpdatePageBreaks( nPrintTab, NULL );      // sonst wird das Ende markiert
3009*cdf0e10cSrcweir 
3010*cdf0e10cSrcweir     //
3011*cdf0e10cSrcweir     //  Seiteneinteilung nach Umbruechen in Col/RowFlags
3012*cdf0e10cSrcweir     //  Von mehreren Umbruechen in einem ausgeblendeten Bereich zaehlt nur einer.
3013*cdf0e10cSrcweir     //
3014*cdf0e10cSrcweir 
3015*cdf0e10cSrcweir     nPagesX = 0;
3016*cdf0e10cSrcweir     nPagesY = 0;
3017*cdf0e10cSrcweir     nTotalY = 0;
3018*cdf0e10cSrcweir 
3019*cdf0e10cSrcweir     bool bVisCol = false;
3020*cdf0e10cSrcweir     SCCOL nLastCol = -1;
3021*cdf0e10cSrcweir     for (SCCOL i=nStartCol; i<=nEndCol; i++)
3022*cdf0e10cSrcweir     {
3023*cdf0e10cSrcweir         bool bHidden = pDoc->ColHidden(i, nPrintTab, nLastCol);
3024*cdf0e10cSrcweir         bool bPageBreak = (pDoc->HasColBreak(i, nPrintTab) & BREAK_PAGE);
3025*cdf0e10cSrcweir         if ( i>nStartCol && bVisCol && bPageBreak )
3026*cdf0e10cSrcweir         {
3027*cdf0e10cSrcweir             pPageEndX[nPagesX] = i-1;
3028*cdf0e10cSrcweir             ++nPagesX;
3029*cdf0e10cSrcweir             bVisCol = false;
3030*cdf0e10cSrcweir         }
3031*cdf0e10cSrcweir         if (!bHidden)
3032*cdf0e10cSrcweir             bVisCol = true;
3033*cdf0e10cSrcweir     }
3034*cdf0e10cSrcweir     if (bVisCol)    // auch am Ende keine leeren Seiten
3035*cdf0e10cSrcweir     {
3036*cdf0e10cSrcweir         pPageEndX[nPagesX] = nEndCol;
3037*cdf0e10cSrcweir         ++nPagesX;
3038*cdf0e10cSrcweir     }
3039*cdf0e10cSrcweir 
3040*cdf0e10cSrcweir     bool bVisRow = false;
3041*cdf0e10cSrcweir     SCROW nPageStartRow = nStartRow;
3042*cdf0e10cSrcweir     SCROW nLastVisibleRow = -1;
3043*cdf0e10cSrcweir 
3044*cdf0e10cSrcweir     ::boost::scoped_ptr<ScRowBreakIterator> pRowBreakIter(pDoc->GetRowBreakIterator(nPrintTab));
3045*cdf0e10cSrcweir     SCROW nNextPageBreak = pRowBreakIter->first();
3046*cdf0e10cSrcweir     while (nNextPageBreak != ScRowBreakIterator::NOT_FOUND && nNextPageBreak < nStartRow)
3047*cdf0e10cSrcweir         // Skip until the page break position is at the start row or greater.
3048*cdf0e10cSrcweir         nNextPageBreak = pRowBreakIter->next();
3049*cdf0e10cSrcweir 
3050*cdf0e10cSrcweir     for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
3051*cdf0e10cSrcweir     {
3052*cdf0e10cSrcweir         bool bPageBreak = (nNextPageBreak == nRow);
3053*cdf0e10cSrcweir         if (bPageBreak)
3054*cdf0e10cSrcweir             nNextPageBreak = pRowBreakIter->next();
3055*cdf0e10cSrcweir 
3056*cdf0e10cSrcweir         if (nRow > nStartRow && bVisRow && bPageBreak )
3057*cdf0e10cSrcweir         {
3058*cdf0e10cSrcweir             pPageEndY[nTotalY] = nRow-1;
3059*cdf0e10cSrcweir             ++nTotalY;
3060*cdf0e10cSrcweir 
3061*cdf0e10cSrcweir             if ( !aTableParam.bSkipEmpty ||
3062*cdf0e10cSrcweir                     !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nRow-1 ) )
3063*cdf0e10cSrcweir             {
3064*cdf0e10cSrcweir                 pPageRows[nPagesY].SetStartRow( nPageStartRow );
3065*cdf0e10cSrcweir                 pPageRows[nPagesY].SetEndRow( nRow-1 );
3066*cdf0e10cSrcweir                 pPageRows[nPagesY].SetPagesX( nPagesX );
3067*cdf0e10cSrcweir                 if (aTableParam.bSkipEmpty)
3068*cdf0e10cSrcweir                     lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX );
3069*cdf0e10cSrcweir                 ++nPagesY;
3070*cdf0e10cSrcweir             }
3071*cdf0e10cSrcweir 
3072*cdf0e10cSrcweir             nPageStartRow = nRow;
3073*cdf0e10cSrcweir             bVisRow = false;
3074*cdf0e10cSrcweir         }
3075*cdf0e10cSrcweir 
3076*cdf0e10cSrcweir         if (nRow <= nLastVisibleRow)
3077*cdf0e10cSrcweir         {
3078*cdf0e10cSrcweir             // This row is still visible.  Don't bother calling RowHidden() to
3079*cdf0e10cSrcweir             // find out, for speed optimization.
3080*cdf0e10cSrcweir             bVisRow = true;
3081*cdf0e10cSrcweir             continue;
3082*cdf0e10cSrcweir         }
3083*cdf0e10cSrcweir 
3084*cdf0e10cSrcweir         SCROW nLastRow = -1;
3085*cdf0e10cSrcweir         if (!pDoc->RowHidden(nRow, nPrintTab, NULL, &nLastRow))
3086*cdf0e10cSrcweir         {
3087*cdf0e10cSrcweir             bVisRow = true;
3088*cdf0e10cSrcweir             nLastVisibleRow = nLastRow;
3089*cdf0e10cSrcweir         }
3090*cdf0e10cSrcweir         else
3091*cdf0e10cSrcweir             // skip all hidden rows.
3092*cdf0e10cSrcweir             nRow = nLastRow;
3093*cdf0e10cSrcweir     }
3094*cdf0e10cSrcweir 
3095*cdf0e10cSrcweir     if (bVisRow)
3096*cdf0e10cSrcweir     {
3097*cdf0e10cSrcweir         pPageEndY[nTotalY] = nEndRow;
3098*cdf0e10cSrcweir         ++nTotalY;
3099*cdf0e10cSrcweir 
3100*cdf0e10cSrcweir         if ( !aTableParam.bSkipEmpty ||
3101*cdf0e10cSrcweir                 !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nEndRow ) )
3102*cdf0e10cSrcweir         {
3103*cdf0e10cSrcweir             pPageRows[nPagesY].SetStartRow( nPageStartRow );
3104*cdf0e10cSrcweir             pPageRows[nPagesY].SetEndRow( nEndRow );
3105*cdf0e10cSrcweir             pPageRows[nPagesY].SetPagesX( nPagesX );
3106*cdf0e10cSrcweir             if (aTableParam.bSkipEmpty)
3107*cdf0e10cSrcweir                 lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX );
3108*cdf0e10cSrcweir             ++nPagesY;
3109*cdf0e10cSrcweir         }
3110*cdf0e10cSrcweir     }
3111*cdf0e10cSrcweir }
3112*cdf0e10cSrcweir 
3113*cdf0e10cSrcweir //------------------------------------------------------------------------
3114*cdf0e10cSrcweir //	class ScJobSetup
3115*cdf0e10cSrcweir //------------------------------------------------------------------------
3116*cdf0e10cSrcweir 
3117*cdf0e10cSrcweir ScJobSetup::ScJobSetup( SfxPrinter* pPrinter )
3118*cdf0e10cSrcweir {
3119*cdf0e10cSrcweir 	eOrientation = pPrinter->GetOrientation();
3120*cdf0e10cSrcweir 	nPaperBin	 = pPrinter->GetPaperBin();
3121*cdf0e10cSrcweir 	ePaper		 = pPrinter->GetPaper();
3122*cdf0e10cSrcweir 
3123*cdf0e10cSrcweir 	if ( PAPER_USER == ePaper )
3124*cdf0e10cSrcweir 	{
3125*cdf0e10cSrcweir 		aUserSize = pPrinter->GetPaperSize();
3126*cdf0e10cSrcweir 		aUserMapMode = pPrinter->GetMapMode();
3127*cdf0e10cSrcweir 	}
3128*cdf0e10cSrcweir };
3129*cdf0e10cSrcweir 
3130*cdf0e10cSrcweir 
3131*cdf0e10cSrcweir 
3132*cdf0e10cSrcweir 
3133*cdf0e10cSrcweir 
3134