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 .
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 <o3tl/sorted_vector.hxx>
35 class SetGetExpFields
;
37 class SwViewOptionAdjust_Impl
;
41 /** this must match the definitions in css::text::NotePrintMode */
42 enum class SwPostItMode
54 const SwRenderData
* m_pRenderData
; // not owner
58 bool m_bPrintGraphic
, m_bPrintTable
, m_bPrintDraw
, m_bPrintControl
, m_bPrintPageBackground
,
60 //#i81434# - printing of hidden text
61 m_bPrintHiddenText
, m_bPrintTextPlaceholder
,
62 m_bPrintLeftPages
, m_bPrintRightPages
, m_bPrintReverse
, m_bPrintProspect
,
64 m_bPrintSingleJobs
, m_bPaperFromSetup
,
68 SwPostItMode m_nPrintPostIts
;
73 m_pRenderData
= nullptr;
81 m_bPrintPageBackground
=
82 m_bPrintEmptyPages
= true;
91 m_bPrintTextPlaceholder
= false;
93 m_nPrintPostIts
= SwPostItMode::NONE
;
96 virtual ~SwPrintData() {}
98 SwPrintData(SwPrintData
const &) = default;
99 SwPrintData(SwPrintData
&&) = default;
100 SwPrintData
& operator =(SwPrintData
const &) = default;
101 SwPrintData
& operator =(SwPrintData
&&) = default;
103 bool operator==(const SwPrintData
& rData
)const
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
;
126 /** Note: in the context where this class is used the pointers should always be valid
127 during the lifetime of this object */
128 const SwRenderData
& GetRenderData() const { return *m_pRenderData
; }
129 void SetRenderData( const SwRenderData
*pData
) { m_pRenderData
= pData
; }
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
; }
142 bool IsPrintPageBackground() const { return m_bPrintPageBackground
; }
143 bool IsPrintBlackFont() const { return m_bPrintBlackFont
; }
144 bool IsPrintSingleJobs() const { return m_bPrintSingleJobs
; }
145 SwPostItMode
GetPrintPostIts() const { return m_nPrintPostIts
; }
146 const OUString
& GetFaxName() const { return m_sFaxName
; }
147 bool IsPrintHiddenText() const { return m_bPrintHiddenText
; }
148 bool IsPrintTextPlaceholder() const { return m_bPrintTextPlaceholder
; }
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
; }
169 virtual void doSetModified () {}
172 class SwPrintUIOptions final
: public vcl::PrinterOptionsHelper
174 VclPtr
< OutputDevice
> m_pLast
;
175 const SwPrintData
& m_rDefaultPrintData
;
178 SwPrintUIOptions( sal_uInt16 nCurrentPage
, bool bWeb
, bool bSwSrcView
, bool bHasSelection
, bool bHasPostIts
, const SwPrintData
&rDefaultPrintData
);
179 virtual ~SwPrintUIOptions();
181 bool processPropertiesAndCheckFormat( const css::uno::Sequence
< css::beans::PropertyValue
>& i_rNewProp
);
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
); }
193 bool IsPrintLeftPages() const;
194 bool IsPrintRightPages() const;
195 bool IsPrintEmptyPages( bool bIsPDFExport
) const;
196 bool IsPrintGraphics() const;
197 bool IsPrintDrawings() const;
200 /** A class that stores temporary data that is needed for rendering the document.
201 Usually this data is created when 'getRendererCount' is called and
202 and it is used in the 'render' function of that same interface */
205 /** pages valid for printing (according to the current settings)
206 This set of pages does NOT depend on the 'PageRange' that is used as a printing option! */
207 o3tl::sorted_vector
< sal_Int32
> m_aValidPages
; ///< the set of possible pages (see StringRangeEnumerator::getRangesFromString )
209 /// printer paper tray to use for each of the m_aValidPages above
210 std::map
< sal_Int32
, sal_Int32
> m_aPrinterPaperTrays
;
212 /** vector of pages and their order to be printed (duplicates and any order allowed!)
213 (see 'render' in unotxdoc.cxx)
214 negative entry indicates the page to be printed is from the post-it doc */
215 std::vector
< sal_Int32
> m_aPagesToPrint
;
217 /** for prospect printing: the pairs of pages to be printed together on a single prospect page.
218 -1 indicates a half page to be left empty. */
219 std::vector
< std::pair
< sal_Int32
, sal_Int32
> > m_aPagePairs
;
221 OUString m_aPageRange
;
223 /** temp print document -- must live longer than m_pViewOptionAdjust!
224 also this is a Lock and not a Ref because Ref does not delete the doc */
225 SfxObjectShellLock m_xTempDocShell
;
227 /// the view options to be applied for printing
228 std::unique_ptr
<SwViewOptionAdjust_Impl
> m_pViewOptionAdjust
;
230 std::unique_ptr
<SwPrintData
> m_pPrtOptions
;
234 // PostIt relevant data
235 /// an array of "SetGetExpField *" sorted by page and line numbers
236 std::unique_ptr
<SetGetExpFields
> m_pPostItFields
;
237 /// this contains a SwDoc with the post-it content
238 std::unique_ptr
<SwViewShell
> m_pPostItShell
;
244 bool HasPostItData() const { return m_pPostItShell
!= nullptr; }
245 void CreatePostItData( SwDoc
& rDoc
, const SwViewOption
*pViewOpt
, OutputDevice
*pOutDev
);
246 void DeletePostItData();
248 SfxObjectShellLock
const& GetTempDocShell() const { return m_xTempDocShell
;}
249 void SetTempDocShell(SfxObjectShellLock
const&);
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();
256 void ViewOptionAdjustCrashPreventionKludge();
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
);
263 typedef std::vector
< std::pair
< sal_Int32
, sal_Int32
> > PagePairsVec_t
;
265 o3tl::sorted_vector
< sal_Int32
> & GetValidPagesSet() { return m_aValidPages
; }
266 const o3tl::sorted_vector
< sal_Int32
> & GetValidPagesSet() const { return m_aValidPages
; }
268 /** a map for printer paper tray numbers to use for each document page
269 a value of -1 for the tray means that there is no specific tray defined */
270 std::map
< sal_Int32
, sal_Int32
>& GetPrinterPaperTrays() { return m_aPrinterPaperTrays
; }
271 const std::map
< sal_Int32
, sal_Int32
>& GetPrinterPaperTrays() const { return m_aPrinterPaperTrays
; }
273 /** used for 'normal' printing
274 A page value of 0 as entry indicates that this page is not from the document but
275 from the post-it document. (See also GetPostItStartFrame below) */
276 std::vector
< sal_Int32
> & GetPagesToPrint() { return m_aPagesToPrint
; }
277 const std::vector
< sal_Int32
> & GetPagesToPrint() const { return m_aPagesToPrint
; }
279 /// used for prospect printing only
280 PagePairsVec_t
& GetPagePairsForProspectPrinting() { return m_aPagePairs
; }
281 const PagePairsVec_t
& GetPagePairsForProspectPrinting() const { return m_aPagePairs
; }
283 const OUString
& GetPageRange() const { return m_aPageRange
; }
284 void SetPageRange( const OUString
&rRange
) { m_aPageRange
= rRange
; }
289 void InitPrintOptionsFromApplication(SwPrintData
& o_rData
, bool const bWeb
);
293 #endif // INCLUDED_SW_INC_PRINTDATA_HXX
295 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */