update credits
[LibreOffice.git] / sw / inc / printdata.hxx
blobe92c164c7bf789d87d2515d74084f59a0219a9fd
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 .
19 #ifndef SW_PRINTDATA_HXX
20 #define SW_PRINTDATA_HXX
22 #include <sal/types.h>
23 #include <rtl/ustring.hxx>
24 #include <vcl/print.hxx>
25 #include <sfx2/objsh.hxx>
27 #include <boost/scoped_ptr.hpp>
29 #include <set>
30 #include <map>
31 #include <vector>
32 #include <utility>
34 class SwDoc;
35 class SwDocShell;
36 class _SetGetExpFlds;
37 class SwViewOption;
38 class OutputDevice;
39 class SwViewOptionAdjust_Impl;
40 class ViewShell;
41 class SfxViewShell;
43 // forward declarations
44 class SwPrintUIOptions;
45 class SwRenderData;
47 ////////////////////////////////////////////////////////////
50 class SwPrintData
52 const SwPrintUIOptions * m_pPrintUIOptions; // not owner
53 const SwRenderData * m_pRenderData; // not owner
55 public:
57 sal_Bool bPrintGraphic, bPrintTable, bPrintDraw, bPrintControl, bPrintPageBackground,
58 bPrintBlackFont,
59 //#i81434# - printing of hidden text
60 bPrintHiddenText, bPrintTextPlaceholder,
61 bPrintLeftPages, bPrintRightPages, bPrintReverse, bPrintProspect,
62 bPrintProspectRTL,
63 bPrintSingleJobs, bPaperFromSetup,
64 /// Print empty pages
65 bPrintEmptyPages,
67 /// #i56195# no field update while printing mail merge documents
68 bUpdateFieldsInPrinting,
69 bModified;
71 sal_Int16 nPrintPostIts;
72 OUString sFaxName;
74 SwPrintData()
76 m_pPrintUIOptions = NULL;
77 m_pRenderData = NULL;
79 bPrintGraphic =
80 bPrintTable =
81 bPrintDraw =
82 bPrintControl =
83 bPrintLeftPages =
84 bPrintRightPages =
85 bPrintPageBackground =
86 bPrintEmptyPages =
87 bUpdateFieldsInPrinting = sal_True;
89 bPaperFromSetup =
90 bPrintReverse =
91 bPrintProspect =
92 bPrintProspectRTL =
93 bPrintSingleJobs =
94 bModified =
95 bPrintBlackFont =
96 bPrintHiddenText =
97 bPrintTextPlaceholder = sal_False;
99 nPrintPostIts = 0;
102 virtual ~SwPrintData() {}
104 sal_Bool operator==(const SwPrintData& rData)const
106 return
107 bPrintGraphic == rData.bPrintGraphic &&
108 bPrintTable == rData.bPrintTable &&
109 bPrintDraw == rData.bPrintDraw &&
110 bPrintControl == rData.bPrintControl &&
111 bPrintPageBackground== rData.bPrintPageBackground &&
112 bPrintBlackFont == rData.bPrintBlackFont &&
113 bPrintLeftPages == rData.bPrintLeftPages &&
114 bPrintRightPages == rData.bPrintRightPages &&
115 bPrintReverse == rData.bPrintReverse &&
116 bPrintProspect == rData.bPrintProspect &&
117 bPrintProspectRTL == rData.bPrintProspectRTL &&
118 bPrintSingleJobs == rData.bPrintSingleJobs &&
119 bPaperFromSetup == rData.bPaperFromSetup &&
120 bPrintEmptyPages == rData.bPrintEmptyPages &&
121 bUpdateFieldsInPrinting == rData.bUpdateFieldsInPrinting &&
122 nPrintPostIts == rData.nPrintPostIts &&
123 sFaxName == rData.sFaxName &&
124 bPrintHiddenText == rData.bPrintHiddenText &&
125 bPrintTextPlaceholder == rData.bPrintTextPlaceholder;
128 /** Note: in the context where this class ist used the pointers should always be valid
129 during the lifetime of this object */
130 const SwPrintUIOptions & GetPrintUIOptions() const { return *m_pPrintUIOptions; }
131 const SwRenderData & GetRenderData() const { return *m_pRenderData; }
132 void SetPrintUIOptions( const SwPrintUIOptions *pOpt ) { m_pPrintUIOptions = pOpt; }
133 void SetRenderData( const SwRenderData *pData ) { m_pRenderData = pData; }
135 sal_Bool IsPrintGraphic() const { return bPrintGraphic; }
136 sal_Bool IsPrintTable() const { return bPrintTable; }
137 sal_Bool IsPrintDraw() const { return bPrintDraw; }
138 sal_Bool IsPrintControl() const { return bPrintControl; }
139 sal_Bool IsPrintLeftPage() const { return bPrintLeftPages; }
140 sal_Bool IsPrintRightPage() const { return bPrintRightPages; }
141 sal_Bool IsPrintReverse() const { return bPrintReverse; }
142 sal_Bool IsPaperFromSetup() const { return bPaperFromSetup; }
143 sal_Bool IsPrintEmptyPages() const { return bPrintEmptyPages; }
144 sal_Bool IsPrintProspect() const { return bPrintProspect; }
145 sal_Bool IsPrintProspectRTL() const { return bPrintProspectRTL; }
146 sal_Bool IsPrintPageBackground() const { return bPrintPageBackground; }
147 sal_Bool IsPrintBlackFont() const { return bPrintBlackFont; }
148 sal_Bool IsPrintSingleJobs() const { return bPrintSingleJobs; }
149 sal_Int16 GetPrintPostIts() const { return nPrintPostIts; }
150 const OUString GetFaxName() const { return sFaxName; }
151 sal_Bool IsPrintHiddenText() const { return bPrintHiddenText; }
152 sal_Bool IsPrintTextPlaceholder() const { return bPrintTextPlaceholder; }
154 void SetPrintGraphic( sal_Bool b ) { doSetModified(); bPrintGraphic = b; }
155 void SetPrintTable( sal_Bool b ) { doSetModified(); bPrintTable = b; }
156 void SetPrintDraw( sal_Bool b ) { doSetModified(); bPrintDraw = b; }
157 void SetPrintControl( sal_Bool b ) { doSetModified(); bPrintControl = b; }
158 void SetPrintLeftPage( sal_Bool b ) { doSetModified(); bPrintLeftPages = b; }
159 void SetPrintRightPage( sal_Bool b ) { doSetModified(); bPrintRightPages = b; }
160 void SetPrintReverse( sal_Bool b ) { doSetModified(); bPrintReverse = b; }
161 void SetPaperFromSetup( sal_Bool b ) { doSetModified(); bPaperFromSetup = b; }
162 void SetPrintEmptyPages( sal_Bool b ) { doSetModified(); bPrintEmptyPages = b; }
163 void SetPrintPostIts( sal_Int16 n ) { doSetModified(); nPrintPostIts = n; }
164 void SetPrintProspect( sal_Bool b ) { doSetModified(); bPrintProspect = b; }
165 void SetPrintProspect_RTL( sal_Bool b ) { doSetModified(); bPrintProspectRTL = b; }
166 void SetPrintPageBackground( sal_Bool b ) { doSetModified(); bPrintPageBackground = b; }
167 void SetPrintBlackFont( sal_Bool b ) { doSetModified(); bPrintBlackFont = b; }
168 void SetPrintSingleJobs( sal_Bool b ) { doSetModified(); bPrintSingleJobs = b; }
169 void SetFaxName( const OUString& rSet ) { sFaxName = rSet; }
170 void SetPrintHiddenText( sal_Bool b ) { doSetModified(); bPrintHiddenText = b; }
171 void SetPrintTextPlaceholder( sal_Bool b ) { doSetModified(); bPrintTextPlaceholder = b; }
173 virtual void doSetModified () { bModified = sal_True;}
177 ////////////////////////////////////////////////////////////
180 class SwPrintUIOptions : public vcl::PrinterOptionsHelper
182 OutputDevice* m_pLast;
183 const SwPrintData & m_rDefaultPrintData;
185 public:
186 SwPrintUIOptions( sal_uInt16 nCurrentPage, bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts, const SwPrintData &rDefaultPrintData );
187 virtual ~SwPrintUIOptions();
189 bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp );
191 bool IsPrintFormControls() const { return getBoolValue( "PrintControls", m_rDefaultPrintData.bPrintControl ); }
192 bool IsPrintPageBackground() const { return getBoolValue( "PrintPageBackground", m_rDefaultPrintData.bPrintPageBackground ); }
193 bool IsPrintProspect() const { return getBoolValue( "PrintProspect", m_rDefaultPrintData.bPrintProspect ); }
194 bool IsPrintProspectRTL() const { return getIntValue( "PrintProspectRTL", m_rDefaultPrintData.bPrintProspectRTL ) ? true : false; }
195 bool IsPrintTextPlaceholders() const { return getBoolValue( "PrintTextPlaceholder", m_rDefaultPrintData.bPrintTextPlaceholder ); }
196 bool IsPrintHiddenText() const { return getBoolValue( "PrintHiddenText", m_rDefaultPrintData.bPrintHiddenText ); }
197 bool IsPrintWithBlackTextColor() const { return getBoolValue( "PrintBlackFonts", m_rDefaultPrintData.bPrintBlackFont ); }
198 sal_Int16 GetPrintPostItsType() const { return static_cast< sal_Int16 >(getIntValue( "PrintAnnotationMode", m_rDefaultPrintData.nPrintPostIts )); }
199 bool IsPaperFromSetup() const { return getBoolValue( "PrintPaperFromSetup", m_rDefaultPrintData.bPaperFromSetup ); }
200 bool IsPrintReverse() const { return false; /*handled by print dialog now*/ }
202 bool IsPrintLeftPages() const;
203 bool IsPrintRightPages() const;
204 bool IsPrintEmptyPages( bool bIsPDFExport ) const;
205 bool IsPrintTables() const;
206 bool IsPrintGraphics() const;
207 bool IsPrintDrawings() const;
211 ////////////////////////////////////////////////////////////
213 /** A class that stores temporary data that is needed for rendering the document.
214 Usually this data is created when 'getRendererCount' is called and
215 and it is used in the 'render' function of that same interface */
216 class SwRenderData
218 /** pages valid for printing (according to the current settings)
219 This set of pages does NOT depend on the 'PageRange' that is used as a printing option! */
220 std::set< sal_Int32 > m_aValidPages; ///< the set of possible pages (see StringRangeEnumerator::getRangesFromString )
222 /// printer paper tray to use for each of the m_aValidPages above
223 std::map< sal_Int32, sal_Int32 > m_aPrinterPaperTrays;
225 /** vector of pages and their order to be printed (duplicates and any order allowed!)
226 (see 'render' in unotxdoc.cxx)
227 negative entry indicates the page to be printed is from the post-it doc */
228 std::vector< sal_Int32 > m_aPagesToPrint;
230 /** for prospect printing: the pairs of pages to be printed together on a single prospect page.
231 -1 indicates a half page to be left empty. */
232 std::vector< std::pair< sal_Int32, sal_Int32 > > m_aPagePairs;
234 OUString m_aPageRange;
236 /** temp print document -- must live longer than m_pViewOptionAdjust!
237 also this is a Lock and not a Ref because Ref does not delete the doc */
238 SfxObjectShellLock m_xTempDocShell;
240 /// the view options to be applied for printing
241 ::boost::scoped_ptr<SwViewOptionAdjust_Impl> m_pViewOptionAdjust;
243 ::boost::scoped_ptr<SwPrintData> m_pPrtOptions;
245 public:
247 // PostIt relevant data
248 /// an array of "_SetGetExpFld *" sorted by page and line numbers
249 ::boost::scoped_ptr<_SetGetExpFlds> m_pPostItFields;
250 /// this contains a SwDoc with the post-it content
251 ::boost::scoped_ptr<ViewShell> m_pPostItShell;
253 public:
254 SwRenderData();
255 ~SwRenderData();
258 bool HasPostItData() const { return m_pPostItShell != 0; }
259 void CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev );
260 void DeletePostItData();
262 SfxObjectShellLock const& GetTempDocShell() const;
263 void SetTempDocShell(SfxObjectShellLock const&);
265 bool IsViewOptionAdjust() const { return m_pViewOptionAdjust != 0; }
266 bool NeedNewViewOptionAdjust( const ViewShell& ) const;
267 void ViewOptionAdjustStart( ViewShell &rSh, const SwViewOption &rViewOptions);
268 void ViewOptionAdjust( SwPrintData const* const pPrtOptions );
269 void ViewOptionAdjustStop();
270 void ViewOptionAdjustCrashPreventionKludge();
272 bool HasSwPrtOptions() const { return m_pPrtOptions != 0; }
273 SwPrintData const* GetSwPrtOptions() const { return m_pPrtOptions.get(); }
274 void MakeSwPrtOptions( SwDocShell const*const pDocShell,
275 SwPrintUIOptions const*const pOpt, bool const bIsPDFExport );
278 typedef std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t;
280 std::set< sal_Int32 > & GetValidPagesSet() { return m_aValidPages; }
281 const std::set< sal_Int32 > & GetValidPagesSet() const { return m_aValidPages; }
283 /** a map for printer paper tray numbers to use for each document page
284 a value of -1 for the tray means that there is no specific tray defined */
285 std::map< sal_Int32, sal_Int32 >& GetPrinterPaperTrays() { return m_aPrinterPaperTrays; }
286 const std::map< sal_Int32, sal_Int32 >& GetPrinterPaperTrays() const { return m_aPrinterPaperTrays; }
288 /** used for 'normal' printing
289 A page value of 0 as entry indicates that this page is not from the document but
290 from the post-it document. (See also GetPostItStartFrame below) */
291 std::vector< sal_Int32 > & GetPagesToPrint() { return m_aPagesToPrint; }
292 const std::vector< sal_Int32 > & GetPagesToPrint() const { return m_aPagesToPrint; }
294 /// used for prospect printing only
295 PagePairsVec_t & GetPagePairsForProspectPrinting() { return m_aPagePairs; }
296 const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return m_aPagePairs; }
298 OUString GetPageRange() const { return m_aPageRange; }
299 void SetPageRange( const OUString &rRange ) { m_aPageRange = rRange; }
303 ////////////////////////////////////////////////////////////
305 /// last remnants of swprtopt.hxx:
306 #define POSTITS_NONE 0
307 #define POSTITS_ONLY 1
308 #define POSTITS_ENDDOC 2
309 #define POSTITS_ENDPAGE 3
311 namespace sw {
313 void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb);
315 } ///< namespace sw
317 #endif // SW_PRINTDATA_HXX
319 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */