1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: printfun.hxx,v $
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>
51 class ScHeaderEditEngine
;
52 class ScPageBreakData
;
53 class ScPreviewLocationData
;
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
73 long nHeight
; // insgesamt (Hoehe+Abstand+Rahmen)
74 long nManHeight
; // eingestellte Groesse (Min. bei dynamisch)
76 USHORT nLeft
; // Raender
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:
91 ScJobSetup( SfxPrinter
* pPrinter
);
96 Orientation eOrientation
;
100 struct ScPrintState
// Variablen aus ScPrintFunc retten
123 //! Anzahl wirklich sichtbarer cachen???
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;
148 ScDocShell
* pDocShell
;
150 SfxPrinter
* pPrinter
;
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
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:
176 USHORT nBottomMargin
;
180 BOOL bSourceRangeValid
;
183 Size aPageSize
; // Drucker-Twips
184 const SvxBoxItem
* pBorderItem
;
185 const SvxBrushItem
* pBackgroundItem
;
186 const SvxShadowItem
* pShadowItem
;
188 ScRange aLastSourceRange
;
191 ScPageTableParam aTableParam
;
192 ScPageAreaParam aAreaParam
;
196 BOOL bPrintCurrentTable
;
201 Rectangle aPageRect
; // Dokument-Twips
203 MapMode aLogicMode
; // in DoPrint gesetzt
209 SCCOL nRepeatStartCol
;
211 SCROW nRepeatStartRow
;
219 SCCOL
* pPageEndX
; // Seitenaufteilung
221 ScPageRowEntry
* pPageRows
;
226 ScHeaderEditEngine
* pEditEngine
;
227 SfxItemSet
* pEditDefaults
;
229 ScHeaderFieldData aFieldData
;
231 List aNotePosList
; // Reihenfolge der Notizen
233 ScPageBreakData
* pPageData
; // zum Eintragen der Umbrueche etc.
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
);
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
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
;}
317 void Construct( const ScPrintOptions
* pOptions
);
318 void InitParam( const ScPrintOptions
* pOptions
);
319 void CalcZoom( USHORT nRangeNo
);
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
);
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
);