diff options
author | Oliver Bolte <obo@openoffice.org> | 2007-01-23 06:40:17 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2007-01-23 06:40:17 +0000 |
commit | 697dfdda54487535639eaed6da630be34b720b30 (patch) | |
tree | 55b8d165dadc2c308a1f856e2dfe191073446b7d /sfx2 | |
parent | 35fa2104eeee318ab14ba19cc1b6c4e6911fcfd0 (diff) |
INTEGRATION: CWS fwk59 (1.23.92); FILE MERGED
2007/01/10 09:01:32 mav 1.23.92.1: #i19025# do not allow to change document modified state when configuration requires so
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/viewprn.cxx | 70 |
1 files changed, 43 insertions, 27 deletions
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 4d260f36aa4a..a3a48813e6f7 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -4,9 +4,9 @@ * * $RCSfile: viewprn.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: obo $ $Date: 2007-01-23 07:15:25 $ + * last change: $Author: obo $ $Date: 2007-01-23 07:40:17 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -339,6 +339,38 @@ SfxPrinter* SfxViewShell::SetPrinter_Impl( SfxPrinter *pNewPrinter ) #pragma optimize ( "", off ) #endif +class SfxPrintGuard_Impl +{ + SfxObjectShell* m_pObjectShell; + sal_Bool m_bOrigStatus; + sal_Bool m_bNeedsChange; + +public: + SfxPrintGuard_Impl( SfxObjectShell* pObjectShell ) + : m_pObjectShell( pObjectShell ) + , m_bOrigStatus( sal_False ) + , m_bNeedsChange( sal_False ) + { + if ( m_pObjectShell ) + { + m_bOrigStatus = m_pObjectShell->IsEnableSetModified(); + + // check configuration: shall update of printing information in DocInfo set the document to "modified"? + if ( m_bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() ) + { + m_pObjectShell->EnableSetModified( sal_False ); + m_bNeedsChange = sal_True; + } + } + } + + ~SfxPrintGuard_Impl() + { + if ( m_pObjectShell && m_bNeedsChange ) + m_pObjectShell->EnableSetModified( m_bOrigStatus ); + } +}; + void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) { USHORT nCopies=1; @@ -426,6 +458,13 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) const SfxFilter* pFilter = pMedium ? pMedium->GetFilter() : NULL; sal_Bool bPrintOnHelp = ( pFilter && pFilter->GetFilterName() == aHelpFilterName ); + SfxObjectShell* pDoc = NULL; + if ( SID_PRINTDOC == nId ) + pDoc = GetObjectShell(); + + // Let the document stay nonmodified during the printing if the configuration says to do so + SfxPrintGuard_Impl aGuard( pDoc ); + // if no arguments are given, retrieve them from a dialog if ( !bIsAPI ) { @@ -434,7 +473,6 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) nDialogRet = 0; if ( SID_PRINTDOC == nId ) { - SfxObjectShell* pDoc = GetObjectShell(); bool bDetectHidden = ( !bSilent && !bPrintOnHelp && pDoc ); if ( !bDetectHidden || pDoc->QueryHiddenInformation( WhenPrinting, NULL ) == RET_YES ) @@ -684,33 +722,18 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) if ( !pInfo->IsUseUserData() ) aUserName.Erase(); - // check configuration: shall update of printing information in DocInfo set the document to "modified"? - BOOL bOldFlag = pObjSh->IsEnableSetModified(); - BOOL bDontModifyDoc = !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed(); - if ( bDontModifyDoc && bOldFlag ) - // prevent document from getting into the "modified" state - pObjSh->EnableSetModified( FALSE ); + // Let the document stay nonmodified during the printing if the configuration says to do so + SfxPrintGuard_Impl aGuard( pObjSh ); pInfo->SetPrinted( aUserName ); pObjSh->Broadcast( SfxDocumentInfoHint( pInfo ) ); - if ( bDontModifyDoc && bOldFlag != pObjSh->IsEnableSetModified() ) - pObjSh->EnableSetModified( bOldFlag ); - GetObjectShell()->Broadcast( SfxPrintingHint( -1, pPrintDlg, pPrinter ) ); ErrCode nError = DoPrint( pPrinter, pPrintDlg, bSilent ); if ( nError == PRINTER_OK ) { - // printer was started sucessfully - bOldFlag = pObjSh->IsEnableSetModified(); - if ( bDontModifyDoc && bOldFlag ) - pObjSh->EnableSetModified( FALSE ); - pObjSh->FlushDocInfo(); - if ( bDontModifyDoc && bOldFlag != pObjSh->IsEnableSetModified() ) - pObjSh->EnableSetModified( bOldFlag ); - Invalidate( SID_PRINTDOC ); Invalidate( SID_PRINTDOCDIRECT ); Invalidate( SID_SETUPPRINTER ); @@ -728,17 +751,10 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) } else { - bOldFlag = pObjSh->IsEnableSetModified(); - if ( bDontModifyDoc && bOldFlag ) - pObjSh->EnableSetModified( FALSE ); - // printing not succesful, reset DocInfo pInfo->SetPrinted(aOldStamp); pObjSh->Broadcast( SfxDocumentInfoHint( pInfo ) ); - if ( bDontModifyDoc && bOldFlag != pObjSh->IsEnableSetModified() ) - pObjSh->EnableSetModified( bOldFlag ); - if ( nError != PRINTER_ABORT ) { // "real" problem (not simply printing cancelled by user) |