dr78: #i88468# merge page margin display back into DoPrint
[LibreOffice.git] / sc / source / ui / inc / printfun.hxx
blob0c84978479ed4d28d313add3a996ebe6b4d46bd5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #ifndef SC_PRINTFUN_HXX
30 #define SC_PRINTFUN_HXX
33 #include "pagepar.hxx"
34 #include "editutil.hxx"
36 #include <vcl/print.hxx>
38 class SfxPrinter;
39 class SfxProgress;
40 class ScDocShell;
41 class ScDocument;
42 class ScViewData;
43 class SfxItemSet;
44 class ScPageHFItem;
45 class EditTextObject;
46 class MultiSelection;
47 class ScHeaderEditEngine;
48 class ScPageBreakData;
49 class ScPreviewLocationData;
50 class ScPrintOptions;
51 class SvxBoxItem;
52 class SvxBrushItem;
53 class SvxShadowItem;
54 class FmFormView;
56 #define RANGENO_NORANGE USHRT_MAX
58 #define PRINT_HEADER_WIDTH (1.0 * TWIPS_PER_CM)
59 #define PRINT_HEADER_HEIGHT (12.8 * TWIPS_PER_POINT)
60 #define PRINT_HEADER_FONTHEIGHT 200
63 // Einstellungen fuer Kopf-/Fusszeilen
64 struct ScPrintHFParam
66 sal_Bool bEnable;
67 sal_Bool bDynamic;
68 sal_Bool bShared;
69 long nHeight; // insgesamt (Hoehe+Abstand+Rahmen)
70 long nManHeight; // eingestellte Groesse (Min. bei dynamisch)
71 sal_uInt16 nDistance;
72 sal_uInt16 nLeft; // Raender
73 sal_uInt16 nRight;
74 const ScPageHFItem* pLeft;
75 const ScPageHFItem* pRight;
76 const SvxBoxItem* pBorder;
77 const SvxBrushItem* pBack;
78 const SvxShadowItem* pShadow;
82 // "Ersatz" fuer SV-JobSetup:
84 class ScJobSetup
86 public:
87 ScJobSetup( SfxPrinter* pPrinter );
89 Size aUserSize;
90 MapMode aUserMapMode;
91 Paper ePaper;
92 Orientation eOrientation;
93 sal_uInt16 nPaperBin;
96 struct ScPrintState // Variablen aus ScPrintFunc retten
98 SCTAB nPrintTab;
99 SCCOL nStartCol;
100 SCROW nStartRow;
101 SCCOL nEndCol;
102 SCROW nEndRow;
103 sal_uInt16 nZoom;
104 size_t nPagesX;
105 size_t nPagesY;
106 long nTabPages;
107 long nTotalPages;
108 long nPageStart;
109 long nDocPages;
112 class ScPageRowEntry
114 private:
115 SCROW nStartRow;
116 SCROW nEndRow;
117 size_t nPagesX;
118 sal_Bool* pHidden;
119 //! Anzahl wirklich sichtbarer cachen???
121 public:
122 ScPageRowEntry() { nStartRow = nEndRow = 0; nPagesX = 0; pHidden = NULL; }
123 ~ScPageRowEntry() { delete[] pHidden; }
125 ScPageRowEntry(const ScPageRowEntry& r);
126 const ScPageRowEntry& operator=(const ScPageRowEntry& r);
128 SCROW GetStartRow() const { return nStartRow; }
129 SCROW GetEndRow() const { return nEndRow; }
130 size_t GetPagesX() const { return nPagesX; }
131 void SetStartRow(SCROW n) { nStartRow = n; }
132 void SetEndRow(SCROW n) { nEndRow = n; }
134 void SetPagesX(size_t nNew);
135 void SetHidden(size_t nX);
136 sal_Bool IsHidden(size_t nX) const;
138 size_t CountVisible() const;
141 class ScPrintFunc
143 private:
144 ScDocShell* pDocShell;
145 ScDocument* pDoc;
146 SfxPrinter* pPrinter;
147 OutputDevice* pDev;
148 FmFormView* pDrawView;
150 MapMode aOldPrinterMode; // MapMode vor dem Aufruf
152 Point aSrcOffset; // Papier-1/100 mm
153 Point aOffset; // mit Faktor aus Seitenformat skaliert
154 sal_uInt16 nManualZoom; // Zoom in Preview (Prozent)
155 sal_Bool bClearWin; // Ausgabe vorher loeschen
156 sal_Bool bUseStyleColor;
157 sal_Bool bIsRender;
159 SCTAB nPrintTab;
160 long nPageStart; // Offset fuer erste Seite
161 long nDocPages; // Seiten im Dokument
163 const ScRange* pUserArea; // Selektion, wenn im Dialog eingestellt
165 const SfxItemSet* pParamSet; // eingestellte Vorlage
166 sal_Bool bState; // aus State-struct erzeugt
168 // Parameter aus Vorlage:
169 sal_uInt16 nLeftMargin;
170 sal_uInt16 nTopMargin;
171 sal_uInt16 nRightMargin;
172 sal_uInt16 nBottomMargin;
173 sal_Bool bCenterHor;
174 sal_Bool bCenterVer;
175 sal_Bool bLandscape;
176 sal_Bool bSourceRangeValid;
178 sal_uInt16 nPageUsage;
179 Size aPageSize; // Drucker-Twips
180 const SvxBoxItem* pBorderItem;
181 const SvxBrushItem* pBackgroundItem;
182 const SvxShadowItem* pShadowItem;
184 ScRange aLastSourceRange;
185 ScPrintHFParam aHdr;
186 ScPrintHFParam aFtr;
187 ScPageTableParam aTableParam;
188 ScPageAreaParam aAreaParam;
190 // berechnete Werte:
191 sal_uInt16 nZoom;
192 sal_Bool bPrintCurrentTable;
193 sal_Bool bMultiArea;
194 long nTabPages;
195 long nTotalPages;
197 Rectangle aPageRect; // Dokument-Twips
199 MapMode aLogicMode; // in DoPrint gesetzt
200 MapMode aOffsetMode;
201 MapMode aTwipMode;
202 double nScaleX;
203 double nScaleY;
205 SCCOL nRepeatStartCol;
206 SCCOL nRepeatEndCol;
207 SCROW nRepeatStartRow;
208 SCROW nRepeatEndRow;
210 SCCOL nStartCol;
211 SCROW nStartRow;
212 SCCOL nEndCol;
213 SCROW nEndRow;
215 SCCOL* pPageEndX; // Seitenaufteilung
216 SCROW* pPageEndY;
217 ScPageRowEntry* pPageRows;
218 size_t nPagesX;
219 size_t nPagesY;
220 size_t nTotalY;
222 ScHeaderEditEngine* pEditEngine;
223 SfxItemSet* pEditDefaults;
225 ScHeaderFieldData aFieldData;
227 std::vector<ScAddress> aNotePosList; // Reihenfolge der Notizen
229 ScPageBreakData* pPageData; // zum Eintragen der Umbrueche etc.
231 public:
232 ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
233 long nPage = 0, long nDocP = 0,
234 const ScRange* pArea = NULL,
235 const ScPrintOptions* pOptions = NULL,
236 ScPageBreakData* pData = NULL );
238 // ctors for device other than printer - for preview and pdf:
240 ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
241 long nPage = 0, long nDocP = 0,
242 const ScRange* pArea = NULL,
243 const ScPrintOptions* pOptions = NULL );
245 ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
246 const ScPrintState& rState,
247 const ScPrintOptions* pOptions );
249 ~ScPrintFunc();
251 static void DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor,
252 const Rectangle& rBound, ScViewData* pViewData, sal_Bool bMetaFile );
254 void SetDrawView( FmFormView* pNew );
256 void SetOffset( const Point& rOfs );
257 void SetManualZoom( sal_uInt16 nNewZoom );
258 void SetDateTime( const Date& rDate, const Time& rTime );
260 void SetClearFlag( sal_Bool bFlag );
261 void SetUseStyleColor( sal_Bool bFlag );
262 void SetRenderFlag( sal_Bool bFlag );
264 void SetExclusivelyDrawOleAndDrawObjects();//for printing selected objects without surrounding cell contents
266 sal_Bool UpdatePages();
268 void ApplyPrintSettings(); // aus DoPrint() schon gerufen
269 long DoPrint( const MultiSelection& rPageRanges,
270 long nStartPage, long nDisplayStart, bool bDoPrint,
271 SfxProgress* pProgress, ScPreviewLocationData* pLocationData );
273 // Werte abfragen - sofort
275 Size GetPageSize() const { return aPageSize; }
276 Size GetDataSize() const;
277 void GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr );
278 long GetFirstPageNo() const { return aTableParam.nFirstPageNo; }
280 // letzte Werte abfragen - nach DoPrint !!!
282 double GetScaleX() const { return nScaleX; }
283 double GetScaleY() const { return nScaleY; }
284 long GetTotalPages() const { return nTotalPages; }
285 sal_uInt16 GetZoom() const { return nZoom; }
287 void ResetBreaks( SCTAB nTab );
289 void GetPrintState( ScPrintState& rState );
290 sal_Bool GetLastSourceRange( ScRange& rRange ) const;
291 sal_uInt16 GetLeftMargin() const{return nLeftMargin;}
292 sal_uInt16 GetRightMargin() const{return nRightMargin;}
293 sal_uInt16 GetTopMargin() const{return nTopMargin;}
294 sal_uInt16 GetBottomMargin() const{return nBottomMargin;}
295 void SetLeftMargin(sal_uInt16 nRulerLeftDistance){ nLeftMargin = nRulerLeftDistance; }
296 void SetRightMargin(sal_uInt16 nRulerRightDistance){ nRightMargin = nRulerRightDistance; }
297 void SetTopMargin(sal_uInt16 nRulerTopDistance){ nTopMargin = nRulerTopDistance; }
298 void SetBottomMargin(sal_uInt16 nRulerBottomDistance){ nBottomMargin = nRulerBottomDistance; }
299 ScPrintHFParam GetHeader(){return aHdr;}
300 ScPrintHFParam GetFooter(){return aFtr;}
302 private:
303 void Construct( const ScPrintOptions* pOptions );
304 void InitParam( const ScPrintOptions* pOptions );
305 void CalcZoom( sal_uInt16 nRangeNo );
306 void CalcPages();
307 long CountPages();
308 long CountNotePages();
310 sal_Bool AdjustPrintArea( sal_Bool bNew );
312 Size GetDocPageSize();
314 long TextHeight( const EditTextObject* pObject );
315 void MakeEditEngine();
316 void UpdateHFHeight( ScPrintHFParam& rParam );
318 void InitModes();
320 sal_Bool IsLeft( long nPageNo );
321 sal_Bool IsMirror( long nPageNo );
322 void ReplaceFields( long nPageNo ); // aendert Text in pEditEngine
323 void MakeTableString(); // setzt aTableStr
325 void PrintPage( long nPageNo,
326 SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
327 sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
328 void PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
329 long nScrX, long nScrY,
330 sal_Bool bShLeft, sal_Bool bShTop, sal_Bool bShRight, sal_Bool bShBottom );
331 void LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
332 long nScrX, long nScrY, sal_Bool bRepCol, sal_Bool bRepRow,
333 ScPreviewLocationData& rLocationData );
334 void PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY );
335 void PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY );
336 void LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
337 sal_Bool bRepCol, ScPreviewLocationData& rLocationData );
338 void LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
339 sal_Bool bRepRow, ScPreviewLocationData& rLocationData );
340 void PrintHF( long nPageNo, sal_Bool bHeader, long nStartY,
341 sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
343 long PrintNotes( long nPageNo, long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
344 long DoNotes( long nNoteStart, sal_Bool bDoPrint, ScPreviewLocationData* pLocationData );
346 void DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
347 const SvxBoxItem* pBorderData,
348 const SvxBrushItem* pBackground,
349 const SvxShadowItem* pShadow );
351 void FillPageData();
356 #endif
358 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */