Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / printfun.hxx
blob7273283a77372583e91f2078d9083090c1e0fcd0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef SC_PRINTFUN_HXX
21 #define SC_PRINTFUN_HXX
24 #include "pagepar.hxx"
25 #include "editutil.hxx"
27 #include <vcl/print.hxx>
29 class SfxPrinter;
30 class ScDocShell;
31 class ScDocument;
32 class ScViewData;
33 class SfxItemSet;
34 class ScPageHFItem;
35 class EditTextObject;
36 class MultiSelection;
37 class ScHeaderEditEngine;
38 class ScPageBreakData;
39 class ScPreviewLocationData;
40 class ScPrintOptions;
41 class SvxBoxItem;
42 class SvxBrushItem;
43 class SvxShadowItem;
44 class FmFormView;
46 #define RANGENO_NORANGE USHRT_MAX
48 #define PRINT_HEADER_WIDTH (1.0 * TWIPS_PER_CM)
49 #define PRINT_HEADER_HEIGHT (12.8 * TWIPS_PER_POINT)
50 #define PRINT_HEADER_FONTHEIGHT 200
53 // Settings for headers/footers
54 struct ScPrintHFParam
56 sal_Bool bEnable;
57 sal_Bool bDynamic;
58 sal_Bool bShared;
59 long nHeight; // in total (height + distance + frames)
60 long nManHeight; // set size (min when dynamic)
61 sal_uInt16 nDistance;
62 sal_uInt16 nLeft; // edges
63 sal_uInt16 nRight;
64 const ScPageHFItem* pLeft;
65 const ScPageHFItem* pRight;
66 const SvxBoxItem* pBorder;
67 const SvxBrushItem* pBack;
68 const SvxShadowItem* pShadow;
72 struct ScPrintState // Save Variables from ScPrintFunc
74 SCTAB nPrintTab;
75 SCCOL nStartCol;
76 SCROW nStartRow;
77 SCCOL nEndCol;
78 SCROW nEndRow;
79 sal_uInt16 nZoom;
80 size_t nPagesX;
81 size_t nPagesY;
82 long nTabPages;
83 long nTotalPages;
84 long nPageStart;
85 long nDocPages;
88 class ScPageRowEntry
90 private:
91 SCROW nStartRow;
92 SCROW nEndRow;
93 size_t nPagesX;
94 sal_Bool* pHidden;
95 //! Cache Number of really visible?
97 public:
98 ScPageRowEntry() { nStartRow = nEndRow = 0; nPagesX = 0; pHidden = NULL; }
99 ~ScPageRowEntry() { delete[] pHidden; }
101 ScPageRowEntry(const ScPageRowEntry& r);
102 const ScPageRowEntry& operator=(const ScPageRowEntry& r);
104 SCROW GetStartRow() const { return nStartRow; }
105 SCROW GetEndRow() const { return nEndRow; }
106 size_t GetPagesX() const { return nPagesX; }
107 void SetStartRow(SCROW n) { nStartRow = n; }
108 void SetEndRow(SCROW n) { nEndRow = n; }
110 void SetPagesX(size_t nNew);
111 void SetHidden(size_t nX);
112 sal_Bool IsHidden(size_t nX) const;
114 size_t CountVisible() const;
117 class ScPrintFunc
119 private:
120 ScDocShell* pDocShell;
121 ScDocument* pDoc;
122 SfxPrinter* pPrinter;
123 OutputDevice* pDev;
124 FmFormView* pDrawView;
126 MapMode aOldPrinterMode; // MapMode befor the call
128 Point aSrcOffset; // Paper-1/100 mm
129 Point aOffset; // scaled by a factor of page size
130 sal_uInt16 nManualZoom; // Zoom in Preview (percent)
131 sal_Bool bClearWin; // Clear output before
132 sal_Bool bUseStyleColor;
133 sal_Bool bIsRender;
135 SCTAB nPrintTab;
136 long nPageStart; // Offset for the first page
137 long nDocPages; // Number of Pages in Document
139 const ScRange* pUserArea; // Selection, if set in dialog
141 const SfxItemSet* pParamSet; // Selected template
142 sal_Bool bState; // created from State-struct
144 // Parameter from template:
145 sal_uInt16 nLeftMargin;
146 sal_uInt16 nTopMargin;
147 sal_uInt16 nRightMargin;
148 sal_uInt16 nBottomMargin;
149 sal_Bool bCenterHor;
150 sal_Bool bCenterVer;
151 sal_Bool bLandscape;
152 sal_Bool bSourceRangeValid;
154 sal_uInt16 nPageUsage;
155 Size aPageSize; // Printer Twips
156 const SvxBoxItem* pBorderItem;
157 const SvxBrushItem* pBackgroundItem;
158 const SvxShadowItem* pShadowItem;
160 ScRange aLastSourceRange;
161 ScPrintHFParam aHdr;
162 ScPrintHFParam aFtr;
163 ScPageTableParam aTableParam;
164 ScPageAreaParam aAreaParam;
166 // Calculated values:
167 sal_uInt16 nZoom;
168 sal_Bool bPrintCurrentTable;
169 sal_Bool bMultiArea;
170 long nTabPages;
171 long nTotalPages;
173 Rectangle aPageRect; // Document Twips
175 MapMode aLogicMode; // Set in DoPrint
176 MapMode aOffsetMode;
177 MapMode aTwipMode;
178 double nScaleX;
179 double nScaleY;
181 SCCOL nRepeatStartCol;
182 SCCOL nRepeatEndCol;
183 SCROW nRepeatStartRow;
184 SCROW nRepeatEndRow;
186 SCCOL nStartCol;
187 SCROW nStartRow;
188 SCCOL nEndCol;
189 SCROW nEndRow;
191 SCCOL* pPageEndX; // page layout
192 SCROW* pPageEndY;
193 ScPageRowEntry* pPageRows;
194 size_t nPagesX;
195 size_t nPagesY;
196 size_t nTotalY;
198 ScHeaderEditEngine* pEditEngine;
199 SfxItemSet* pEditDefaults;
201 ScHeaderFieldData aFieldData;
203 std::vector<ScAddress> aNotePosList; // The order of notes
205 ScPageBreakData* pPageData; // for recording the breaks etc.
207 public:
208 ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
209 long nPage = 0, long nDocP = 0,
210 const ScRange* pArea = NULL,
211 const ScPrintOptions* pOptions = NULL,
212 ScPageBreakData* pData = NULL );
214 // ctors for device other than printer - for preview and pdf:
216 ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
217 long nPage = 0, long nDocP = 0,
218 const ScRange* pArea = NULL,
219 const ScPrintOptions* pOptions = NULL );
221 ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
222 const ScPrintState& rState,
223 const ScPrintOptions* pOptions );
225 ~ScPrintFunc();
227 static void DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor,
228 const Rectangle& rBound, ScViewData* pViewData, sal_Bool bMetaFile );
230 void SetDrawView( FmFormView* pNew );
232 void SetOffset( const Point& rOfs );
233 void SetManualZoom( sal_uInt16 nNewZoom );
234 void SetDateTime( const Date& rDate, const Time& rTime );
236 void SetClearFlag( sal_Bool bFlag );
237 void SetUseStyleColor( sal_Bool bFlag );
238 void SetRenderFlag( sal_Bool bFlag );
240 void SetExclusivelyDrawOleAndDrawObjects();//for printing selected objects without surrounding cell contents
242 sal_Bool UpdatePages();
244 void ApplyPrintSettings(); // Already called from DoPrint()
245 long DoPrint( const MultiSelection& rPageRanges,
246 long nStartPage, long nDisplayStart, bool bDoPrint,
247 ScPreviewLocationData* pLocationData );
249 // Query values - immediately
251 Size GetPageSize() const { return aPageSize; }
252 Size GetDataSize() const;
253 void GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr );
254 long GetFirstPageNo() const { return aTableParam.nFirstPageNo; }
256 // Query last value - after DoPrint!!
258 double GetScaleX() const { return nScaleX; }
259 double GetScaleY() const { return nScaleY; }
260 long GetTotalPages() const { return nTotalPages; }
261 sal_uInt16 GetZoom() const { return nZoom; }
263 void ResetBreaks( SCTAB nTab );
265 void GetPrintState( ScPrintState& rState );
266 sal_Bool GetLastSourceRange( ScRange& rRange ) const;
267 sal_uInt16 GetLeftMargin() const{return nLeftMargin;}
268 sal_uInt16 GetRightMargin() const{return nRightMargin;}
269 sal_uInt16 GetTopMargin() const{return nTopMargin;}
270 sal_uInt16 GetBottomMargin() const{return nBottomMargin;}
271 void SetLeftMargin(sal_uInt16 nRulerLeftDistance){ nLeftMargin = nRulerLeftDistance; }
272 void SetRightMargin(sal_uInt16 nRulerRightDistance){ nRightMargin = nRulerRightDistance; }
273 void SetTopMargin(sal_uInt16 nRulerTopDistance){ nTopMargin = nRulerTopDistance; }
274 void SetBottomMargin(sal_uInt16 nRulerBottomDistance){ nBottomMargin = nRulerBottomDistance; }
275 ScPrintHFParam GetHeader(){return aHdr;}
276 ScPrintHFParam GetFooter(){return aFtr;}
278 private:
279 void Construct( const ScPrintOptions* pOptions );
280 void InitParam( const ScPrintOptions* pOptions );
281 void CalcZoom( sal_uInt16 nRangeNo );
282 void CalcPages();
283 long CountPages();
284 long CountNotePages();
286 sal_Bool AdjustPrintArea( sal_Bool bNew );
288 Size GetDocPageSize();
290 long TextHeight( const EditTextObject* pObject );
291 void MakeEditEngine();
292 void UpdateHFHeight( ScPrintHFParam& rParam );
294 void InitModes();
296 sal_Bool IsLeft( long nPageNo );
297 sal_Bool IsMirror( long nPageNo );
298 void ReplaceFields( long nPageNo ); // changes Text in pEditEngine
299 void MakeTableString(); // sets aTableStr
301 void PrintPage( long nPageNo,
302 SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
303 sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
304 void PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
305 long nScrX, long nScrY,
306 sal_Bool bShLeft, sal_Bool bShTop, sal_Bool bShRight, sal_Bool bShBottom );
307 void LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
308 long nScrX, long nScrY, sal_Bool bRepCol, sal_Bool bRepRow,
309 ScPreviewLocationData& rLocationData );
310 void PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY );
311 void PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY );
312 void LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
313 sal_Bool bRepCol, ScPreviewLocationData& rLocationData );
314 void LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
315 sal_Bool bRepRow, ScPreviewLocationData& rLocationData );
316 void PrintHF( long nPageNo, sal_Bool bHeader, long nStartY,
317 sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
319 long PrintNotes( long nPageNo, long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
320 long DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
322 void DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
323 const SvxBoxItem* pBorderData,
324 const SvxBrushItem* pBackground,
325 const SvxShadowItem* pShadow );
327 void FillPageData();
332 #endif
334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */