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