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