fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / inc / printfun.hxx
blob265789578cca4207cebeb8ab12fecdf1c16a812c
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 INCLUDED_SC_SOURCE_UI_INC_PRINTFUN_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_PRINTFUN_HXX
23 #include "pagepar.hxx"
24 #include "editutil.hxx"
26 #include <vcl/print.hxx>
28 class SfxPrinter;
29 class ScDocShell;
30 class ScDocument;
31 class ScViewData;
32 class SfxItemSet;
33 class ScPageHFItem;
34 class EditTextObject;
35 class MultiSelection;
36 class ScHeaderEditEngine;
37 class ScPageBreakData;
38 class ScPreviewLocationData;
39 class ScPrintOptions;
40 class SvxBoxItem;
41 class SvxBrushItem;
42 class SvxShadowItem;
43 class FmFormView;
45 #define RANGENO_NORANGE USHRT_MAX
47 #define PRINT_HEADER_WIDTH (1.0 * TWIPS_PER_CM)
48 #define PRINT_HEADER_HEIGHT (12.8 * TWIPS_PER_POINT)
50 // Settings for headers/footers
51 struct ScPrintHFParam
53 bool bEnable;
54 bool bDynamic;
55 bool bShared;
56 long nHeight; // in total (height + distance + frames)
57 long nManHeight; // set size (min when dynamic)
58 sal_uInt16 nDistance;
59 sal_uInt16 nLeft; // edges
60 sal_uInt16 nRight;
61 const ScPageHFItem* pLeft;
62 const ScPageHFItem* pRight;
63 const SvxBoxItem* pBorder;
64 const SvxBrushItem* pBack;
65 const SvxShadowItem* pShadow;
68 struct ScPrintState // Save Variables from ScPrintFunc
70 SCTAB nPrintTab;
71 SCCOL nStartCol;
72 SCROW nStartRow;
73 SCCOL nEndCol;
74 SCROW nEndRow;
75 sal_uInt16 nZoom;
76 size_t nPagesX;
77 size_t nPagesY;
78 long nTabPages;
79 long nTotalPages;
80 long nPageStart;
81 long nDocPages;
82 ScPrintState()
83 : nPrintTab(0)
84 , nStartCol(0)
85 , nStartRow(0)
86 , nEndCol(0)
87 , nEndRow(0)
88 , nZoom(0)
89 , nPagesX(0)
90 , nPagesY(0)
91 , nTabPages(0)
92 , nTotalPages(0)
93 , nPageStart(0)
94 , nDocPages(0)
99 class ScPageRowEntry
101 private:
102 SCROW nStartRow;
103 SCROW nEndRow;
104 size_t nPagesX;
105 bool* pHidden;
106 //! Cache Number of really visible?
108 public:
109 ScPageRowEntry() { nStartRow = nEndRow = 0; nPagesX = 0; pHidden = NULL; }
110 ~ScPageRowEntry() { delete[] pHidden; }
112 ScPageRowEntry(const ScPageRowEntry& r);
113 const ScPageRowEntry& operator=(const ScPageRowEntry& r);
115 SCROW GetStartRow() const { return nStartRow; }
116 SCROW GetEndRow() const { return nEndRow; }
117 size_t GetPagesX() const { return nPagesX; }
118 void SetStartRow(SCROW n) { nStartRow = n; }
119 void SetEndRow(SCROW n) { nEndRow = n; }
121 void SetPagesX(size_t nNew);
122 void SetHidden(size_t nX);
123 bool IsHidden(size_t nX) const;
125 size_t CountVisible() const;
128 class ScPrintFunc
130 private:
131 ScDocShell* pDocShell;
132 ScDocument* pDoc;
133 VclPtr<SfxPrinter> pPrinter;
134 VclPtr<OutputDevice> pDev;
135 FmFormView* pDrawView;
137 MapMode aOldPrinterMode; // MapMode before the call
139 Point aSrcOffset; // Paper-1/100 mm
140 Point aOffset; // scaled by a factor of page size
141 sal_uInt16 nManualZoom; // Zoom in Preview (percent)
142 bool bClearWin; // Clear output before
143 bool bUseStyleColor;
144 bool bIsRender;
146 SCTAB nPrintTab;
147 long nPageStart; // Offset for the first page
148 long nDocPages; // Number of Pages in Document
150 const ScRange* pUserArea; // Selection, if set in dialog
152 const SfxItemSet* pParamSet; // Selected template
153 bool bState; // created from State-struct
155 // Parameter from template:
156 sal_uInt16 nLeftMargin;
157 sal_uInt16 nTopMargin;
158 sal_uInt16 nRightMargin;
159 sal_uInt16 nBottomMargin;
160 bool bCenterHor;
161 bool bCenterVer;
162 bool bLandscape;
163 bool bSourceRangeValid;
165 sal_uInt16 nPageUsage;
166 Size aPageSize; // Printer Twips
167 const SvxBoxItem* pBorderItem;
168 const SvxBrushItem* pBackgroundItem;
169 const SvxShadowItem* pShadowItem;
171 ScRange aLastSourceRange;
172 ScPrintHFParam aHdr;
173 ScPrintHFParam aFtr;
174 ScPageTableParam aTableParam;
175 ScPageAreaParam aAreaParam;
177 // Calculated values:
178 sal_uInt16 nZoom;
179 bool bPrintCurrentTable;
180 bool bMultiArea;
181 bool mbHasPrintRange;
182 long nTabPages;
183 long nTotalPages;
185 Rectangle aPageRect; // Document Twips
187 MapMode aLogicMode; // Set in DoPrint
188 MapMode aOffsetMode;
189 MapMode aTwipMode;
190 double nScaleX;
191 double nScaleY;
193 SCCOL nRepeatStartCol;
194 SCCOL nRepeatEndCol;
195 SCROW nRepeatStartRow;
196 SCROW nRepeatEndRow;
198 SCCOL nStartCol;
199 SCROW nStartRow;
200 SCCOL nEndCol;
201 SCROW nEndRow;
203 std::vector< SCCOL > maPageEndX;
204 std::vector< SCROW > maPageEndY;
205 std::vector< ScPageRowEntry> maPageRows;
207 size_t nPagesX;
208 size_t nPagesY;
209 size_t nTotalY;
211 ScHeaderEditEngine* pEditEngine;
212 SfxItemSet* pEditDefaults;
214 ScHeaderFieldData aFieldData;
216 std::vector<ScAddress> aNotePosList; // The order of notes
218 ScPageBreakData* pPageData; // for recording the breaks etc.
220 public:
221 ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
222 long nPage = 0, long nDocP = 0,
223 const ScRange* pArea = NULL,
224 const ScPrintOptions* pOptions = NULL,
225 ScPageBreakData* pData = NULL );
227 // ctors for device other than printer - for preview and pdf:
229 ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
230 long nPage = 0, long nDocP = 0,
231 const ScRange* pArea = NULL,
232 const ScPrintOptions* pOptions = NULL );
234 ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
235 const ScPrintState& rState,
236 const ScPrintOptions* pOptions );
238 ~ScPrintFunc();
240 static void DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor,
241 const Rectangle& rBound, ScViewData* pViewData, bool bMetaFile );
243 void SetDrawView( FmFormView* pNew );
245 void SetOffset( const Point& rOfs );
246 void SetManualZoom( sal_uInt16 nNewZoom );
247 void SetDateTime( const Date& rDate, const tools::Time& rTime );
249 void SetClearFlag( bool bFlag );
250 void SetUseStyleColor( bool bFlag );
251 void SetRenderFlag( bool bFlag );
253 void SetExclusivelyDrawOleAndDrawObjects();//for printing selected objects without surrounding cell contents
255 bool UpdatePages();
257 void ApplyPrintSettings(); // Already called from DoPrint()
258 long DoPrint( const MultiSelection& rPageRanges,
259 long nStartPage, long nDisplayStart, bool bDoPrint,
260 ScPreviewLocationData* pLocationData );
262 // Query values - immediately
264 Size GetPageSize() const { return aPageSize; }
265 Size GetDataSize() const;
266 void GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr );
267 long GetFirstPageNo() const { return aTableParam.nFirstPageNo; }
269 // Query last value - after DoPrint!!
271 double GetScaleX() const { return nScaleX; }
272 double GetScaleY() const { return nScaleY; }
273 long GetTotalPages() const { return nTotalPages; }
274 sal_uInt16 GetZoom() const { return nZoom; }
276 void ResetBreaks( SCTAB nTab );
278 void GetPrintState( ScPrintState& rState );
279 bool GetLastSourceRange( ScRange& rRange ) const;
280 sal_uInt16 GetLeftMargin() const{return nLeftMargin;}
281 sal_uInt16 GetRightMargin() const{return nRightMargin;}
282 sal_uInt16 GetTopMargin() const{return nTopMargin;}
283 sal_uInt16 GetBottomMargin() const{return nBottomMargin;}
284 void SetLeftMargin(sal_uInt16 nRulerLeftDistance){ nLeftMargin = nRulerLeftDistance; }
285 void SetRightMargin(sal_uInt16 nRulerRightDistance){ nRightMargin = nRulerRightDistance; }
286 void SetTopMargin(sal_uInt16 nRulerTopDistance){ nTopMargin = nRulerTopDistance; }
287 void SetBottomMargin(sal_uInt16 nRulerBottomDistance){ nBottomMargin = nRulerBottomDistance; }
288 ScPrintHFParam GetHeader(){return aHdr;}
289 ScPrintHFParam GetFooter(){return aFtr;}
291 bool HasPrintRange() const { return mbHasPrintRange;}
293 private:
294 void Construct( const ScPrintOptions* pOptions );
295 void InitParam( const ScPrintOptions* pOptions );
296 void CalcZoom( sal_uInt16 nRangeNo );
297 void CalcPages();
298 long CountPages();
299 long CountNotePages();
301 bool AdjustPrintArea( bool bNew );
303 Size GetDocPageSize();
305 long TextHeight( const EditTextObject* pObject );
306 void MakeEditEngine();
307 void UpdateHFHeight( ScPrintHFParam& rParam );
309 void InitModes();
311 bool IsLeft( long nPageNo );
312 bool IsMirror( long nPageNo );
313 void ReplaceFields( long nPageNo ); // changes Text in pEditEngine
314 void MakeTableString(); // sets aTableStr
316 void PrintPage( long nPageNo,
317 SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
318 bool bDoPrint, ScPreviewLocationData* pLocationData );
319 void PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
320 long nScrX, long nScrY,
321 bool bShLeft, bool bShTop, bool bShRight, bool bShBottom );
322 void LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
323 long nScrX, long nScrY, bool bRepCol, bool bRepRow,
324 ScPreviewLocationData& rLocationData );
325 void PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY );
326 void PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY );
327 void LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
328 bool bRepCol, ScPreviewLocationData& rLocationData );
329 void LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
330 bool bRepRow, ScPreviewLocationData& rLocationData );
331 void PrintHF( long nPageNo, bool bHeader, long nStartY,
332 bool bDoPrint, ScPreviewLocationData* pLocationData );
334 long PrintNotes( long nPageNo, long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData );
335 long DoNotes( long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData );
337 void DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
338 const SvxBoxItem* pBorderData,
339 const SvxBrushItem* pBackground,
340 const SvxShadowItem* pShadow );
342 void FillPageData();
345 #endif
347 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */