1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
36 class ScHeaderEditEngine
;
37 class ScPageBreakData
;
38 class ScPreviewLocationData
;
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
56 long nHeight
; // in total (height + distance + frames)
57 long nManHeight
; // set size (min when dynamic)
59 sal_uInt16 nLeft
; // edges
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
106 //! Cache Number of really visible?
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;
131 ScDocShell
* pDocShell
;
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
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
;
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
;
174 ScPageTableParam aTableParam
;
175 ScPageAreaParam aAreaParam
;
177 // Calculated values:
179 bool bPrintCurrentTable
;
181 bool mbHasPrintRange
;
185 Rectangle aPageRect
; // Document Twips
187 MapMode aLogicMode
; // Set in DoPrint
193 SCCOL nRepeatStartCol
;
195 SCROW nRepeatStartRow
;
203 std::vector
< SCCOL
> maPageEndX
;
204 std::vector
< SCROW
> maPageEndY
;
205 std::vector
< ScPageRowEntry
> maPageRows
;
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.
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
);
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
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
;}
294 void Construct( const ScPrintOptions
* pOptions
);
295 void InitParam( const ScPrintOptions
* pOptions
);
296 void CalcZoom( sal_uInt16 nRangeNo
);
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
);
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
);
347 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */