summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-05-20 11:00:19 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-05-20 11:26:20 +0100
commitf937ef20f57b306191f7583c2d47b5ad3f2a73ee (patch)
tree47d03b0c855130b22aed1b44b19307ad0310e249
parent62a68bbbe0acea471a04a702ca1372495fc7a2fb (diff)
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
-rw-r--r--include/vcl/print.hxx2
-rw-r--r--vcl/inc/printdlg.hxx1
-rw-r--r--vcl/source/gdi/print3.cxx53
-rw-r--r--vcl/source/window/printdlg.cxx12
-rw-r--r--vcl/uiconfig/ui/printdialog.ui20
5 files changed, 68 insertions, 20 deletions
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index f40801e438ff..40997dd25336 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -521,6 +521,8 @@ public:
VCL_PLUGIN_PUBLIC void setLastPage( sal_Bool i_bLastPage );
SAL_DLLPRIVATE void setReversePrint( sal_Bool i_bReverse );
SAL_DLLPRIVATE bool getReversePrint() const;
+ SAL_DLLPRIVATE void setPapersizeFromSetup( sal_Bool i_bPapersizeFromSetup );
+ SAL_DLLPRIVATE bool getPapersizeFromSetup() const;
SAL_DLLPRIVATE void pushPropertiesToPrinter();
SAL_DLLPRIVATE void resetPaperToLastConfigured();
VCL_PLUGIN_PUBLIC void setJobState( com::sun::star::view::PrintableState );
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<PrinterController>& 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<Printer>& 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_ptr<PrinterCont
maJobPage.mpSetupButton->SetClickHdl( 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 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
+ <!-- interface-requires LibreOffice 1.0 -->
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">16384</property>
@@ -1128,8 +1129,6 @@
<object class="vcllo-ShowNupOrderWindow" id="orderpreview">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">False</property>
- <property name="vexpand">False</property>
<property name="halign">center</property>
<property name="valign">start</property>
</object>
@@ -1464,6 +1463,23 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="papersizefromsetup">
+ <property name="label" translatable="yes">Use only paper size from printer preferences</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="no_show_all">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
</child>
</object>