summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-05-17 15:20:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-05-17 15:25:40 +0100
commit7a5bfde13afd98f1a8e110a96a636119da2ad911 (patch)
treeb1510b2f09ad194af477fb1e16fd2573447048cd
parent6389bf38961d84fd3e1c8fbdc78040e1b1be3ba9 (diff)
Related: fdo#61186 ensure printer settings paper format is not clobbered
scenario 1: with attached test document a file->printer settings->properties->paper set a paper size, ideally something not used in the test doc, e.g. Executive b file->print->print c file->printer settings->properties->paper the paper size here should now still be what was selected in a and *not* what happened to be the last page format used in the document which is letter Change-Id: I66be32e2d03381dc2103479f1be46669a342a2ab
-rw-r--r--include/vcl/print.hxx1
-rw-r--r--vcl/source/gdi/print3.cxx45
2 files changed, 42 insertions, 4 deletions
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index c0cb364b7307..f40801e438ff 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -522,6 +522,7 @@ public:
SAL_DLLPRIVATE void setReversePrint( sal_Bool i_bReverse );
SAL_DLLPRIVATE bool getReversePrint() const;
SAL_DLLPRIVATE void pushPropertiesToPrinter();
+ SAL_DLLPRIVATE void resetPaperToLastConfigured();
VCL_PLUGIN_PUBLIC void setJobState( com::sun::star::view::PrintableState );
SAL_DLLPRIVATE bool setupPrinter( Window* i_pDlgParent );
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 3d0e4b0390b5..0eb299d59285 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -159,12 +159,14 @@ public:
ImplPageCache maPageCache;
- // set by user through printer config dialog
+ // 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 config dialog
+ // set by user through printer properties subdialog of printer settings dialog
sal_Int32 mnDefaultPaperBin;
- // Set by user through printer preferences in print dialog.
+ // Set by user through printer properties subdialog of print dialog.
// Overrides application-set tray for a page.
sal_Int32 mnFixedPaperBin;
@@ -203,6 +205,7 @@ public:
bool isFixedPageSize() const
{ return maFixedPageSize.Width() != 0 && maFixedPageSize.Height() != 0; }
PrinterController::PageSize modifyJobSetup( const Sequence< PropertyValue >& i_rProps, bool bNoNUP );
+ void resetPaperToLastConfigured();
};
PrinterController::PrinterController( const boost::shared_ptr<Printer>& i_pPrinter )
@@ -502,6 +505,8 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr
pController->getPrinter()->StartJob( String( aJobName ), pController );
+ pController->resetPaperToLastConfigured();
+
pController->jobFinished( pController->getJobState() );
}
@@ -756,10 +761,15 @@ void PrinterController::setPrinter( const boost::shared_ptr<Printer>& i_rPrinter
setValue( OUString( "Name" ),
makeAny( OUString( i_rPrinter->GetName() ) ) );
mpImplData->mnDefaultPaperBin = mpImplData->mpPrinter->GetPaperBin();
+ mpImplData->mpPrinter->Push();
+ mpImplData->mpPrinter->SetMapMode(MapMode(MAP_100TH_MM));
+ mpImplData->maDefaultPageSize = mpImplData->mpPrinter->GetPaperSize();
+ mpImplData->mpPrinter->Pop();
mpImplData->mnFixedPaperBin = -1;
+ mpImplData->maFixedPageSize = Size();
}
-void PrinterController:: resetPrinterOptions( bool i_bFileOutput )
+void PrinterController::resetPrinterOptions( bool i_bFileOutput )
{
PrinterOptions aOpt;
aOpt.ReadFromConfig( i_bFileOutput );
@@ -861,6 +871,28 @@ PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( cons
return aPageSize;
}
+//fdo#61886
+//
+//when printing is finished, set the paper size of the printer to either what
+//the user explicitly set as the desired paper size, or fallback to whatever
+//the printer had before printing started. That way it doesn't contain the last
+//paper size of a multiple paper size using document when we are in our normal
+//auto accept document paper size mode and end up overwriting the original
+//paper size setting for file->printer_settings just by pressing "ok" in the
+//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());
+ mpPrinter->Pop();
+}
+
int PrinterController::getPageCountProtected() const
{
const MapMode aMapMode( MAP_100TH_MM );
@@ -1604,6 +1636,11 @@ const PrinterController::MultiPageSetup& PrinterController::getMultipage() const
return mpImplData->maMultiPage;
}
+void PrinterController::resetPaperToLastConfigured()
+{
+ mpImplData->resetPaperToLastConfigured();
+}
+
void PrinterController::pushPropertiesToPrinter()
{
sal_Int32 nCopyCount = 1;