LCOV - code coverage report
Current view: top level - libreoffice/vcl/inc/vcl - print.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 11 0.0 %
Date: 2012-12-27 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          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             : 
      20             : #ifndef _SV_PRINT_HXX
      21             : #define _SV_PRINT_HXX
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : 
      25             : #include "tools/errcode.hxx"
      26             : #include "tools/solar.h"
      27             : #include "vcl/dllapi.h"
      28             : #include "vcl/outdev.hxx"
      29             : #include "vcl/prntypes.hxx"
      30             : #include "vcl/jobset.hxx"
      31             : #include "vcl/gdimtf.hxx"
      32             : #include "tools/stream.hxx"
      33             : #include "tools/multisel.hxx"
      34             : 
      35             : #include "com/sun/star/beans/PropertyValue.hpp"
      36             : #include "com/sun/star/view/PrintableState.hpp"
      37             : 
      38             : #include <boost/shared_ptr.hpp>
      39             : #include <boost/unordered_map.hpp>
      40             : #include <set>
      41             : 
      42             : class SalInfoPrinter;
      43             : struct SalPrinterQueueInfo;
      44             : class SalPrinter;
      45             : class VirtualDevice;
      46             : class Window;
      47             : 
      48             : namespace vcl {
      49             :     class PrinterController;
      50             :     class PrintDialog;
      51             : }
      52             : 
      53             : // -----------------
      54             : // - Printer-Types -
      55             : // -----------------
      56             : 
      57             : #define PAGEQUEUE_ALLPAGES   0xFFFF
      58             : 
      59             : enum PrinterSupport { SUPPORT_SET_ORIENTATION, SUPPORT_SET_PAPERBIN,
      60             :                       SUPPORT_SET_PAPERSIZE, SUPPORT_SET_PAPER,
      61             :                       SUPPORT_COPY, SUPPORT_COLLATECOPY,
      62             :                       SUPPORT_SETUPDIALOG, SUPPORT_FAX, SUPPORT_PDF };
      63             : 
      64             : // ---------------
      65             : // - PrinterPage -
      66             : // ---------------
      67             : 
      68             : class VCL_DLLPUBLIC PrinterPage
      69             : {
      70             :     GDIMetaFile*    mpMtf;
      71             :     JobSetup        maJobSetup;
      72             :     sal_uInt16          mbNewJobSetup;
      73             : 
      74             : public:
      75             : 
      76             :     PrinterPage() : mpMtf( new GDIMetaFile() ) {}
      77             :     PrinterPage( GDIMetaFile* pMtf, sal_Bool bNewJobSetup, const JobSetup& rSetup ) :
      78             :            mpMtf( pMtf ), maJobSetup( rSetup ), mbNewJobSetup( bNewJobSetup ) {}
      79             :     ~PrinterPage() { delete mpMtf; }
      80             : 
      81             :     GDIMetaFile*    GetGDIMetaFile() const { return mpMtf; }
      82             :     const JobSetup& GetJobSetup() const { return maJobSetup; }
      83             :     sal_Bool            IsNewJobSetup() const { return (mbNewJobSetup != 0); }
      84             : };
      85             : 
      86             : 
      87             : // -------------
      88             : // - QueueInfo -
      89             : // -------------
      90             : 
      91             : class VCL_DLLPUBLIC QueueInfo
      92             : {
      93             :     friend class Printer;
      94             : 
      95             : private:
      96             :     rtl::OUString                   maPrinterName;
      97             :     rtl::OUString                   maDriver;
      98             :     rtl::OUString                   maLocation;
      99             :     rtl::OUString                   maComment;
     100             :     sal_uInt32                  mnStatus;
     101             :     sal_uInt32                  mnJobs;
     102             : 
     103             : public:
     104             :                                 QueueInfo();
     105             :                                 QueueInfo( const QueueInfo& rInfo );
     106             :                                 ~QueueInfo();
     107             : 
     108           0 :     const rtl::OUString&            GetPrinterName() const { return maPrinterName; }
     109             :     const rtl::OUString&            GetDriver() const { return maDriver; }
     110           0 :     const rtl::OUString&            GetLocation() const { return maLocation; }
     111           0 :     const rtl::OUString&            GetComment() const { return maComment; }
     112             :     sal_uInt32                  GetStatus() const { return mnStatus; }
     113             :     sal_uInt32                  GetJobs() const { return mnJobs; }
     114             : 
     115             :     bool operator==( const QueueInfo& rInfo ) const;
     116             : 
     117             :     friend VCL_DLLPUBLIC SvStream&          operator>>( SvStream& rIStream, QueueInfo& rInfo );
     118             :     friend VCL_DLLPUBLIC SvStream&          operator<<( SvStream& rOStream, const QueueInfo& rInfo );
     119             : };
     120             : 
     121             : // ------------------
     122             : // - PrinterOptions -
     123             : // ------------------
     124             : 
     125             : enum PrinterTransparencyMode
     126             : {
     127             :     PRINTER_TRANSPARENCY_AUTO = 0,
     128             :     PRINTER_TRANSPARENCY_NONE = 1
     129             : };
     130             : 
     131             : // -----------------------------------------------------------------------------
     132             : 
     133             : enum PrinterGradientMode
     134             : {
     135             :     PRINTER_GRADIENT_STRIPES = 0,
     136             :     PRINTER_GRADIENT_COLOR = 1
     137             : };
     138             : 
     139             : // -----------------------------------------------------------------------------
     140             : 
     141             : enum PrinterBitmapMode
     142             : {
     143             :     PRINTER_BITMAP_OPTIMAL = 0,
     144             :     PRINTER_BITMAP_NORMAL = 1,
     145             :     PRINTER_BITMAP_RESOLUTION = 2
     146             : };
     147             : 
     148             : // -----------------------------------------------------------------------------
     149             : 
     150             : class VCL_DLLPUBLIC PrinterOptions
     151             : {
     152             : private:
     153             : 
     154             :     sal_Bool                        mbReduceTransparency;
     155             :     PrinterTransparencyMode     meReducedTransparencyMode;
     156             :     sal_Bool                        mbReduceGradients;
     157             :     PrinterGradientMode         meReducedGradientsMode;
     158             :     sal_uInt16                      mnReducedGradientStepCount;
     159             :     sal_Bool                        mbReduceBitmaps;
     160             :     PrinterBitmapMode           meReducedBitmapMode;
     161             :     sal_uInt16                      mnReducedBitmapResolution;
     162             :     sal_Bool                        mbReducedBitmapsIncludeTransparency;
     163             :     sal_Bool                        mbConvertToGreyscales;
     164             :     sal_Bool                        mbPDFAsStandardPrintJobFormat;
     165             : 
     166             : public:
     167             : 
     168             :                                 PrinterOptions();
     169             :                                 ~PrinterOptions();
     170             : 
     171             :     sal_Bool                        IsReduceTransparency() const { return mbReduceTransparency; }
     172             :     void                        SetReduceTransparency( sal_Bool bSet ) { mbReduceTransparency = bSet; }
     173             : 
     174             :     PrinterTransparencyMode     GetReducedTransparencyMode() const { return meReducedTransparencyMode; }
     175             :     void                        SetReducedTransparencyMode( PrinterTransparencyMode eMode ) { meReducedTransparencyMode = eMode; }
     176             : 
     177             :     sal_Bool                        IsReduceGradients() const { return mbReduceGradients; }
     178             :     void                        SetReduceGradients( sal_Bool bSet ) { mbReduceGradients = bSet; }
     179             : 
     180             :     PrinterGradientMode         GetReducedGradientMode() const { return meReducedGradientsMode; }
     181             :     void                        SetReducedGradientMode( PrinterGradientMode eMode ) { meReducedGradientsMode = eMode; }
     182             : 
     183             :     sal_uInt16                      GetReducedGradientStepCount() const { return mnReducedGradientStepCount; }
     184             :     void                        SetReducedGradientStepCount( sal_uInt16 nStepCount ) { mnReducedGradientStepCount = nStepCount; }
     185             : 
     186             :     sal_Bool                        IsReduceBitmaps() const { return mbReduceBitmaps; }
     187             :     void                        SetReduceBitmaps( sal_Bool bSet ) { mbReduceBitmaps = bSet; }
     188             : 
     189             :     PrinterBitmapMode           GetReducedBitmapMode() const { return meReducedBitmapMode; }
     190             :     void                        SetReducedBitmapMode( PrinterBitmapMode eMode ) { meReducedBitmapMode = eMode; }
     191             : 
     192             :     sal_uInt16                      GetReducedBitmapResolution() const { return mnReducedBitmapResolution; }
     193             :     void                        SetReducedBitmapResolution( sal_uInt16 nResolution ) { mnReducedBitmapResolution = nResolution; }
     194             : 
     195             :     sal_Bool                        IsReducedBitmapIncludesTransparency() const { return mbReducedBitmapsIncludeTransparency; }
     196             :     void                        SetReducedBitmapIncludesTransparency( sal_Bool bSet ) { mbReducedBitmapsIncludeTransparency = bSet; }
     197             : 
     198           0 :     sal_Bool                        IsConvertToGreyscales() const { return mbConvertToGreyscales; }
     199             :     void                        SetConvertToGreyscales( sal_Bool bSet ) { mbConvertToGreyscales = bSet; }
     200             : 
     201             :     sal_Bool                        IsPDFAsStandardPrintJobFormat() const { return mbPDFAsStandardPrintJobFormat; }
     202             :     void                        SetPDFAsStandardPrintJobFormat( sal_Bool bSet ) { mbPDFAsStandardPrintJobFormat = bSet; }
     203             : 
     204             :     // read printer options from configuration, parameter decides whether the set for
     205             :     // print "to printer" or "to file" should be read.
     206             :     // returns true if config was read, false if an error occured
     207             :     bool                        ReadFromConfig( bool bFile );
     208             : };
     209             : 
     210             : // -----------
     211             : // - Printer -
     212             : // -----------
     213             : 
     214             : class VCL_DLLPUBLIC Printer : public OutputDevice
     215             : {
     216             :     friend class OutputDevice;
     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             :     rtl::OUString                   maPrinterName;
     227             :     rtl::OUString                   maDriver;
     228             :     rtl::OUString                   maPrintFile;
     229             :     rtl::OUString                   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 rtl::OUString& rPrinterName,
     254             :                                                   const rtl::OUString* pDriver );
     255             :     SAL_DLLPRIVATE void         ImplUpdatePageData();
     256             :     SAL_DLLPRIVATE void         ImplUpdateFontList();
     257             :     SAL_DLLPRIVATE void         ImplFindPaperFormatForUserSize( JobSetup&, bool bMatchNearest );
     258             : 
     259             :     SAL_DLLPRIVATE bool StartJob( const rtl::OUString& rJobName, boost::shared_ptr<vcl::PrinterController>& );
     260             : 
     261             :     static SAL_DLLPRIVATE sal_uLong ImplSalPrinterErrorCodeToVCL( sal_uLong nError );
     262             : 
     263             : private:
     264             :     SAL_DLLPRIVATE sal_Bool         EndJob();
     265             :     SAL_DLLPRIVATE              Printer( const Printer& rPrinter );
     266             :     SAL_DLLPRIVATE Printer&     operator =( const Printer& rPrinter );
     267             : public:
     268             :     SAL_DLLPRIVATE void         ImplStartPage();
     269             :     SAL_DLLPRIVATE void         ImplEndPage();
     270             : public:
     271             :     void                        DrawGradientEx( OutputDevice* pOut, const Rectangle& rRect, const Gradient& rGradient );
     272             : 
     273             : protected:
     274             : 
     275             :     void                        SetSelfAsQueuePrinter( sal_Bool bQueuePrinter ) { mbIsQueuePrinter = bQueuePrinter; }
     276             :     sal_Bool                        IsQueuePrinter() const { return mbIsQueuePrinter; }
     277             : 
     278             : public:
     279             :                                 Printer();
     280             :                                 Printer( const JobSetup& rJobSetup );
     281             :                                 Printer( const QueueInfo& rQueueInfo );
     282             :                                 Printer( const rtl::OUString& rPrinterName );
     283             :     virtual                     ~Printer();
     284             : 
     285             :     static const std::vector< rtl::OUString >& GetPrinterQueues();
     286             :     static const QueueInfo*     GetQueueInfo( const rtl::OUString& rPrinterName, bool bStatusUpdate );
     287             :     static rtl::OUString            GetDefaultPrinterName();
     288             : 
     289             :     virtual void                Error();
     290             : 
     291           0 :     const rtl::OUString&            GetName() const             { return maPrinterName; }
     292             :     const rtl::OUString&            GetDriverName() const       { return maDriver; }
     293             :     sal_Bool                        IsDefPrinter() const        { return mbDefPrinter; }
     294             :     sal_Bool                        IsDisplayPrinter() const    { return mpDisplayDev != NULL; }
     295             :     sal_Bool                        IsValid() const             { return !IsDisplayPrinter(); }
     296             : 
     297             :     sal_uLong                       GetCapabilities( sal_uInt16 nType ) const;
     298             :     sal_Bool                        HasSupport( PrinterSupport eFeature ) const;
     299             : 
     300             :     sal_Bool                        SetJobSetup( const JobSetup& rSetup );
     301             :     const JobSetup&             GetJobSetup() const { return maJobSetup; }
     302             :     void                        SetJobValue( const rtl::OUString& rKey, const rtl::OUString& rValue ) { maJobSetup.SetValue( rKey, rValue ); }
     303             : 
     304             :     sal_Bool                        Setup( Window* pWindow = NULL );
     305             :     sal_Bool                        SetPrinterProps( const Printer* pPrinter );
     306             : 
     307             :     // SetPrinterOptions is used internally only now
     308             :     // in earlier times it was used only to set the options loaded directly from the configuration
     309             :     // in SfxPrinter::InitJob, this is now handled internally
     310             :     // should the need arise to set the printer options outside vcl, also a method would have to be devised
     311             :     // to not override these again internally
     312             :     SAL_DLLPRIVATE void         SetPrinterOptions( const PrinterOptions& rOptions );
     313           0 :     const PrinterOptions&       GetPrinterOptions() const { return( *mpPrinterOptions ); }
     314             : 
     315             :     sal_Bool                        SetOrientation( Orientation eOrient );
     316             :     Orientation                 GetOrientation() const;
     317             :     sal_Bool                        SetDuplexMode( DuplexMode );
     318             :     // returns the angle that a landscape page will be turned counterclockwise
     319             :     // wrt to portrait. The return value may be only valid for
     320             :     // the current paper
     321             :     int                         GetLandscapeAngle() const;
     322             :     sal_Bool                        SetPaperBin( sal_uInt16 nPaperBin );
     323             :     sal_uInt16                      GetPaperBin() const;
     324             :     sal_Bool                        SetPaper( Paper ePaper );
     325             :     sal_Bool                        SetPaperSizeUser( const Size& rSize );
     326             :     sal_Bool                        SetPaperSizeUser( const Size& rSize, bool bMatchNearest );
     327             :     Paper                   GetPaper() const;
     328             :     static rtl::OUString        GetPaperName( Paper ePaper );
     329             :     // return a UI string for the current paper; i_bPaperUser == false means an empty string for PAPER_USER
     330             :     rtl::OUString               GetPaperName( bool i_bPaperUser = true ) const;
     331             : 
     332             :     // returns number of available paper formats
     333             :     int                         GetPaperInfoCount() const;
     334             :     // returns info about paper format nPaper
     335             :     const PaperInfo&            GetPaperInfo( int nPaper ) const;
     336             :     sal_uInt16                      GetPaperBinCount() const;
     337             :     rtl::OUString                   GetPaperBinName( sal_uInt16 nPaperBin ) const;
     338             : 
     339           0 :     const Size&                 GetPaperSizePixel() const { return maPaperSize; }
     340             :     Size                        GetPaperSize() const { return PixelToLogic( maPaperSize ); }
     341           0 :     const Point&                GetPageOffsetPixel() const { return maPageOffset; }
     342             :     Point                       GetPageOffset() const { return PixelToLogic( maPageOffset ); }
     343             : 
     344             :     sal_Bool                        SetCopyCount( sal_uInt16 nCopy, sal_Bool bCollate = sal_False );
     345             :     sal_uInt16                      GetCopyCount() const { return mnCopyCount; }
     346             :     sal_Bool                        IsCollateCopy() const { return mbCollateCopy; }
     347             : 
     348             :     sal_Bool                        IsPrinting() const { return mbPrinting; }
     349             : 
     350             :     const rtl::OUString&            GetCurJobName() const { return maJobName; }
     351             :     sal_uInt16                      GetCurPage() const { return mnCurPage; }
     352             :     sal_Bool                        IsJobActive() const { return mbJobActive; }
     353             : 
     354             :     sal_uLong                       GetError() const { return ERRCODE_TOERROR(mnError); }
     355             :     sal_uLong                       GetErrorCode() const { return mnError; }
     356             : 
     357             :     void                        SetErrorHdl( const Link& rLink ) { maErrorHdl = rLink; }
     358             :     const Link&                 GetErrorHdl() const { return maErrorHdl; }
     359             : 
     360             :     void                        Compat_OldPrinterMetrics( bool bSet );
     361             : 
     362             :     /** checks the printer list and updates it necessary
     363             :     *
     364             :     *   sends a DataChanged event of type DATACHANGED_PRINTER
     365             :     *   if the printer list changed
     366             :     */
     367             :     static void updatePrinters();
     368             : 
     369             :     /** execute a print job
     370             : 
     371             :         starts a print job asynchronously (that is will return
     372             : 
     373             :     */
     374             :     static void PrintJob( const boost::shared_ptr<vcl::PrinterController>& i_pController,
     375             :                           const JobSetup& i_rInitSetup
     376             :                           );
     377             : 
     378             :     // implementation detail of PrintJob being asynchronous
     379             :     // not exported, not usable outside vcl
     380             :     static void SAL_DLLPRIVATE ImplPrintJob( const boost::shared_ptr<vcl::PrinterController>& i_pController,
     381             :                                              const JobSetup& i_rInitSetup
     382             :                                              );
     383             : };
     384             : 
     385             : namespace vcl
     386             : {
     387             : class ImplPrinterControllerData;
     388             : 
     389             : class VCL_DLLPUBLIC PrinterController
     390             : {
     391             :     ImplPrinterControllerData* mpImplData;
     392             : protected:
     393             :     PrinterController( const boost::shared_ptr<Printer>& );
     394             : public:
     395             :     enum NupOrderType
     396             :     { LRTB, TBLR, TBRL, RLTB };
     397             :     struct MultiPageSetup
     398             :     {
     399             :         // all metrics in 100th mm
     400             :         int                                    nRows;
     401             :         int                                    nColumns;
     402             :         int                                    nRepeat;
     403             :         Size                                   aPaperSize;
     404             :         long                                   nLeftMargin;
     405             :         long                                   nTopMargin;
     406             :         long                                   nRightMargin;
     407             :         long                                   nBottomMargin;
     408             :         long                                   nHorizontalSpacing;
     409             :         long                                   nVerticalSpacing;
     410             :         bool                                   bDrawBorder;
     411             :         PrinterController::NupOrderType        nOrder;
     412             : 
     413           0 :         MultiPageSetup()
     414             :         : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 )
     415             :         , nLeftMargin( 0 ), nTopMargin( 0 )
     416             :         , nRightMargin( 0 ), nBottomMargin( 0 )
     417             :         , nHorizontalSpacing( 0 ), nVerticalSpacing( 0 )
     418             :         , bDrawBorder( false )
     419           0 :         , nOrder( LRTB )
     420             :         {
     421           0 :         }
     422             :     };
     423             : 
     424             :     struct PageSize
     425             :     {
     426             :         Size        aSize;          // in 100th mm
     427             :         bool        bFullPaper;     // full paper, not only imageable area is printed
     428             : 
     429             :         PageSize( const Size& i_rSize = Size( 21000, 29700 ),
     430             :                   bool i_bFullPaper = false
     431             :                   ) : aSize( i_rSize ), bFullPaper( i_bFullPaper ) {}
     432             :     };
     433             : 
     434             :     virtual ~PrinterController();
     435             : 
     436             :     const boost::shared_ptr<Printer>& getPrinter() const;
     437             :     /* for implementations: get current job properties as changed by e.g. print dialog
     438             :        this gets the current set of properties initially told to Printer::PrintJob
     439             : 
     440             :        For convenience a second sequence will be merged in to get a combined sequence.
     441             :        In case of duplicate property names, the value of i_MergeList wins.
     442             :     */
     443             :     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >
     444             :         getJobProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rMergeList ) const;
     445             : 
     446             :     /* get the PropertyValue of a Property
     447             :     */
     448             :     com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& i_rPropertyName );
     449             :     const com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& i_rPropertyName ) const;
     450             :     /* get a bool property
     451             :        in case the property is unknown or not convertible to bool, i_bFallback is returned
     452             :     */
     453             :     sal_Bool getBoolProperty( const rtl::OUString& i_rPropertyName, sal_Bool i_bFallback ) const;
     454             :     /* get an int property
     455             :        in case the property is unknown or not convertible to bool, i_nFallback is returned
     456             :     */
     457             :     sal_Int32 getIntProperty( const rtl::OUString& i_rPropertyName, sal_Int32 i_nFallback ) const;
     458             : 
     459             :     /* set a property value - can also be used to add another UI property
     460             :     */
     461             :     void setValue( const rtl::OUString& i_rPropertyName, const com::sun::star::uno::Any& i_rValue );
     462             :     void setValue( const com::sun::star::beans::PropertyValue& i_rValue );
     463             : 
     464             :     /* return the currently active UI options. These are the same that were passed to setUIOptions.
     465             :     */
     466             :     const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& getUIOptions() const;
     467             :     /* set possible UI options. should only be done once before passing the PrinterListener
     468             :        to Printer::PrintJob
     469             :     */
     470             :     void setUIOptions( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& );
     471             :     /* enable/disable an option; this can be used to implement dialog logic.
     472             :     */
     473             :     bool isUIOptionEnabled( const rtl::OUString& rPropName ) const;
     474             :     bool isUIChoiceEnabled( const rtl::OUString& rPropName, sal_Int32 nChoice ) const;
     475             :     /* returns the property name rPropName depends on or an empty string
     476             :        if no dependency exists.
     477             :     */
     478             :     rtl::OUString getDependency( const rtl::OUString& rPropName ) const;
     479             :     /* makeEnabled will chage the property rPropName depends on to the value
     480             :        that makes rPropName enabled. If the dependency itself is also disabled,
     481             :        no action will be performed.
     482             : 
     483             :        returns the property name rPropName depends on or an empty string
     484             :        if no change was made.
     485             :     */
     486             :     rtl::OUString makeEnabled( const rtl::OUString& rPropName );
     487             : 
     488             :     virtual int  getPageCount() const = 0; // must be overloaded by the app
     489             :     /* get the page parameters, namely the jobsetup that should be active for the page
     490             :        (describing among others the physical page size) and the "page size". In writer
     491             :        case this would probably be the same as the JobSetup since writer sets the page size
     492             :        draw/impress for example print their page on the paper set on the printer,
     493             :        possibly adjusting the page size to fit. That means the page size can be different from
     494             :        the paper size.
     495             :     */
     496             :     // must be overloaded by the app, return page size in 1/100th mm
     497             :     virtual com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParameters( int i_nPage ) const = 0;
     498             :     virtual void printPage( int i_nPage ) const = 0; // must be overloaded by the app
     499             :     virtual void jobStarted(); // will be called after a possible dialog has been shown and the real printjob starts
     500             :     virtual void jobFinished( com::sun::star::view::PrintableState );
     501             : 
     502             :     com::sun::star::view::PrintableState getJobState() const;
     503             : 
     504             :     void abortJob();
     505             : 
     506             :     bool isShowDialogs() const;
     507             :     bool isDirectPrint() const;
     508             : 
     509             :     // implementation details, not usable outside vcl
     510             :     // don't use outside vcl. Some of these are exported for
     511             :     // the benefit of vcl's plugins.
     512             :     // Still: DO NOT USE OUTSIDE VCL
     513             :     VCL_PLUGIN_PUBLIC int getFilteredPageCount();
     514             :     SAL_DLLPRIVATE PageSize getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false );
     515             :     VCL_PLUGIN_PUBLIC PageSize getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false );
     516             :     VCL_PLUGIN_PUBLIC void printFilteredPage( int i_nPage );
     517             :     SAL_DLLPRIVATE void setPrinter( const boost::shared_ptr<Printer>& );
     518             :     SAL_DLLPRIVATE void setOptionChangeHdl( const Link& );
     519             :     VCL_PLUGIN_PUBLIC void createProgressDialog();
     520             :     VCL_PLUGIN_PUBLIC bool isProgressCanceled() const;
     521             :     SAL_DLLPRIVATE void setMultipage( const MultiPageSetup& );
     522             :     SAL_DLLPRIVATE const MultiPageSetup& getMultipage() const;
     523             :     VCL_PLUGIN_PUBLIC void setLastPage( sal_Bool i_bLastPage );
     524             :     SAL_DLLPRIVATE void setReversePrint( sal_Bool i_bReverse );
     525             :     SAL_DLLPRIVATE bool getReversePrint() const;
     526             :     SAL_DLLPRIVATE void pushPropertiesToPrinter();
     527             :     VCL_PLUGIN_PUBLIC void setJobState( com::sun::star::view::PrintableState );
     528             :     SAL_DLLPRIVATE bool setupPrinter( Window* i_pDlgParent );
     529             : 
     530             :     SAL_DLLPRIVATE int getPageCountProtected() const;
     531             :     SAL_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParametersProtected( int i_nPage ) const;
     532             : 
     533             :     SAL_DLLPRIVATE sal_uLong removeTransparencies( GDIMetaFile& i_rIn, GDIMetaFile& o_rOut );
     534             :     SAL_DLLPRIVATE void resetPrinterOptions( bool i_bFileOutput );
     535             : };
     536             : 
     537             : class VCL_DLLPUBLIC PrinterOptionsHelper
     538             : {
     539             :     protected:
     540             :     boost::unordered_map< rtl::OUString, com::sun::star::uno::Any, rtl::OUStringHash >        m_aPropertyMap;
     541             :     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >              m_aUIProperties;
     542             : 
     543             :     public:
     544             :     PrinterOptionsHelper() {} // create without ui properties
     545             :     PrinterOptionsHelper( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rUIProperties )
     546             :     : m_aUIProperties( i_rUIProperties )
     547             :     {}
     548             :     ~PrinterOptionsHelper()
     549             :     {}
     550             : 
     551             :     /* process a new set of properties
     552             :      * merges changed properties and returns "true" if any occurred
     553             :      * if the optional output set is not NULL then the names of the changed properties are returned
     554             :     **/
     555             :     bool processProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp,
     556             :                             std::set< rtl::OUString >* o_pChangeProp = NULL );
     557             :     /* append  to a sequence of property values the ui property sequence passed at creation
     558             :      * as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property
     559             :      * will be appended.
     560             :     **/
     561             :     void appendPrintUIOptions( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& io_rProps ) const;
     562             : 
     563             :     // returns an empty Any for not existing properties
     564             :     com::sun::star::uno::Any getValue( const rtl::OUString& i_rPropertyName ) const;
     565             : 
     566             :     sal_Bool getBoolValue( const rtl::OUString& i_rPropertyName, sal_Bool i_bDefault = sal_False ) const;
     567             :     // convenience for fixed strings
     568             :     sal_Bool getBoolValue( const char* i_pPropName, sal_Bool i_bDefault = sal_False ) const
     569             :     { return getBoolValue( rtl::OUString::createFromAscii( i_pPropName ), i_bDefault ); }
     570             : 
     571             :     sal_Int64 getIntValue( const rtl::OUString& i_rPropertyName, sal_Int64 i_nDefault = 0 ) const;
     572             :     // convenience for fixed strings
     573             :     sal_Int64 getIntValue( const char* i_pPropName, sal_Int64 i_nDefault = 0 ) const
     574             :     { return getIntValue( rtl::OUString::createFromAscii( i_pPropName ), i_nDefault ); }
     575             : 
     576             :     rtl::OUString getStringValue( const rtl::OUString& i_rPropertyName, const rtl::OUString& i_rDefault = rtl::OUString() ) const;
     577             :     // convenience for fixed strings
     578             :     rtl::OUString getStringValue( const char* i_pPropName, const rtl::OUString& i_rDefault = rtl::OUString() ) const
     579             :     { return getStringValue( rtl::OUString::createFromAscii( i_pPropName ), i_rDefault ); }
     580             : 
     581             :     // helper functions for user to create a single control
     582             :     struct UIControlOptions
     583             :     {
     584             :         rtl::OUString   maDependsOnName;
     585             :         sal_Int32       mnDependsOnEntry;
     586             :         sal_Bool        mbAttachToDependency;
     587             :         rtl::OUString   maGroupHint;
     588             :         sal_Bool        mbInternalOnly;
     589             :         sal_Bool        mbEnabled;
     590             :         com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > maAddProps;
     591             : 
     592             :         UIControlOptions( const rtl::OUString& i_rDependsOnName = rtl::OUString(),
     593             :                           sal_Int32 i_nDependsOnEntry = -1,
     594             :                           sal_Bool i_bAttachToDependency = sal_False,
     595             :                           const rtl::OUString& i_rGroupHint = rtl::OUString(),
     596             :                           sal_Bool i_bInternalOnly = sal_False,
     597             :                           sal_Bool i_bEnabled = sal_True
     598             :                          )
     599             :         : maDependsOnName( i_rDependsOnName )
     600             :         , mnDependsOnEntry( i_nDependsOnEntry )
     601             :         , mbAttachToDependency( i_bAttachToDependency )
     602             :         , maGroupHint( i_rGroupHint )
     603             :         , mbInternalOnly( i_bInternalOnly )
     604             :         , mbEnabled( i_bEnabled ) {}
     605             :     };
     606             : 
     607             :     // note: in the following helper functions HelpIds are expected as an rtl::OUString
     608             :     // the normal HelpId form is rtl::OString (byte string instead of UTF16 string)
     609             :     // this is because the whole interface is base on UNO properties; in fact the structures
     610             :     // are passed over UNO interfaces. UNO does not know a byte string, hence the string is
     611             :     // transported via UTF16 strings.
     612             : 
     613             :     // Show general control
     614             :     static com::sun::star::uno::Any setUIControlOpt( const com::sun::star::uno::Sequence< rtl::OUString >& i_rIDs,
     615             :                                                      const rtl::OUString& i_rTitle,
     616             :                                                      const com::sun::star::uno::Sequence< rtl::OUString >& i_rHelpId,
     617             :                                                      const rtl::OUString& i_rType,
     618             :                                                      const com::sun::star::beans::PropertyValue* i_pValue = NULL,
     619             :                                                      const UIControlOptions& i_rControlOptions = UIControlOptions()
     620             :                                                      );
     621             : 
     622             :     // Show and set the title of a TagPage of id i_rID
     623             :     static com::sun::star::uno::Any setGroupControlOpt(const rtl::OUString& i_rID,
     624             :                                                        const rtl::OUString& i_rTitle,
     625             :                                                        const rtl::OUString& i_rHelpId);
     626             : 
     627             :     // Show and set the label of a VclFrame of id i_rID
     628             :     static com::sun::star::uno::Any setSubgroupControlOpt(const rtl::OUString& i_rID,
     629             :                                                           const rtl::OUString& i_rTitle,
     630             :                                                           const rtl::OUString& i_rHelpId,
     631             :                                                           const UIControlOptions& i_rControlOptions = UIControlOptions());
     632             : 
     633             :     // Show a bool option as a checkbox
     634             :     static com::sun::star::uno::Any setBoolControlOpt(const rtl::OUString& i_rID,
     635             :                                                       const rtl::OUString& i_rTitle,
     636             :                                                       const rtl::OUString& i_rHelpId,
     637             :                                                       const rtl::OUString& i_rProperty,
     638             :                                                       sal_Bool i_bValue,
     639             :                                                       const UIControlOptions& i_rControlOptions = UIControlOptions());
     640             : 
     641             :     // Show a set of choices in a list box
     642             :     static com::sun::star::uno::Any setChoiceListControlOpt(const rtl::OUString& i_rID,
     643             :                                                             const rtl::OUString& i_rTitle,
     644             :                                                             const com::sun::star::uno::Sequence< rtl::OUString >& i_rHelpId,
     645             :                                                             const rtl::OUString& i_rProperty,
     646             :                                                             const com::sun::star::uno::Sequence< rtl::OUString >& i_rChoices,
     647             :                                                             sal_Int32 i_nValue,
     648             :                                                             const com::sun::star::uno::Sequence< sal_Bool >& i_rDisabledChoices = com::sun::star::uno::Sequence< sal_Bool >(),
     649             :                                                             const UIControlOptions& i_rControlOptions = UIControlOptions());
     650             : 
     651             :     // show a set of choices as radio buttons
     652             :     static com::sun::star::uno::Any setChoiceRadiosControlOpt(const com::sun::star::uno::Sequence< rtl::OUString >& i_rIDs,
     653             :                                                             const rtl::OUString& i_rTitle,
     654             :                                                             const com::sun::star::uno::Sequence< rtl::OUString >& i_rHelpId,
     655             :                                                             const rtl::OUString& i_rProperty,
     656             :                                                             const com::sun::star::uno::Sequence< rtl::OUString >& i_rChoices,
     657             :                                                             sal_Int32 i_nValue,
     658             :                                                             const com::sun::star::uno::Sequence< sal_Bool >& i_rDisabledChoices = com::sun::star::uno::Sequence< sal_Bool >(),
     659             :                                                             const UIControlOptions& i_rControlOptions = UIControlOptions());
     660             : 
     661             : 
     662             :     // show an integer range (e.g. a spin field)
     663             :     // note: max value < min value means do not apply min/max values
     664             :     static com::sun::star::uno::Any setRangeControlOpt(const rtl::OUString& i_rID,
     665             :                                                        const rtl::OUString& i_rTitle,
     666             :                                                        const rtl::OUString& i_rHelpId,
     667             :                                                        const rtl::OUString& i_rProperty,
     668             :                                                        sal_Int32 i_nValue,
     669             :                                                        sal_Int32 i_nMinValue = -1,
     670             :                                                        sal_Int32 i_nMaxValue = -2,
     671             :                                                        const UIControlOptions& i_rControlOptions = UIControlOptions());
     672             : 
     673             :     // show a string field
     674             :     // note: max value < min value means do not apply min/max values
     675             :     static com::sun::star::uno::Any setEditControlOpt(const rtl::OUString& i_rID,
     676             :                                                       const rtl::OUString& i_rTitle,
     677             :                                                       const rtl::OUString& i_rHelpId,
     678             :                                                       const rtl::OUString& i_rProperty,
     679             :                                                       const rtl::OUString& i_rValue,
     680             :                                                       const UIControlOptions& i_rControlOptions = UIControlOptions());
     681             : };
     682             : 
     683             : }
     684             : 
     685             : 
     686             : #endif  // _SV_PRINT_HXX
     687             : 
     688             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10