summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/print3.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/gdi/print3.cxx')
-rwxr-xr-x[-rw-r--r--]vcl/source/gdi/print3.cxx80
1 files changed, 55 insertions, 25 deletions
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index f6bd81ef1bea..8b4bf5163839 100644..100755
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -186,17 +186,17 @@ public:
{}
~ImplPrinterControllerData() { delete mpProgress; }
- Size getRealPaperSize( const Size& i_rPageSize ) const
+ Size getRealPaperSize( const Size& i_rPageSize, bool bNoNUP ) const
{
if( maFixedPageSize.Width() > 0 && maFixedPageSize.Height() > 0 )
return maFixedPageSize;
- if( maMultiPage.nRows * maMultiPage.nColumns > 1 )
+ if( maMultiPage.nRows * maMultiPage.nColumns > 1 && ! bNoNUP )
return maMultiPage.aPaperSize;
return i_rPageSize;
}
bool isFixedPageSize() const
{ return maFixedPageSize.Width() != 0 && maFixedPageSize.Height() != 0; }
- PrinterController::PageSize modifyJobSetup( const Sequence< PropertyValue >& i_rProps );
+ PrinterController::PageSize modifyJobSetup( const Sequence< PropertyValue >& i_rProps, bool bNoNUP );
};
PrinterController::PrinterController()
@@ -446,8 +446,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() )
@@ -455,9 +454,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" ) ),
@@ -596,17 +593,25 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl::
i_pController->jobStarted();
int nJobs = 1;
- int nRepeatCount = bUserCopy ? mnCopyCount : 1;
+ int nOuterRepeatCount = 1;
+ int nInnerRepeatCount = 1;
+ if( bUserCopy )
+ {
+ if( mbCollateCopy )
+ nOuterRepeatCount = mnCopyCount;
+ else
+ nInnerRepeatCount = mnCopyCount;
+ }
if( bSinglePrintJobs )
{
nJobs = mnCopyCount;
nCopies = 1;
- nRepeatCount = 1;
+ nOuterRepeatCount = nInnerRepeatCount = 1;
}
for( int nJobIteration = 0; nJobIteration < nJobs; nJobIteration++ )
{
- bool bError = false;
+ bool bError = false, bAborted = false;
if( mpPrinter->StartJob( pPrintFile,
i_rJobName,
Application::GetDisplayName(),
@@ -618,13 +623,26 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl::
mbJobActive = TRUE;
i_pController->createProgressDialog();
int nPages = i_pController->getFilteredPageCount();
- for( int nIteration = 0; nIteration < nRepeatCount; nIteration++ )
+ for( int nOuterIteration = 0; nOuterIteration < nOuterRepeatCount && ! bAborted; nOuterIteration++ )
{
- for( int nPage = 0; nPage < nPages; nPage++ )
+ for( int nPage = 0; nPage < nPages && ! bAborted; nPage++ )
{
- if( nPage == nPages-1 && nIteration == nRepeatCount-1 && nJobIteration == nJobs-1 )
- i_pController->setLastPage( sal_True );
- i_pController->printFilteredPage( nPage );
+ for( int nInnerIteration = 0; nInnerIteration < nInnerRepeatCount && ! bAborted; nInnerIteration++ )
+ {
+ if( nPage == nPages-1 &&
+ nOuterIteration == nOuterRepeatCount-1 &&
+ nInnerIteration == nInnerRepeatCount-1 &&
+ nJobIteration == nJobs-1 )
+ {
+ i_pController->setLastPage( sal_True );
+ }
+ i_pController->printFilteredPage( nPage );
+ if( i_pController->isProgressCanceled() )
+ {
+ i_pController->abortJob();
+ bAborted = true;
+ }
+ }
}
// FIXME: duplex ?
}
@@ -740,7 +758,7 @@ bool PrinterController::setupPrinter( Window* i_pParent )
return bRet;
}
-PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( const Sequence< PropertyValue >& i_rProps )
+PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( const Sequence< PropertyValue >& i_rProps, bool bNoNUP )
{
PrinterController::PageSize aPageSize;
aPageSize.aSize = mpPrinter->GetPaperSize();
@@ -775,7 +793,7 @@ PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( cons
if( aSetSize.Width && aSetSize.Height )
{
Size aSetPaperSize( aSetSize.Width, aSetSize.Height );
- Size aRealPaperSize( getRealPaperSize( aSetPaperSize ) );
+ Size aRealPaperSize( getRealPaperSize( aSetPaperSize, bNoNUP ) );
if( aRealPaperSize != aCurSize )
aIsSize = aSetSize;
}
@@ -785,7 +803,7 @@ PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( cons
aPageSize.aSize.Width() = aIsSize.Width;
aPageSize.aSize.Height() = aIsSize.Height;
- Size aRealPaperSize( getRealPaperSize( aPageSize.aSize ) );
+ Size aRealPaperSize( getRealPaperSize( aPageSize.aSize, bNoNUP ) );
if( aRealPaperSize != aCurSize )
mpPrinter->SetPaperSizeUser( aRealPaperSize, ! isFixedPageSize() );
}
@@ -851,7 +869,7 @@ PrinterController::PageSize PrinterController::getPageFile( int i_nUnfilteredPag
mpImplData->mpPrinter->SetMapMode( aMapMode );
// modify job setup if necessary
- PrinterController::PageSize aPageSize = mpImplData->modifyJobSetup( aPageParm );
+ PrinterController::PageSize aPageSize = mpImplData->modifyJobSetup( aPageParm, true );
o_rMtf.SetPrefSize( aPageSize.aSize );
o_rMtf.SetPrefMapMode( aMapMode );
@@ -933,7 +951,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte
rMPS.nTopMargin == 0 && rMPS.nBottomMargin == 0 )
{
PrinterController::PageSize aPageSize = getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache );
- Size aPaperSize = mpImplData->getRealPaperSize( aPageSize.aSize );
+ Size aPaperSize = mpImplData->getRealPaperSize( aPageSize.aSize, true );
mpImplData->mpPrinter->SetMapMode( MapMode( MAP_100TH_MM ) );
mpImplData->mpPrinter->SetPaperSizeUser( aPaperSize, ! mpImplData->isFixedPageSize() );
if( aPaperSize != aPageSize.aSize )
@@ -942,7 +960,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte
o_rMtf.WindStart();
long nDX = (aPaperSize.Width() - aPageSize.aSize.Width()) / 2;
long nDY = (aPaperSize.Height() - aPageSize.aSize.Height()) / 2;
- o_rMtf.Move( nDX, nDY );
+ o_rMtf.Move( nDX, nDY, mpImplData->mpPrinter->ImplGetDPIX(), mpImplData->mpPrinter->ImplGetDPIY() );
o_rMtf.WindStart();
o_rMtf.SetPrefSize( aPaperSize );
aPageSize.aSize = aPaperSize;
@@ -955,7 +973,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte
sal_Bool bIsLastPage = mpImplData->mbLastPage;
mpImplData->mbLastPage = sal_False;
- Size aPaperSize( mpImplData->getRealPaperSize( mpImplData->maMultiPage.aPaperSize ) );
+ Size aPaperSize( mpImplData->getRealPaperSize( mpImplData->maMultiPage.aPaperSize, false ) );
// multi page area: page size minus margins + one time spacing right and down
// the added spacing is so each subpage can be calculated including its spacing
@@ -1017,7 +1035,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte
long nOffY = (aSubPageSize.Height() - long(double(aPageSize.aSize.Height()) * fScale)) / 2;
long nX = rMPS.nLeftMargin + nOffX + nAdvX * nCellX;
long nY = rMPS.nTopMargin + nOffY + nAdvY * nCellY;
- aPageFile.Move( nX, nY );
+ aPageFile.Move( nX, nY, mpImplData->mpPrinter->ImplGetDPIX(), mpImplData->mpPrinter->ImplGetDPIY() );
aPageFile.WindStart();
// calculate border rectangle
Rectangle aSubPageRect( Point( nX, nY ),
@@ -1137,7 +1155,7 @@ void PrinterController::printFilteredPage( int i_nPage )
{
Point aPageOffset( mpImplData->mpPrinter->GetPageOffset() );
aPageFile.WindStart();
- aPageFile.Move( -aPageOffset.X(), -aPageOffset.Y() );
+ aPageFile.Move( -aPageOffset.X(), -aPageOffset.Y(), mpImplData->mpPrinter->ImplGetDPIX(), mpImplData->mpPrinter->ImplGetDPIY() );
}
GDIMetaFile aCleanedFile;
@@ -1169,6 +1187,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 )
@@ -1522,6 +1547,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;