summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM>2010-08-12 13:32:56 +0200
committerPhilipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM>2010-08-12 13:32:56 +0200
commit6bb9f5bea7037dcda3cb3e104452fb0104544bfb (patch)
tree6d9317db3e0cbb557f9c9ad016cf0cca87fb0944
parent95e33c19c083f800dc188ffc63bb5c550950724a (diff)
ooo33gsl05: #i113821# ensure last page renders when aborting job
-rw-r--r--vcl/inc/vcl/print.hxx1
-rwxr-xr-xvcl/source/gdi/print3.cxx32
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<Printer>& );
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<PrinterController>& 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<PrinterController>& 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_ptr<vcl::
for( int nJobIteration = 0; nJobIteration < nJobs; nJobIteration++ )
{
- bool bError = false;
+ bool bError = false, bAborted = false;
if( mpPrinter->StartJob( pPrintFile,
i_rJobName,
Application::GetDisplayName(),
@@ -624,11 +621,11 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl::
mbJobActive = TRUE;
i_pController->createProgressDialog();
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_ptr<vcl::
i_pController->setLastPage( 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;