From f937ef20f57b306191f7583c2d47b5ad3f2a73ee Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 20 May 2013 11:00:19 +0100 Subject: Related: fdo#61186 add a toggle to override the paper format We now need a mechanism to instruct the print dialog that we want to force printing to use the printer settings configured paper. Particularly useful for nup printing and brochures scenario 3: forcing printing to use the printer settings paper a file->printer settings->properties->paper set a paper size, ideally something not used in the test doc, e.g. Executive b file->print->page layout and set pages per sheet to 4 the auto selection for paper will be the first paper size in use, i.e. legal c flip to options and toggle "use only paper size from printer preferences" preview should reconfigure as "Executive" Change-Id: Ie224c252c2cb6c9ee21be5c54e470bca1c7eb0bb --- vcl/inc/printdlg.hxx | 1 + vcl/source/gdi/print3.cxx | 53 ++++++++++++++++++++++++++++-------------- vcl/source/window/printdlg.cxx | 12 +++++++++- vcl/uiconfig/ui/printdialog.ui | 20 ++++++++++++++-- 4 files changed, 66 insertions(+), 20 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx index 30e5fe8e9b6b..f879a63a2431 100644 --- a/vcl/inc/printdlg.hxx +++ b/vcl/inc/printdlg.hxx @@ -175,6 +175,7 @@ namespace vcl public: CheckBox* mpToFileBox; CheckBox* mpCollateSingleJobsBox; + CheckBox* mpPapersizeFromSetup; OutputOptPage( VclBuilder* ); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index cea6bc379a25..7ea71ccc776c 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -151,6 +151,7 @@ public: sal_Bool mbFirstPage; sal_Bool mbLastPage; sal_Bool mbReversePageOrder; + sal_Bool mbPapersizeFromSetup; view::PrintableState meJobState; vcl::PrinterController::MultiPageSetup maMultiPage; @@ -161,9 +162,6 @@ public: // set by user through printer properties subdialog of printer settings dialog Size maDefaultPageSize; - // Set by user through printer properties subdialog of print dialog. - // if set, pages are centered and trimmed onto the fixed page - Size maFixedPageSize; // set by user through printer properties subdialog of printer settings dialog sal_Int32 mnDefaultPaperBin; // Set by user through printer properties subdialog of print dialog. @@ -187,6 +185,7 @@ public: mbFirstPage( sal_True ), mbLastPage( sal_False ), mbReversePageOrder( sal_False ), + mbPapersizeFromSetup( sal_False ), meJobState( view::PrintableState_JOB_STARTED ), mpProgress( NULL ), mnDefaultPaperBin( -1 ), @@ -196,14 +195,14 @@ public: Size getRealPaperSize( const Size& i_rPageSize, bool bNoNUP ) const { - if( maFixedPageSize.Width() > 0 && maFixedPageSize.Height() > 0 ) - return maFixedPageSize; + if( mbPapersizeFromSetup ) + return maDefaultPageSize; if( maMultiPage.nRows * maMultiPage.nColumns > 1 && ! bNoNUP ) return maMultiPage.aPaperSize; return i_rPageSize; } bool isFixedPageSize() const - { return maFixedPageSize.Width() != 0 && maFixedPageSize.Height() != 0; } + { return mbPapersizeFromSetup; } PrinterController::PageSize modifyJobSetup( const Sequence< PropertyValue >& i_rProps, bool bNoNUP ); void resetPaperToLastConfigured(); }; @@ -407,6 +406,14 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr pController->setReversePrint( bReverse ); } + beans::PropertyValue* pPapersizeFromSetupVal = i_pController->getValue( OUString( "PapersizeFromSetup" ) ); + if( pPapersizeFromSetupVal ) + { + sal_Bool bPapersizeFromSetup = sal_False; + pPapersizeFromSetupVal->Value >>= bPapersizeFromSetup; + pController->setPapersizeFromSetup( bPapersizeFromSetup ); + } + // setup NUp printing from properties sal_Int32 nRows = i_pController->getIntProperty( OUString( "NUpRows" ), 1 ); sal_Int32 nCols = i_pController->getIntProperty( OUString( "NUpColumns" ), 1 ); @@ -766,7 +773,6 @@ void PrinterController::setPrinter( const boost::shared_ptr& i_rPrinter mpImplData->maDefaultPageSize = mpImplData->mpPrinter->GetPaperSize(); mpImplData->mpPrinter->Pop(); mpImplData->mnFixedPaperBin = -1; - mpImplData->maFixedPageSize = Size(); } void PrinterController::resetPrinterOptions( bool i_bFileOutput ) @@ -797,19 +803,25 @@ bool PrinterController::setupPrinter( Window* i_pParent ) Size aNewPaperSize(mpImplData->mpPrinter->GetPaperSize()); if (bRet) { - // was papersize or bin overridden ? if so we need to take action - if( aNewPaperSize != aPaperSize ) + bool bInvalidateCache = false; + + // was papersize overridden ? if so we need to take action if we're + // configured to use the driver papersize + if (aNewPaperSize != mpImplData->maDefaultPageSize) { - mpImplData->maFixedPageSize = aNewPaperSize; + mpImplData->maDefaultPageSize = aNewPaperSize; + bInvalidateCache = getPapersizeFromSetup(); } + // was bin overridden ? if so we need to take action sal_uInt16 nNewPaperBin = mpImplData->mpPrinter->GetPaperBin(); - if( nNewPaperBin != nPaperBin ) + if (nNewPaperBin != nPaperBin) { mpImplData->mnFixedPaperBin = nNewPaperBin; + bInvalidateCache = true; } - if( aNewPaperSize != aPaperSize || nNewPaperBin != nPaperBin ) + if (bInvalidateCache) { mpImplData->maPageCache.invalidate(); } @@ -897,14 +909,11 @@ PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( cons //print dialog void vcl::ImplPrinterControllerData::resetPaperToLastConfigured() { - Size aPaperSize(maDefaultPageSize); - if (maFixedPageSize.Width() > 0 && maFixedPageSize.Height() > 0) - aPaperSize = maFixedPageSize; mpPrinter->Push(); mpPrinter->SetMapMode(MapMode(MAP_100TH_MM)); Size aCurSize(mpPrinter->GetPaperSize()); - if (aPaperSize != aCurSize) - mpPrinter->SetPaperSizeUser(aPaperSize, !isFixedPageSize()); + if (aCurSize != maDefaultPageSize) + mpPrinter->SetPaperSizeUser(maDefaultPageSize, !isFixedPageSize()); mpPrinter->Pop(); } @@ -1331,6 +1340,16 @@ bool PrinterController::getReversePrint() const return mpImplData->mbReversePageOrder; } +void PrinterController::setPapersizeFromSetup( sal_Bool i_bPapersizeFromSetup ) +{ + mpImplData->mbPapersizeFromSetup = i_bPapersizeFromSetup; +} + +bool PrinterController::getPapersizeFromSetup() const +{ + return mpImplData->mbPapersizeFromSetup; +} + Sequence< PropertyValue > PrinterController::getJobProperties( const Sequence< PropertyValue >& i_rMergeList ) const { boost::unordered_set< OUString, OUStringHash > aMergeSet; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 97804a9ba828..f11044c6263e 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -534,6 +534,7 @@ PrintDialog::OutputOptPage::OutputOptPage( VclBuilder *pUIBuilder ) { pUIBuilder->get(mpToFileBox, "printtofile"); pUIBuilder->get(mpCollateSingleJobsBox, "singleprintjob"); + pUIBuilder->get(mpPapersizeFromSetup, "papersizefromsetup"); } void PrintDialog::OutputOptPage::readFromSettings() @@ -671,6 +672,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrSetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maNUpPage.mpBorderCB->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maOptionsPage.mpToFileBox->SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); + maOptionsPage.mpPapersizeFromSetup->SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); maJobPage.mpReverseOrderBox->SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); maOptionsPage.mpCollateSingleJobsBox->SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); maNUpPage.mpPagesBtn->SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); @@ -723,7 +725,7 @@ void PrintDialog::readFromSettings() maNUpPage.readFromSettings(); maOptionsPage.readFromSettings(); - // read last selected tab page; if it exists, actiavte it + // read last selected tab page; if it exists, activate it SettingsConfigItem* pItem = SettingsConfigItem::get(); OUString aValue = pItem->getValue( OUString( "PrintDialog" ), OUString( "LastPage" ) ); @@ -1534,6 +1536,14 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) maPController->resetPrinterOptions( maOptionsPage.mpToFileBox->IsChecked() ); preparePreview( true, true ); } + else if( pButton == maOptionsPage.mpPapersizeFromSetup ) + { + sal_Bool bChecked = maOptionsPage.mpPapersizeFromSetup->IsChecked(); + maPController->setPapersizeFromSetup( bChecked ); + maPController->setValue( OUString( "PapersizeFromSetup" ), + makeAny( bChecked ) ); + preparePreview( true, true ); + } else if( pButton == maNUpPage.mpBrochureBtn ) { PropertyValue* pVal = getValueForWindow( pButton ); diff --git a/vcl/uiconfig/ui/printdialog.ui b/vcl/uiconfig/ui/printdialog.ui index a0d9453dd232..2aa464b88d6c 100644 --- a/vcl/uiconfig/ui/printdialog.ui +++ b/vcl/uiconfig/ui/printdialog.ui @@ -1,6 +1,7 @@ + 1 16384 @@ -1128,8 +1129,6 @@ True False - False - False center start @@ -1464,6 +1463,23 @@ 1 + + + Use only paper size from printer preferences + True + True + False + True + 0 + True + + + 0 + 3 + 1 + 1 + + -- cgit