LCOV - code coverage report
Current view: top level - sfx2/source/view - viewprn.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 358 0.3 %
Date: 2012-08-25 Functions: 1 30 3.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 875 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                 :            : 
      30                 :            : #include <com/sun/star/document/XDocumentProperties.hpp>
      31                 :            : #include <com/sun/star/view/PrintableState.hpp>
      32                 :            : #include "com/sun/star/view/XRenderable.hpp"
      33                 :            : 
      34                 :            : #include <svl/itempool.hxx>
      35                 :            : #include <vcl/msgbox.hxx>
      36                 :            : #include <svtools/prnsetup.hxx>
      37                 :            : #include <svl/flagitem.hxx>
      38                 :            : #include <svl/stritem.hxx>
      39                 :            : #include <svl/intitem.hxx>
      40                 :            : #include <svl/eitem.hxx>
      41                 :            : #include <sfx2/app.hxx>
      42                 :            : #include <unotools/useroptions.hxx>
      43                 :            : #include <unotools/printwarningoptions.hxx>
      44                 :            : #include <tools/datetime.hxx>
      45                 :            : #include <sfx2/bindings.hxx>
      46                 :            : #include <sfx2/objface.hxx>
      47                 :            : #include <sfx2/viewsh.hxx>
      48                 :            : #include "viewimp.hxx"
      49                 :            : #include <sfx2/viewfrm.hxx>
      50                 :            : #include <sfx2/prnmon.hxx>
      51                 :            : #include "sfx2/sfxresid.hxx"
      52                 :            : #include <sfx2/request.hxx>
      53                 :            : #include <sfx2/objsh.hxx>
      54                 :            : #include "sfxtypes.hxx"
      55                 :            : #include <sfx2/event.hxx>
      56                 :            : #include <sfx2/docfile.hxx>
      57                 :            : #include <sfx2/docfilt.hxx>
      58                 :            : 
      59                 :            : #include "toolkit/awt/vclxdevice.hxx"
      60                 :            : 
      61                 :            : #include "view.hrc"
      62                 :            : #include "helpid.hrc"
      63                 :            : 
      64                 :            : using namespace com::sun::star;
      65                 :            : using namespace com::sun::star::uno;
      66                 :            : 
      67 [ #  # ][ #  # ]:     107053 : TYPEINIT1(SfxPrintingHint, SfxHint);
      68                 :            : 
      69                 :            : // -----------------------------------------------------------------------
      70                 :            : class SfxPrinterController : public vcl::PrinterController, public SfxListener
      71                 :            : {
      72                 :            :     Any                                     maCompleteSelection;
      73                 :            :     Any                                     maSelection;
      74                 :            :     Reference< view::XRenderable >          mxRenderable;
      75                 :            :     mutable Printer*                        mpLastPrinter;
      76                 :            :     mutable Reference<awt::XDevice>         mxDevice;
      77                 :            :     SfxViewShell*                           mpViewShell;
      78                 :            :     SfxObjectShell*                         mpObjectShell;
      79                 :            :     sal_Bool        m_bOrigStatus;
      80                 :            :     sal_Bool        m_bNeedsChange;
      81                 :            :     sal_Bool        m_bApi;
      82                 :            :     sal_Bool        m_bTempPrinter;
      83                 :            :     util::DateTime  m_aLastPrinted;
      84                 :            :     ::rtl::OUString m_aLastPrintedBy;
      85                 :            : 
      86                 :            :     Sequence< beans::PropertyValue > getMergedOptions() const;
      87                 :            :     const Any& getSelectionObject() const;
      88                 :            : public:
      89                 :            :     SfxPrinterController( const boost::shared_ptr<Printer>& i_rPrinter,
      90                 :            :                           const Any& i_rComplete,
      91                 :            :                           const Any& i_rSelection,
      92                 :            :                           const Any& i_rViewProp,
      93                 :            :                           const Reference< view::XRenderable >& i_xRender,
      94                 :            :                           sal_Bool i_bApi, sal_Bool i_bDirect,
      95                 :            :                           SfxViewShell* pView,
      96                 :            :                           const uno::Sequence< beans::PropertyValue >& rProps
      97                 :            :                         );
      98                 :            : 
      99                 :            :     virtual ~SfxPrinterController();
     100                 :            :     virtual void Notify( SfxBroadcaster&, const SfxHint& );
     101                 :            : 
     102                 :            :     virtual int  getPageCount() const;
     103                 :            :     virtual Sequence< beans::PropertyValue > getPageParameters( int i_nPage ) const;
     104                 :            :     virtual void printPage( int i_nPage ) const;
     105                 :            :     virtual void jobStarted();
     106                 :            :     virtual void jobFinished( com::sun::star::view::PrintableState );
     107                 :            : };
     108                 :            : 
     109                 :          0 : SfxPrinterController::SfxPrinterController( const boost::shared_ptr<Printer>& i_rPrinter,
     110                 :            :                                             const Any& i_rComplete,
     111                 :            :                                             const Any& i_rSelection,
     112                 :            :                                             const Any& i_rViewProp,
     113                 :            :                                             const Reference< view::XRenderable >& i_xRender,
     114                 :            :                                             sal_Bool i_bApi, sal_Bool i_bDirect,
     115                 :            :                                             SfxViewShell* pView,
     116                 :            :                                             const uno::Sequence< beans::PropertyValue >& rProps
     117                 :            :                                           )
     118                 :            :     : PrinterController( i_rPrinter)
     119                 :            :     , maCompleteSelection( i_rComplete )
     120                 :            :     , maSelection( i_rSelection )
     121                 :            :     , mxRenderable( i_xRender )
     122                 :            :     , mpLastPrinter( NULL )
     123                 :            :     , mpViewShell( pView )
     124                 :            :     , mpObjectShell(0)
     125                 :            :     , m_bOrigStatus( sal_False )
     126                 :            :     , m_bNeedsChange( sal_False )
     127                 :            :     , m_bApi(i_bApi)
     128         [ #  # ]:          0 :     , m_bTempPrinter( i_rPrinter.get() != NULL )
     129                 :            : {
     130         [ #  # ]:          0 :     if ( mpViewShell )
     131                 :            :     {
     132         [ #  # ]:          0 :         StartListening( *mpViewShell );
     133         [ #  # ]:          0 :         mpObjectShell = mpViewShell->GetObjectShell();
     134         [ #  # ]:          0 :         StartListening( *mpObjectShell );
     135                 :            :     }
     136                 :            : 
     137                 :            :     // initialize extra ui options
     138         [ #  # ]:          0 :     if( mxRenderable.is() )
     139                 :            :     {
     140         [ #  # ]:          0 :         for (sal_Int32 nProp=0; nProp < rProps.getLength(); ++nProp)
     141         [ #  # ]:          0 :             setValue( rProps[nProp].Name, rProps[nProp].Value );
     142                 :            : 
     143         [ #  # ]:          0 :         Sequence< beans::PropertyValue > aRenderOptions( 3 );
     144         [ #  # ]:          0 :         aRenderOptions[0].Name = rtl::OUString( "ExtraPrintUIOptions"  );
     145         [ #  # ]:          0 :         aRenderOptions[1].Name = rtl::OUString( "View"  );
     146         [ #  # ]:          0 :         aRenderOptions[1].Value = i_rViewProp;
     147         [ #  # ]:          0 :         aRenderOptions[2].Name = rtl::OUString( "IsPrinter"  );
     148 [ #  # ][ #  # ]:          0 :         aRenderOptions[2].Value <<= sal_True;
     149                 :            :         try
     150                 :            :         {
     151 [ #  # ][ #  # ]:          0 :             Sequence< beans::PropertyValue > aRenderParms( mxRenderable->getRenderer( 0 , getSelectionObject(), aRenderOptions ) );
                 [ #  # ]
     152                 :          0 :             int nProps = aRenderParms.getLength();
     153         [ #  # ]:          0 :             for( int i = 0; i < nProps; i++ )
     154                 :            :             {
     155 [ #  # ][ #  # ]:          0 :                 if ( aRenderParms[i].Name == "ExtraPrintUIOptions" )
     156                 :            :                 {
     157         [ #  # ]:          0 :                     Sequence< beans::PropertyValue > aUIProps;
     158 [ #  # ][ #  # ]:          0 :                     aRenderParms[i].Value >>= aUIProps;
     159         [ #  # ]:          0 :                     setUIOptions( aUIProps );
     160         [ #  # ]:          0 :                     break;
     161                 :            :                 }
     162 [ #  # ][ #  # ]:          0 :             }
     163                 :            :         }
     164         [ #  # ]:          0 :         catch( lang::IllegalArgumentException& )
     165                 :            :         {
     166                 :            :             // the first renderer should always be available for the UI options,
     167                 :            :             // but catch the exception to be safe
     168         [ #  # ]:          0 :         }
     169                 :            :     }
     170                 :            : 
     171                 :            :     // set some job parameters
     172 [ #  # ][ #  # ]:          0 :     setValue( rtl::OUString( "IsApi"  ), makeAny( i_bApi ) );
     173 [ #  # ][ #  # ]:          0 :     setValue( rtl::OUString( "IsDirect"  ), makeAny( i_bDirect ) );
     174 [ #  # ][ #  # ]:          0 :     setValue( rtl::OUString( "IsPrinter"  ), makeAny( sal_True ) );
     175         [ #  # ]:          0 :     setValue( rtl::OUString( "View"  ), i_rViewProp );
     176                 :          0 : }
     177                 :            : 
     178                 :          0 : void SfxPrinterController::Notify( SfxBroadcaster& , const SfxHint& rHint )
     179                 :            : {
     180         [ #  # ]:          0 :     if ( rHint.IsA(TYPE(SfxSimpleHint)) )
     181                 :            :     {
     182         [ #  # ]:          0 :         if ( ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
     183                 :            :         {
     184                 :          0 :             EndListening(*mpViewShell);
     185                 :          0 :             EndListening(*mpObjectShell);
     186                 :          0 :             mpViewShell = 0;
     187                 :          0 :             mpObjectShell = 0;
     188                 :            :         }
     189                 :            :     }
     190                 :          0 : }
     191                 :            : 
     192         [ #  # ]:          0 : SfxPrinterController::~SfxPrinterController()
     193                 :            : {
     194         [ #  # ]:          0 : }
     195                 :            : 
     196                 :          0 : const Any& SfxPrinterController::getSelectionObject() const
     197                 :            : {
     198         [ #  # ]:          0 :     const beans::PropertyValue* pVal = getValue( rtl::OUString( "PrintSelectionOnly"  ) );
     199         [ #  # ]:          0 :     if( pVal )
     200                 :            :     {
     201                 :          0 :         sal_Bool bSel = sal_False;
     202                 :          0 :         pVal->Value >>= bSel;
     203         [ #  # ]:          0 :         return bSel ? maSelection : maCompleteSelection;
     204                 :            :     }
     205                 :            : 
     206                 :          0 :     sal_Int32 nChoice = 0;
     207         [ #  # ]:          0 :     pVal = getValue( rtl::OUString( "PrintContent"  ) );
     208         [ #  # ]:          0 :     if( pVal )
     209                 :          0 :         pVal->Value >>= nChoice;
     210         [ #  # ]:          0 :     return (nChoice > 1) ? maSelection : maCompleteSelection;
     211                 :            : }
     212                 :            : 
     213                 :          0 : Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const
     214                 :            : {
     215 [ #  # ][ #  # ]:          0 :     boost::shared_ptr<Printer> pPrinter( getPrinter() );
     216         [ #  # ]:          0 :     if( pPrinter.get() != mpLastPrinter )
     217                 :            :     {
     218                 :          0 :         mpLastPrinter = pPrinter.get();
     219         [ #  # ]:          0 :         VCLXDevice* pXDevice = new VCLXDevice();
     220                 :          0 :         pXDevice->SetOutputDevice( mpLastPrinter );
     221 [ #  # ][ #  # ]:          0 :         mxDevice = Reference< awt::XDevice >( pXDevice );
     222                 :            :     }
     223                 :            : 
     224         [ #  # ]:          0 :     Sequence< beans::PropertyValue > aRenderOptions( 1 );
     225         [ #  # ]:          0 :     aRenderOptions[ 0 ].Name = rtl::OUString( "RenderDevice"  );
     226 [ #  # ][ #  # ]:          0 :     aRenderOptions[ 0 ].Value <<= mxDevice;
     227                 :            : 
     228 [ #  # ][ #  # ]:          0 :     aRenderOptions = getJobProperties( aRenderOptions );
                 [ #  # ]
     229         [ #  # ]:          0 :     return aRenderOptions;
     230                 :            : }
     231                 :            : 
     232                 :          0 : int SfxPrinterController::getPageCount() const
     233                 :            : {
     234                 :          0 :     int nPages = 0;
     235 [ #  # ][ #  # ]:          0 :     boost::shared_ptr<Printer> pPrinter( getPrinter() );
     236 [ #  # ][ #  # ]:          0 :     if( mxRenderable.is() && pPrinter )
                 [ #  # ]
     237                 :            :     {
     238         [ #  # ]:          0 :         Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() );
     239                 :            :         try
     240                 :            :         {
     241 [ #  # ][ #  # ]:          0 :             nPages = mxRenderable->getRendererCount( getSelectionObject(), aJobOptions );
                 [ #  # ]
     242                 :            :         }
     243   [ #  #  #  # ]:          0 :         catch (lang::DisposedException &)
     244                 :            :         {
     245                 :            :             OSL_TRACE("SfxPrinterController: document disposed while printing");
     246                 :            :             const_cast<SfxPrinterController*>(this)->setJobState(
     247         [ #  # ]:          0 :                     view::PrintableState_JOB_ABORTED);
     248         [ #  # ]:          0 :         }
     249                 :            :     }
     250         [ #  # ]:          0 :     return nPages;
     251                 :            : }
     252                 :            : 
     253                 :          0 : Sequence< beans::PropertyValue > SfxPrinterController::getPageParameters( int i_nPage ) const
     254                 :            : {
     255 [ #  # ][ #  # ]:          0 :     boost::shared_ptr<Printer> pPrinter( getPrinter() );
     256         [ #  # ]:          0 :     Sequence< beans::PropertyValue > aResult;
     257                 :            : 
     258 [ #  # ][ #  # ]:          0 :     if( mxRenderable.is() && pPrinter )
                 [ #  # ]
     259                 :            :     {
     260         [ #  # ]:          0 :         Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() );
     261                 :            :         try
     262                 :            :         {
     263 [ #  # ][ #  # ]:          0 :             aResult = mxRenderable->getRenderer( i_nPage, getSelectionObject(), aJobOptions );
         [ #  # ][ #  # ]
                 [ #  # ]
     264                 :            :         }
     265         [ #  # ]:          0 :         catch( lang::IllegalArgumentException& )
     266                 :            :         {
     267                 :            :         }
     268   [ #  #  #  #  :          0 :         catch (lang::DisposedException &)
                      # ]
     269                 :            :         {
     270                 :            :             OSL_TRACE("SfxPrinterController: document disposed while printing");
     271                 :            :             const_cast<SfxPrinterController*>(this)->setJobState(
     272         [ #  # ]:          0 :                     view::PrintableState_JOB_ABORTED);
     273         [ #  # ]:          0 :         }
     274                 :            :     }
     275         [ #  # ]:          0 :     return aResult;
     276                 :            : }
     277                 :            : 
     278                 :          0 : void SfxPrinterController::printPage( int i_nPage ) const
     279                 :            : {
     280 [ #  # ][ #  # ]:          0 :     boost::shared_ptr<Printer> pPrinter( getPrinter() );
     281 [ #  # ][ #  # ]:          0 :     if( mxRenderable.is() && pPrinter )
                 [ #  # ]
     282                 :            :     {
     283         [ #  # ]:          0 :         Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() );
     284                 :            :         try
     285                 :            :         {
     286 [ #  # ][ #  # ]:          0 :             mxRenderable->render( i_nPage, getSelectionObject(), aJobOptions );
                 [ #  # ]
     287                 :            :         }
     288         [ #  # ]:          0 :         catch( lang::IllegalArgumentException& )
     289                 :            :         {
     290                 :            :             // don't care enough about nonexistant page here
     291                 :            :             // to provoke a crash
     292                 :            :         }
     293   [ #  #  #  #  :          0 :         catch (lang::DisposedException &)
                      # ]
     294                 :            :         {
     295                 :            :             OSL_TRACE("SfxPrinterController: document disposed while printing");
     296                 :            :             const_cast<SfxPrinterController*>(this)->setJobState(
     297         [ #  # ]:          0 :                     view::PrintableState_JOB_ABORTED);
     298         [ #  # ]:          0 :         }
     299         [ #  # ]:          0 :     }
     300                 :          0 : }
     301                 :            : 
     302                 :          0 : void SfxPrinterController::jobStarted()
     303                 :            : {
     304         [ #  # ]:          0 :     if ( mpObjectShell )
     305                 :            :     {
     306         [ #  # ]:          0 :         m_bOrigStatus = mpObjectShell->IsEnableSetModified();
     307                 :            : 
     308                 :            :         // check configuration: shall update of printing information in DocInfo set the document to "modified"?
     309 [ #  # ][ #  # ]:          0 :         if ( m_bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     310                 :            :         {
     311         [ #  # ]:          0 :             mpObjectShell->EnableSetModified( sal_False );
     312                 :          0 :             m_bNeedsChange = sal_True;
     313                 :            :         }
     314                 :            : 
     315                 :            :         // refresh document info
     316         [ #  # ]:          0 :         uno::Reference<document::XDocumentProperties> xDocProps(mpObjectShell->getDocProperties());
     317 [ #  # ][ #  # ]:          0 :         m_aLastPrintedBy = xDocProps->getPrintedBy();
     318 [ #  # ][ #  # ]:          0 :         m_aLastPrinted = xDocProps->getPrintDate();
     319                 :            : 
     320 [ #  # ][ #  # ]:          0 :         xDocProps->setPrintedBy( mpObjectShell->IsUseUserData()
     321                 :            :             ? ::rtl::OUString( SvtUserOptions().GetFullName() )
     322 [ #  # ][ #  # ]:          0 :             : ::rtl::OUString() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     323         [ #  # ]:          0 :         ::DateTime now( ::DateTime::SYSTEM );
     324                 :            : 
     325         [ #  # ]:          0 :         xDocProps->setPrintDate( util::DateTime(
     326                 :          0 :             now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(),
     327         [ #  # ]:          0 :             now.GetDay(), now.GetMonth(), now.GetYear() ) );
     328                 :            : 
     329                 :            :         // FIXME: how to get all print options incl. AdditionalOptions easily?
     330         [ #  # ]:          0 :         uno::Sequence < beans::PropertyValue > aOpts;
     331 [ #  # ][ #  # ]:          0 :         mpObjectShell->Broadcast( SfxPrintingHint( view::PrintableState_JOB_STARTED, aOpts ) );
         [ #  # ][ #  # ]
     332                 :            :     }
     333                 :          0 : }
     334                 :            : 
     335                 :          0 : void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nState )
     336                 :            : {
     337         [ #  # ]:          0 :     if ( mpObjectShell )
     338                 :            :     {
     339                 :          0 :         bool bCopyJobSetup = false;
     340         [ #  # ]:          0 :         mpObjectShell->Broadcast( SfxPrintingHint( nState ) );
     341   [ #  #  #  # ]:          0 :         switch ( nState )
     342                 :            :         {
     343                 :            :             case view::PrintableState_JOB_FAILED :
     344                 :            :             {
     345                 :            :                 // "real" problem (not simply printing cancelled by user)
     346 [ #  # ][ #  # ]:          0 :                 rtl::OUString aMsg( SfxResId(STR_NOSTARTPRINTER).toString() );
     347         [ #  # ]:          0 :                 if ( !m_bApi )
     348 [ #  # ][ #  # ]:          0 :                     ErrorBox( mpViewShell->GetWindow(), WB_OK | WB_DEF_OK,  aMsg ).Execute();
         [ #  # ][ #  # ]
                 [ #  # ]
     349                 :            :                 // intentionally no break
     350                 :            :             }
     351                 :            :             case view::PrintableState_JOB_ABORTED :
     352                 :            :             {
     353                 :            :                 // printing not successful, reset DocInfo
     354         [ #  # ]:          0 :                 uno::Reference<document::XDocumentProperties> xDocProps(mpObjectShell->getDocProperties());
     355 [ #  # ][ #  # ]:          0 :                 xDocProps->setPrintedBy(m_aLastPrintedBy);
     356 [ #  # ][ #  # ]:          0 :                 xDocProps->setPrintDate(m_aLastPrinted);
     357                 :          0 :                 break;
     358                 :            :             }
     359                 :            : 
     360                 :            :             case view::PrintableState_JOB_SPOOLED :
     361                 :            :             case view::PrintableState_JOB_COMPLETED :
     362                 :            :             {
     363                 :          0 :                 SfxBindings& rBind = mpViewShell->GetViewFrame()->GetBindings();
     364                 :          0 :                 rBind.Invalidate( SID_PRINTDOC );
     365                 :          0 :                 rBind.Invalidate( SID_PRINTDOCDIRECT );
     366                 :          0 :                 rBind.Invalidate( SID_SETUPPRINTER );
     367                 :          0 :                 bCopyJobSetup = ! m_bTempPrinter;
     368                 :          0 :                 break;
     369                 :            :             }
     370                 :            : 
     371                 :            :             default:
     372                 :          0 :                 break;
     373                 :            :         }
     374                 :            : 
     375 [ #  # ][ #  # ]:          0 :         if( bCopyJobSetup && mpViewShell )
     376                 :            :         {
     377                 :            :             // #i114306#
     378                 :            :             // Note: this possibly creates a printer that gets immediately replaced
     379                 :            :             // by a new one. The reason for this is that otherwise we would not get
     380                 :            :             // the printer's SfxItemSet here to copy. Awkward, but at the moment there is no
     381                 :            :             // other way here to get the item set.
     382                 :          0 :             SfxPrinter* pDocPrt = mpViewShell->GetPrinter(sal_True);
     383         [ #  # ]:          0 :             if( pDocPrt )
     384                 :            :             {
     385         [ #  # ]:          0 :                 if( pDocPrt->GetName() == getPrinter()->GetName() )
     386                 :          0 :                     pDocPrt->SetJobSetup( getPrinter()->GetJobSetup() );
     387                 :            :                 else
     388                 :            :                 {
     389 [ #  # ][ #  # ]:          0 :                     SfxPrinter* pNewPrt = new SfxPrinter( pDocPrt->GetOptions().Clone(), getPrinter()->GetName() );
     390                 :          0 :                     pNewPrt->SetJobSetup( getPrinter()->GetJobSetup() );
     391                 :          0 :                     mpViewShell->SetPrinter( pNewPrt, SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP );
     392                 :            :                 }
     393                 :            :             }
     394                 :            :         }
     395                 :            : 
     396         [ #  # ]:          0 :         if ( m_bNeedsChange )
     397                 :          0 :             mpObjectShell->EnableSetModified( m_bOrigStatus );
     398                 :            : 
     399         [ #  # ]:          0 :         if ( mpViewShell )
     400                 :            :         {
     401                 :          0 :             mpViewShell->pImp->m_pPrinterController.reset();
     402                 :            :         }
     403                 :            :     }
     404                 :          0 : }
     405                 :            : 
     406                 :            : //====================================================================
     407                 :            : 
     408                 :            : class SfxDialogExecutor_Impl
     409                 :            : 
     410                 :            : /*  [Description]
     411                 :            : 
     412                 :            :     An instance of this class is created for the life span of the
     413                 :            :     printer dialogue, to create in its click handler for the additions by the
     414                 :            :     virtual method of the derived SfxViewShell generated print options dialogue
     415                 :            :     and to cache the options set there as SfxItemSet.
     416                 :            : */
     417                 :            : 
     418                 :            : {
     419                 :            : private:
     420                 :            :     SfxViewShell*           _pViewSh;
     421                 :            :     PrinterSetupDialog*     _pSetupParent;
     422                 :            :     SfxItemSet*             _pOptions;
     423                 :            :     sal_Bool                _bHelpDisabled;
     424                 :            : 
     425                 :            :     DECL_LINK( Execute, void * );
     426                 :            : 
     427                 :            : public:
     428                 :            :             SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrinterSetupDialog* pParent );
     429                 :            :             ~SfxDialogExecutor_Impl() { delete _pOptions; }
     430                 :            : 
     431                 :          0 :     Link                GetLink() const { return LINK( this, SfxDialogExecutor_Impl, Execute); }
     432                 :          0 :     const SfxItemSet*   GetOptions() const { return _pOptions; }
     433                 :          0 :     void                DisableHelp() { _bHelpDisabled = sal_True; }
     434                 :            : };
     435                 :            : 
     436                 :            : //--------------------------------------------------------------------
     437                 :            : 
     438                 :          0 : SfxDialogExecutor_Impl::SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrinterSetupDialog* pParent ) :
     439                 :            : 
     440                 :            :     _pViewSh        ( pViewSh ),
     441                 :            :     _pSetupParent   ( pParent ),
     442                 :            :     _pOptions       ( NULL ),
     443                 :          0 :     _bHelpDisabled  ( sal_False )
     444                 :            : 
     445                 :            : {
     446                 :          0 : }
     447                 :            : 
     448                 :            : //--------------------------------------------------------------------
     449                 :            : 
     450                 :          0 : IMPL_LINK_NOARG(SfxDialogExecutor_Impl, Execute)
     451                 :            : {
     452                 :            :     // Options noted locally
     453         [ #  # ]:          0 :     if ( !_pOptions )
     454                 :            :     {
     455                 :            :         DBG_ASSERT( _pSetupParent, "no dialog parent" );
     456         [ #  # ]:          0 :         if( _pSetupParent )
     457                 :          0 :             _pOptions = ( (SfxPrinter*)_pSetupParent->GetPrinter() )->GetOptions().Clone();
     458                 :            :     }
     459                 :            : 
     460                 :            :     // Create Dialog
     461                 :            :     SfxPrintOptionsDialog* pDlg = new SfxPrintOptionsDialog( static_cast<Window*>(_pSetupParent),
     462         [ #  # ]:          0 :                                                              _pViewSh, _pOptions );
     463         [ #  # ]:          0 :     if ( _bHelpDisabled )
     464                 :          0 :         pDlg->DisableHelp();
     465         [ #  # ]:          0 :     if ( pDlg->Execute() == RET_OK )
     466                 :            :     {
     467         [ #  # ]:          0 :         delete _pOptions;
     468                 :          0 :         _pOptions = pDlg->GetOptions().Clone();
     469                 :            : 
     470                 :            :     }
     471         [ #  # ]:          0 :     delete pDlg;
     472                 :            : 
     473                 :          0 :     return 0;
     474                 :            : }
     475                 :            : 
     476                 :            : //-------------------------------------------------------------------------
     477                 :            : 
     478                 :          0 : SfxPrinter* SfxViewShell::SetPrinter_Impl( SfxPrinter *pNewPrinter )
     479                 :            : 
     480                 :            : 
     481                 :            : /* Internal method for setting the differences between 'pNewPrinter' to the
     482                 :            :    current printer. pNewPrinter is either taken over or deleted.
     483                 :            : */
     484                 :            : 
     485                 :            : {
     486                 :            :     // get current Printer
     487         [ #  # ]:          0 :     SfxPrinter *pDocPrinter = GetPrinter();
     488                 :            : 
     489                 :            :     // Evaluate Printer Options
     490                 :          0 :     bool bOriToDoc = false;
     491                 :          0 :     bool bSizeToDoc = false;
     492         [ #  # ]:          0 :     if ( &pDocPrinter->GetOptions() )
     493                 :            :     {
     494         [ #  # ]:          0 :         sal_uInt16 nWhich = GetPool().GetWhich(SID_PRINTER_CHANGESTODOC);
     495                 :          0 :         const SfxFlagItem *pFlagItem = 0;
     496         [ #  # ]:          0 :         pDocPrinter->GetOptions().GetItemState( nWhich, sal_False, (const SfxPoolItem**) &pFlagItem );
     497 [ #  # ][ #  # ]:          0 :         bOriToDoc = pFlagItem ? (pFlagItem->GetValue() & SFX_PRINTER_CHG_ORIENTATION) : sal_False;
     498 [ #  # ][ #  # ]:          0 :         bSizeToDoc = pFlagItem ? (pFlagItem->GetValue() & SFX_PRINTER_CHG_SIZE) : sal_False;
     499                 :            :     }
     500                 :            : 
     501                 :            :     // Determine the previous format and size
     502         [ #  # ]:          0 :     Orientation eOldOri = pDocPrinter->GetOrientation();
     503                 :          0 :     Size aOldPgSz = pDocPrinter->GetPaperSizePixel();
     504                 :            : 
     505                 :            :     // Determine the new format and size
     506         [ #  # ]:          0 :     Orientation eNewOri = pNewPrinter->GetOrientation();
     507                 :          0 :     Size aNewPgSz = pNewPrinter->GetPaperSizePixel();
     508                 :            : 
     509                 :            :     // Determine the changes in page format
     510 [ #  # ][ #  # ]:          0 :     sal_Bool bOriChg = (eOldOri != eNewOri) && bOriToDoc;
     511                 :          0 :     sal_Bool bPgSzChg = ( aOldPgSz.Height() !=
     512                 :          0 :             ( bOriChg ? aNewPgSz.Width() : aNewPgSz.Height() ) ||
     513                 :          0 :             aOldPgSz.Width() !=
     514                 :          0 :             ( bOriChg ? aNewPgSz.Height() : aNewPgSz.Width() ) ) &&
     515   [ #  #  #  # ]:          0 :             bSizeToDoc;
         [ #  # ][ #  # ]
                 [ #  # ]
     516                 :            : 
     517                 :            :     // Message and Flags for page format, summaries changes
     518                 :          0 :     rtl::OUString aMsg;
     519                 :          0 :     sal_uInt16 nNewOpt=0;
     520 [ #  # ][ #  # ]:          0 :     if( bOriChg && bPgSzChg )
     521                 :            :     {
     522 [ #  # ][ #  # ]:          0 :         aMsg = SfxResId(STR_PRINT_NEWORISIZE).toString();
     523                 :          0 :         nNewOpt = SFX_PRINTER_CHG_ORIENTATION | SFX_PRINTER_CHG_SIZE;
     524                 :            :     }
     525         [ #  # ]:          0 :     else if (bOriChg )
     526                 :            :     {
     527 [ #  # ][ #  # ]:          0 :         aMsg = SfxResId(STR_PRINT_NEWORI).toString();
     528                 :          0 :         nNewOpt = SFX_PRINTER_CHG_ORIENTATION;
     529                 :            :     }
     530         [ #  # ]:          0 :     else if (bPgSzChg)
     531                 :            :     {
     532 [ #  # ][ #  # ]:          0 :         aMsg = SfxResId(STR_PRINT_NEWSIZE).toString();
     533                 :          0 :         nNewOpt = SFX_PRINTER_CHG_SIZE;
     534                 :            :     }
     535                 :            : 
     536                 :            :     // Summaries in this variable what has been changed.
     537                 :          0 :     sal_uInt16 nChangedFlags = 0;
     538                 :            : 
     539                 :            :     // Ask if possible, if page format should be taken over from printer.
     540 [ #  # ][ #  # ]:          0 :     if ( ( bOriChg  || bPgSzChg ) &&
         [ #  # ][ #  # ]
     541 [ #  # ][ #  # ]:          0 :         RET_YES == QueryBox(0, WB_YES_NO | WB_DEF_OK, aMsg).Execute() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     542                 :            :     // Flags wich changes for  <SetPrinter(SfxPrinter*)> are maintained
     543                 :          0 :     nChangedFlags |= nNewOpt;
     544                 :            : 
     545                 :            :     // For the MAC to have its "temporary of class String" in next if()
     546         [ #  # ]:          0 :     String aTempPrtName = pNewPrinter->GetName();
     547         [ #  # ]:          0 :     String aDocPrtName = pDocPrinter->GetName();
     548                 :            : 
     549                 :            :     // Was the printer selection changed from Default to Specific
     550                 :            :     // or the other way around?
     551 [ #  # ][ #  # ]:          0 :     if ( (aTempPrtName != aDocPrtName) || (pDocPrinter->IsDefPrinter() != pNewPrinter->IsDefPrinter()) )
         [ #  # ][ #  # ]
     552                 :            :     {
     553                 :          0 :         nChangedFlags |= SFX_PRINTER_PRINTER|SFX_PRINTER_JOBSETUP;
     554                 :          0 :         pDocPrinter = pNewPrinter;
     555                 :            :     }
     556                 :            :     else
     557                 :            :     {
     558                 :            :         // Compare extra options
     559 [ #  # ][ #  # ]:          0 :         if ( ! (pNewPrinter->GetOptions() == pDocPrinter->GetOptions()) )
     560                 :            :         {
     561                 :            :             // Option have changed
     562         [ #  # ]:          0 :             pDocPrinter->SetOptions( pNewPrinter->GetOptions() );
     563                 :          0 :             nChangedFlags |= SFX_PRINTER_OPTIONS;
     564                 :            :         }
     565                 :            : 
     566                 :            :         // Compare JobSetups
     567         [ #  # ]:          0 :         JobSetup aNewJobSetup = pNewPrinter->GetJobSetup();
     568         [ #  # ]:          0 :         JobSetup aOldJobSetup = pDocPrinter->GetJobSetup();
     569 [ #  # ][ #  # ]:          0 :         if ( aNewJobSetup != aOldJobSetup )
     570                 :            :         {
     571                 :          0 :             nChangedFlags |= SFX_PRINTER_JOBSETUP;
     572                 :            :         }
     573                 :            : 
     574                 :            :         // Keep old changed Printer.
     575         [ #  # ]:          0 :         pDocPrinter->SetPrinterProps( pNewPrinter );
     576 [ #  # ][ #  # ]:          0 :         delete pNewPrinter;
         [ #  # ][ #  # ]
     577                 :            :     }
     578                 :            : 
     579         [ #  # ]:          0 :     if ( 0 != nChangedFlags )
     580                 :            :         // SetPrinter will delete the old printer if it changes
     581         [ #  # ]:          0 :         SetPrinter( pDocPrinter, nChangedFlags );
     582 [ #  # ][ #  # ]:          0 :     return pDocPrinter;
     583                 :            : }
     584                 :            : 
     585                 :            : //-------------------------------------------------------------------------
     586                 :            : // Sadly enough the problem arises with WIN32 that nothing is printed when
     587                 :            : // SID_PRINTDOCDIRECT auflaueft. At the moment the only known solution in this
     588                 :            : // case is to turn off the optimazation.
     589                 :            : #ifdef _MSC_VER
     590                 :            : #pragma optimize ( "", off )
     591                 :            : #endif
     592                 :            : 
     593                 :          0 : void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rProps, sal_Bool bIsAPI, sal_Bool bIsDirect )
     594                 :            : {
     595                 :            :     // get the current selection; our controller should know it
     596         [ #  # ]:          0 :     Reference< frame::XController > xController( GetController() );
     597         [ #  # ]:          0 :     Reference< view::XSelectionSupplier > xSupplier( xController, UNO_QUERY );
     598                 :            : 
     599                 :          0 :     Any aSelection;
     600         [ #  # ]:          0 :     if( xSupplier.is() )
     601 [ #  # ][ #  # ]:          0 :         aSelection = xSupplier->getSelection();
     602                 :            :     else
     603 [ #  # ][ #  # ]:          0 :         aSelection <<= GetObjectShell()->GetModel();
                 [ #  # ]
     604 [ #  # ][ #  # ]:          0 :     Any aComplete( makeAny( GetObjectShell()->GetModel() ) );
                 [ #  # ]
     605         [ #  # ]:          0 :     Any aViewProp( makeAny( xController ) );
     606         [ #  # ]:          0 :     boost::shared_ptr<Printer> aPrt;
     607                 :            : 
     608                 :          0 :     const beans::PropertyValue* pVal = rProps.getConstArray();
     609         [ #  # ]:          0 :     for( sal_Int32 i = 0; i < rProps.getLength(); i++ )
     610                 :            :     {
     611         [ #  # ]:          0 :         if ( pVal[i].Name == "PrinterName" )
     612                 :            :         {
     613                 :          0 :             rtl::OUString aPrinterName;
     614                 :          0 :             pVal[i].Value >>= aPrinterName;
     615 [ #  # ][ #  # ]:          0 :             aPrt.reset( new Printer( aPrinterName ) );
                 [ #  # ]
     616                 :          0 :             break;
     617                 :            :         }
     618                 :            :     }
     619                 :            : 
     620                 :            :     boost::shared_ptr<vcl::PrinterController> pController( new SfxPrinterController(
     621                 :            :                                                                                aPrt,
     622                 :            :                                                                                aComplete,
     623                 :            :                                                                                aSelection,
     624                 :            :                                                                                aViewProp,
     625                 :          0 :                                                                                GetRenderable(),
     626                 :            :                                                                                bIsAPI,
     627                 :            :                                                                                bIsDirect,
     628                 :            :                                                                                this,
     629                 :            :                                                                                rProps
     630 [ #  # ][ #  # ]:          0 :                                                                                ) );
         [ #  # ][ #  # ]
     631         [ #  # ]:          0 :     pImp->m_pPrinterController = pController;
     632                 :            : 
     633         [ #  # ]:          0 :     SfxObjectShell *pObjShell = GetObjectShell();
     634                 :            :     pController->setValue( rtl::OUString( "JobName"  ),
     635 [ #  # ][ #  # ]:          0 :                         makeAny( rtl::OUString( pObjShell->GetTitle(0) ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     636                 :            : 
     637                 :            :     // FIXME: job setup
     638         [ #  # ]:          0 :     SfxPrinter* pDocPrt = GetPrinter(sal_False);
     639 [ #  # ][ #  # ]:          0 :     JobSetup aJobSetup = pDocPrt ? pDocPrt->GetJobSetup() : GetJobSetup();
                 [ #  # ]
     640         [ #  # ]:          0 :     if( bIsDirect )
     641                 :            :         aJobSetup.SetValue( String( "IsQuickJob"  ),
     642 [ #  # ][ #  # ]:          0 :                             String( "true"  ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     643                 :            : 
     644 [ #  # ][ #  # ]:          0 :     Printer::PrintJob( pController, aJobSetup );
         [ #  # ][ #  # ]
     645                 :          0 : }
     646                 :            : 
     647                 :          0 : Printer* SfxViewShell::GetActivePrinter() const
     648                 :            : {
     649                 :            :     return (pImp->m_pPrinterController)
     650         [ #  # ]:          0 :         ?  pImp->m_pPrinterController->getPrinter().get() : 0;
     651                 :            : }
     652                 :            : 
     653                 :          0 : void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
     654                 :            : {
     655                 :          0 :     sal_uInt16              nDialogRet = RET_CANCEL;
     656                 :          0 :     SfxPrinter*             pPrinter = 0;
     657                 :          0 :     SfxDialogExecutor_Impl* pExecutor = 0;
     658                 :          0 :     bool                    bSilent = false;
     659                 :            : 
     660                 :            :     // does the function have been called by the user interface or by an API call
     661         [ #  # ]:          0 :     sal_Bool bIsAPI = rReq.IsAPI();
     662         [ #  # ]:          0 :     if ( bIsAPI )
     663                 :            :     {
     664                 :            :         // the function have been called by the API
     665                 :            : 
     666                 :            :         // Should it be visible on the user interface,
     667                 :            :         // should it launch popup dialogue ?
     668 [ #  # ][ #  # ]:          0 :         SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
     669 [ #  # ][ #  # ]:          0 :         bSilent = pSilentItem && pSilentItem->GetValue();
     670                 :            :     }
     671                 :            : 
     672                 :            :     // no help button in dialogs if called from the help window
     673                 :            :     // (pressing help button would exchange the current page inside the help
     674                 :            :     // document that is going to be printed!)
     675         [ #  # ]:          0 :     String aHelpFilterName( DEFINE_CONST_UNICODE("writer_web_HTML_help") );
     676         [ #  # ]:          0 :     SfxMedium* pMedium = GetViewFrame()->GetObjectShell()->GetMedium();
     677 [ #  # ][ #  # ]:          0 :     const SfxFilter* pFilter = pMedium ? pMedium->GetFilter() : NULL;
     678 [ #  # ][ #  # ]:          0 :     sal_Bool bPrintOnHelp = ( pFilter && pFilter->GetFilterName() == aHelpFilterName );
                 [ #  # ]
     679                 :            : 
     680                 :          0 :     const sal_uInt16 nId = rReq.GetSlot();
     681      [ #  #  # ]:          0 :     switch( nId )
     682                 :            :     {
     683                 :            :         case SID_PRINTDOC: // display the printer selection and properties dialogue : File > Printā€¦
     684                 :            :         case SID_PRINTDOCDIRECT: // Print the document directly, without displaying the dialogue
     685                 :            :         {
     686         [ #  # ]:          0 :             SfxObjectShell* pDoc = GetObjectShell();
     687                 :            : 
     688                 :            :             // derived class may decide to abort this
     689 [ #  # ][ #  # ]:          0 :             if( pDoc == NULL || !pDoc->QuerySlotExecutable( nId ) )
         [ #  # ][ #  # ]
     690                 :            :             {
     691 [ #  # ][ #  # ]:          0 :                 rReq.SetReturnValue( SfxBoolItem( 0, sal_False ) );
                 [ #  # ]
     692                 :            :                 return;
     693                 :            :             }
     694                 :            : 
     695 [ #  # ][ #  # ]:          0 :             if ( !bSilent && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES )
         [ #  # ][ #  # ]
     696                 :            :                 return;
     697                 :            : 
     698         [ #  # ]:          0 :             uno::Sequence < beans::PropertyValue > aProps;
     699         [ #  # ]:          0 :             if ( bIsAPI )
     700                 :            :             {
     701                 :            :                 // supported properties:
     702                 :            :                 // String PrinterName
     703                 :            :                 // String FileName
     704                 :            :                 // Int16 From
     705                 :            :                 // Int16 To
     706                 :            :                 // In16 Copies
     707                 :            :                 // String RangeText
     708                 :            :                 // bool Selection
     709                 :            :                 // bool Asynchron
     710                 :            :                 // bool Collate
     711                 :            :                 // bool Silent
     712                 :            : 
     713                 :            :                 // the TransformItems function overwrite aProps
     714 [ #  # ][ #  # ]:          0 :                 TransformItems( nId, *rReq.GetArgs(), aProps, GetInterface()->GetSlot(nId) );
                 [ #  # ]
     715                 :            : 
     716         [ #  # ]:          0 :                 for ( sal_Int32 nProp=0; nProp < aProps.getLength(); ++nProp )
     717                 :            :                 {
     718 [ #  # ][ #  # ]:          0 :                     if ( aProps[nProp].Name == "Copies" )
     719                 :            :                     {
     720         [ #  # ]:          0 :                         aProps[nProp]. Name = rtl::OUString("CopyCount");
     721                 :            :                     }
     722 [ #  # ][ #  # ]:          0 :                     else if ( aProps[nProp].Name == "RangeText" )
     723                 :            :                     {
     724         [ #  # ]:          0 :                         aProps[nProp]. Name = rtl::OUString("Pages");
     725                 :            :                     }
     726 [ #  # ][ #  # ]:          0 :                     else if ( aProps[nProp].Name == "Asynchron" )
     727                 :            :                     {
     728         [ #  # ]:          0 :                         aProps[nProp]. Name = rtl::OUString("Wait");
     729                 :          0 :                         sal_Bool bAsynchron = sal_False;
     730         [ #  # ]:          0 :                         aProps[nProp].Value >>= bAsynchron;
     731 [ #  # ][ #  # ]:          0 :                         aProps[nProp].Value <<= (sal_Bool) (!bAsynchron);
     732                 :            :                     }
     733 [ #  # ][ #  # ]:          0 :                     else if ( aProps[nProp].Name == "Silent" )
     734                 :            :                     {
     735         [ #  # ]:          0 :                         aProps[nProp]. Name = rtl::OUString("MonitorVisible");
     736                 :          0 :                         sal_Bool bPrintSilent = sal_False;
     737         [ #  # ]:          0 :                         aProps[nProp].Value >>= bPrintSilent;
     738 [ #  # ][ #  # ]:          0 :                         aProps[nProp].Value <<= (sal_Bool) (!bPrintSilent);
     739                 :            :                     }
     740                 :            :                 }
     741                 :            :             }
     742                 :            : 
     743                 :            :             // we will add the "PrintSelectionOnly" or "HideHelpButton" properties
     744                 :            :             // we have to increase the capacity of aProps
     745                 :          0 :             sal_Int32 nLen = aProps.getLength();
     746         [ #  # ]:          0 :             aProps.realloc( nLen + 1 );
     747                 :            : 
     748                 :            :             // HACK: writer sets the SID_SELECTION item when printing directly and expects
     749                 :            :             // to get only the selection document in that case (see getSelectionObject)
     750                 :            :             // however it also reacts to the PrintContent property. We need this distinction here, too,
     751                 :            :             // else one of the combinations print / print direct and selection / all will not work.
     752                 :            :             // it would be better if writer handled this internally
     753         [ #  # ]:          0 :             if( nId == SID_PRINTDOCDIRECT )
     754                 :            :             {
     755                 :            :                 // should we print only the selection or the whole document
     756 [ #  # ][ #  # ]:          0 :                 SFX_REQUEST_ARG(rReq, pSelectItem, SfxBoolItem, SID_SELECTION, sal_False);
     757 [ #  # ][ #  # ]:          0 :                 sal_Bool bSelection = ( pSelectItem != NULL && pSelectItem->GetValue() );
     758                 :            : 
     759         [ #  # ]:          0 :                 aProps[nLen].Name = rtl::OUString( "PrintSelectionOnly"  );
     760 [ #  # ][ #  # ]:          0 :                 aProps[nLen].Value = makeAny( bSelection );
     761                 :            :             }
     762                 :            :             else // if nId == SID_PRINTDOC ; nothing to do with the previous HACK
     763                 :            :             {
     764                 :            :                 // should the printer selection and properties dialogue display an help button
     765         [ #  # ]:          0 :                 aProps[nLen].Name = rtl::OUString( "HideHelpButton" );
     766 [ #  # ][ #  # ]:          0 :                 aProps[nLen].Value = makeAny( bPrintOnHelp );
     767                 :            :             }
     768                 :            : 
     769         [ #  # ]:          0 :             ExecPrint( aProps, bIsAPI, (nId == SID_PRINTDOCDIRECT) );
     770                 :            : 
     771                 :            :             // FIXME: Recording
     772         [ #  # ]:          0 :             rReq.Done();
     773         [ #  # ]:          0 :             break;
     774                 :            :         }
     775                 :            :         case SID_SETUPPRINTER : // display the printer settings dialogue : File > Printer Settingsā€¦
     776                 :            :         case SID_PRINTER_NAME : // only for recorded macros
     777                 :            :         {
     778                 :            :             // get printer and printer settings from the document
     779         [ #  # ]:          0 :             SfxPrinter *pDocPrinter = GetPrinter(sal_True);
     780                 :            : 
     781                 :            :             // look for printer in parameters
     782 [ #  # ][ #  # ]:          0 :             SFX_REQUEST_ARG( rReq, pPrinterItem, SfxStringItem, SID_PRINTER_NAME, sal_False );
     783         [ #  # ]:          0 :             if ( pPrinterItem )
     784                 :            :             {
     785                 :            :                 // use PrinterName parameter to create a printer
     786 [ #  # ][ #  # ]:          0 :                 pPrinter = new SfxPrinter( pDocPrinter->GetOptions().Clone(), ((const SfxStringItem*) pPrinterItem)->GetValue() );
                 [ #  # ]
     787                 :            : 
     788                 :            :                 // if printer is unknown, it can't be used - now printer from document will be used
     789         [ #  # ]:          0 :                 if ( !pPrinter->IsKnown() )
     790 [ #  # ][ #  # ]:          0 :                     DELETEZ(pPrinter);
     791                 :            :             }
     792                 :            : 
     793         [ #  # ]:          0 :             if ( SID_PRINTER_NAME == nId )
     794                 :            :             {
     795                 :            :                 // just set a recorded printer name
     796         [ #  # ]:          0 :                 if ( pPrinter )
     797         [ #  # ]:          0 :                     SetPrinter( pPrinter, SFX_PRINTER_PRINTER  );
     798                 :            :                 return;
     799                 :            :             }
     800                 :            : 
     801                 :            :             // no PrinterName parameter in ItemSet or the PrinterName points to an unknown printer
     802         [ #  # ]:          0 :             if ( !pPrinter )
     803                 :            :                 // use default printer from document
     804                 :          0 :                 pPrinter = pDocPrinter;
     805                 :            : 
     806 [ #  # ][ #  # ]:          0 :             if( !pPrinter || !pPrinter->IsValid() )
                 [ #  # ]
     807                 :            :             {
     808                 :            :                 // no valid printer either in ItemSet or at the document
     809         [ #  # ]:          0 :                 if ( !bSilent )
     810 [ #  # ][ #  # ]:          0 :                     ErrorBox( NULL, WB_OK | WB_DEF_OK, SfxResId(STR_NODEFPRINTER).toString() ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     811                 :            : 
     812 [ #  # ][ #  # ]:          0 :                 rReq.SetReturnValue(SfxBoolItem(0,sal_False));
                 [ #  # ]
     813                 :            : 
     814                 :          0 :                 break;
     815                 :            :             }
     816                 :            : 
     817                 :            :             // FIXME: printer isn't used for printing anymore!
     818         [ #  # ]:          0 :             if( pPrinter->IsPrinting() )
     819                 :            :             {
     820                 :            :                 // if printer is busy, abort configuration
     821         [ #  # ]:          0 :                 if ( !bSilent )
     822 [ #  # ][ #  # ]:          0 :                     InfoBox( NULL, SfxResId(STR_ERROR_PRINTER_BUSY).toString() ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     823 [ #  # ][ #  # ]:          0 :                 rReq.SetReturnValue(SfxBoolItem(0,sal_False));
                 [ #  # ]
     824                 :            : 
     825                 :            :                 return;
     826                 :            :             }
     827                 :            : 
     828                 :            :             // if no arguments are given, retrieve them from a dialog
     829         [ #  # ]:          0 :             if ( !bIsAPI )
     830                 :            :             {
     831                 :            :                 // PrinterDialog needs a temporary printer
     832         [ #  # ]:          0 :                 SfxPrinter* pDlgPrinter = pPrinter->Clone();
     833                 :          0 :                 nDialogRet = 0;
     834                 :            : 
     835                 :            :                 // execute PrinterSetupDialog
     836 [ #  # ][ #  # ]:          0 :                 PrinterSetupDialog* pPrintSetupDlg = new PrinterSetupDialog( GetWindow() );
     837                 :            : 
     838         [ #  # ]:          0 :                 if (pImp->m_bHasPrintOptions)
     839                 :            :                 {
     840                 :            :                     // additional controls for dialog
     841         [ #  # ]:          0 :                     pExecutor = new SfxDialogExecutor_Impl( this, pPrintSetupDlg );
     842         [ #  # ]:          0 :                     if ( bPrintOnHelp )
     843                 :          0 :                         pExecutor->DisableHelp();
     844 [ #  # ][ #  # ]:          0 :                     pPrintSetupDlg->SetOptionsHdl( pExecutor->GetLink() );
     845                 :            :                 }
     846                 :            : 
     847                 :          0 :                 pPrintSetupDlg->SetPrinter( pDlgPrinter );
     848         [ #  # ]:          0 :                 nDialogRet = pPrintSetupDlg->Execute();
     849                 :            : 
     850 [ #  # ][ #  # ]:          0 :                 if ( pExecutor && pExecutor->GetOptions() )
                 [ #  # ]
     851                 :            :                 {
     852         [ #  # ]:          0 :                     if ( nDialogRet == RET_OK )
     853                 :            :                         // remark: have to be recorded if possible!
     854         [ #  # ]:          0 :                         pDlgPrinter->SetOptions( *pExecutor->GetOptions() );
     855                 :            :                     else
     856                 :            :                     {
     857         [ #  # ]:          0 :                         pPrinter->SetOptions( *pExecutor->GetOptions() );
     858         [ #  # ]:          0 :                         SetPrinter( pPrinter, SFX_PRINTER_OPTIONS );
     859                 :            :                     }
     860                 :            :                 }
     861                 :            : 
     862 [ #  # ][ #  # ]:          0 :                 DELETEZ( pPrintSetupDlg );
     863                 :            : 
     864                 :            :                 // no recording of PrinterSetup except printer name (is printer dependent)
     865         [ #  # ]:          0 :                 rReq.Ignore();
     866                 :            : 
     867         [ #  # ]:          0 :                 if ( nDialogRet == RET_OK )
     868                 :            :                 {
     869         [ #  # ]:          0 :                     if ( pPrinter->GetName() != pDlgPrinter->GetName() )
     870                 :            :                     {
     871                 :            :                         // user has changed the printer -> macro recording
     872         [ #  # ]:          0 :                         SfxRequest aReq( GetViewFrame(), SID_PRINTER_NAME );
     873 [ #  # ][ #  # ]:          0 :                         aReq.AppendItem( SfxStringItem( SID_PRINTER_NAME, pDlgPrinter->GetName() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     874 [ #  # ][ #  # ]:          0 :                         aReq.Done();
     875                 :            :                     }
     876         [ #  # ]:          0 :                     if ( nId == SID_SETUPPRINTER )
     877                 :            :                     {
     878 [ #  # ][ #  # ]:          0 :                         rReq.AppendItem( SfxBoolItem( SID_DIALOG_RETURN, sal_True ) );
                 [ #  # ]
     879                 :            :                     }
     880                 :            : 
     881                 :            :                     // take the changes made in the dialog
     882         [ #  # ]:          0 :                     pPrinter = SetPrinter_Impl( pDlgPrinter );
     883                 :            : 
     884                 :            :                     // forget new printer, it was taken over (as pPrinter) or deleted
     885                 :          0 :                     pDlgPrinter = NULL;
     886                 :            : 
     887                 :            :                 }
     888                 :            :                 else
     889                 :            :                 {
     890                 :            :                     // PrinterDialog is used to transfer information on printing,
     891                 :            :                     // so it will only be deleted here if dialog was cancelled
     892 [ #  # ][ #  # ]:          0 :                     DELETEZ( pDlgPrinter );
     893         [ #  # ]:          0 :                     rReq.Ignore();
     894         [ #  # ]:          0 :                     if ( SID_PRINTDOC == nId )
     895 [ #  # ][ #  # ]:          0 :                         rReq.SetReturnValue(SfxBoolItem(0,sal_False));
                 [ #  # ]
     896         [ #  # ]:          0 :                     if ( nId == SID_SETUPPRINTER )
     897 [ #  # ][ #  # ]:          0 :                         rReq.AppendItem( SfxBoolItem( SID_DIALOG_RETURN, sal_False ) );
                 [ #  # ]
     898                 :            :                 }
     899                 :            :             }
     900                 :            :         }
     901 [ #  # ][ #  # ]:          0 :     }
     902                 :            : }
     903                 :            : 
     904                 :            : // Turn on optimazation again.
     905                 :            : #ifdef _MSC_VER
     906                 :            : #pragma optimize ( "", on )
     907                 :            : #endif
     908                 :            : 
     909                 :            : //--------------------------------------------------------------------
     910                 :            : 
     911                 :          0 : SfxPrinter* SfxViewShell::GetPrinter( sal_Bool /*bCreate*/ )
     912                 :            : {
     913                 :          0 :     return 0;
     914                 :            : }
     915                 :            : 
     916                 :            : //--------------------------------------------------------------------
     917                 :            : 
     918                 :          0 : sal_uInt16 SfxViewShell::SetPrinter( SfxPrinter* /*pNewPrinter*/, sal_uInt16 /*nDiffFlags*/, bool )
     919                 :            : {
     920                 :          0 :     return 0;
     921                 :            : }
     922                 :            : 
     923                 :            : //--------------------------------------------------------------------
     924                 :            : 
     925                 :          0 : SfxTabPage* SfxViewShell::CreatePrintOptionsPage
     926                 :            : (
     927                 :            :     Window*             /*pParent*/,
     928                 :            :     const SfxItemSet&   /*rOptions*/
     929                 :            : )
     930                 :            : {
     931                 :          0 :     return 0;
     932                 :            : }
     933                 :            : 
     934                 :          0 : JobSetup SfxViewShell::GetJobSetup() const
     935                 :            : {
     936                 :          0 :     return JobSetup();
     937                 :            : }
     938                 :            : 
     939                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10