1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SV_PRINT_HXX 25 #define _SV_PRINT_HXX 26 27 #include "tools/errcode.hxx" 28 #include "vcl/sv.h" 29 #include "vcl/dllapi.h" 30 #include "vcl/outdev.hxx" 31 #include "vcl/prntypes.hxx" 32 #include "vcl/jobset.hxx" 33 #include "vcl/gdimtf.hxx" 34 #include "tools/stream.hxx" 35 #include "tools/multisel.hxx" 36 37 #include "com/sun/star/beans/PropertyValue.hpp" 38 #include "com/sun/star/view/PrintableState.hpp" 39 40 #include <boost/shared_ptr.hpp> 41 #include <hash_map> 42 #include <set> 43 44 struct SalPrinterInfoQueue; 45 class SalInfoPrinter; 46 struct SalPrinterQueueInfo; 47 class SalPrinter; 48 class VirtualDevice; 49 class Window; 50 51 namespace vcl { 52 class PrinterController; 53 class PrintDialog; 54 } 55 56 // ----------------- 57 // - Printer-Types - 58 // ----------------- 59 60 #define PAGEQUEUE_ALLPAGES 0xFFFF 61 62 enum PrinterSupport { SUPPORT_SET_ORIENTATION, SUPPORT_SET_PAPERBIN, 63 SUPPORT_SET_PAPERSIZE, SUPPORT_SET_PAPER, 64 SUPPORT_COPY, SUPPORT_COLLATECOPY, 65 SUPPORT_SETUPDIALOG, SUPPORT_FAX, SUPPORT_PDF }; 66 67 // --------------- 68 // - PrinterPage - 69 // --------------- 70 71 class VCL_DLLPUBLIC PrinterPage 72 { 73 GDIMetaFile* mpMtf; 74 JobSetup maJobSetup; 75 sal_uInt16 mbNewJobSetup; 76 77 public: 78 PrinterPage()79 PrinterPage() : mpMtf( new GDIMetaFile() ) {} PrinterPage(GDIMetaFile * pMtf,sal_Bool bNewJobSetup,const JobSetup & rSetup)80 PrinterPage( GDIMetaFile* pMtf, sal_Bool bNewJobSetup, const JobSetup& rSetup ) : 81 mpMtf( pMtf ), maJobSetup( rSetup ), mbNewJobSetup( bNewJobSetup ) {} ~PrinterPage()82 ~PrinterPage() { delete mpMtf; } 83 GetGDIMetaFile() const84 GDIMetaFile* GetGDIMetaFile() const { return mpMtf; } GetJobSetup() const85 const JobSetup& GetJobSetup() const { return maJobSetup; } IsNewJobSetup() const86 sal_Bool IsNewJobSetup() const { return (mbNewJobSetup != 0); } 87 }; 88 89 90 // ------------- 91 // - QueueInfo - 92 // ------------- 93 94 class VCL_DLLPUBLIC QueueInfo 95 { 96 friend class Printer; 97 98 private: 99 XubString maPrinterName; 100 XubString maDriver; 101 XubString maLocation; 102 XubString maComment; 103 sal_uInt32 mnStatus; 104 sal_uInt32 mnJobs; 105 106 public: 107 QueueInfo(); 108 QueueInfo( const QueueInfo& rInfo ); 109 ~QueueInfo(); 110 GetPrinterName() const111 const XubString& GetPrinterName() const { return maPrinterName; } GetDriver() const112 const XubString& GetDriver() const { return maDriver; } GetLocation() const113 const XubString& GetLocation() const { return maLocation; } GetComment() const114 const XubString& GetComment() const { return maComment; } GetStatus() const115 sal_uInt32 GetStatus() const { return mnStatus; } GetJobs() const116 sal_uInt32 GetJobs() const { return mnJobs; } 117 118 bool operator==( const QueueInfo& rInfo ) const; 119 120 friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, QueueInfo& rInfo ); 121 friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const QueueInfo& rInfo ); 122 }; 123 124 // ------------------ 125 // - PrinterOptions - 126 // ------------------ 127 128 enum PrinterTransparencyMode 129 { 130 PRINTER_TRANSPARENCY_AUTO = 0, 131 PRINTER_TRANSPARENCY_NONE = 1 132 }; 133 134 // ----------------------------------------------------------------------------- 135 136 enum PrinterGradientMode 137 { 138 PRINTER_GRADIENT_STRIPES = 0, 139 PRINTER_GRADIENT_COLOR = 1 140 }; 141 142 // ----------------------------------------------------------------------------- 143 144 enum PrinterBitmapMode 145 { 146 PRINTER_BITMAP_OPTIMAL = 0, 147 PRINTER_BITMAP_NORMAL = 1, 148 PRINTER_BITMAP_RESOLUTION = 2 149 }; 150 151 // ----------------------------------------------------------------------------- 152 153 class VCL_DLLPUBLIC PrinterOptions 154 { 155 private: 156 157 sal_Bool mbReduceTransparency; 158 PrinterTransparencyMode meReducedTransparencyMode; 159 sal_Bool mbReduceGradients; 160 PrinterGradientMode meReducedGradientsMode; 161 sal_uInt16 mnReducedGradientStepCount; 162 sal_Bool mbReduceBitmaps; 163 PrinterBitmapMode meReducedBitmapMode; 164 sal_uInt16 mnReducedBitmapResolution; 165 sal_Bool mbReducedBitmapsIncludeTransparency; 166 sal_Bool mbConvertToGreyscales; 167 168 public: 169 170 PrinterOptions(); 171 ~PrinterOptions(); 172 IsReduceTransparency() const173 sal_Bool IsReduceTransparency() const { return mbReduceTransparency; } SetReduceTransparency(sal_Bool bSet)174 void SetReduceTransparency( sal_Bool bSet ) { mbReduceTransparency = bSet; } 175 GetReducedTransparencyMode() const176 PrinterTransparencyMode GetReducedTransparencyMode() const { return meReducedTransparencyMode; } SetReducedTransparencyMode(PrinterTransparencyMode eMode)177 void SetReducedTransparencyMode( PrinterTransparencyMode eMode ) { meReducedTransparencyMode = eMode; } 178 IsReduceGradients() const179 sal_Bool IsReduceGradients() const { return mbReduceGradients; } SetReduceGradients(sal_Bool bSet)180 void SetReduceGradients( sal_Bool bSet ) { mbReduceGradients = bSet; } 181 GetReducedGradientMode() const182 PrinterGradientMode GetReducedGradientMode() const { return meReducedGradientsMode; } SetReducedGradientMode(PrinterGradientMode eMode)183 void SetReducedGradientMode( PrinterGradientMode eMode ) { meReducedGradientsMode = eMode; } 184 GetReducedGradientStepCount() const185 sal_uInt16 GetReducedGradientStepCount() const { return mnReducedGradientStepCount; } SetReducedGradientStepCount(sal_uInt16 nStepCount)186 void SetReducedGradientStepCount( sal_uInt16 nStepCount ) { mnReducedGradientStepCount = nStepCount; } 187 IsReduceBitmaps() const188 sal_Bool IsReduceBitmaps() const { return mbReduceBitmaps; } SetReduceBitmaps(sal_Bool bSet)189 void SetReduceBitmaps( sal_Bool bSet ) { mbReduceBitmaps = bSet; } 190 GetReducedBitmapMode() const191 PrinterBitmapMode GetReducedBitmapMode() const { return meReducedBitmapMode; } SetReducedBitmapMode(PrinterBitmapMode eMode)192 void SetReducedBitmapMode( PrinterBitmapMode eMode ) { meReducedBitmapMode = eMode; } 193 GetReducedBitmapResolution() const194 sal_uInt16 GetReducedBitmapResolution() const { return mnReducedBitmapResolution; } SetReducedBitmapResolution(sal_uInt16 nResolution)195 void SetReducedBitmapResolution( sal_uInt16 nResolution ) { mnReducedBitmapResolution = nResolution; } 196 IsReducedBitmapIncludesTransparency() const197 sal_Bool IsReducedBitmapIncludesTransparency() const { return mbReducedBitmapsIncludeTransparency; } SetReducedBitmapIncludesTransparency(sal_Bool bSet)198 void SetReducedBitmapIncludesTransparency( sal_Bool bSet ) { mbReducedBitmapsIncludeTransparency = bSet; } 199 IsConvertToGreyscales() const200 sal_Bool IsConvertToGreyscales() const { return mbConvertToGreyscales; } SetConvertToGreyscales(sal_Bool bSet)201 void SetConvertToGreyscales( sal_Bool bSet ) { mbConvertToGreyscales = bSet; } 202 203 // read printer options from configuration, parameter decides whether the set for 204 // print "to printer" or "to file" should be read. 205 // returns true if config was read, false if an error occured 206 bool ReadFromConfig( bool bFile ); 207 }; 208 209 // ----------- 210 // - Printer - 211 // ----------- 212 213 class VCL_DLLPUBLIC Printer : public OutputDevice 214 { 215 friend class OutputDevice; 216 friend class ImplQPrinter; 217 218 private: 219 SalInfoPrinter* mpInfoPrinter; 220 SalPrinter* mpPrinter; 221 SalGraphics* mpJobGraphics; 222 Printer* mpPrev; 223 Printer* mpNext; 224 VirtualDevice* mpDisplayDev; 225 PrinterOptions* mpPrinterOptions; 226 XubString maPrinterName; 227 XubString maDriver; 228 XubString maPrintFile; 229 XubString maJobName; 230 JobSetup maJobSetup; 231 Point maPageOffset; 232 Size maPaperSize; 233 sal_uLong mnError; 234 sal_uInt16 mnCurPage; 235 sal_uInt16 mnCurPrintPage; 236 sal_uInt16 mnPageQueueSize; 237 sal_uInt16 mnCopyCount; 238 sal_Bool mbDefPrinter; 239 sal_Bool mbPrinting; 240 sal_Bool mbJobActive; 241 sal_Bool mbCollateCopy; 242 sal_Bool mbPrintFile; 243 sal_Bool mbInPrintPage; 244 sal_Bool mbNewJobSetup; 245 sal_Bool mbIsQueuePrinter; 246 sal_Bool mbUserSetupCompleted; 247 sal_Bool mbUserSetupResult; 248 Link maErrorHdl; 249 250 SAL_DLLPRIVATE void ImplInitData(); 251 SAL_DLLPRIVATE void ImplInit( SalPrinterQueueInfo* pInfo ); 252 SAL_DLLPRIVATE void ImplInitDisplay( const Window* pWindow ); 253 SAL_DLLPRIVATE static SalPrinterQueueInfo* ImplGetQueueInfo( const XubString& rPrinterName, 254 const XubString* pDriver ); 255 SAL_DLLPRIVATE void ImplUpdatePageData(); 256 SAL_DLLPRIVATE void ImplUpdateFontList(); 257 SAL_DLLPRIVATE void ImplFindPaperFormatForUserSize( JobSetup&, bool bMatchNearest ); 258 DECL_DLLPRIVATE_LINK( ImplDestroyPrinterAsync, void* ); 259 260 SAL_DLLPRIVATE bool StartJob( const rtl::OUString& rJobName, boost::shared_ptr<vcl::PrinterController>& ); 261 262 static SAL_DLLPRIVATE sal_uLong ImplSalPrinterErrorCodeToVCL( sal_uLong nError ); 263 264 private: 265 SAL_DLLPRIVATE void ImplEndPrint(); 266 SAL_DLLPRIVATE sal_Bool EndJob(); 267 SAL_DLLPRIVATE Printer( const Printer& rPrinter ); 268 SAL_DLLPRIVATE Printer& operator =( const Printer& rPrinter ); 269 public: 270 SAL_DLLPRIVATE void ImplStartPage(); 271 SAL_DLLPRIVATE void ImplEndPage(); 272 public: 273 void DrawGradientEx( OutputDevice* pOut, const Rectangle& rRect, const Gradient& rGradient ); 274 void DrawGradientEx( OutputDevice* pOut, const PolyPolygon& rPolyPoly, const Gradient& rGradient ); 275 276 protected: 277 SetSelfAsQueuePrinter(sal_Bool bQueuePrinter)278 void SetSelfAsQueuePrinter( sal_Bool bQueuePrinter ) { mbIsQueuePrinter = bQueuePrinter; } IsQueuePrinter() const279 sal_Bool IsQueuePrinter() const { return mbIsQueuePrinter; } 280 281 public: 282 Printer(); 283 Printer( const Window* pWindow ); 284 Printer( const JobSetup& rJobSetup ); 285 Printer( const QueueInfo& rQueueInfo ); 286 Printer( const XubString& rPrinterName ); 287 virtual ~Printer(); 288 289 static const std::vector< rtl::OUString >& GetPrinterQueues(); 290 static const QueueInfo* GetQueueInfo( const String& rPrinterName, bool bStatusUpdate ); 291 static XubString GetDefaultPrinterName(); 292 293 virtual void Error(); 294 GetName() const295 const XubString& GetName() const { return maPrinterName; } GetDriverName() const296 const XubString& GetDriverName() const { return maDriver; } IsDefPrinter() const297 sal_Bool IsDefPrinter() const { return mbDefPrinter; } IsDisplayPrinter() const298 sal_Bool IsDisplayPrinter() const { return mpDisplayDev != NULL; } IsValid() const299 sal_Bool IsValid() const { return !IsDisplayPrinter(); } 300 301 sal_uLong GetCapabilities( sal_uInt16 nType ) const; 302 sal_Bool HasSupport( PrinterSupport eFeature ) const; 303 304 sal_Bool SetJobSetup( const JobSetup& rSetup ); GetJobSetup() const305 const JobSetup& GetJobSetup() const { return maJobSetup; } GetJobValue(const String & rKey) const306 String GetJobValue( const String& rKey ) const { return maJobSetup.GetValue( rKey ); } SetJobValue(const String & rKey,const String & rValue)307 void SetJobValue( const String& rKey, const String& rValue ) { maJobSetup.SetValue( rKey, rValue ); } 308 309 sal_Bool Setup( Window* pWindow = NULL ); 310 sal_Bool SetPrinterProps( const Printer* pPrinter ); 311 312 // SetPrinterOptions is used internally only now 313 // in earlier times it was used only to set the options loaded directly from the configuration 314 // in SfxPrinter::InitJob, this is now handled internally 315 // should the need arise to set the printer options outside vcl, also a method would have to be devised 316 // to not override these again internally 317 SAL_DLLPRIVATE void SetPrinterOptions( const PrinterOptions& rOptions ); GetPrinterOptions() const318 const PrinterOptions& GetPrinterOptions() const { return( *mpPrinterOptions ); } 319 320 sal_Bool SetOrientation( Orientation eOrient ); 321 Orientation GetOrientation() const; 322 DuplexMode GetDuplexMode() const; 323 sal_Bool SetDuplexMode( DuplexMode ); 324 // returns the angle that a landscape page will be turned counterclockwise 325 // wrt to portrait. The return value may be only valid for 326 // the current paper 327 int GetLandscapeAngle() const; 328 sal_Bool SetPaperBin( sal_uInt16 nPaperBin ); 329 sal_uInt16 GetPaperBin() const; 330 sal_Bool SetPaper( Paper ePaper ); 331 sal_Bool SetPaperSizeUser( const Size& rSize ); 332 sal_Bool SetPaperSizeUser( const Size& rSize, bool bMatchNearest ); 333 Paper GetPaper() const; 334 static rtl::OUString GetPaperName( Paper ePaper ); 335 // return a UI string for the current paper; i_bPaperUser == false means an empty string for PAPER_USER 336 rtl::OUString GetPaperName( bool i_bPaperUser = true ) const; 337 338 // returns number of available paper formats 339 int GetPaperInfoCount() const; 340 // returns info about paper format nPaper 341 const PaperInfo& GetPaperInfo( int nPaper ) const; 342 sal_uInt16 GetPaperBinCount() const; 343 XubString GetPaperBinName( sal_uInt16 nPaperBin ) const; 344 GetPaperSizePixel() const345 const Size& GetPaperSizePixel() const { return maPaperSize; } GetPaperSize() const346 Size GetPaperSize() const { return PixelToLogic( maPaperSize ); } GetPageOffsetPixel() const347 const Point& GetPageOffsetPixel() const { return maPageOffset; } GetPageOffset() const348 Point GetPageOffset() const { return PixelToLogic( maPageOffset ); } 349 350 sal_Bool SetCopyCount( sal_uInt16 nCopy, sal_Bool bCollate = sal_False ); GetCopyCount() const351 sal_uInt16 GetCopyCount() const { return mnCopyCount; } IsCollateCopy() const352 sal_Bool IsCollateCopy() const { return mbCollateCopy; } 353 IsPrinting() const354 sal_Bool IsPrinting() const { return mbPrinting; } 355 356 sal_Bool AbortJob(); GetCurJobName() const357 const XubString& GetCurJobName() const { return maJobName; } GetCurPage() const358 sal_uInt16 GetCurPage() const { return mnCurPage; } IsJobActive() const359 sal_Bool IsJobActive() const { return mbJobActive; } 360 GetError() const361 sal_uLong GetError() const { return ERRCODE_TOERROR(mnError); } GetErrorCode() const362 sal_uLong GetErrorCode() const { return mnError; } 363 SetErrorHdl(const Link & rLink)364 void SetErrorHdl( const Link& rLink ) { maErrorHdl = rLink; } GetErrorHdl() const365 const Link& GetErrorHdl() const { return maErrorHdl; } 366 367 void Compat_OldPrinterMetrics( bool bSet ); 368 369 /** checks the printer list and updates it necessary 370 * 371 * sends a DataChanged event of type DATACHANGED_PRINTER 372 * if the printer list changed 373 */ 374 static void updatePrinters(); 375 376 /** execute a print job 377 378 starts a print job asynchronously (that is will return 379 380 */ 381 static void PrintJob( const boost::shared_ptr<vcl::PrinterController>& i_pController, 382 const JobSetup& i_rInitSetup 383 ); 384 385 // implementation detail of PrintJob being asynchronous 386 // not exported, not usable outside vcl 387 static void SAL_DLLPRIVATE ImplPrintJob( const boost::shared_ptr<vcl::PrinterController>& i_pController, 388 const JobSetup& i_rInitSetup 389 ); 390 }; 391 392 namespace vcl 393 { 394 class ImplPrinterControllerData; 395 396 class VCL_DLLPUBLIC PrinterController 397 { 398 ImplPrinterControllerData* mpImplData; 399 protected: 400 PrinterController( const boost::shared_ptr<Printer>& ); 401 public: 402 enum NupOrderType 403 { LRTB, TBLR, TBRL, RLTB }; 404 struct MultiPageSetup 405 { 406 // all metrics in 100th mm 407 int nRows; 408 int nColumns; 409 int nRepeat; 410 Size aPaperSize; 411 long nLeftMargin; 412 long nTopMargin; 413 long nRightMargin; 414 long nBottomMargin; 415 long nHorizontalSpacing; 416 long nVerticalSpacing; 417 bool bDrawBorder; 418 PrinterController::NupOrderType nOrder; 419 MultiPageSetupvcl::PrinterController::MultiPageSetup420 MultiPageSetup() 421 : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 ) 422 , nLeftMargin( 0 ), nTopMargin( 0 ) 423 , nRightMargin( 0 ), nBottomMargin( 0 ) 424 , nHorizontalSpacing( 0 ), nVerticalSpacing( 0 ) 425 , bDrawBorder( false ) 426 , nOrder( LRTB ) 427 { 428 } 429 }; 430 431 struct PageSize 432 { 433 Size aSize; // in 100th mm 434 bool bFullPaper; // full paper, not only imageable area is printed 435 PageSizevcl::PrinterController::PageSize436 PageSize( const Size& i_rSize = Size( 21000, 29700 ), 437 bool i_bFullPaper = false 438 ) : aSize( i_rSize ), bFullPaper( i_bFullPaper ) {} 439 }; 440 441 PrinterController(); 442 virtual ~PrinterController(); 443 444 const boost::shared_ptr<Printer>& getPrinter() const; 445 /* for implementations: get current job properties as changed by e.g. print dialog 446 this gets the current set of properties initially told to Printer::PrintJob 447 448 For convenience a second sequence will be merged in to get a combined sequence. 449 In case of duplicate property names, the value of i_MergeList wins. 450 */ 451 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > 452 getJobProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rMergeList ) const; 453 454 /* get the PropertyValue of a Property 455 */ 456 com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& i_rPropertyName ); 457 const com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& i_rPropertyName ) const; 458 // get a sequence of properties 459 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getValues( const com::sun::star::uno::Sequence< rtl::OUString >& ) const; 460 /* get a bool property 461 in case the property is unknown or not convertible to bool, i_bFallback is returned 462 */ 463 sal_Bool getBoolProperty( const rtl::OUString& i_rPropertyName, sal_Bool i_bFallback ) const; 464 /* get an int property 465 in case the property is unknown or not convertible to bool, i_nFallback is returned 466 */ 467 sal_Int32 getIntProperty( const rtl::OUString& i_rPropertyName, sal_Int32 i_nFallback ) const; 468 469 /* set a property value - can also be used to add another UI property 470 */ 471 void setValue( const rtl::OUString& i_rPropertyName, const com::sun::star::uno::Any& i_rValue ); 472 void setValue( const com::sun::star::beans::PropertyValue& i_rValue ); 473 474 /* return the currently active UI options. These are the same that were passed to setUIOptions. 475 */ 476 const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& getUIOptions() const; 477 /* set possible UI options. should only be done once before passing the PrinterListener 478 to Printer::PrintJob 479 */ 480 void setUIOptions( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& ); 481 /* enable/disable an option; this can be used to implement dialog logic. 482 */ 483 void enableUIOption( const rtl::OUString& rPropName, bool bEnable ); 484 bool isUIOptionEnabled( const rtl::OUString& rPropName ) const; 485 bool isUIChoiceEnabled( const rtl::OUString& rPropName, sal_Int32 nChoice ) const; 486 /* returns the property name rPropName depends on or an empty string 487 if no dependency exists. 488 */ 489 rtl::OUString getDependency( const rtl::OUString& rPropName ) const; 490 /* makeEnabled will chage the property rPropName depends on to the value 491 that makes rPropName enabled. If the dependency itself is also disabled, 492 no action will be performed. 493 494 returns the property name rPropName depends on or an empty string 495 if no change was made. 496 */ 497 rtl::OUString makeEnabled( const rtl::OUString& rPropName ); 498 499 virtual int getPageCount() const = 0; // must be overloaded by the app 500 /* get the page parameters, namely the jobsetup that should be active for the page 501 (describing among others the physical page size) and the "page size". In writer 502 case this would probably be the same as the JobSetup since writer sets the page size 503 draw/impress for example print their page on the paper set on the printer, 504 possibly adjusting the page size to fit. That means the page size can be different from 505 the paper size. 506 */ 507 // must be overloaded by the app, return page size in 1/100th mm 508 virtual com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParameters( int i_nPage ) const = 0; 509 virtual void printPage( int i_nPage ) const = 0; // must be overloaded by the app 510 virtual void jobStarted(); // will be called after a possible dialog has been shown and the real printjob starts 511 virtual void jobFinished( com::sun::star::view::PrintableState ); 512 513 com::sun::star::view::PrintableState getJobState() const; 514 515 void abortJob(); 516 517 // applications (well, sw) depend on a page request with "IsLastPage" = true 518 // to free resources, else they (well, sw) will crash eventually 519 void triggerAppToFreeResources(); 520 521 bool isShowDialogs() const; 522 bool isDirectPrint() const; 523 524 // implementation details, not usable outside vcl 525 // don't use outside vcl. Some of these are exported for 526 // the benefit of vcl's plugins. 527 // Still: DO NOT USE OUTSIDE VCL 528 VCL_PLUGIN_PUBLIC int getFilteredPageCount(); 529 SAL_DLLPRIVATE PageSize getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false ); 530 VCL_PLUGIN_PUBLIC PageSize getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false ); 531 SAL_DLLPRIVATE void printFilteredPage( int i_nPage ); 532 SAL_DLLPRIVATE void setPrinter( const boost::shared_ptr<Printer>& ); 533 SAL_DLLPRIVATE void setOptionChangeHdl( const Link& ); 534 VCL_PLUGIN_PUBLIC void createProgressDialog(); 535 VCL_PLUGIN_PUBLIC bool isProgressCanceled() const; 536 SAL_DLLPRIVATE void setMultipage( const MultiPageSetup& ); 537 SAL_DLLPRIVATE const MultiPageSetup& getMultipage() const; 538 VCL_PLUGIN_PUBLIC void setLastPage( sal_Bool i_bLastPage ); 539 SAL_DLLPRIVATE void setReversePrint( sal_Bool i_bReverse ); 540 SAL_DLLPRIVATE bool getReversePrint() const; 541 SAL_DLLPRIVATE void pushPropertiesToPrinter(); 542 VCL_PLUGIN_PUBLIC void setJobState( com::sun::star::view::PrintableState ); 543 SAL_DLLPRIVATE bool setupPrinter( Window* i_pDlgParent ); 544 545 SAL_DLLPRIVATE int getPageCountProtected() const; 546 SAL_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParametersProtected( int i_nPage ) const; 547 548 SAL_DLLPRIVATE sal_uLong removeTransparencies( GDIMetaFile& i_rIn, GDIMetaFile& o_rOut ); 549 SAL_DLLPRIVATE void resetPrinterOptions( bool i_bFileOutput ); 550 }; 551 552 class VCL_DLLPUBLIC PrinterOptionsHelper 553 { 554 protected: 555 std::hash_map< rtl::OUString, com::sun::star::uno::Any, rtl::OUStringHash > m_aPropertyMap; 556 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > m_aUIProperties; 557 558 public: PrinterOptionsHelper()559 PrinterOptionsHelper() {} // create without ui properties PrinterOptionsHelper(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & i_rUIProperties)560 PrinterOptionsHelper( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rUIProperties ) 561 : m_aUIProperties( i_rUIProperties ) 562 {} ~PrinterOptionsHelper()563 ~PrinterOptionsHelper() 564 {} 565 566 /* process a new set of properties 567 * merges changed properties and returns "true" if any occured 568 * if the optional output set is not NULL then the names of the changed properties are returned 569 **/ 570 bool processProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp, 571 std::set< rtl::OUString >* o_pChangeProp = NULL ); 572 /* append to a sequence of property values the ui property sequence passed at creation 573 * as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property 574 * will be appended. 575 **/ 576 void appendPrintUIOptions( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& io_rProps ) const; 577 578 // check if a property exists 579 bool hasProperty( const rtl::OUString& i_rPropertyName ) const; hasProperty(const char * i_pPropertyName) const580 bool hasProperty( const char* i_pPropertyName ) const 581 { return hasProperty( rtl::OUString::createFromAscii( i_pPropertyName ) ); } 582 583 // returns an empty Any for not existing properties 584 com::sun::star::uno::Any getValue( const rtl::OUString& i_rPropertyName ) const; 585 // change a value in the property set; this will not have an effect to an eventual PrinterController 586 // the user of setValue must decide whether it is necessary to set the value there also 587 void setValue( const rtl::OUString& i_rPropertyName, const com::sun::star::uno::Any& i_rValue ); setValue(const char * i_pPropertyName,const com::sun::star::uno::Any & i_rValue)588 void setValue( const char* i_pPropertyName, const com::sun::star::uno::Any& i_rValue ) 589 { setValue( rtl::OUString::createFromAscii( i_pPropertyName ), i_rValue ); } 590 591 sal_Bool getBoolValue( const rtl::OUString& i_rPropertyName, sal_Bool i_bDefault = sal_False ) const; 592 // convenience for fixed strings getBoolValue(const char * i_pPropName,sal_Bool i_bDefault=sal_False) const593 sal_Bool getBoolValue( const char* i_pPropName, sal_Bool i_bDefault = sal_False ) const 594 { return getBoolValue( rtl::OUString::createFromAscii( i_pPropName ), i_bDefault ); } 595 596 sal_Int64 getIntValue( const rtl::OUString& i_rPropertyName, sal_Int64 i_nDefault = 0 ) const; 597 // convenience for fixed strings getIntValue(const char * i_pPropName,sal_Int64 i_nDefault=0) const598 sal_Int64 getIntValue( const char* i_pPropName, sal_Int64 i_nDefault = 0 ) const 599 { return getIntValue( rtl::OUString::createFromAscii( i_pPropName ), i_nDefault ); } 600 601 rtl::OUString getStringValue( const rtl::OUString& i_rPropertyName, const rtl::OUString& i_rDefault = rtl::OUString() ) const; 602 // convenience for fixed strings getStringValue(const char * i_pPropName,const rtl::OUString & i_rDefault=rtl::OUString ()) const603 rtl::OUString getStringValue( const char* i_pPropName, const rtl::OUString& i_rDefault = rtl::OUString() ) const 604 { return getStringValue( rtl::OUString::createFromAscii( i_pPropName ), i_rDefault ); } 605 606 // helper functions for user to create a single control 607 struct UIControlOptions 608 { 609 rtl::OUString maDependsOnName; 610 sal_Int32 mnDependsOnEntry; 611 sal_Bool mbAttachToDependency; 612 rtl::OUString maGroupHint; 613 sal_Bool mbInternalOnly; 614 sal_Bool mbEnabled; 615 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > maAddProps; 616 UIControlOptionsvcl::PrinterOptionsHelper::UIControlOptions617 UIControlOptions( const rtl::OUString& i_rDependsOnName = rtl::OUString(), 618 sal_Int32 i_nDependsOnEntry = -1, 619 sal_Bool i_bAttachToDependency = sal_False, 620 const rtl::OUString& i_rGroupHint = rtl::OUString(), 621 sal_Bool i_bInternalOnly = sal_False, 622 sal_Bool i_bEnabled = sal_True 623 ) 624 : maDependsOnName( i_rDependsOnName ) 625 , mnDependsOnEntry( i_nDependsOnEntry ) 626 , mbAttachToDependency( i_bAttachToDependency ) 627 , maGroupHint( i_rGroupHint ) 628 , mbInternalOnly( i_bInternalOnly ) 629 , mbEnabled( i_bEnabled ) {} 630 }; 631 632 // note: in the following helper functions HelpIds are expected as an rtl::OUString 633 // the normal HelpId form is rtl::OString (byte string instead of UTF16 string) 634 // this is because the whole interface is base on UNO properties; in fact the structures 635 // are passed over UNO interfaces. UNO does not know a byte string, hence the string is 636 // transported via UTF16 strings. 637 638 // general control 639 static com::sun::star::uno::Any getUIControlOpt( const rtl::OUString& i_rTitle, 640 const com::sun::star::uno::Sequence< rtl::OUString >& i_rHelpId, 641 const rtl::OUString& i_rType, 642 const com::sun::star::beans::PropertyValue* i_pValue = NULL, 643 const UIControlOptions& i_rControlOptions = UIControlOptions() 644 ); 645 // create a group (e.g. a TabPage); following controls will be grouped in it until the next 646 // group begins 647 static com::sun::star::uno::Any getGroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpId ); 648 649 // create a subgroup (e.g. a FixedLine); following controls will be grouped in it until the next 650 // subgroup or group begins 651 // setting bJobPage = true will make the subgroup appear on the first page of the print dialog 652 static com::sun::star::uno::Any getSubgroupControlOpt( const rtl::OUString& i_rTitle, 653 const rtl::OUString& i_rHelpId, 654 const UIControlOptions& i_rControlOptions = UIControlOptions() 655 ); 656 657 // create a bool option (usually a checkbox) 658 static com::sun::star::uno::Any getBoolControlOpt( const rtl::OUString& i_rTitle, 659 const rtl::OUString& i_rHelpId, 660 const rtl::OUString& i_rProperty, 661 sal_Bool i_bValue, 662 const UIControlOptions& i_rControlOptions = UIControlOptions() 663 ); 664 665 // create a set of choices (either a radio button group or a list box) 666 static com::sun::star::uno::Any getChoiceControlOpt( const rtl::OUString& i_rTitle, 667 const com::sun::star::uno::Sequence< rtl::OUString >& i_rHelpId, 668 const rtl::OUString& i_rProperty, 669 const com::sun::star::uno::Sequence< rtl::OUString >& i_rChoices, 670 sal_Int32 i_nValue, 671 const rtl::OUString& i_rType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Radio" ) ), 672 const com::sun::star::uno::Sequence< sal_Bool >& i_rDisabledChoices = com::sun::star::uno::Sequence< sal_Bool >(), 673 const UIControlOptions& i_rControlOptions = UIControlOptions() 674 ); 675 676 // create an integer range (e.g. a spin field) 677 // note: max value < min value means do not apply min/max values 678 static com::sun::star::uno::Any getRangeControlOpt( const rtl::OUString& i_rTitle, 679 const rtl::OUString& i_rHelpId, 680 const rtl::OUString& i_rProperty, 681 sal_Int32 i_nValue, 682 sal_Int32 i_nMinValue = -1, 683 sal_Int32 i_nMaxValue = -2, 684 const UIControlOptions& i_rControlOptions = UIControlOptions() 685 ); 686 687 // create a string field 688 // note: max value < min value means do not apply min/max values 689 static com::sun::star::uno::Any getEditControlOpt( const rtl::OUString& i_rTitle, 690 const rtl::OUString& i_rHelpId, 691 const rtl::OUString& i_rProperty, 692 const rtl::OUString& i_rValue, 693 const UIControlOptions& i_rControlOptions = UIControlOptions() 694 ); 695 }; 696 697 } 698 699 700 #endif // _SV_PRINT_HXX 701