Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_PRINTFUN_HXX
30 : : #define SC_PRINTFUN_HXX
31 : :
32 : :
33 : : #include "pagepar.hxx"
34 : : #include "editutil.hxx"
35 : :
36 : : #include <vcl/print.hxx>
37 : :
38 : : class SfxPrinter;
39 : : class ScDocShell;
40 : : class ScDocument;
41 : : class ScViewData;
42 : : class SfxItemSet;
43 : : class ScPageHFItem;
44 : : class EditTextObject;
45 : : class MultiSelection;
46 : : class ScHeaderEditEngine;
47 : : class ScPageBreakData;
48 : : class ScPreviewLocationData;
49 : : class ScPrintOptions;
50 : : class SvxBoxItem;
51 : : class SvxBrushItem;
52 : : class SvxShadowItem;
53 : : class FmFormView;
54 : :
55 : : #define RANGENO_NORANGE USHRT_MAX
56 : :
57 : : #define PRINT_HEADER_WIDTH (1.0 * TWIPS_PER_CM)
58 : : #define PRINT_HEADER_HEIGHT (12.8 * TWIPS_PER_POINT)
59 : : #define PRINT_HEADER_FONTHEIGHT 200
60 : :
61 : :
62 : : // Settings for headers/footers
63 : : struct ScPrintHFParam
64 : : {
65 : : sal_Bool bEnable;
66 : : sal_Bool bDynamic;
67 : : sal_Bool bShared;
68 : : long nHeight; // in total (height + distance + frames)
69 : : long nManHeight; // set size (min when dynamic)
70 : : sal_uInt16 nDistance;
71 : : sal_uInt16 nLeft; // edges
72 : : sal_uInt16 nRight;
73 : : const ScPageHFItem* pLeft;
74 : : const ScPageHFItem* pRight;
75 : : const SvxBoxItem* pBorder;
76 : : const SvxBrushItem* pBack;
77 : : const SvxShadowItem* pShadow;
78 : : };
79 : :
80 : :
81 : : struct ScPrintState // Save Variables from ScPrintFunc
82 : : {
83 : : SCTAB nPrintTab;
84 : : SCCOL nStartCol;
85 : : SCROW nStartRow;
86 : : SCCOL nEndCol;
87 : : SCROW nEndRow;
88 : : sal_uInt16 nZoom;
89 : : size_t nPagesX;
90 : : size_t nPagesY;
91 : : long nTabPages;
92 : : long nTotalPages;
93 : : long nPageStart;
94 : : long nDocPages;
95 : : };
96 : :
97 : : class ScPageRowEntry
98 : : {
99 : : private:
100 : : SCROW nStartRow;
101 : : SCROW nEndRow;
102 : : size_t nPagesX;
103 : : sal_Bool* pHidden;
104 : : //! Cache Number of really visible?
105 : :
106 : : public:
107 : 190840832 : ScPageRowEntry() { nStartRow = nEndRow = 0; nPagesX = 0; pHidden = NULL; }
108 [ - + ]: 190840832 : ~ScPageRowEntry() { delete[] pHidden; }
109 : :
110 : : ScPageRowEntry(const ScPageRowEntry& r);
111 : : const ScPageRowEntry& operator=(const ScPageRowEntry& r);
112 : :
113 : 242 : SCROW GetStartRow() const { return nStartRow; }
114 : 242 : SCROW GetEndRow() const { return nEndRow; }
115 : 138 : size_t GetPagesX() const { return nPagesX; }
116 : 182 : void SetStartRow(SCROW n) { nStartRow = n; }
117 : 182 : void SetEndRow(SCROW n) { nEndRow = n; }
118 : :
119 : : void SetPagesX(size_t nNew);
120 : : void SetHidden(size_t nX);
121 : : sal_Bool IsHidden(size_t nX) const;
122 : :
123 : : size_t CountVisible() const;
124 : : };
125 : :
126 : : class ScPrintFunc
127 : : {
128 : : private:
129 : : ScDocShell* pDocShell;
130 : : ScDocument* pDoc;
131 : : SfxPrinter* pPrinter;
132 : : OutputDevice* pDev;
133 : : FmFormView* pDrawView;
134 : :
135 : : MapMode aOldPrinterMode; // MapMode befor the call
136 : :
137 : : Point aSrcOffset; // Paper-1/100 mm
138 : : Point aOffset; // scaled by a factor of page size
139 : : sal_uInt16 nManualZoom; // Zoom in Preview (percent)
140 : : sal_Bool bClearWin; // Clear output before
141 : : sal_Bool bUseStyleColor;
142 : : sal_Bool bIsRender;
143 : :
144 : : SCTAB nPrintTab;
145 : : long nPageStart; // Offset for the first page
146 : : long nDocPages; // Number of Pages in Document
147 : :
148 : : const ScRange* pUserArea; // Selection, if set in dialog
149 : :
150 : : const SfxItemSet* pParamSet; // Selected template
151 : : sal_Bool bState; // created from State-struct
152 : :
153 : : // Parameter from template:
154 : : sal_uInt16 nLeftMargin;
155 : : sal_uInt16 nTopMargin;
156 : : sal_uInt16 nRightMargin;
157 : : sal_uInt16 nBottomMargin;
158 : : sal_Bool bCenterHor;
159 : : sal_Bool bCenterVer;
160 : : sal_Bool bLandscape;
161 : : sal_Bool bSourceRangeValid;
162 : :
163 : : sal_uInt16 nPageUsage;
164 : : Size aPageSize; // Printer Twips
165 : : const SvxBoxItem* pBorderItem;
166 : : const SvxBrushItem* pBackgroundItem;
167 : : const SvxShadowItem* pShadowItem;
168 : :
169 : : ScRange aLastSourceRange;
170 : : ScPrintHFParam aHdr;
171 : : ScPrintHFParam aFtr;
172 : : ScPageTableParam aTableParam;
173 : : ScPageAreaParam aAreaParam;
174 : :
175 : : // Calculated values:
176 : : sal_uInt16 nZoom;
177 : : sal_Bool bPrintCurrentTable;
178 : : sal_Bool bMultiArea;
179 : : long nTabPages;
180 : : long nTotalPages;
181 : :
182 : : Rectangle aPageRect; // Document Twips
183 : :
184 : : MapMode aLogicMode; // Set in DoPrint
185 : : MapMode aOffsetMode;
186 : : MapMode aTwipMode;
187 : : double nScaleX;
188 : : double nScaleY;
189 : :
190 : : SCCOL nRepeatStartCol;
191 : : SCCOL nRepeatEndCol;
192 : : SCROW nRepeatStartRow;
193 : : SCROW nRepeatEndRow;
194 : :
195 : : SCCOL nStartCol;
196 : : SCROW nStartRow;
197 : : SCCOL nEndCol;
198 : : SCROW nEndRow;
199 : :
200 : : SCCOL* pPageEndX; // page layout
201 : : SCROW* pPageEndY;
202 : : ScPageRowEntry* pPageRows;
203 : : size_t nPagesX;
204 : : size_t nPagesY;
205 : : size_t nTotalY;
206 : :
207 : : ScHeaderEditEngine* pEditEngine;
208 : : SfxItemSet* pEditDefaults;
209 : :
210 : : ScHeaderFieldData aFieldData;
211 : :
212 : : std::vector<ScAddress> aNotePosList; // The order of notes
213 : :
214 : : ScPageBreakData* pPageData; // for recording the breaks etc.
215 : :
216 : : public:
217 : : ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
218 : : long nPage = 0, long nDocP = 0,
219 : : const ScRange* pArea = NULL,
220 : : const ScPrintOptions* pOptions = NULL,
221 : : ScPageBreakData* pData = NULL );
222 : :
223 : : // ctors for device other than printer - for preview and pdf:
224 : :
225 : : ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
226 : : long nPage = 0, long nDocP = 0,
227 : : const ScRange* pArea = NULL,
228 : : const ScPrintOptions* pOptions = NULL );
229 : :
230 : : ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
231 : : const ScPrintState& rState,
232 : : const ScPrintOptions* pOptions );
233 : :
234 : : ~ScPrintFunc();
235 : :
236 : : static void DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor,
237 : : const Rectangle& rBound, ScViewData* pViewData, sal_Bool bMetaFile );
238 : :
239 : : void SetDrawView( FmFormView* pNew );
240 : :
241 : : void SetOffset( const Point& rOfs );
242 : : void SetManualZoom( sal_uInt16 nNewZoom );
243 : : void SetDateTime( const Date& rDate, const Time& rTime );
244 : :
245 : : void SetClearFlag( sal_Bool bFlag );
246 : : void SetUseStyleColor( sal_Bool bFlag );
247 : : void SetRenderFlag( sal_Bool bFlag );
248 : :
249 : : void SetExclusivelyDrawOleAndDrawObjects();//for printing selected objects without surrounding cell contents
250 : :
251 : : sal_Bool UpdatePages();
252 : :
253 : : void ApplyPrintSettings(); // Already called from DoPrint()
254 : : long DoPrint( const MultiSelection& rPageRanges,
255 : : long nStartPage, long nDisplayStart, bool bDoPrint,
256 : : ScPreviewLocationData* pLocationData );
257 : :
258 : : // Query values - immediately
259 : :
260 : 138 : Size GetPageSize() const { return aPageSize; }
261 : : Size GetDataSize() const;
262 : : void GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr );
263 : 34 : long GetFirstPageNo() const { return aTableParam.nFirstPageNo; }
264 : :
265 : : // Query last value - after DoPrint!!
266 : :
267 : : double GetScaleX() const { return nScaleX; }
268 : : double GetScaleY() const { return nScaleY; }
269 : 34 : long GetTotalPages() const { return nTotalPages; }
270 : 104 : sal_uInt16 GetZoom() const { return nZoom; }
271 : :
272 : : void ResetBreaks( SCTAB nTab );
273 : :
274 : : void GetPrintState( ScPrintState& rState );
275 : : sal_Bool GetLastSourceRange( ScRange& rRange ) const;
276 : 104 : sal_uInt16 GetLeftMargin() const{return nLeftMargin;}
277 : 104 : sal_uInt16 GetRightMargin() const{return nRightMargin;}
278 : 104 : sal_uInt16 GetTopMargin() const{return nTopMargin;}
279 : 104 : sal_uInt16 GetBottomMargin() const{return nBottomMargin;}
280 : : void SetLeftMargin(sal_uInt16 nRulerLeftDistance){ nLeftMargin = nRulerLeftDistance; }
281 : : void SetRightMargin(sal_uInt16 nRulerRightDistance){ nRightMargin = nRulerRightDistance; }
282 : : void SetTopMargin(sal_uInt16 nRulerTopDistance){ nTopMargin = nRulerTopDistance; }
283 : : void SetBottomMargin(sal_uInt16 nRulerBottomDistance){ nBottomMargin = nRulerBottomDistance; }
284 : 208 : ScPrintHFParam GetHeader(){return aHdr;}
285 : 208 : ScPrintHFParam GetFooter(){return aFtr;}
286 : :
287 : : private:
288 : : void Construct( const ScPrintOptions* pOptions );
289 : : void InitParam( const ScPrintOptions* pOptions );
290 : : void CalcZoom( sal_uInt16 nRangeNo );
291 : : void CalcPages();
292 : : long CountPages();
293 : : long CountNotePages();
294 : :
295 : : sal_Bool AdjustPrintArea( sal_Bool bNew );
296 : :
297 : : Size GetDocPageSize();
298 : :
299 : : long TextHeight( const EditTextObject* pObject );
300 : : void MakeEditEngine();
301 : : void UpdateHFHeight( ScPrintHFParam& rParam );
302 : :
303 : : void InitModes();
304 : :
305 : : sal_Bool IsLeft( long nPageNo );
306 : : sal_Bool IsMirror( long nPageNo );
307 : : void ReplaceFields( long nPageNo ); // changes Text in pEditEngine
308 : : void MakeTableString(); // sets aTableStr
309 : :
310 : : void PrintPage( long nPageNo,
311 : : SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
312 : : sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
313 : : void PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
314 : : long nScrX, long nScrY,
315 : : sal_Bool bShLeft, sal_Bool bShTop, sal_Bool bShRight, sal_Bool bShBottom );
316 : : void LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
317 : : long nScrX, long nScrY, sal_Bool bRepCol, sal_Bool bRepRow,
318 : : ScPreviewLocationData& rLocationData );
319 : : void PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY );
320 : : void PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY );
321 : : void LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
322 : : sal_Bool bRepCol, ScPreviewLocationData& rLocationData );
323 : : void LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
324 : : sal_Bool bRepRow, ScPreviewLocationData& rLocationData );
325 : : void PrintHF( long nPageNo, sal_Bool bHeader, long nStartY,
326 : : sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
327 : :
328 : : long PrintNotes( long nPageNo, long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
329 : : long DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
330 : :
331 : : void DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
332 : : const SvxBoxItem* pBorderData,
333 : : const SvxBrushItem* pBackground,
334 : : const SvxShadowItem* pShadow );
335 : :
336 : : void FillPageData();
337 : : };
338 : :
339 : :
340 : :
341 : : #endif
342 : :
343 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|