LibreOffice Module sw (master)  1
printdata.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_SW_INC_PRINTDATA_HXX
20 #define INCLUDED_SW_INC_PRINTDATA_HXX
21 
22 #include <sal/types.h>
23 #include <rtl/ustring.hxx>
24 #include <vcl/print.hxx>
25 #include <sfx2/objsh.hxx>
26 
27 #include <set>
28 #include <map>
29 #include <vector>
30 #include <utility>
31 #include <memory>
32 
33 class SwDoc;
34 class SwDocShell;
35 class SetGetExpFields;
36 class SwViewOption;
38 class SwViewShell;
39 class SwRenderData;
40 
42 enum class SwPostItMode
43 {
44  NONE = 0,
45  Only = 1,
46  EndDoc = 2,
47  EndPage = 3,
48  InMargins = 4
49 };
50 
51 
53 {
54  const SwRenderData * m_pRenderData; // not owner
55 
56 public:
57 
60  //#i81434# - printing of hidden text
67 
69  OUString m_sFaxName;
70 
72  {
73  m_pRenderData = nullptr;
74 
75  m_bPrintGraphic =
76  m_bPrintTable =
77  m_bPrintDraw =
78  m_bPrintControl =
79  m_bPrintLeftPages =
80  m_bPrintRightPages =
81  m_bPrintPageBackground =
82  m_bPrintEmptyPages = true;
83 
84  m_bPaperFromSetup =
85  m_bPrintReverse =
86  m_bPrintProspect =
87  m_bPrintProspectRTL =
88  m_bPrintSingleJobs =
89  m_bPrintBlackFont =
90  m_bPrintHiddenText =
91  m_bPrintTextPlaceholder = false;
92 
93  m_nPrintPostIts = SwPostItMode::NONE;
94  }
95 
96  virtual ~SwPrintData() {}
97 
98  SwPrintData(SwPrintData const &) = default;
99  SwPrintData(SwPrintData &&) = default;
100  SwPrintData & operator =(SwPrintData const &) = default;
101  SwPrintData & operator =(SwPrintData &&) = default;
102 
103  bool operator==(const SwPrintData& rData)const
104  {
105  return
106  m_bPrintGraphic == rData.m_bPrintGraphic &&
107  m_bPrintTable == rData.m_bPrintTable &&
108  m_bPrintDraw == rData.m_bPrintDraw &&
109  m_bPrintControl == rData.m_bPrintControl &&
110  m_bPrintPageBackground== rData.m_bPrintPageBackground &&
111  m_bPrintBlackFont == rData.m_bPrintBlackFont &&
112  m_bPrintLeftPages == rData.m_bPrintLeftPages &&
113  m_bPrintRightPages == rData.m_bPrintRightPages &&
114  m_bPrintReverse == rData.m_bPrintReverse &&
115  m_bPrintProspect == rData.m_bPrintProspect &&
116  m_bPrintProspectRTL == rData.m_bPrintProspectRTL &&
117  m_bPrintSingleJobs == rData.m_bPrintSingleJobs &&
118  m_bPaperFromSetup == rData.m_bPaperFromSetup &&
119  m_bPrintEmptyPages == rData.m_bPrintEmptyPages &&
120  m_nPrintPostIts == rData.m_nPrintPostIts &&
121  m_sFaxName == rData.m_sFaxName &&
122  m_bPrintHiddenText == rData.m_bPrintHiddenText &&
123  m_bPrintTextPlaceholder == rData.m_bPrintTextPlaceholder;
124  }
125 
128  const SwRenderData & GetRenderData() const { return *m_pRenderData; }
129  void SetRenderData( const SwRenderData *pData ) { m_pRenderData = pData; }
130 
131  bool IsPrintGraphic() const { return m_bPrintGraphic; }
132  bool IsPrintTable() const { return m_bPrintTable; }
133  bool IsPrintDraw() const { return m_bPrintDraw; }
134  bool IsPrintControl() const { return m_bPrintControl; }
135  bool IsPrintLeftPage() const { return m_bPrintLeftPages; }
136  bool IsPrintRightPage() const { return m_bPrintRightPages; }
137  bool IsPrintReverse() const { return m_bPrintReverse; }
138  bool IsPaperFromSetup() const { return m_bPaperFromSetup; }
139  bool IsPrintEmptyPages() const { return m_bPrintEmptyPages; }
140  bool IsPrintProspect() const { return m_bPrintProspect; }
141  bool IsPrintProspectRTL() const { return m_bPrintProspectRTL; }
143  bool IsPrintBlackFont() const { return m_bPrintBlackFont; }
144  bool IsPrintSingleJobs() const { return m_bPrintSingleJobs; }
146  const OUString& GetFaxName() const { return m_sFaxName; }
147  bool IsPrintHiddenText() const { return m_bPrintHiddenText; }
149 
150  void SetPrintGraphic( bool b ) { doSetModified(); m_bPrintGraphic = b; }
151  void SetPrintTable( bool b ) { doSetModified(); m_bPrintTable = b; }
152  void SetPrintDraw( bool b ) { doSetModified(); m_bPrintDraw = b; }
153  void SetPrintControl( bool b ) { doSetModified(); m_bPrintControl = b; }
154  void SetPrintLeftPage( bool b ) { doSetModified(); m_bPrintLeftPages = b; }
155  void SetPrintRightPage( bool b ) { doSetModified(); m_bPrintRightPages = b; }
156  void SetPrintReverse( bool b ) { doSetModified(); m_bPrintReverse = b; }
157  void SetPaperFromSetup( bool b ) { doSetModified(); m_bPaperFromSetup = b; }
158  void SetPrintEmptyPages( bool b ) { doSetModified(); m_bPrintEmptyPages = b; }
159  void SetPrintPostIts( SwPostItMode n ) { doSetModified(); m_nPrintPostIts = n; }
160  void SetPrintProspect( bool b ) { doSetModified(); m_bPrintProspect = b; }
161  void SetPrintProspect_RTL( bool b ) { doSetModified(); m_bPrintProspectRTL = b; }
162  void SetPrintPageBackground( bool b ) { doSetModified(); m_bPrintPageBackground = b; }
163  void SetPrintBlackFont( bool b ) { doSetModified(); m_bPrintBlackFont = b; }
164  void SetPrintSingleJobs( bool b ) { doSetModified(); m_bPrintSingleJobs = b; }
165  void SetFaxName( const OUString& rSet ) { m_sFaxName = rSet; }
166  void SetPrintHiddenText( bool b ) { doSetModified(); m_bPrintHiddenText = b; }
167  void SetPrintTextPlaceholder( bool b ) { doSetModified(); m_bPrintTextPlaceholder = b; }
168 
169  virtual void doSetModified () {}
170 };
171 
173 {
176 
177 public:
178  SwPrintUIOptions( sal_uInt16 nCurrentPage, bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts, const SwPrintData &rDefaultPrintData );
179  virtual ~SwPrintUIOptions();
180 
181  bool processPropertiesAndCheckFormat( const css::uno::Sequence< css::beans::PropertyValue >& i_rNewProp );
182 
183  bool IsPrintFormControls() const { return getBoolValue( "PrintControls", m_rDefaultPrintData.m_bPrintControl ); }
184  bool IsPrintPageBackground() const { return getBoolValue( "PrintPageBackground", m_rDefaultPrintData.m_bPrintPageBackground ); }
185  bool IsPrintProspect() const { return getBoolValue( "PrintProspect", m_rDefaultPrintData.m_bPrintProspect ); }
186  bool IsPrintProspectRTL() const { return getIntValue( "PrintProspectRTL", m_rDefaultPrintData.m_bPrintProspectRTL ? 1 : 0 ) != 0; }
187  bool IsPrintTextPlaceholders() const { return getBoolValue( "PrintTextPlaceholder", m_rDefaultPrintData.m_bPrintTextPlaceholder ); }
188  bool IsPrintHiddenText() const { return getBoolValue( "PrintHiddenText", m_rDefaultPrintData.m_bPrintHiddenText ); }
189  bool IsPrintWithBlackTextColor() const { return getBoolValue( "PrintBlackFonts", m_rDefaultPrintData.m_bPrintBlackFont ); }
190  SwPostItMode GetPrintPostItsType() const { return static_cast< SwPostItMode >(getIntValue( "PrintAnnotationMode", static_cast<sal_uInt16>(m_rDefaultPrintData.m_nPrintPostIts) )); }
191  bool IsPaperFromSetup() const { return getBoolValue( "PrintPaperFromSetup", m_rDefaultPrintData.m_bPaperFromSetup ); }
192 
193  bool IsPrintLeftPages() const;
194  bool IsPrintRightPages() const;
195  bool IsPrintEmptyPages( bool bIsPDFExport ) const;
196  bool IsPrintGraphics() const;
197  bool IsPrintDrawings() const;
198 };
199 
204 {
207  std::set< sal_Int32 > m_aValidPages;
208 
210  std::map< sal_Int32, sal_Int32 > m_aPrinterPaperTrays;
211 
215  std::vector< sal_Int32 > m_aPagesToPrint;
216 
219  std::vector< std::pair< sal_Int32, sal_Int32 > > m_aPagePairs;
220 
221  OUString m_aPageRange;
222 
226 
228  std::unique_ptr<SwViewOptionAdjust_Impl> m_pViewOptionAdjust;
229 
230  std::unique_ptr<SwPrintData> m_pPrtOptions;
231 
232 public:
233 
234  // PostIt relevant data
236  std::unique_ptr<SetGetExpFields> m_pPostItFields;
238  std::unique_ptr<SwViewShell> m_pPostItShell;
239 
240 public:
241  SwRenderData();
242  ~SwRenderData();
243 
244  bool HasPostItData() const { return m_pPostItShell != nullptr; }
245  void CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev );
246  void DeletePostItData();
247 
249  void SetTempDocShell(SfxObjectShellLock const&);
250 
251  bool IsViewOptionAdjust() const { return m_pViewOptionAdjust != nullptr; }
252  bool NeedNewViewOptionAdjust( const SwViewShell& ) const;
253  void ViewOptionAdjustStart( SwViewShell &rSh, const SwViewOption &rViewOptions);
254  void ViewOptionAdjust( SwPrintData const* const pPrtOptions, bool setShowPlaceHoldersInPDF );
255  void ViewOptionAdjustStop();
257 
258  bool HasSwPrtOptions() const { return m_pPrtOptions != nullptr; }
259  SwPrintData const* GetSwPrtOptions() const { return m_pPrtOptions.get(); }
260  void MakeSwPrtOptions( SwDocShell const*const pDocShell,
261  SwPrintUIOptions const*const pOpt, bool const bIsPDFExport );
262 
263  typedef std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t;
264 
265  std::set< sal_Int32 > & GetValidPagesSet() { return m_aValidPages; }
266  const std::set< sal_Int32 > & GetValidPagesSet() const { return m_aValidPages; }
267 
270  std::map< sal_Int32, sal_Int32 >& GetPrinterPaperTrays() { return m_aPrinterPaperTrays; }
271  const std::map< sal_Int32, sal_Int32 >& GetPrinterPaperTrays() const { return m_aPrinterPaperTrays; }
272 
276  std::vector< sal_Int32 > & GetPagesToPrint() { return m_aPagesToPrint; }
277  const std::vector< sal_Int32 > & GetPagesToPrint() const { return m_aPagesToPrint; }
278 
280  PagePairsVec_t & GetPagePairsForProspectPrinting() { return m_aPagePairs; }
281  const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return m_aPagePairs; }
282 
283  const OUString& GetPageRange() const { return m_aPageRange; }
284  void SetPageRange( const OUString &rRange ) { m_aPageRange = rRange; }
285 };
286 
287 namespace sw {
288 
289 void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb);
290 
291 }
292 
293 #endif // INCLUDED_SW_INC_PRINTDATA_HXX
294 
295 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsPaperFromSetup() const
Definition: printdata.hxx:138
void SetPrintPostIts(SwPostItMode n)
Definition: printdata.hxx:159
std::unique_ptr< SwPrintData > m_pPrtOptions
Definition: printdata.hxx:230
bool getBoolValue(const OUString &i_rPropertyName, bool i_bDefault) const
PagePairsVec_t & GetPagePairsForProspectPrinting()
used for prospect printing only
Definition: printdata.hxx:280
SfxObjectShellLock const & GetTempDocShell() const
Definition: printdata.hxx:248
bool IsPaperFromSetup() const
Definition: printdata.hxx:191
std::vector< std::pair< sal_Int32, sal_Int32 > > m_aPagePairs
for prospect printing: the pairs of pages to be printed together on a single prospect page...
Definition: printdata.hxx:219
void SetPrintLeftPage(bool b)
Definition: printdata.hxx:154
void SetPrintRightPage(bool b)
Definition: printdata.hxx:155
void InitPrintOptionsFromApplication(SwPrintData &o_rData, bool const bWeb)
Definition: view.cxx:1871
SwPostItMode GetPrintPostIts() const
Definition: printdata.hxx:145
OUString m_sFaxName
Definition: printdata.hxx:69
virtual void doSetModified()
Definition: printdata.hxx:169
void SetPrintControl(bool b)
Definition: printdata.hxx:153
std::unique_ptr< SwViewShell > m_pPostItShell
this contains a SwDoc with the post-it content
Definition: printdata.hxx:238
void SetPrintTextPlaceholder(bool b)
Definition: printdata.hxx:167
std::set< sal_Int32 > & GetValidPagesSet()
Definition: printdata.hxx:265
Definition: doc.hxx:185
bool m_bPrintSingleJobs
Definition: printdata.hxx:58
void CreatePostItData(SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev)
Definition: printdata.cxx:49
bool IsPrintTable() const
Definition: printdata.hxx:132
std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t
Definition: printdata.hxx:263
void SetTempDocShell(SfxObjectShellLock const &)
Definition: printdata.cxx:79
bool m_bPrintRightPages
Definition: printdata.hxx:58
std::unique_ptr< SwViewOptionAdjust_Impl > m_pViewOptionAdjust
the view options to be applied for printing
Definition: printdata.hxx:228
Dialog to specify the properties of date form field.
bool m_bPrintReverse
Definition: printdata.hxx:58
bool IsPrintProspectRTL() const
Definition: printdata.hxx:141
void SetPrintGraphic(bool b)
Definition: printdata.hxx:150
bool IsPrintHiddenText() const
Definition: printdata.hxx:147
std::unique_ptr< SetGetExpFields > m_pPostItFields
an array of "SetGetExpField *" sorted by page and line numbers
Definition: printdata.hxx:236
bool IsPrintReverse() const
Definition: printdata.hxx:137
bool m_bPrintProspectRTL
Definition: printdata.hxx:58
A class that stores temporary data that is needed for rendering the document.
Definition: printdata.hxx:203
bool IsPrintProspect() const
Definition: printdata.hxx:185
bool m_bPrintGraphic
Definition: printdata.hxx:58
const OUString & GetFaxName() const
Definition: printdata.hxx:146
SwPrintData const * GetSwPrtOptions() const
Definition: printdata.hxx:259
bool processPropertiesAndCheckFormat(const css::uno::Sequence< css::beans::PropertyValue > &i_rNewProp)
Definition: printdata.cxx:436
bool m_bPrintProspect
Definition: printdata.hxx:58
void ViewOptionAdjustStart(SwViewShell &rSh, const SwViewOption &rViewOptions)
Definition: printdata.cxx:89
void SetPageRange(const OUString &rRange)
Definition: printdata.hxx:284
bool IsPrintGraphic() const
Definition: printdata.hxx:131
const std::map< sal_Int32, sal_Int32 > & GetPrinterPaperTrays() const
Definition: printdata.hxx:271
void SetPrintEmptyPages(bool b)
Definition: printdata.hxx:158
void SetFaxName(const OUString &rSet)
Definition: printdata.hxx:165
bool IsPrintPageBackground() const
Definition: printdata.hxx:142
std::map< sal_Int32, sal_Int32 > m_aPrinterPaperTrays
printer paper tray to use for each of the m_aValidPages above
Definition: printdata.hxx:210
bool IsPrintHiddenText() const
Definition: printdata.hxx:188
bool m_bPrintPageBackground
Definition: printdata.hxx:58
bool m_bPrintTextPlaceholder
Definition: printdata.hxx:58
const SwRenderData & GetRenderData() const
Note: in the context where this class is used the pointers should always be valid during the lifetime...
Definition: printdata.hxx:128
void SetPrintProspect_RTL(bool b)
Definition: printdata.hxx:161
void SetPrintBlackFont(bool b)
Definition: printdata.hxx:163
bool IsPrintRightPage() const
Definition: printdata.hxx:136
void SetPrintHiddenText(bool b)
Definition: printdata.hxx:166
bool m_bPrintLeftPages
Definition: printdata.hxx:58
void DeletePostItData()
Definition: printdata.cxx:64
bool IsPrintPageBackground() const
Definition: printdata.hxx:184
bool IsPrintSingleJobs() const
Definition: printdata.hxx:144
virtual ~SwPrintUIOptions()
Definition: printdata.cxx:377
void SetPrintReverse(bool b)
Definition: printdata.hxx:156
SwPrintUIOptions(sal_uInt16 nCurrentPage, bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts, const SwPrintData &rDefaultPrintData)
Definition: printdata.cxx:156
bool m_bPrintDraw
Definition: printdata.hxx:58
SwPostItMode GetPrintPostItsType() const
Definition: printdata.hxx:190
void SetPrintTable(bool b)
Definition: printdata.hxx:151
bool m_bPrintTable
Definition: printdata.hxx:58
bool IsPrintLeftPages() const
Definition: printdata.cxx:381
void SetPaperFromSetup(bool b)
Definition: printdata.hxx:157
bool IsPrintControl() const
Definition: printdata.hxx:134
bool m_bPrintControl
Definition: printdata.hxx:58
std::vector< sal_Int32 > m_aPagesToPrint
vector of pages and their order to be printed (duplicates and any order allowed!) (see 'render' in un...
Definition: printdata.hxx:215
const OUString & GetPageRange() const
Definition: printdata.hxx:283
void SetPrintPageBackground(bool b)
Definition: printdata.hxx:162
bool IsPrintTextPlaceholder() const
Definition: printdata.hxx:148
bool IsPrintBlackFont() const
Definition: printdata.hxx:143
bool IsPrintTextPlaceholders() const
Definition: printdata.hxx:187
bool IsPrintGraphics() const
Definition: printdata.cxx:416
virtual ~SwPrintData()
Definition: printdata.hxx:96
SwPostItMode
this must match the definitions in css::text::NotePrintMode
Definition: printdata.hxx:42
bool m_bPrintBlackFont
Definition: printdata.hxx:58
bool HasSwPrtOptions() const
Definition: printdata.hxx:258
std::set< sal_Int32 > m_aValidPages
pages valid for printing (according to the current settings) This set of pages does NOT depend on the...
Definition: printdata.hxx:207
SfxObjectShellLock m_xTempDocShell
temp print document – must live longer than m_pViewOptionAdjust! also this is a Lock and not a Ref b...
Definition: printdata.hxx:225
const SwPrintData & m_rDefaultPrintData
Definition: printdata.hxx:175
bool IsViewOptionAdjust() const
Definition: printdata.hxx:251
void MakeSwPrtOptions(SwDocShell const *const pDocShell, SwPrintUIOptions const *const pOpt, bool const bIsPDFExport)
Definition: printdata.cxx:115
bool IsPrintWithBlackTextColor() const
Definition: printdata.hxx:189
std::map< sal_Int32, sal_Int32 > & GetPrinterPaperTrays()
a map for printer paper tray numbers to use for each document page a value of -1 for the tray means t...
Definition: printdata.hxx:270
bool HasPostItData() const
Definition: printdata.hxx:244
SwPrintData & operator=(SwPrintData const &)=default
void SetPrintSingleJobs(bool b)
Definition: printdata.hxx:164
bool IsPrintDraw() const
Definition: printdata.hxx:133
bool m_bPaperFromSetup
Definition: printdata.hxx:58
bool IsPrintProspectRTL() const
Definition: printdata.hxx:186
bool m_bPrintHiddenText
Definition: printdata.hxx:58
bool IsPrintEmptyPages() const
Definition: printdata.hxx:139
VclPtr< OutputDevice > m_pLast
Definition: printdata.hxx:174
const std::set< sal_Int32 > & GetValidPagesSet() const
Definition: printdata.hxx:266
bool IsPrintFormControls() const
Definition: printdata.hxx:183
bool m_bPrintEmptyPages
Print empty pages.
Definition: printdata.hxx:58
OUString m_aPageRange
Definition: printdata.hxx:221
bool NeedNewViewOptionAdjust(const SwViewShell &) const
Definition: printdata.cxx:84
bool operator==(const SwPrintData &rData) const
Definition: printdata.hxx:103
void SetPrintProspect(bool b)
Definition: printdata.hxx:160
const std::vector< sal_Int32 > & GetPagesToPrint() const
Definition: printdata.hxx:277
void ViewOptionAdjustCrashPreventionKludge()
Definition: printdata.cxx:110
std::vector< sal_Int32 > & GetPagesToPrint()
used for 'normal' printing A page value of 0 as entry indicates that this page is not from the docume...
Definition: printdata.hxx:276
bool IsPrintRightPages() const
Definition: printdata.cxx:395
bool IsPrintDrawings() const
Definition: printdata.cxx:426
bool IsPrintLeftPage() const
Definition: printdata.hxx:135
bool IsPrintProspect() const
Definition: printdata.hxx:140
void SetPrintDraw(bool b)
Definition: printdata.hxx:152
const SwRenderData * m_pRenderData
Definition: printdata.hxx:54
SwPostItMode m_nPrintPostIts
Definition: printdata.hxx:68
void SetRenderData(const SwRenderData *pData)
Definition: printdata.hxx:129
const PagePairsVec_t & GetPagePairsForProspectPrinting() const
Definition: printdata.hxx:281
void ViewOptionAdjust(SwPrintData const *const pPrtOptions, bool setShowPlaceHoldersInPDF)
Definition: printdata.cxx:100
sal_Int64 getIntValue(const OUString &i_rPropertyName, sal_Int64 i_nDefault) const
bool IsPrintEmptyPages(bool bIsPDFExport) const
Definition: printdata.cxx:406
void ViewOptionAdjustStop()
Definition: printdata.cxx:105