From 6bb9f5bea7037dcda3cb3e104452fb0104544bfb Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 12 Aug 2010 13:32:56 +0200 Subject: ooo33gsl05: #i113821# ensure last page renders when aborting job --- vcl/inc/vcl/print.hxx | 1 + vcl/source/gdi/print3.cxx | 32 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 96822d9bc756..0cd56e32d83d 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -520,6 +520,7 @@ public: SAL_DLLPRIVATE void setPrinter( const boost::shared_ptr& ); SAL_DLLPRIVATE void setOptionChangeHdl( const Link& ); SAL_DLLPRIVATE void createProgressDialog(); + SAL_DLLPRIVATE bool isProgressCanceled() const; SAL_DLLPRIVATE void setMultipage( const MultiPageSetup& ); SAL_DLLPRIVATE const MultiPageSetup& getMultipage() const; SAL_DLLPRIVATE void setLastPage( sal_Bool i_bLastPage ); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 0aeb928856fc..b3f858a06f2d 100755 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -444,8 +444,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr if( ! aDlg.Execute() ) { GDIMetaFile aPageFile; - i_pController->setLastPage( sal_True ); - i_pController->getFilteredPageFile( 0, aPageFile ); + i_pController->abortJob(); return; } if( aDlg.isPrintToFile() ) @@ -453,9 +452,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr rtl::OUString aFile = queryFile( pController->getPrinter().get() ); if( ! aFile.getLength() ) { - GDIMetaFile aPageFile; - i_pController->setLastPage( sal_True ); - i_pController->getFilteredPageFile( 0, aPageFile ); + i_pController->abortJob(); return; } pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ), @@ -612,7 +609,7 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrStartJob( pPrintFile, i_rJobName, Application::GetDisplayName(), @@ -624,11 +621,11 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrcreateProgressDialog(); int nPages = i_pController->getFilteredPageCount(); - for( int nOuterIteration = 0; nOuterIteration < nOuterRepeatCount; nOuterIteration++ ) + for( int nOuterIteration = 0; nOuterIteration < nOuterRepeatCount && ! bAborted; nOuterIteration++ ) { - for( int nPage = 0; nPage < nPages; nPage++ ) + for( int nPage = 0; nPage < nPages && ! bAborted; nPage++ ) { - for( int nInnerIteration = 0; nInnerIteration < nInnerRepeatCount; nInnerIteration++ ) + for( int nInnerIteration = 0; nInnerIteration < nInnerRepeatCount && ! bAborted; nInnerIteration++ ) { if( nPage == nPages-1 && nOuterIteration == nOuterRepeatCount-1 && @@ -638,6 +635,11 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrsetLastPage( sal_True ); } i_pController->printFilteredPage( nPage ); + if( i_pController->isProgressCanceled() ) + { + i_pController->abortJob(); + bAborted = true; + } } } // FIXME: duplex ? @@ -1183,6 +1185,13 @@ void PrinterController::jobFinished( view::PrintableState ) void PrinterController::abortJob() { setJobState( view::PrintableState_JOB_ABORTED ); + // applications (well, sw) depend on a page request with "IsLastPage" = true + // to free resources, else they (well, sw) will crash eventually + setLastPage( sal_True ); + delete mpImplData->mpProgress; + mpImplData->mpProgress = NULL; + GDIMetaFile aMtf; + getPageFile( 0, aMtf, false ); } void PrinterController::setLastPage( sal_Bool i_bLastPage ) @@ -1515,6 +1524,11 @@ void PrinterController::createProgressDialog() mpImplData->mpProgress->reset(); } +bool PrinterController::isProgressCanceled() const +{ + return mpImplData->mpProgress && mpImplData->mpProgress->isCanceled(); +} + void PrinterController::setMultipage( const MultiPageSetup& i_rMPS ) { mpImplData->maMultiPage = i_rMPS; -- cgit v1.2.3