xref: /trunk/main/sc/source/ui/inc/printfun.hxx (revision d636f962)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_PRINTFUN_HXX
25 #define SC_PRINTFUN_HXX
26 
27 
28 #include "pagepar.hxx"
29 #include "editutil.hxx"
30 
31 #ifndef _PRINT_HXX //autogen
32 #include <vcl/print.hxx>
33 #endif
34 
35 class SfxPrinter;
36 class SfxProgress;
37 class ScDocShell;
38 class ScDocument;
39 class ScViewData;
40 class SfxItemSet;
41 class ScPageHFItem;
42 class EditTextObject;
43 class MultiSelection;
44 class ScHeaderEditEngine;
45 class ScPageBreakData;
46 class ScPreviewLocationData;
47 class ScPrintOptions;
48 class SvxBoxItem;
49 class SvxBrushItem;
50 class SvxShadowItem;
51 class FmFormView;
52 
53 #define RANGENO_NORANGE				USHRT_MAX
54 
55 #define PRINT_HEADER_WIDTH			(1.0 * TWIPS_PER_CM)
56 #define PRINT_HEADER_HEIGHT 		(12.8 * TWIPS_PER_POINT)
57 #define PRINT_HEADER_FONTHEIGHT 	200
58 
59 
60 											//	Einstellungen fuer Kopf-/Fusszeilen
61 struct ScPrintHFParam
62 {
63 	sal_Bool				bEnable;
64 	sal_Bool				bDynamic;
65 	sal_Bool				bShared;
66 	long				nHeight;			//	insgesamt (Hoehe+Abstand+Rahmen)
67 	long				nManHeight;			//	eingestellte Groesse (Min. bei dynamisch)
68 	sal_uInt16				nDistance;
69 	sal_uInt16				nLeft;				//	Raender
70 	sal_uInt16				nRight;
71 	const ScPageHFItem* pLeft;
72 	const ScPageHFItem* pRight;
73 	const SvxBoxItem*	pBorder;
74 	const SvxBrushItem* pBack;
75 	const SvxShadowItem* pShadow;
76 };
77 
78 
79 // "Ersatz" fuer SV-JobSetup:
80 
81 class ScJobSetup
82 {
83 public:
84 	ScJobSetup( SfxPrinter* pPrinter );
85 
86 	Size		aUserSize;
87 	MapMode		aUserMapMode;
88 	Paper	ePaper;
89 	Orientation eOrientation;
90 	sal_uInt16		nPaperBin;
91 };
92 
93 struct ScPrintState							//	Variablen aus ScPrintFunc retten
94 {
95 	SCTAB	nPrintTab;
96 	SCCOL	nStartCol;
97 	SCROW	nStartRow;
98 	SCCOL	nEndCol;
99 	SCROW	nEndRow;
100 	sal_uInt16	nZoom;
101 	size_t	nPagesX;
102 	size_t	nPagesY;
103 	long	nTabPages;
104 	long	nTotalPages;
105 	long	nPageStart;
106 	long	nDocPages;
107 };
108 
109 class ScPageRowEntry
110 {
111 private:
112 	SCROW	nStartRow;
113 	SCROW	nEndRow;
114 	size_t	nPagesX;
115 	sal_Bool*	pHidden;
116 	//!		Anzahl wirklich sichtbarer cachen???
117 
118 public:
ScPageRowEntry()119 			ScPageRowEntry()	{ nStartRow = nEndRow = 0; nPagesX = 0; pHidden = NULL; }
~ScPageRowEntry()120 			~ScPageRowEntry()	{ delete[] pHidden; }
121 
122 			ScPageRowEntry(const ScPageRowEntry& r);
123 	const ScPageRowEntry& operator=(const ScPageRowEntry& r);
124 
GetStartRow() const125 	SCROW	GetStartRow() const		{ return nStartRow; }
GetEndRow() const126 	SCROW	GetEndRow() const		{ return nEndRow; }
GetPagesX() const127 	size_t	GetPagesX() const		{ return nPagesX; }
SetStartRow(SCROW n)128 	void	SetStartRow(SCROW n)	{ nStartRow = n; }
SetEndRow(SCROW n)129 	void	SetEndRow(SCROW n)		{ nEndRow = n; }
130 
131 	void	SetPagesX(size_t nNew);
132 	void	SetHidden(size_t nX);
133 	sal_Bool	IsHidden(size_t nX) const;
134 
135 	size_t	CountVisible() const;
136 };
137 
138 class ScPrintFunc
139 {
140 private:
141 	ScDocShell* 		pDocShell;
142 	ScDocument* 		pDoc;
143 	SfxPrinter* 		pPrinter;
144 	OutputDevice*		pDev;
145 	FmFormView*			pDrawView;
146 
147 	MapMode				aOldPrinterMode;	//	MapMode vor dem Aufruf
148 
149 	Point				aSrcOffset;			//	Papier-1/100 mm
150 	Point				aOffset;			//	mit Faktor aus Seitenformat skaliert
151 	sal_uInt16				nManualZoom;		//	Zoom in Preview (Prozent)
152 	sal_Bool				bClearWin;			//	Ausgabe vorher loeschen
153 	sal_Bool				bUseStyleColor;
154 	sal_Bool				bIsRender;
155 
156 	SCTAB				nPrintTab;
157 	long				nPageStart;			//	Offset fuer erste Seite
158 	long				nDocPages;			//	Seiten im Dokument
159 
160 	const ScRange*		pUserArea;			//	Selektion, wenn im Dialog eingestellt
161 
162 	const SfxItemSet*	pParamSet;			//	eingestellte Vorlage
163 	sal_Bool				bState;				//	aus State-struct erzeugt
164 
165 											//	Parameter aus Vorlage:
166 	sal_uInt16				nLeftMargin;
167 	sal_uInt16				nTopMargin;
168 	sal_uInt16				nRightMargin;
169 	sal_uInt16				nBottomMargin;
170 	sal_Bool				bCenterHor;
171 	sal_Bool				bCenterVer;
172 	sal_Bool				bLandscape;
173 	sal_Bool				bSourceRangeValid;
174 
175 	sal_uInt16				nPageUsage;
176 	Size				aPageSize;			//	Drucker-Twips
177 	const SvxBoxItem*	pBorderItem;
178 	const SvxBrushItem* pBackgroundItem;
179 	const SvxShadowItem* pShadowItem;
180 
181 	ScRange				aLastSourceRange;
182 	ScPrintHFParam		aHdr;
183 	ScPrintHFParam		aFtr;
184 	ScPageTableParam	aTableParam;
185 	ScPageAreaParam 	aAreaParam;
186 
187 											//	berechnete Werte:
188 	sal_uInt16				nZoom;
189 	sal_Bool				bPrintCurrentTable;
190 	sal_Bool				bMultiArea;
191 	long				nTabPages;
192 	long				nTotalPages;
193 
194 	Rectangle			aPageRect;			//	Dokument-Twips
195 
196 	MapMode 			aLogicMode; 		//	in DoPrint gesetzt
197 	MapMode 			aOffsetMode;
198 	MapMode 			aTwipMode;
199 	double				nScaleX;
200 	double				nScaleY;
201 
202 	SCCOL				nRepeatStartCol;
203 	SCCOL				nRepeatEndCol;
204 	SCROW				nRepeatStartRow;
205 	SCROW				nRepeatEndRow;
206 
207 	SCCOL				nStartCol;
208 	SCROW				nStartRow;
209 	SCCOL				nEndCol;
210 	SCROW				nEndRow;
211 
212     // #123672# use dynamic mem to react on size changes
213     std::vector< SCCOL >            maPageEndX;
214     std::vector< SCROW >            maPageEndY;
215     std::vector< ScPageRowEntry>    maPageRows;
216 
217     size_t				nPagesX;
218 	size_t				nPagesY;
219 	size_t				nTotalY;
220 
221 	ScHeaderEditEngine*	pEditEngine;
222 	SfxItemSet* 		pEditDefaults;
223 
224 	ScHeaderFieldData	aFieldData;
225 
226 	List				aNotePosList;		//	Reihenfolge der Notizen
227 
228 	ScPageBreakData*	pPageData;			// zum Eintragen der Umbrueche etc.
229 
230 public:
231 					ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
232 								 long nPage = 0, long nDocP = 0,
233 								 const ScRange* pArea = NULL,
234 								 const ScPrintOptions* pOptions = NULL,
235 								 ScPageBreakData* pData = NULL );
236 
237 					// ctors for device other than printer - for preview and pdf:
238 
239 					ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
240 								 long nPage = 0, long nDocP = 0,
241 								 const ScRange* pArea = NULL,
242 								 const ScPrintOptions* pOptions = NULL );
243 
244 					ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
245 								 const ScPrintState& rState,
246 								 const ScPrintOptions* pOptions );
247 
248 					~ScPrintFunc();
249 
250 	static void 	DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor,
251 								const Rectangle& rBound, ScViewData* pViewData, sal_Bool bMetaFile );
252 
253 	void			SetDrawView( FmFormView* pNew );
254 
255 	void			SetOffset( const Point& rOfs );
256 	void			SetManualZoom( sal_uInt16 nNewZoom );
257 	void			SetDateTime( const Date& rDate, const Time& rTime );
258 
259 	void			SetClearFlag( sal_Bool bFlag );
260 	void			SetUseStyleColor( sal_Bool bFlag );
261 	void			SetRenderFlag( sal_Bool bFlag );
262 
263     void            SetExclusivelyDrawOleAndDrawObjects();//for printing selected objects without surrounding cell contents
264 
265 	sal_Bool			UpdatePages();
266 
267 	void			ApplyPrintSettings();		// aus DoPrint() schon gerufen
268 	long			DoPrint( const MultiSelection& rPageRanges,
269                                 long nStartPage, long nDisplayStart, sal_Bool bDoPrint,
270                                 ScPreviewLocationData* pLocationData );
271 
272 					//	Werte abfragen - sofort
273 
GetPageSize() const274 	Size			GetPageSize() const { return aPageSize; }
275 	Size			GetDataSize() const;
276 	void			GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr );
GetFirstPageNo() const277 	long			GetFirstPageNo() const	{ return aTableParam.nFirstPageNo; }
278 
279 					//	letzte Werte abfragen - nach DoPrint !!!
280 
GetScaleX() const281 	double			GetScaleX() const { return nScaleX; }
GetScaleY() const282 	double			GetScaleY() const { return nScaleY; }
GetTotalPages() const283 	long			GetTotalPages() const { return nTotalPages; }
GetZoom() const284 	sal_uInt16			GetZoom() const { return nZoom; }
285 
286 	void			ResetBreaks( SCTAB nTab );
287 
288 	void			GetPrintState( ScPrintState& rState );
289 	sal_Bool			GetLastSourceRange( ScRange& rRange ) const;
GetLeftMargin() const290     sal_uInt16          GetLeftMargin() const{return nLeftMargin;}
GetRightMargin() const291     sal_uInt16          GetRightMargin() const{return nRightMargin;}
GetTopMargin() const292     sal_uInt16          GetTopMargin() const{return nTopMargin;}
GetBottomMargin() const293     sal_uInt16          GetBottomMargin() const{return nBottomMargin;}
SetLeftMargin(sal_uInt16 nRulerLeftDistance)294     void            SetLeftMargin(sal_uInt16 nRulerLeftDistance){ nLeftMargin = nRulerLeftDistance; }
SetRightMargin(sal_uInt16 nRulerRightDistance)295     void            SetRightMargin(sal_uInt16 nRulerRightDistance){ nRightMargin = nRulerRightDistance; }
SetTopMargin(sal_uInt16 nRulerTopDistance)296     void            SetTopMargin(sal_uInt16 nRulerTopDistance){ nTopMargin = nRulerTopDistance; }
SetBottomMargin(sal_uInt16 nRulerBottomDistance)297     void            SetBottomMargin(sal_uInt16 nRulerBottomDistance){ nBottomMargin = nRulerBottomDistance; }
GetHeader()298     ScPrintHFParam  GetHeader(){return aHdr;}
GetFooter()299     ScPrintHFParam  GetFooter(){return aFtr;}
300 
301 private:
302 	void			Construct( const ScPrintOptions* pOptions );
303 	void			InitParam( const ScPrintOptions* pOptions );
304 	void			CalcZoom( sal_uInt16 nRangeNo );
305 	void			CalcPages();
306 	long			CountPages();
307 	long			CountNotePages();
308 
309 	sal_Bool			AdjustPrintArea( sal_Bool bNew );
310 
311 	Size			GetDocPageSize();
312 
313 	long			TextHeight( const EditTextObject* pObject );
314 	void			MakeEditEngine();
315 	void			UpdateHFHeight( ScPrintHFParam& rParam );
316 
317 	void			InitModes();
318 
319 	sal_Bool			IsLeft( long nPageNo );
320 	sal_Bool			IsMirror( long nPageNo );
321 	void			ReplaceFields( long nPageNo );		// aendert Text in pEditEngine
322 	void			MakeTableString();				 	// setzt aTableStr
323 
324 	void			PrintPage( long nPageNo,
325 									SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
326 									sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
327 	void			PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
328 									long nScrX, long nScrY,
329 									sal_Bool bShLeft, sal_Bool bShTop, sal_Bool bShRight, sal_Bool bShBottom );
330 	void			LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
331 									long nScrX, long nScrY, sal_Bool bRepCol, sal_Bool bRepRow,
332 									ScPreviewLocationData& rLocationData );
333 	void			PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY );
334 	void			PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY );
335 	void			LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
336 								sal_Bool bRepCol, ScPreviewLocationData& rLocationData );
337 	void			LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
338 								sal_Bool bRepRow, ScPreviewLocationData& rLocationData );
339 	void			PrintHF( long nPageNo, sal_Bool bHeader, long nStartY,
340 									sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
341 
342 	long			PrintNotes( long nPageNo, long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
343 	long			DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
344 
345 	void			DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
346 									const SvxBoxItem* pBorderData,
347 									const SvxBrushItem* pBackground,
348 									const SvxShadowItem* pShadow );
349 
350 	void			FillPageData();
351 };
352 
353 
354 
355 #endif
356 
357