update dev300-m58
[ooovba.git] / sc / source / ui / inc / printfun.hxx
blob6ede377d8baa70c9c7f5e05fba2220e043fb0729
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: printfun.hxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_PRINTFUN_HXX
32 #define SC_PRINTFUN_HXX
35 #include "pagepar.hxx"
36 #include "editutil.hxx"
38 #ifndef _PRINT_HXX //autogen
39 #include <vcl/print.hxx>
40 #endif
42 class SfxPrinter;
43 class SfxProgress;
44 class ScDocShell;
45 class ScDocument;
46 class ScViewData;
47 class SfxItemSet;
48 class ScPageHFItem;
49 class EditTextObject;
50 class MultiSelection;
51 class ScHeaderEditEngine;
52 class ScPageBreakData;
53 class ScPreviewLocationData;
54 class ScPrintOptions;
55 class SvxBoxItem;
56 class SvxBrushItem;
57 class SvxShadowItem;
58 class FmFormView;
60 #define RANGENO_NORANGE USHRT_MAX
62 #define PRINT_HEADER_WIDTH (1.0 * TWIPS_PER_CM)
63 #define PRINT_HEADER_HEIGHT (12.8 * TWIPS_PER_POINT)
64 #define PRINT_HEADER_FONTHEIGHT 200
67 // Einstellungen fuer Kopf-/Fusszeilen
68 struct ScPrintHFParam
70 BOOL bEnable;
71 BOOL bDynamic;
72 BOOL bShared;
73 long nHeight; // insgesamt (Hoehe+Abstand+Rahmen)
74 long nManHeight; // eingestellte Groesse (Min. bei dynamisch)
75 USHORT nDistance;
76 USHORT nLeft; // Raender
77 USHORT nRight;
78 const ScPageHFItem* pLeft;
79 const ScPageHFItem* pRight;
80 const SvxBoxItem* pBorder;
81 const SvxBrushItem* pBack;
82 const SvxShadowItem* pShadow;
86 // "Ersatz" fuer SV-JobSetup:
88 class ScJobSetup
90 public:
91 ScJobSetup( SfxPrinter* pPrinter );
93 Size aUserSize;
94 MapMode aUserMapMode;
95 Paper ePaper;
96 Orientation eOrientation;
97 USHORT nPaperBin;
100 struct ScPrintState // Variablen aus ScPrintFunc retten
102 SCTAB nPrintTab;
103 SCCOL nStartCol;
104 SCROW nStartRow;
105 SCCOL nEndCol;
106 SCROW nEndRow;
107 USHORT nZoom;
108 size_t nPagesX;
109 size_t nPagesY;
110 long nTabPages;
111 long nTotalPages;
112 long nPageStart;
113 long nDocPages;
116 class ScPageRowEntry
118 private:
119 SCROW nStartRow;
120 SCROW nEndRow;
121 size_t nPagesX;
122 BOOL* pHidden;
123 //! Anzahl wirklich sichtbarer cachen???
125 public:
126 ScPageRowEntry() { nStartRow = nEndRow = 0; nPagesX = 0; pHidden = NULL; }
127 ~ScPageRowEntry() { delete[] pHidden; }
129 ScPageRowEntry(const ScPageRowEntry& r);
130 const ScPageRowEntry& operator=(const ScPageRowEntry& r);
132 SCROW GetStartRow() const { return nStartRow; }
133 SCROW GetEndRow() const { return nEndRow; }
134 size_t GetPagesX() const { return nPagesX; }
135 void SetStartRow(SCROW n) { nStartRow = n; }
136 void SetEndRow(SCROW n) { nEndRow = n; }
138 void SetPagesX(size_t nNew);
139 void SetHidden(size_t nX);
140 BOOL IsHidden(size_t nX) const;
142 size_t CountVisible() const;
145 class ScPrintFunc
147 private:
148 ScDocShell* pDocShell;
149 ScDocument* pDoc;
150 SfxPrinter* pPrinter;
151 OutputDevice* pDev;
152 FmFormView* pDrawView;
154 MapMode aOldPrinterMode; // MapMode vor dem Aufruf
156 Point aSrcOffset; // Papier-1/100 mm
157 Point aOffset; // mit Faktor aus Seitenformat skaliert
158 USHORT nManualZoom; // Zoom in Preview (Prozent)
159 BOOL bClearWin; // Ausgabe vorher loeschen
160 BOOL bUseStyleColor;
161 BOOL bIsRender;
163 SCTAB nPrintTab;
164 long nPageStart; // Offset fuer erste Seite
165 long nDocPages; // Seiten im Dokument
167 const ScRange* pUserArea; // Selektion, wenn im Dialog eingestellt
169 const SfxItemSet* pParamSet; // eingestellte Vorlage
170 BOOL bState; // aus State-struct erzeugt
172 // Parameter aus Vorlage:
173 USHORT nLeftMargin;
174 USHORT nTopMargin;
175 USHORT nRightMargin;
176 USHORT nBottomMargin;
177 BOOL bCenterHor;
178 BOOL bCenterVer;
179 BOOL bLandscape;
180 BOOL bSourceRangeValid;
182 USHORT nPageUsage;
183 Size aPageSize; // Drucker-Twips
184 const SvxBoxItem* pBorderItem;
185 const SvxBrushItem* pBackgroundItem;
186 const SvxShadowItem* pShadowItem;
188 ScRange aLastSourceRange;
189 ScPrintHFParam aHdr;
190 ScPrintHFParam aFtr;
191 ScPageTableParam aTableParam;
192 ScPageAreaParam aAreaParam;
194 // berechnete Werte:
195 USHORT nZoom;
196 BOOL bPrintCurrentTable;
197 BOOL bMultiArea;
198 long nTabPages;
199 long nTotalPages;
201 Rectangle aPageRect; // Dokument-Twips
203 MapMode aLogicMode; // in DoPrint gesetzt
204 MapMode aOffsetMode;
205 MapMode aTwipMode;
206 double nScaleX;
207 double nScaleY;
209 SCCOL nRepeatStartCol;
210 SCCOL nRepeatEndCol;
211 SCROW nRepeatStartRow;
212 SCROW nRepeatEndRow;
214 SCCOL nStartCol;
215 SCROW nStartRow;
216 SCCOL nEndCol;
217 SCROW nEndRow;
219 SCCOL* pPageEndX; // Seitenaufteilung
220 SCROW* pPageEndY;
221 ScPageRowEntry* pPageRows;
222 size_t nPagesX;
223 size_t nPagesY;
224 size_t nTotalY;
226 ScHeaderEditEngine* pEditEngine;
227 SfxItemSet* pEditDefaults;
229 ScHeaderFieldData aFieldData;
231 List aNotePosList; // Reihenfolge der Notizen
233 ScPageBreakData* pPageData; // zum Eintragen der Umbrueche etc.
235 public:
236 ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
237 long nPage = 0, long nDocP = 0,
238 const ScRange* pArea = NULL,
239 const ScPrintOptions* pOptions = NULL,
240 ScPageBreakData* pData = NULL );
242 // ctors for device other than printer - for preview and pdf:
244 ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
245 long nPage = 0, long nDocP = 0,
246 const ScRange* pArea = NULL,
247 const ScPrintOptions* pOptions = NULL );
249 ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
250 const ScPrintState& rState,
251 const ScPrintOptions* pOptions );
253 ScPrintFunc( ScDocShell* pShell, Window* pWindow, SCTAB nTab,
254 long nPage = 0, long nDocP = 0,
255 const ScRange* pArea = NULL,
256 const ScPrintOptions* pOptions = NULL );
258 ScPrintFunc( ScDocShell* pShell, Window* pWindow,
259 const ScPrintState& rState,
260 const ScPrintOptions* pOptions );
261 ~ScPrintFunc();
263 static void DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor,
264 const Rectangle& rBound, ScViewData* pViewData, BOOL bMetaFile );
266 void SetDrawView( FmFormView* pNew );
268 void SetOffset( const Point& rOfs );
269 void SetManualZoom( USHORT nNewZoom );
270 void SetDateTime( const Date& rDate, const Time& rTime );
272 void SetClearFlag( BOOL bFlag );
273 void SetUseStyleColor( BOOL bFlag );
274 void SetRenderFlag( BOOL bFlag );
276 void SetExclusivelyDrawOleAndDrawObjects();//for printing selected objects without surrounding cell contents
278 BOOL UpdatePages();
280 void ApplyPrintSettings(); // aus DoPrint() schon gerufen
281 long DoPrint( const MultiSelection& rPageRanges,
282 /*long nStartPage, long nDisplayStart, BOOL bDoPrint,
283 SfxProgress* pProgress, ScPreviewLocationData* pLocationData );*/
284 long nStartPage, long nDisplayStart, BOOL bDoPrint = TRUE,
285 SfxProgress* pProgress = NULL, ScPreviewLocationData* pLocationData = NULL);
287 // Werte abfragen - sofort
289 Size GetPageSize() const { return aPageSize; }
290 Size GetDataSize() const;
291 void GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr );
292 long GetFirstPageNo() const { return aTableParam.nFirstPageNo; }
294 // letzte Werte abfragen - nach DoPrint !!!
296 double GetScaleX() const { return nScaleX; }
297 double GetScaleY() const { return nScaleY; }
298 long GetTotalPages() const { return nTotalPages; }
299 USHORT GetZoom() const { return nZoom; }
301 void ResetBreaks( SCTAB nTab );
303 void GetPrintState( ScPrintState& rState );
304 BOOL GetLastSourceRange( ScRange& rRange ) const;
305 USHORT GetLeftMargin() const{return nLeftMargin;}
306 USHORT GetRightMargin() const{return nRightMargin;}
307 USHORT GetTopMargin() const{return nTopMargin;}
308 USHORT GetBottomMargin() const{return nBottomMargin;}
309 void SetLeftMargin(USHORT nRulerLeftDistance){ nLeftMargin = nRulerLeftDistance; }
310 void SetRightMargin(USHORT nRulerRightDistance){ nRightMargin = nRulerRightDistance; }
311 void SetTopMargin(USHORT nRulerTopDistance){ nTopMargin = nRulerTopDistance; }
312 void SetBottomMargin(USHORT nRulerBottomDistance){ nBottomMargin = nRulerBottomDistance; }
313 ScPrintHFParam GetHeader(){return aHdr;}
314 ScPrintHFParam GetFooter(){return aFtr;}
316 private:
317 void Construct( const ScPrintOptions* pOptions );
318 void InitParam( const ScPrintOptions* pOptions );
319 void CalcZoom( USHORT nRangeNo );
320 void CalcPages();
321 long CountPages();
322 long CountNotePages();
324 BOOL AdjustPrintArea( BOOL bNew );
326 Size GetDocPageSize();
328 long TextHeight( const EditTextObject* pObject );
329 void MakeEditEngine();
330 void UpdateHFHeight( ScPrintHFParam& rParam );
332 void InitModes();
334 BOOL IsLeft( long nPageNo );
335 BOOL IsMirror( long nPageNo );
336 void ReplaceFields( long nPageNo ); // aendert Text in pEditEngine
337 void MakeTableString(); // setzt aTableStr
339 void PrintPage( long nPageNo,
340 SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
341 BOOL bDoPrint, ScPreviewLocationData* pLocationData );
342 void PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
343 long nScrX, long nScrY,
344 BOOL bShLeft, BOOL bShTop, BOOL bShRight, BOOL bShBottom );
345 void LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
346 long nScrX, long nScrY, BOOL bRepCol, BOOL bRepRow,
347 ScPreviewLocationData& rLocationData );
348 void PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY );
349 void PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY );
350 void LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
351 BOOL bRepCol, ScPreviewLocationData& rLocationData );
352 void LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
353 BOOL bRepRow, ScPreviewLocationData& rLocationData );
354 void PrintHF( long nPageNo, BOOL bHeader, long nStartY,
355 BOOL bDoPrint, ScPreviewLocationData* pLocationData );
357 long PrintNotes( long nPageNo, long nNoteStart, BOOL bDoPrint, ScPreviewLocationData* pLocationData );
358 long DoNotes( long nNoteStart, BOOL bDoPrint, ScPreviewLocationData* pLocationData );
360 void DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
361 const SvxBoxItem* pBorderData,
362 const SvxBrushItem* pBackground,
363 const SvxShadowItem* pShadow );
365 void FillPageData();
370 #endif