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

Generated by: LCOV version 1.10