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 SW_PRINTDATA_HXX
20 : #define SW_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 ViewShell;
41 : class SfxViewShell;
42 :
43 : // forward declarations
44 : class SwPrintUIOptions;
45 : class SwRenderData;
46 :
47 : ////////////////////////////////////////////////////////////
48 :
49 :
50 284 : class SwPrintData
51 : {
52 : const SwPrintUIOptions * m_pPrintUIOptions; // not owner
53 : const SwRenderData * m_pRenderData; // not owner
54 :
55 : public:
56 :
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,
66 :
67 : /// #i56195# no field update while printing mail merge documents
68 : bUpdateFieldsInPrinting,
69 : bModified;
70 :
71 : sal_Int16 nPrintPostIts;
72 : rtl::OUString sFaxName;
73 :
74 305 : SwPrintData()
75 305 : {
76 305 : m_pPrintUIOptions = NULL;
77 305 : m_pRenderData = NULL;
78 :
79 : bPrintGraphic =
80 : bPrintTable =
81 : bPrintDraw =
82 : bPrintControl =
83 : bPrintLeftPages =
84 : bPrintRightPages =
85 : bPrintPageBackground =
86 : bPrintEmptyPages =
87 305 : bUpdateFieldsInPrinting = sal_True;
88 :
89 : bPaperFromSetup =
90 : bPrintReverse =
91 : bPrintProspect =
92 : bPrintProspectRTL =
93 : bPrintSingleJobs =
94 : bModified =
95 : bPrintBlackFont =
96 : bPrintHiddenText =
97 305 : bPrintTextPlaceholder = sal_False;
98 :
99 305 : nPrintPostIts = 0;
100 305 : }
101 :
102 232 : virtual ~SwPrintData() {}
103 :
104 0 : sal_Bool operator==(const SwPrintData& rData)const
105 : {
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 0 : sFaxName == rData.sFaxName &&
124 : bPrintHiddenText == rData.bPrintHiddenText &&
125 0 : bPrintTextPlaceholder == rData.bPrintTextPlaceholder;
126 : }
127 :
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 0 : const SwRenderData & GetRenderData() const { return *m_pRenderData; }
132 0 : void SetPrintUIOptions( const SwPrintUIOptions *pOpt ) { m_pPrintUIOptions = pOpt; }
133 0 : void SetRenderData( const SwRenderData *pData ) { m_pRenderData = pData; }
134 :
135 2 : sal_Bool IsPrintGraphic() const { return bPrintGraphic; }
136 2 : sal_Bool IsPrintTable() const { return bPrintTable; }
137 2 : sal_Bool IsPrintDraw() const { return bPrintDraw; }
138 2 : sal_Bool IsPrintControl() const { return bPrintControl; }
139 2 : sal_Bool IsPrintLeftPage() const { return bPrintLeftPages; }
140 2 : sal_Bool IsPrintRightPage() const { return bPrintRightPages; }
141 2 : sal_Bool IsPrintReverse() const { return bPrintReverse; }
142 2 : sal_Bool IsPaperFromSetup() const { return bPaperFromSetup; }
143 2 : sal_Bool IsPrintEmptyPages() const { return bPrintEmptyPages; }
144 2 : sal_Bool IsPrintProspect() const { return bPrintProspect; }
145 2 : sal_Bool IsPrintProspectRTL() const { return bPrintProspectRTL; }
146 2 : sal_Bool IsPrintPageBackground() const { return bPrintPageBackground; }
147 2 : sal_Bool IsPrintBlackFont() const { return bPrintBlackFont; }
148 2 : sal_Bool IsPrintSingleJobs() const { return bPrintSingleJobs; }
149 2 : sal_Int16 GetPrintPostIts() const { return nPrintPostIts; }
150 2 : const rtl::OUString GetFaxName() const { return sFaxName; }
151 2 : sal_Bool IsPrintHiddenText() const { return bPrintHiddenText; }
152 2 : sal_Bool IsPrintTextPlaceholder() const { return bPrintTextPlaceholder; }
153 :
154 18 : void SetPrintGraphic( sal_Bool b ) { doSetModified(); bPrintGraphic = b; }
155 18 : void SetPrintTable( sal_Bool b ) { doSetModified(); bPrintTable = b; }
156 18 : void SetPrintDraw( sal_Bool b ) { doSetModified(); bPrintDraw = b; }
157 18 : void SetPrintControl( sal_Bool b ) { doSetModified(); bPrintControl = b; }
158 18 : void SetPrintLeftPage( sal_Bool b ) { doSetModified(); bPrintLeftPages = b; }
159 18 : void SetPrintRightPage( sal_Bool b ) { doSetModified(); bPrintRightPages = b; }
160 18 : void SetPrintReverse( sal_Bool b ) { doSetModified(); bPrintReverse = b; }
161 18 : void SetPaperFromSetup( sal_Bool b ) { doSetModified(); bPaperFromSetup = b; }
162 17 : void SetPrintEmptyPages( sal_Bool b ) { doSetModified(); bPrintEmptyPages = b; }
163 18 : void SetPrintPostIts( sal_Int16 n ) { doSetModified(); nPrintPostIts = n; }
164 18 : void SetPrintProspect( sal_Bool b ) { doSetModified(); bPrintProspect = b; }
165 17 : void SetPrintProspect_RTL( sal_Bool b ) { doSetModified(); bPrintProspectRTL = b; }
166 18 : void SetPrintPageBackground( sal_Bool b ) { doSetModified(); bPrintPageBackground = b; }
167 18 : void SetPrintBlackFont( sal_Bool b ) { doSetModified(); bPrintBlackFont = b; }
168 18 : void SetPrintSingleJobs( sal_Bool b ) { doSetModified(); bPrintSingleJobs = b; }
169 18 : void SetFaxName( const rtl::OUString& rSet ) { sFaxName = rSet; }
170 17 : void SetPrintHiddenText( sal_Bool b ) { doSetModified(); bPrintHiddenText = b; }
171 17 : void SetPrintTextPlaceholder( sal_Bool b ) { doSetModified(); bPrintTextPlaceholder = b; }
172 :
173 302 : virtual void doSetModified () { bModified = sal_True;}
174 : };
175 :
176 :
177 : ////////////////////////////////////////////////////////////
178 :
179 :
180 : class SwPrintUIOptions : public vcl::PrinterOptionsHelper
181 : {
182 : OutputDevice* m_pLast;
183 : const SwPrintData & m_rDefaultPrintData;
184 :
185 : public:
186 : SwPrintUIOptions( sal_uInt16 nCurrentPage, bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts, const SwPrintData &rDefaultPrintData );
187 : virtual ~SwPrintUIOptions();
188 :
189 : bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp );
190 :
191 0 : bool IsPrintFormControls() const { return getBoolValue( "PrintControls", m_rDefaultPrintData.bPrintControl ); }
192 0 : bool IsPrintPageBackground() const { return getBoolValue( "PrintPageBackground", m_rDefaultPrintData.bPrintPageBackground ); }
193 0 : bool IsPrintProspect() const { return getBoolValue( "PrintProspect", m_rDefaultPrintData.bPrintProspect ); }
194 0 : bool IsPrintProspectRTL() const { return getIntValue( "PrintProspectRTL", m_rDefaultPrintData.bPrintProspectRTL ) ? true : false; }
195 0 : bool IsPrintTextPlaceholders() const { return getBoolValue( "PrintTextPlaceholder", m_rDefaultPrintData.bPrintTextPlaceholder ); }
196 0 : bool IsPrintHiddenText() const { return getBoolValue( "PrintHiddenText", m_rDefaultPrintData.bPrintHiddenText ); }
197 0 : bool IsPrintWithBlackTextColor() const { return getBoolValue( "PrintBlackFonts", m_rDefaultPrintData.bPrintBlackFont ); }
198 0 : sal_Int16 GetPrintPostItsType() const { return static_cast< sal_Int16 >(getIntValue( "PrintAnnotationMode", m_rDefaultPrintData.nPrintPostIts )); }
199 0 : bool IsPaperFromSetup() const { return getBoolValue( "PrintPaperFromSetup", m_rDefaultPrintData.bPaperFromSetup ); }
200 0 : bool IsPrintReverse() const { return false; /*handled by print dialog now*/ }
201 :
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;
208 : };
209 :
210 :
211 : ////////////////////////////////////////////////////////////
212 :
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
217 : {
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 )
221 :
222 : /// printer paper tray to use for each of the m_aValidPages above
223 : std::map< sal_Int32, sal_Int32 > m_aPrinterPaperTrays;
224 :
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;
229 :
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;
233 :
234 : rtl::OUString m_aPageRange;
235 :
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;
239 :
240 : /// the view options to be applied for printing
241 : ::boost::scoped_ptr<SwViewOptionAdjust_Impl> m_pViewOptionAdjust;
242 :
243 : ::boost::scoped_ptr<SwPrintData> m_pPrtOptions;
244 :
245 : public:
246 :
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;
252 :
253 : public:
254 : SwRenderData();
255 : ~SwRenderData();
256 :
257 :
258 0 : bool HasPostItData() const { return m_pPostItShell != 0; }
259 : void CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev );
260 : void DeletePostItData();
261 :
262 : SfxObjectShellLock const& GetTempDocShell() const;
263 : void SetTempDocShell(SfxObjectShellLock const&);
264 :
265 0 : 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();
271 :
272 0 : bool HasSwPrtOptions() const { return m_pPrtOptions != 0; }
273 0 : SwPrintData const* GetSwPrtOptions() const { return m_pPrtOptions.get(); }
274 : void MakeSwPrtOptions( SwDocShell const*const pDocShell,
275 : SwPrintUIOptions const*const pOpt, bool const bIsPDFExport );
276 :
277 :
278 : typedef std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t;
279 :
280 0 : std::set< sal_Int32 > & GetValidPagesSet() { return m_aValidPages; }
281 : const std::set< sal_Int32 > & GetValidPagesSet() const { return m_aValidPages; }
282 :
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 0 : std::map< sal_Int32, sal_Int32 >& GetPrinterPaperTrays() { return m_aPrinterPaperTrays; }
286 : const std::map< sal_Int32, sal_Int32 >& GetPrinterPaperTrays() const { return m_aPrinterPaperTrays; }
287 :
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 0 : std::vector< sal_Int32 > & GetPagesToPrint() { return m_aPagesToPrint; }
292 0 : const std::vector< sal_Int32 > & GetPagesToPrint() const { return m_aPagesToPrint; }
293 :
294 : /// used for prospect printing only
295 0 : PagePairsVec_t & GetPagePairsForProspectPrinting() { return m_aPagePairs; }
296 0 : const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return m_aPagePairs; }
297 :
298 0 : rtl::OUString GetPageRange() const { return m_aPageRange; }
299 0 : void SetPageRange( const rtl::OUString &rRange ) { m_aPageRange = rRange; }
300 : };
301 :
302 :
303 : ////////////////////////////////////////////////////////////
304 :
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
310 :
311 : namespace sw {
312 :
313 : void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb);
314 :
315 : } ///< namespace sw
316 :
317 : #endif // SW_PRINTDATA_HXX
318 :
319 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|