LCOV - code coverage report
Current view: top level - vcl/inc/vcl - print.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 11 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10