update emoji autocorrect entries from po-files
[LibreOffice.git] / sw / inc / printdata.hxx
blob5f7b7cb0a9c044d873c16f321e5c90f75b1a6903
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 INCLUDED_SW_INC_PRINTDATA_HXX
20 #define INCLUDED_SW_INC_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 _SetGetExpFields;
37 class SwViewOption;
38 class OutputDevice;
39 class SwViewOptionAdjust_Impl;
40 class SwViewShell;
41 class SfxViewShell;
43 // forward declarations
44 class SwPrintUIOptions;
45 class SwRenderData;
47 class SwPrintData
49 const SwPrintUIOptions * m_pPrintUIOptions; // not owner
50 const SwRenderData * m_pRenderData; // not owner
52 public:
54 bool bPrintGraphic, bPrintTable, bPrintDraw, bPrintControl, bPrintPageBackground,
55 bPrintBlackFont,
56 //#i81434# - printing of hidden text
57 bPrintHiddenText, bPrintTextPlaceholder,
58 bPrintLeftPages, bPrintRightPages, bPrintReverse, bPrintProspect,
59 bPrintProspectRTL,
60 bPrintSingleJobs, bPaperFromSetup,
61 /// Print empty pages
62 bPrintEmptyPages,
64 /// #i56195# no field update while printing mail merge documents
65 bUpdateFieldsInPrinting,
66 bModified;
68 sal_Int16 nPrintPostIts;
69 OUString sFaxName;
71 SwPrintData()
73 m_pPrintUIOptions = NULL;
74 m_pRenderData = NULL;
76 bPrintGraphic =
77 bPrintTable =
78 bPrintDraw =
79 bPrintControl =
80 bPrintLeftPages =
81 bPrintRightPages =
82 bPrintPageBackground =
83 bPrintEmptyPages =
84 bUpdateFieldsInPrinting = true;
86 bPaperFromSetup =
87 bPrintReverse =
88 bPrintProspect =
89 bPrintProspectRTL =
90 bPrintSingleJobs =
91 bModified =
92 bPrintBlackFont =
93 bPrintHiddenText =
94 bPrintTextPlaceholder = false;
96 nPrintPostIts = 0;
99 virtual ~SwPrintData() {}
101 bool operator==(const SwPrintData& rData)const
103 return
104 bPrintGraphic == rData.bPrintGraphic &&
105 bPrintTable == rData.bPrintTable &&
106 bPrintDraw == rData.bPrintDraw &&
107 bPrintControl == rData.bPrintControl &&
108 bPrintPageBackground== rData.bPrintPageBackground &&
109 bPrintBlackFont == rData.bPrintBlackFont &&
110 bPrintLeftPages == rData.bPrintLeftPages &&
111 bPrintRightPages == rData.bPrintRightPages &&
112 bPrintReverse == rData.bPrintReverse &&
113 bPrintProspect == rData.bPrintProspect &&
114 bPrintProspectRTL == rData.bPrintProspectRTL &&
115 bPrintSingleJobs == rData.bPrintSingleJobs &&
116 bPaperFromSetup == rData.bPaperFromSetup &&
117 bPrintEmptyPages == rData.bPrintEmptyPages &&
118 bUpdateFieldsInPrinting == rData.bUpdateFieldsInPrinting &&
119 nPrintPostIts == rData.nPrintPostIts &&
120 sFaxName == rData.sFaxName &&
121 bPrintHiddenText == rData.bPrintHiddenText &&
122 bPrintTextPlaceholder == rData.bPrintTextPlaceholder;
125 /** Note: in the context where this class is used the pointers should always be valid
126 during the lifetime of this object */
127 const SwPrintUIOptions & GetPrintUIOptions() const { return *m_pPrintUIOptions; }
128 const SwRenderData & GetRenderData() const { return *m_pRenderData; }
129 void SetPrintUIOptions( const SwPrintUIOptions *pOpt ) { m_pPrintUIOptions = pOpt; }
130 void SetRenderData( const SwRenderData *pData ) { m_pRenderData = pData; }
132 bool IsPrintGraphic() const { return bPrintGraphic; }
133 bool IsPrintTable() const { return bPrintTable; }
134 bool IsPrintDraw() const { return bPrintDraw; }
135 bool IsPrintControl() const { return bPrintControl; }
136 bool IsPrintLeftPage() const { return bPrintLeftPages; }
137 bool IsPrintRightPage() const { return bPrintRightPages; }
138 bool IsPrintReverse() const { return bPrintReverse; }
139 bool IsPaperFromSetup() const { return bPaperFromSetup; }
140 bool IsPrintEmptyPages() const { return bPrintEmptyPages; }
141 bool IsPrintProspect() const { return bPrintProspect; }
142 bool IsPrintProspectRTL() const { return bPrintProspectRTL; }
143 bool IsPrintPageBackground() const { return bPrintPageBackground; }
144 bool IsPrintBlackFont() const { return bPrintBlackFont; }
145 bool IsPrintSingleJobs() const { return bPrintSingleJobs; }
146 sal_Int16 GetPrintPostIts() const { return nPrintPostIts; }
147 const OUString GetFaxName() const { return sFaxName; }
148 bool IsPrintHiddenText() const { return bPrintHiddenText; }
149 bool IsPrintTextPlaceholder() const { return bPrintTextPlaceholder; }
151 void SetPrintGraphic( bool b ) { doSetModified(); bPrintGraphic = b; }
152 void SetPrintTable( bool b ) { doSetModified(); bPrintTable = b; }
153 void SetPrintDraw( bool b ) { doSetModified(); bPrintDraw = b; }
154 void SetPrintControl( bool b ) { doSetModified(); bPrintControl = b; }
155 void SetPrintLeftPage( bool b ) { doSetModified(); bPrintLeftPages = b; }
156 void SetPrintRightPage( bool b ) { doSetModified(); bPrintRightPages = b; }
157 void SetPrintReverse( bool b ) { doSetModified(); bPrintReverse = b; }
158 void SetPaperFromSetup( bool b ) { doSetModified(); bPaperFromSetup = b; }
159 void SetPrintEmptyPages( bool b ) { doSetModified(); bPrintEmptyPages = b; }
160 void SetPrintPostIts( sal_Int16 n ) { doSetModified(); nPrintPostIts = n; }
161 void SetPrintProspect( bool b ) { doSetModified(); bPrintProspect = b; }
162 void SetPrintProspect_RTL( bool b ) { doSetModified(); bPrintProspectRTL = b; }
163 void SetPrintPageBackground( bool b ) { doSetModified(); bPrintPageBackground = b; }
164 void SetPrintBlackFont( bool b ) { doSetModified(); bPrintBlackFont = b; }
165 void SetPrintSingleJobs( bool b ) { doSetModified(); bPrintSingleJobs = b; }
166 void SetFaxName( const OUString& rSet ) { sFaxName = rSet; }
167 void SetPrintHiddenText( bool b ) { doSetModified(); bPrintHiddenText = b; }
168 void SetPrintTextPlaceholder( bool b ) { doSetModified(); bPrintTextPlaceholder = b; }
170 virtual void doSetModified () { bModified = true;}
173 class SwPrintUIOptions : public vcl::PrinterOptionsHelper
175 VclPtr< OutputDevice > m_pLast;
176 const SwPrintData & m_rDefaultPrintData;
178 public:
179 SwPrintUIOptions( sal_uInt16 nCurrentPage, bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts, const SwPrintData &rDefaultPrintData );
180 virtual ~SwPrintUIOptions();
182 bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp );
184 bool IsPrintFormControls() const { return getBoolValue( "PrintControls", m_rDefaultPrintData.bPrintControl ); }
185 bool IsPrintPageBackground() const { return getBoolValue( "PrintPageBackground", m_rDefaultPrintData.bPrintPageBackground ); }
186 bool IsPrintProspect() const { return getBoolValue( "PrintProspect", m_rDefaultPrintData.bPrintProspect ); }
187 bool IsPrintProspectRTL() const { return getIntValue( "PrintProspectRTL", m_rDefaultPrintData.bPrintProspectRTL ? 1 : 0 ) != 0; }
188 bool IsPrintTextPlaceholders() const { return getBoolValue( "PrintTextPlaceholder", m_rDefaultPrintData.bPrintTextPlaceholder ); }
189 bool IsPrintHiddenText() const { return getBoolValue( "PrintHiddenText", m_rDefaultPrintData.bPrintHiddenText ); }
190 bool IsPrintWithBlackTextColor() const { return getBoolValue( "PrintBlackFonts", m_rDefaultPrintData.bPrintBlackFont ); }
191 sal_Int16 GetPrintPostItsType() const { return static_cast< sal_Int16 >(getIntValue( "PrintAnnotationMode", m_rDefaultPrintData.nPrintPostIts )); }
192 bool IsPaperFromSetup() const { return getBoolValue( "PrintPaperFromSetup", m_rDefaultPrintData.bPaperFromSetup ); }
194 bool IsPrintLeftPages() const;
195 bool IsPrintRightPages() const;
196 bool IsPrintEmptyPages( bool bIsPDFExport ) const;
197 bool IsPrintGraphics() const;
198 bool IsPrintDrawings() const;
201 /** A class that stores temporary data that is needed for rendering the document.
202 Usually this data is created when 'getRendererCount' is called and
203 and it is used in the 'render' function of that same interface */
204 class SwRenderData
206 /** pages valid for printing (according to the current settings)
207 This set of pages does NOT depend on the 'PageRange' that is used as a printing option! */
208 std::set< sal_Int32 > m_aValidPages; ///< the set of possible pages (see StringRangeEnumerator::getRangesFromString )
210 /// printer paper tray to use for each of the m_aValidPages above
211 std::map< sal_Int32, sal_Int32 > m_aPrinterPaperTrays;
213 /** vector of pages and their order to be printed (duplicates and any order allowed!)
214 (see 'render' in unotxdoc.cxx)
215 negative entry indicates the page to be printed is from the post-it doc */
216 std::vector< sal_Int32 > m_aPagesToPrint;
218 /** for prospect printing: the pairs of pages to be printed together on a single prospect page.
219 -1 indicates a half page to be left empty. */
220 std::vector< std::pair< sal_Int32, sal_Int32 > > m_aPagePairs;
222 OUString m_aPageRange;
224 /** temp print document -- must live longer than m_pViewOptionAdjust!
225 also this is a Lock and not a Ref because Ref does not delete the doc */
226 SfxObjectShellLock m_xTempDocShell;
228 /// the view options to be applied for printing
229 ::boost::scoped_ptr<SwViewOptionAdjust_Impl> m_pViewOptionAdjust;
231 ::boost::scoped_ptr<SwPrintData> m_pPrtOptions;
233 public:
235 // PostIt relevant data
236 /// an array of "_SetGetExpField *" sorted by page and line numbers
237 ::boost::scoped_ptr<_SetGetExpFields> m_pPostItFields;
238 /// this contains a SwDoc with the post-it content
239 ::boost::scoped_ptr<SwViewShell> m_pPostItShell;
241 public:
242 SwRenderData();
243 ~SwRenderData();
245 bool HasPostItData() const { return m_pPostItShell != 0; }
246 void CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev );
247 void DeletePostItData();
249 SfxObjectShellLock const& GetTempDocShell() const { return m_xTempDocShell;}
250 void SetTempDocShell(SfxObjectShellLock const&);
252 bool IsViewOptionAdjust() const { return m_pViewOptionAdjust != 0; }
253 bool NeedNewViewOptionAdjust( const SwViewShell& ) const;
254 void ViewOptionAdjustStart( SwViewShell &rSh, const SwViewOption &rViewOptions);
255 void ViewOptionAdjust( SwPrintData const* const pPrtOptions );
256 void ViewOptionAdjustStop();
257 void ViewOptionAdjustCrashPreventionKludge();
259 bool HasSwPrtOptions() const { return m_pPrtOptions != 0; }
260 SwPrintData const* GetSwPrtOptions() const { return m_pPrtOptions.get(); }
261 void MakeSwPrtOptions( SwDocShell const*const pDocShell,
262 SwPrintUIOptions const*const pOpt, bool const bIsPDFExport );
264 typedef std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t;
266 std::set< sal_Int32 > & GetValidPagesSet() { return m_aValidPages; }
267 const std::set< sal_Int32 > & GetValidPagesSet() const { return m_aValidPages; }
269 /** a map for printer paper tray numbers to use for each document page
270 a value of -1 for the tray means that there is no specific tray defined */
271 std::map< sal_Int32, sal_Int32 >& GetPrinterPaperTrays() { return m_aPrinterPaperTrays; }
272 const std::map< sal_Int32, sal_Int32 >& GetPrinterPaperTrays() const { return m_aPrinterPaperTrays; }
274 /** used for 'normal' printing
275 A page value of 0 as entry indicates that this page is not from the document but
276 from the post-it document. (See also GetPostItStartFrame below) */
277 std::vector< sal_Int32 > & GetPagesToPrint() { return m_aPagesToPrint; }
278 const std::vector< sal_Int32 > & GetPagesToPrint() const { return m_aPagesToPrint; }
280 /// used for prospect printing only
281 PagePairsVec_t & GetPagePairsForProspectPrinting() { return m_aPagePairs; }
282 const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return m_aPagePairs; }
284 OUString GetPageRange() const { return m_aPageRange; }
285 void SetPageRange( const OUString &rRange ) { m_aPageRange = rRange; }
288 /// last remnants of swprtopt.hxx:
289 #define POSTITS_NONE 0
290 #define POSTITS_ONLY 1
291 #define POSTITS_ENDDOC 2
292 #define POSTITS_ENDPAGE 3
293 #define POSTITS_INMARGINS 4
295 namespace sw {
297 void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb);
299 } ///< namespace sw
301 #endif // INCLUDED_SW_INC_PRINTDATA_HXX
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */