Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef SW_PRINTDATA_HXX
29 : : #define SW_PRINTDATA_HXX
30 : :
31 : : #include <sal/types.h>
32 : : #include <rtl/ustring.hxx>
33 : : #include <vcl/print.hxx>
34 : : #include <sfx2/objsh.hxx>
35 : :
36 : : #include <boost/scoped_ptr.hpp>
37 : :
38 : : #include <set>
39 : : #include <map>
40 : : #include <vector>
41 : : #include <utility>
42 : :
43 : : class SwDoc;
44 : : class SwDocShell;
45 : : class ViewShell;
46 : : class _SetGetExpFlds;
47 : : class SwViewOption;
48 : : class OutputDevice;
49 : : class SwViewOptionAdjust_Impl;
50 : : class ViewShell;
51 : : class SfxViewShell;
52 : :
53 : : // forward declarations
54 : : class SwPrintUIOptions;
55 : : class SwRenderData;
56 : :
57 : : ////////////////////////////////////////////////////////////
58 : :
59 : :
60 : 1582 : class SwPrintData
61 : : {
62 : : const SwPrintUIOptions * m_pPrintUIOptions; // not owner
63 : : const SwRenderData * m_pRenderData; // not owner
64 : :
65 : : public:
66 : :
67 : : sal_Bool bPrintGraphic, bPrintTable, bPrintDraw, bPrintControl, bPrintPageBackground,
68 : : bPrintBlackFont,
69 : : //#i81434# - printing of hidden text
70 : : bPrintHiddenText, bPrintTextPlaceholder,
71 : : bPrintLeftPages, bPrintRightPages, bPrintReverse, bPrintProspect,
72 : : bPrintProspectRTL,
73 : : bPrintSingleJobs, bPaperFromSetup,
74 : : // Print empty pages
75 : : bPrintEmptyPages,
76 : :
77 : : // #i56195# no field update while printing mail merge documents
78 : : bUpdateFieldsInPrinting,
79 : : bModified;
80 : :
81 : : sal_Int16 nPrintPostIts;
82 : : rtl::OUString sFaxName;
83 : :
84 : 1701 : SwPrintData()
85 : 1701 : {
86 : 1701 : m_pPrintUIOptions = NULL;
87 : 1701 : m_pRenderData = NULL;
88 : :
89 : : bPrintGraphic =
90 : : bPrintTable =
91 : : bPrintDraw =
92 : : bPrintControl =
93 : : bPrintLeftPages =
94 : : bPrintRightPages =
95 : : bPrintPageBackground =
96 : : bPrintEmptyPages =
97 : 1701 : bUpdateFieldsInPrinting = sal_True;
98 : :
99 : : bPaperFromSetup =
100 : : bPrintReverse =
101 : : bPrintProspect =
102 : : bPrintProspectRTL =
103 : : bPrintSingleJobs =
104 : : bModified =
105 : : bPrintBlackFont =
106 : : bPrintHiddenText =
107 : 1701 : bPrintTextPlaceholder = sal_False;
108 : :
109 : 1701 : nPrintPostIts = 0;
110 : 1701 : }
111 : :
112 [ - + ]: 3067 : virtual ~SwPrintData() {}
113 : :
114 : 0 : sal_Bool operator==(const SwPrintData& rData)const
115 : : {
116 : : return
117 : : bPrintGraphic == rData.bPrintGraphic &&
118 : : bPrintTable == rData.bPrintTable &&
119 : : bPrintDraw == rData.bPrintDraw &&
120 : : bPrintControl == rData.bPrintControl &&
121 : : bPrintPageBackground== rData.bPrintPageBackground &&
122 : : bPrintBlackFont == rData.bPrintBlackFont &&
123 : : bPrintLeftPages == rData.bPrintLeftPages &&
124 : : bPrintRightPages == rData.bPrintRightPages &&
125 : : bPrintReverse == rData.bPrintReverse &&
126 : : bPrintProspect == rData.bPrintProspect &&
127 : : bPrintProspectRTL == rData.bPrintProspectRTL &&
128 : : bPrintSingleJobs == rData.bPrintSingleJobs &&
129 : : bPaperFromSetup == rData.bPaperFromSetup &&
130 : : bPrintEmptyPages == rData.bPrintEmptyPages &&
131 : : bUpdateFieldsInPrinting == rData.bUpdateFieldsInPrinting &&
132 : : nPrintPostIts == rData.nPrintPostIts &&
133 : 0 : sFaxName == rData.sFaxName &&
134 : : bPrintHiddenText == rData.bPrintHiddenText &&
135 [ # # ][ # # ]: 0 : bPrintTextPlaceholder == rData.bPrintTextPlaceholder;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ][ # # ]
136 : : }
137 : :
138 : : // Note: in the context where this class ist used the pointers should always be valid
139 : : // during the lifetime of this object
140 : : const SwPrintUIOptions & GetPrintUIOptions() const { return *m_pPrintUIOptions; }
141 : 0 : const SwRenderData & GetRenderData() const { return *m_pRenderData; }
142 : 0 : void SetPrintUIOptions( const SwPrintUIOptions *pOpt ) { m_pPrintUIOptions = pOpt; }
143 : 0 : void SetRenderData( const SwRenderData *pData ) { m_pRenderData = pData; }
144 : :
145 : 27 : sal_Bool IsPrintGraphic() const { return bPrintGraphic; }
146 : 27 : sal_Bool IsPrintTable() const { return bPrintTable; }
147 : 27 : sal_Bool IsPrintDraw() const { return bPrintDraw; }
148 : 27 : sal_Bool IsPrintControl() const { return bPrintControl; }
149 : 27 : sal_Bool IsPrintLeftPage() const { return bPrintLeftPages; }
150 : 27 : sal_Bool IsPrintRightPage() const { return bPrintRightPages; }
151 : 27 : sal_Bool IsPrintReverse() const { return bPrintReverse; }
152 : 27 : sal_Bool IsPaperFromSetup() const { return bPaperFromSetup; }
153 : 19 : sal_Bool IsPrintEmptyPages() const { return bPrintEmptyPages; }
154 : 27 : sal_Bool IsPrintProspect() const { return bPrintProspect; }
155 : 19 : sal_Bool IsPrintProspectRTL() const { return bPrintProspectRTL; }
156 : 27 : sal_Bool IsPrintPageBackground() const { return bPrintPageBackground; }
157 : 27 : sal_Bool IsPrintBlackFont() const { return bPrintBlackFont; }
158 : 19 : sal_Bool IsPrintSingleJobs() const { return bPrintSingleJobs; }
159 : 27 : sal_Int16 GetPrintPostIts() const { return nPrintPostIts; }
160 : 27 : const rtl::OUString GetFaxName() const { return sFaxName; }
161 : 19 : sal_Bool IsPrintHiddenText() const { return bPrintHiddenText; }
162 : 19 : sal_Bool IsPrintTextPlaceholder() const { return bPrintTextPlaceholder; }
163 : :
164 : 67 : void SetPrintGraphic( sal_Bool b ) { doSetModified(); bPrintGraphic = b; }
165 : 67 : void SetPrintTable( sal_Bool b ) { doSetModified(); bPrintTable = b; }
166 : 67 : void SetPrintDraw( sal_Bool b ) { doSetModified(); bPrintDraw = b; }
167 : 67 : void SetPrintControl( sal_Bool b ) { doSetModified(); bPrintControl = b; }
168 : 67 : void SetPrintLeftPage( sal_Bool b ) { doSetModified(); bPrintLeftPages = b; }
169 : 67 : void SetPrintRightPage( sal_Bool b ) { doSetModified(); bPrintRightPages = b; }
170 : 67 : void SetPrintReverse( sal_Bool b ) { doSetModified(); bPrintReverse = b; }
171 : 67 : void SetPaperFromSetup( sal_Bool b ) { doSetModified(); bPaperFromSetup = b; }
172 : 63 : void SetPrintEmptyPages( sal_Bool b ) { doSetModified(); bPrintEmptyPages = b; }
173 : 67 : void SetPrintPostIts( sal_Int16 n ) { doSetModified(); nPrintPostIts = n; }
174 : 67 : void SetPrintProspect( sal_Bool b ) { doSetModified(); bPrintProspect = b; }
175 : 55 : void SetPrintProspect_RTL( sal_Bool b ) { doSetModified(); bPrintProspectRTL = b; }
176 : 67 : void SetPrintPageBackground( sal_Bool b ) { doSetModified(); bPrintPageBackground = b; }
177 : 67 : void SetPrintBlackFont( sal_Bool b ) { doSetModified(); bPrintBlackFont = b; }
178 : 63 : void SetPrintSingleJobs( sal_Bool b ) { doSetModified(); bPrintSingleJobs = b; }
179 : 67 : void SetFaxName( const rtl::OUString& rSet ) { sFaxName = rSet; }
180 : 55 : void SetPrintHiddenText( sal_Bool b ) { doSetModified(); bPrintHiddenText = b; }
181 : 55 : void SetPrintTextPlaceholder( sal_Bool b ) { doSetModified(); bPrintTextPlaceholder = b; }
182 : :
183 : 1071 : virtual void doSetModified () { bModified = sal_True;}
184 : : };
185 : :
186 : :
187 : : ////////////////////////////////////////////////////////////
188 : :
189 : :
190 : : class SwPrintUIOptions : public vcl::PrinterOptionsHelper
191 : : {
192 : : OutputDevice* m_pLast;
193 : : const SwPrintData & m_rDefaultPrintData;
194 : :
195 : : public:
196 : : SwPrintUIOptions( sal_uInt16 nCurrentPage, bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts, const SwPrintData &rDefaultPrintData );
197 : : virtual ~SwPrintUIOptions();
198 : :
199 : : bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp );
200 : :
201 : 0 : bool IsPrintFormControls() const { return getBoolValue( "PrintControls", m_rDefaultPrintData.bPrintControl ); }
202 : 0 : bool IsPrintPageBackground() const { return getBoolValue( "PrintPageBackground", m_rDefaultPrintData.bPrintPageBackground ); }
203 : 0 : bool IsPrintProspect() const { return getBoolValue( "PrintProspect", m_rDefaultPrintData.bPrintProspect ); }
204 : 0 : bool IsPrintProspectRTL() const { return getIntValue( "PrintProspectRTL", m_rDefaultPrintData.bPrintProspectRTL ) ? true : false; }
205 : 0 : bool IsPrintTextPlaceholders() const { return getBoolValue( "PrintTextPlaceholder", m_rDefaultPrintData.bPrintTextPlaceholder ); }
206 : 0 : bool IsPrintHiddenText() const { return getBoolValue( "PrintHiddenText", m_rDefaultPrintData.bPrintHiddenText ); }
207 : 0 : bool IsPrintWithBlackTextColor() const { return getBoolValue( "PrintBlackFonts", m_rDefaultPrintData.bPrintBlackFont ); }
208 : 0 : sal_Int16 GetPrintPostItsType() const { return static_cast< sal_Int16 >(getIntValue( "PrintAnnotationMode", m_rDefaultPrintData.nPrintPostIts )); }
209 : 0 : bool IsPaperFromSetup() const { return getBoolValue( "PrintPaperFromSetup", m_rDefaultPrintData.bPaperFromSetup ); }
210 : 0 : bool IsPrintReverse() const { return false; /*handled by print dialog now*/ }
211 : :
212 : : bool IsPrintLeftPages() const;
213 : : bool IsPrintRightPages() const;
214 : : bool IsPrintEmptyPages( bool bIsPDFExport ) const;
215 : : bool IsPrintTables() const;
216 : : bool IsPrintGraphics() const;
217 : : bool IsPrintDrawings() const;
218 : : };
219 : :
220 : :
221 : : ////////////////////////////////////////////////////////////
222 : :
223 : : // A class that stores temporary data that is needed for rendering the document.
224 : : // Usually this data is created when 'getRendererCount' is called and
225 : : // and it is used in the 'render' function of that same interface
226 : : class SwRenderData
227 : : {
228 : : // pages valid for printing (according to the current settings)
229 : : // This set of pages does NOT depend on the 'PageRange' that is used as a printing option!
230 : : std::set< sal_Int32 > m_aValidPages; // the set of possible pages (see StringRangeEnumerator::getRangesFromString )
231 : :
232 : : // printer paper tray to use for each of the m_aValidPages above
233 : : std::map< sal_Int32, sal_Int32 > m_aPrinterPaperTrays;
234 : :
235 : : // vector of pages and their order to be printed (duplicates and any order allowed!)
236 : : // (see 'render' in unotxdoc.cxx)
237 : : // negative entry indicates the page to be printed is from the post-it doc
238 : : std::vector< sal_Int32 > m_aPagesToPrint;
239 : :
240 : : // for prospect printing: the pairs of pages to be printed together on a single prospect page.
241 : : // -1 indicates a half page to be left empty.
242 : : std::vector< std::pair< sal_Int32, sal_Int32 > > m_aPagePairs;
243 : :
244 : : rtl::OUString m_aPageRange;
245 : :
246 : : // temp print document -- must live longer than m_pViewOptionAdjust!
247 : : // also this is a Lock and not a Ref because Ref does not delete the doc
248 : : SfxObjectShellLock m_xTempDocShell;
249 : :
250 : : // the view options to be applied for printing
251 : : ::boost::scoped_ptr<SwViewOptionAdjust_Impl> m_pViewOptionAdjust;
252 : :
253 : : ::boost::scoped_ptr<SwPrintData> m_pPrtOptions;
254 : :
255 : : public:
256 : :
257 : : // PostIt relevant data
258 : : /// an array of "_SetGetExpFld *" sorted by page and line numbers
259 : : ::boost::scoped_ptr<_SetGetExpFlds> m_pPostItFields;
260 : : /// this contains a SwDoc with the post-it content
261 : : ::boost::scoped_ptr<ViewShell> m_pPostItShell;
262 : :
263 : : public:
264 : : SwRenderData();
265 : : ~SwRenderData();
266 : :
267 : :
268 : 0 : bool HasPostItData() const { return m_pPostItShell != 0; }
269 : : void CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev );
270 : : void DeletePostItData();
271 : :
272 : : SfxObjectShellLock const& GetTempDocShell() const;
273 : : void SetTempDocShell(SfxObjectShellLock const&);
274 : :
275 : 0 : bool IsViewOptionAdjust() const { return m_pViewOptionAdjust != 0; }
276 : : bool NeedNewViewOptionAdjust( const ViewShell& ) const;
277 : : void ViewOptionAdjustStart( ViewShell &rSh, const SwViewOption &rViewOptions);
278 : : void ViewOptionAdjust( SwPrintData const* const pPrtOptions );
279 : : void ViewOptionAdjustStop();
280 : :
281 : 0 : bool HasSwPrtOptions() const { return m_pPrtOptions != 0; }
282 : 0 : SwPrintData const* GetSwPrtOptions() const { return m_pPrtOptions.get(); }
283 : : void MakeSwPrtOptions( SwDocShell const*const pDocShell,
284 : : SwPrintUIOptions const*const pOpt, bool const bIsPDFExport );
285 : :
286 : :
287 : : typedef std::vector< std::pair< sal_Int32, sal_Int32 > > PagePairsVec_t;
288 : :
289 : 0 : std::set< sal_Int32 > & GetValidPagesSet() { return m_aValidPages; }
290 : : const std::set< sal_Int32 > & GetValidPagesSet() const { return m_aValidPages; }
291 : :
292 : : // a map for printer paper tray numbers to use for each document page
293 : : // a value of -1 for the tray means that there is no specific tray defined
294 : 0 : std::map< sal_Int32, sal_Int32 >& GetPrinterPaperTrays() { return m_aPrinterPaperTrays; }
295 : : const std::map< sal_Int32, sal_Int32 >& GetPrinterPaperTrays() const { return m_aPrinterPaperTrays; }
296 : :
297 : : // used for 'normal' printing
298 : : // A page value of 0 as entry indicates that this page is not from the document but
299 : : // from the post-it document. (See also GetPostItStartFrame below)
300 : 0 : std::vector< sal_Int32 > & GetPagesToPrint() { return m_aPagesToPrint; }
301 : 0 : const std::vector< sal_Int32 > & GetPagesToPrint() const { return m_aPagesToPrint; }
302 : :
303 : : // used for prospect printing only
304 : 0 : PagePairsVec_t & GetPagePairsForProspectPrinting() { return m_aPagePairs; }
305 : 0 : const PagePairsVec_t & GetPagePairsForProspectPrinting() const { return m_aPagePairs; }
306 : :
307 : 0 : rtl::OUString GetPageRange() const { return m_aPageRange; }
308 : 0 : void SetPageRange( const rtl::OUString &rRange ) { m_aPageRange = rRange; }
309 : : };
310 : :
311 : :
312 : : ////////////////////////////////////////////////////////////
313 : :
314 : : // last remnants of swprtopt.hxx:
315 : : #define POSTITS_NONE 0
316 : : #define POSTITS_ONLY 1
317 : : #define POSTITS_ENDDOC 2
318 : : #define POSTITS_ENDPAGE 3
319 : :
320 : : namespace sw {
321 : :
322 : : void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb);
323 : :
324 : : } // namespace sw
325 : :
326 : : #endif // SW_PRINTDATA_HXX
327 : :
328 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|