LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/vcl - print.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 61 9.8 %
Date: 2013-07-09 Functions: 6 54 11.1 %
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           0 : class VCL_DLLPUBLIC QueueInfo
      92             : {
      93             :     friend class Printer;
      94             : 
      95             : private:
      96             :     OUString                   maPrinterName;
      97             :     OUString                   maDriver;
      98             :     OUString                   maLocation;
      99             :     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 OUString&            GetPrinterName() const { return maPrinterName; }
     109           0 :     const OUString&            GetDriver() const { return maDriver; }
     110           0 :     const OUString&            GetLocation() const { return maLocation; }
     111           0 :     const OUString&            GetComment() const { return maComment; }
     112           0 :     sal_uInt32                  GetStatus() const { return mnStatus; }
     113           0 :     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           0 :     sal_Bool                        IsReduceTransparency() const { return mbReduceTransparency; }
     172           0 :     void                        SetReduceTransparency( sal_Bool bSet ) { mbReduceTransparency = bSet; }
     173             : 
     174           0 :     PrinterTransparencyMode     GetReducedTransparencyMode() const { return meReducedTransparencyMode; }
     175           0 :     void                        SetReducedTransparencyMode( PrinterTransparencyMode eMode ) { meReducedTransparencyMode = eMode; }
     176             : 
     177           0 :     sal_Bool                        IsReduceGradients() const { return mbReduceGradients; }
     178           0 :     void                        SetReduceGradients( sal_Bool bSet ) { mbReduceGradients = bSet; }
     179             : 
     180           0 :     PrinterGradientMode         GetReducedGradientMode() const { return meReducedGradientsMode; }
     181           0 :     void                        SetReducedGradientMode( PrinterGradientMode eMode ) { meReducedGradientsMode = eMode; }
     182             : 
     183           0 :     sal_uInt16                      GetReducedGradientStepCount() const { return mnReducedGradientStepCount; }
     184           0 :     void                        SetReducedGradientStepCount( sal_uInt16 nStepCount ) { mnReducedGradientStepCount = nStepCount; }
     185             : 
     186           0 :     sal_Bool                        IsReduceBitmaps() const { return mbReduceBitmaps; }
     187           0 :     void                        SetReduceBitmaps( sal_Bool bSet ) { mbReduceBitmaps = bSet; }
     188             : 
     189           0 :     PrinterBitmapMode           GetReducedBitmapMode() const { return meReducedBitmapMode; }
     190           0 :     void                        SetReducedBitmapMode( PrinterBitmapMode eMode ) { meReducedBitmapMode = eMode; }
     191             : 
     192           0 :     sal_uInt16                      GetReducedBitmapResolution() const { return mnReducedBitmapResolution; }
     193           0 :     void                        SetReducedBitmapResolution( sal_uInt16 nResolution ) { mnReducedBitmapResolution = nResolution; }
     194             : 
     195           0 :     sal_Bool                        IsReducedBitmapIncludesTransparency() const { return mbReducedBitmapsIncludeTransparency; }
     196           0 :     void                        SetReducedBitmapIncludesTransparency( sal_Bool bSet ) { mbReducedBitmapsIncludeTransparency = bSet; }
     197             : 
     198           0 :     sal_Bool                        IsConvertToGreyscales() const { return mbConvertToGreyscales; }
     199           0 :     void                        SetConvertToGreyscales( sal_Bool bSet ) { mbConvertToGreyscales = bSet; }
     200             : 
     201           0 :     sal_Bool                        IsPDFAsStandardPrintJobFormat() const { return mbPDFAsStandardPrintJobFormat; }
     202           0 :     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 occurred
     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             :     OUString                   maPrinterName;
     227             :     OUString                   maDriver;
     228             :     OUString                   maPrintFile;
     229             :     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 OUString& rPrinterName,
     254             :                                                   const 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 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 OUString& rPrinterName );
     283             :     virtual                     ~Printer();
     284             : 
     285             :     static const std::vector< OUString >& GetPrinterQueues();
     286             :     static const QueueInfo*     GetQueueInfo( const OUString& rPrinterName, bool bStatusUpdate );
     287             :     static OUString            GetDefaultPrinterName();
     288             : 
     289             :     virtual void                Error();
     290             : 
     291         176 :     const OUString&            GetName() const             { return maPrinterName; }
     292           0 :     const OUString&            GetDriverName() const       { return maDriver; }
     293           0 :     sal_Bool                        IsDefPrinter() const        { return mbDefPrinter; }
     294         483 :     sal_Bool                        IsDisplayPrinter() const    { return mpDisplayDev != NULL; }
     295         386 :     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           4 :     const JobSetup&             GetJobSetup() const { return maJobSetup; }
     302             :     void                        SetJobValue( const OUString& rKey, const 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 OUString        GetPaperName( Paper ePaper );
     329             :     // return a UI string for the current paper; i_bPaperUser == false means an empty string for PAPER_USER
     330             :     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             :     OUString                   GetPaperBinName( sal_uInt16 nPaperBin ) const;
     338             : 
     339           0 :     const Size&                 GetPaperSizePixel() const { return maPaperSize; }
     340           0 :     Size                        GetPaperSize() const { return PixelToLogic( maPaperSize ); }
     341         162 :     const Point&                GetPageOffsetPixel() const { return maPageOffset; }
     342           0 :     Point                       GetPageOffset() const { return PixelToLogic( maPageOffset ); }
     343             : 
     344             :     sal_Bool                        SetCopyCount( sal_uInt16 nCopy, sal_Bool bCollate = sal_False );
     345           0 :     sal_uInt16                      GetCopyCount() const { return mnCopyCount; }
     346           0 :     sal_Bool                        IsCollateCopy() const { return mbCollateCopy; }
     347             : 
     348         226 :     sal_Bool                        IsPrinting() const { return mbPrinting; }
     349             : 
     350             :     const OUString&            GetCurJobName() const { return maJobName; }
     351             :     sal_uInt16                      GetCurPage() const { return mnCurPage; }
     352           0 :     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             :     /** checks the printer list and updates it necessary
     361             :     *
     362             :     *   sends a DataChanged event of type DATACHANGED_PRINTER
     363             :     *   if the printer list changed
     364             :     */
     365             :     static void updatePrinters();
     366             : 
     367             :     /** execute a print job
     368             : 
     369             :         starts a print job asynchronously (that is will return
     370             : 
     371             :     */
     372             :     static void PrintJob( const boost::shared_ptr<vcl::PrinterController>& i_pController,
     373             :                           const JobSetup& i_rInitSetup
     374             :                           );
     375             : 
     376             :     // implementation detail of PrintJob being asynchronous
     377             :     // not exported, not usable outside vcl
     378             :     static void SAL_DLLPRIVATE ImplPrintJob( const boost::shared_ptr<vcl::PrinterController>& i_pController,
     379             :                                              const JobSetup& i_rInitSetup
     380             :                                              );
     381             : };
     382             : 
     383             : namespace vcl
     384             : {
     385             : class ImplPrinterControllerData;
     386             : 
     387             : class VCL_DLLPUBLIC PrinterController
     388             : {
     389             :     ImplPrinterControllerData* mpImplData;
     390             : protected:
     391             :     PrinterController( const boost::shared_ptr<Printer>& );
     392             : public:
     393             :     enum NupOrderType
     394             :     { LRTB, TBLR, TBRL, RLTB };
     395             :     struct MultiPageSetup
     396             :     {
     397             :         // all metrics in 100th mm
     398             :         int                                    nRows;
     399             :         int                                    nColumns;
     400             :         int                                    nRepeat;
     401             :         Size                                   aPaperSize;
     402             :         long                                   nLeftMargin;
     403             :         long                                   nTopMargin;
     404             :         long                                   nRightMargin;
     405             :         long                                   nBottomMargin;
     406             :         long                                   nHorizontalSpacing;
     407             :         long                                   nVerticalSpacing;
     408             :         bool                                   bDrawBorder;
     409             :         PrinterController::NupOrderType        nOrder;
     410             : 
     411           0 :         MultiPageSetup()
     412             :         : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 )
     413             :         , nLeftMargin( 0 ), nTopMargin( 0 )
     414             :         , nRightMargin( 0 ), nBottomMargin( 0 )
     415             :         , nHorizontalSpacing( 0 ), nVerticalSpacing( 0 )
     416             :         , bDrawBorder( false )
     417           0 :         , nOrder( LRTB )
     418             :         {
     419           0 :         }
     420             :     };
     421             : 
     422             :     struct PageSize
     423             :     {
     424             :         Size        aSize;          // in 100th mm
     425             :         bool        bFullPaper;     // full paper, not only imageable area is printed
     426             : 
     427           0 :         PageSize( const Size& i_rSize = Size( 21000, 29700 ),
     428             :                   bool i_bFullPaper = false
     429           0 :                   ) : aSize( i_rSize ), bFullPaper( i_bFullPaper ) {}
     430             :     };
     431             : 
     432             :     virtual ~PrinterController();
     433             : 
     434             :     const boost::shared_ptr<Printer>& getPrinter() const;
     435             :     /* for implementations: get current job properties as changed by e.g. print dialog
     436             :        this gets the current set of properties initially told to Printer::PrintJob
     437             : 
     438             :        For convenience a second sequence will be merged in to get a combined sequence.
     439             :        In case of duplicate property names, the value of i_MergeList wins.
     440             :     */
     441             :     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >
     442             :         getJobProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rMergeList ) const;
     443             : 
     444             :     /* get the PropertyValue of a Property
     445             :     */
     446             :     com::sun::star::beans::PropertyValue* getValue( const OUString& i_rPropertyName );
     447             :     const com::sun::star::beans::PropertyValue* getValue( const OUString& i_rPropertyName ) const;
     448             :     /* get a bool property
     449             :        in case the property is unknown or not convertible to bool, i_bFallback is returned
     450             :     */
     451             :     sal_Bool getBoolProperty( const OUString& i_rPropertyName, sal_Bool i_bFallback ) const;
     452             :     /* get an int property
     453             :        in case the property is unknown or not convertible to bool, i_nFallback is returned
     454             :     */
     455             :     sal_Int32 getIntProperty( const OUString& i_rPropertyName, sal_Int32 i_nFallback ) const;
     456             : 
     457             :     /* set a property value - can also be used to add another UI property
     458             :     */
     459             :     void setValue( const OUString& i_rPropertyName, const com::sun::star::uno::Any& i_rValue );
     460             :     void setValue( const com::sun::star::beans::PropertyValue& i_rValue );
     461             : 
     462             :     /* return the currently active UI options. These are the same that were passed to setUIOptions.
     463             :     */
     464             :     const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& getUIOptions() const;
     465             :     /* set possible UI options. should only be done once before passing the PrinterListener
     466             :        to Printer::PrintJob
     467             :     */
     468             :     void setUIOptions( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& );
     469             :     /* enable/disable an option; this can be used to implement dialog logic.
     470             :     */
     471             :     bool isUIOptionEnabled( const OUString& rPropName ) const;
     472             :     bool isUIChoiceEnabled( const OUString& rPropName, sal_Int32 nChoice ) const;
     473             :     /* returns the property name rPropName depends on or an empty string
     474             :        if no dependency exists.
     475             :     */
     476             :     OUString getDependency( const OUString& rPropName ) const;
     477             :     /* makeEnabled will chage the property rPropName depends on to the value
     478             :        that makes rPropName enabled. If the dependency itself is also disabled,
     479             :        no action will be performed.
     480             : 
     481             :        returns the property name rPropName depends on or an empty string
     482             :        if no change was made.
     483             :     */
     484             :     OUString makeEnabled( const OUString& rPropName );
     485             : 
     486             :     virtual int  getPageCount() const = 0; // must be overloaded by the app
     487             :     /* get the page parameters, namely the jobsetup that should be active for the page
     488             :        (describing among others the physical page size) and the "page size". In writer
     489             :        case this would probably be the same as the JobSetup since writer sets the page size
     490             :        draw/impress for example print their page on the paper set on the printer,
     491             :        possibly adjusting the page size to fit. That means the page size can be different from
     492             :        the paper size.
     493             :     */
     494             :     // must be overloaded by the app, return page size in 1/100th mm
     495             :     virtual com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParameters( int i_nPage ) const = 0;
     496             :     virtual void printPage( int i_nPage ) const = 0; // must be overloaded by the app
     497             :     virtual void jobStarted(); // will be called after a possible dialog has been shown and the real printjob starts
     498             :     virtual void jobFinished( com::sun::star::view::PrintableState );
     499             : 
     500             :     com::sun::star::view::PrintableState getJobState() const;
     501             : 
     502             :     void abortJob();
     503             : 
     504             :     bool isShowDialogs() const;
     505             :     bool isDirectPrint() const;
     506             : 
     507             :     // implementation details, not usable outside vcl
     508             :     // don't use outside vcl. Some of these are exported for
     509             :     // the benefit of vcl's plugins.
     510             :     // Still: DO NOT USE OUTSIDE VCL
     511             :     VCL_PLUGIN_PUBLIC int getFilteredPageCount();
     512             :     SAL_DLLPRIVATE PageSize getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false );
     513             :     VCL_PLUGIN_PUBLIC PageSize getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false );
     514             :     VCL_PLUGIN_PUBLIC void printFilteredPage( int i_nPage );
     515             :     SAL_DLLPRIVATE void setPrinter( const boost::shared_ptr<Printer>& );
     516             :     SAL_DLLPRIVATE void setOptionChangeHdl( const Link& );
     517             :     VCL_PLUGIN_PUBLIC void createProgressDialog();
     518             :     VCL_PLUGIN_PUBLIC bool isProgressCanceled() const;
     519             :     SAL_DLLPRIVATE void setMultipage( const MultiPageSetup& );
     520             :     SAL_DLLPRIVATE const MultiPageSetup& getMultipage() const;
     521             :     VCL_PLUGIN_PUBLIC void setLastPage( sal_Bool i_bLastPage );
     522             :     SAL_DLLPRIVATE void setReversePrint( sal_Bool i_bReverse );
     523             :     SAL_DLLPRIVATE bool getReversePrint() const;
     524             :     SAL_DLLPRIVATE void setPapersizeFromSetup( sal_Bool i_bPapersizeFromSetup );
     525             :     SAL_DLLPRIVATE bool getPapersizeFromSetup() const;
     526             :     SAL_DLLPRIVATE void pushPropertiesToPrinter();
     527             :     SAL_DLLPRIVATE void resetPaperToLastConfigured();
     528             :     VCL_PLUGIN_PUBLIC void setJobState( com::sun::star::view::PrintableState );
     529             :     SAL_DLLPRIVATE bool setupPrinter( Window* i_pDlgParent );
     530             : 
     531             :     SAL_DLLPRIVATE int getPageCountProtected() const;
     532             :     SAL_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParametersProtected( int i_nPage ) const;
     533             : 
     534             :     SAL_DLLPRIVATE sal_uLong removeTransparencies( GDIMetaFile& i_rIn, GDIMetaFile& o_rOut );
     535             :     SAL_DLLPRIVATE void resetPrinterOptions( bool i_bFileOutput );
     536             : };
     537             : 
     538             : class VCL_DLLPUBLIC PrinterOptionsHelper
     539             : {
     540             :     protected:
     541             :     boost::unordered_map< OUString, com::sun::star::uno::Any, OUStringHash >        m_aPropertyMap;
     542             :     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >              m_aUIProperties;
     543             : 
     544             :     public:
     545           0 :     PrinterOptionsHelper() {} // create without ui properties
     546             :     PrinterOptionsHelper( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rUIProperties )
     547             :     : m_aUIProperties( i_rUIProperties )
     548             :     {}
     549           0 :     ~PrinterOptionsHelper()
     550           0 :     {}
     551             : 
     552             :     /* process a new set of properties
     553             :      * merges changed properties and returns "true" if any occurred
     554             :      * if the optional output set is not NULL then the names of the changed properties are returned
     555             :     **/
     556             :     bool processProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp,
     557             :                             std::set< OUString >* o_pChangeProp = NULL );
     558             :     /* append  to a sequence of property values the ui property sequence passed at creation
     559             :      * as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property
     560             :      * will be appended.
     561             :     **/
     562             :     void appendPrintUIOptions( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& io_rProps ) const;
     563             : 
     564             :     // returns an empty Any for not existing properties
     565             :     com::sun::star::uno::Any getValue( const OUString& i_rPropertyName ) const;
     566             : 
     567             :     sal_Bool getBoolValue( const OUString& i_rPropertyName, sal_Bool i_bDefault = sal_False ) const;
     568             :     // convenience for fixed strings
     569           0 :     sal_Bool getBoolValue( const char* i_pPropName, sal_Bool i_bDefault = sal_False ) const
     570           0 :     { return getBoolValue( OUString::createFromAscii( i_pPropName ), i_bDefault ); }
     571             : 
     572             :     sal_Int64 getIntValue( const OUString& i_rPropertyName, sal_Int64 i_nDefault = 0 ) const;
     573             :     // convenience for fixed strings
     574           0 :     sal_Int64 getIntValue( const char* i_pPropName, sal_Int64 i_nDefault = 0 ) const
     575           0 :     { return getIntValue( OUString::createFromAscii( i_pPropName ), i_nDefault ); }
     576             : 
     577             :     OUString getStringValue( const OUString& i_rPropertyName, const OUString& i_rDefault = OUString() ) const;
     578             :     // convenience for fixed strings
     579           0 :     OUString getStringValue( const char* i_pPropName, const OUString& i_rDefault = OUString() ) const
     580           0 :     { return getStringValue( OUString::createFromAscii( i_pPropName ), i_rDefault ); }
     581             : 
     582             :     // helper functions for user to create a single control
     583           0 :     struct UIControlOptions
     584             :     {
     585             :         OUString   maDependsOnName;
     586             :         sal_Int32       mnDependsOnEntry;
     587             :         sal_Bool        mbAttachToDependency;
     588             :         OUString   maGroupHint;
     589             :         sal_Bool        mbInternalOnly;
     590             :         sal_Bool        mbEnabled;
     591             :         com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > maAddProps;
     592             : 
     593           0 :         UIControlOptions( const OUString& i_rDependsOnName = OUString(),
     594             :                           sal_Int32 i_nDependsOnEntry = -1,
     595             :                           sal_Bool i_bAttachToDependency = sal_False,
     596             :                           const OUString& i_rGroupHint = OUString(),
     597             :                           sal_Bool i_bInternalOnly = sal_False,
     598             :                           sal_Bool i_bEnabled = sal_True
     599             :                          )
     600             :         : maDependsOnName( i_rDependsOnName )
     601             :         , mnDependsOnEntry( i_nDependsOnEntry )
     602             :         , mbAttachToDependency( i_bAttachToDependency )
     603             :         , maGroupHint( i_rGroupHint )
     604             :         , mbInternalOnly( i_bInternalOnly )
     605           0 :         , mbEnabled( i_bEnabled ) {}
     606             :     };
     607             : 
     608             :     // note: in the following helper functions HelpIds are expected as an OUString
     609             :     // the normal HelpId form is OString (byte string instead of UTF16 string)
     610             :     // this is because the whole interface is base on UNO properties; in fact the structures
     611             :     // are passed over UNO interfaces. UNO does not know a byte string, hence the string is
     612             :     // transported via UTF16 strings.
     613             : 
     614             :     // Show general control
     615             :     static com::sun::star::uno::Any setUIControlOpt( const com::sun::star::uno::Sequence< OUString >& i_rIDs,
     616             :                                                      const OUString& i_rTitle,
     617             :                                                      const com::sun::star::uno::Sequence< OUString >& i_rHelpId,
     618             :                                                      const OUString& i_rType,
     619             :                                                      const com::sun::star::beans::PropertyValue* i_pValue = NULL,
     620             :                                                      const UIControlOptions& i_rControlOptions = UIControlOptions()
     621             :                                                      );
     622             : 
     623             :     // Show and set the title of a TagPage of id i_rID
     624             :     static com::sun::star::uno::Any setGroupControlOpt(const OUString& i_rID,
     625             :                                                        const OUString& i_rTitle,
     626             :                                                        const OUString& i_rHelpId);
     627             : 
     628             :     // Show and set the label of a VclFrame of id i_rID
     629             :     static com::sun::star::uno::Any setSubgroupControlOpt(const OUString& i_rID,
     630             :                                                           const OUString& i_rTitle,
     631             :                                                           const OUString& i_rHelpId,
     632             :                                                           const UIControlOptions& i_rControlOptions = UIControlOptions());
     633             : 
     634             :     // Show a bool option as a checkbox
     635             :     static com::sun::star::uno::Any setBoolControlOpt(const OUString& i_rID,
     636             :                                                       const OUString& i_rTitle,
     637             :                                                       const OUString& i_rHelpId,
     638             :                                                       const OUString& i_rProperty,
     639             :                                                       sal_Bool i_bValue,
     640             :                                                       const UIControlOptions& i_rControlOptions = UIControlOptions());
     641             : 
     642             :     // Show a set of choices in a list box
     643             :     static com::sun::star::uno::Any setChoiceListControlOpt(const OUString& i_rID,
     644             :                                                             const OUString& i_rTitle,
     645             :                                                             const com::sun::star::uno::Sequence< OUString >& i_rHelpId,
     646             :                                                             const OUString& i_rProperty,
     647             :                                                             const com::sun::star::uno::Sequence< OUString >& i_rChoices,
     648             :                                                             sal_Int32 i_nValue,
     649             :                                                             const com::sun::star::uno::Sequence< sal_Bool >& i_rDisabledChoices = com::sun::star::uno::Sequence< sal_Bool >(),
     650             :                                                             const UIControlOptions& i_rControlOptions = UIControlOptions());
     651             : 
     652             :     // show a set of choices as radio buttons
     653             :     static com::sun::star::uno::Any setChoiceRadiosControlOpt(const com::sun::star::uno::Sequence< OUString >& i_rIDs,
     654             :                                                             const OUString& i_rTitle,
     655             :                                                             const com::sun::star::uno::Sequence< OUString >& i_rHelpId,
     656             :                                                             const OUString& i_rProperty,
     657             :                                                             const com::sun::star::uno::Sequence< OUString >& i_rChoices,
     658             :                                                             sal_Int32 i_nValue,
     659             :                                                             const com::sun::star::uno::Sequence< sal_Bool >& i_rDisabledChoices = com::sun::star::uno::Sequence< sal_Bool >(),
     660             :                                                             const UIControlOptions& i_rControlOptions = UIControlOptions());
     661             : 
     662             : 
     663             :     // show an integer range (e.g. a spin field)
     664             :     // note: max value < min value means do not apply min/max values
     665             :     static com::sun::star::uno::Any setRangeControlOpt(const OUString& i_rID,
     666             :                                                        const OUString& i_rTitle,
     667             :                                                        const OUString& i_rHelpId,
     668             :                                                        const OUString& i_rProperty,
     669             :                                                        sal_Int32 i_nValue,
     670             :                                                        sal_Int32 i_nMinValue = -1,
     671             :                                                        sal_Int32 i_nMaxValue = -2,
     672             :                                                        const UIControlOptions& i_rControlOptions = UIControlOptions());
     673             : 
     674             :     // show a string field
     675             :     // note: max value < min value means do not apply min/max values
     676             :     static com::sun::star::uno::Any setEditControlOpt(const OUString& i_rID,
     677             :                                                       const OUString& i_rTitle,
     678             :                                                       const OUString& i_rHelpId,
     679             :                                                       const OUString& i_rProperty,
     680             :                                                       const OUString& i_rValue,
     681             :                                                       const UIControlOptions& i_rControlOptions = UIControlOptions());
     682             : };
     683             : 
     684             : }
     685             : 
     686             : 
     687             : #endif  // _SV_PRINT_HXX
     688             : 
     689             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10