summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/print.hxx3
-rw-r--r--vcl/inc/printdlg.hxx1
-rw-r--r--vcl/source/gdi/print3.cxx15
-rw-r--r--vcl/source/window/printdlg.cxx36
4 files changed, 51 insertions, 4 deletions
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index 93a56a96f0c4..a8069d2fec8c 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -547,7 +547,10 @@ public:
VCL_DLLPRIVATE bool getReversePrint() const;
VCL_DLLPRIVATE void setPapersizeFromSetup( bool i_bPapersizeFromSetup );
VCL_DLLPRIVATE bool getPapersizeFromSetup() const;
+ VCL_DLLPRIVATE Size& getPaperSizeSetup() const;
VCL_DLLPRIVATE void setPaperSizeFromUser( Size i_aUserSize );
+ VCL_DLLPRIVATE Size& getPaperSizeFromUser() const;
+ VCL_DLLPRIVATE bool isPaperSizeFromUser() const;
void setPrinterModified( bool i_bPapersizeFromSetup );
bool getPrinterModified() const;
VCL_DLLPRIVATE void pushPropertiesToPrinter();
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index 7bedf2a6379b..5afddc7fd73d 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -233,6 +233,7 @@ namespace vcl
void setPaperOrientation( Orientation eOrientation );
void updateOrientationBox( bool bAutomatic = true );
bool hasOrientationChanged() const;
+ void checkPaperSize( Size& rPaperSize );
void setPreviewText();
void updatePrinterText();
void checkControlDependencies();
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 0d5c0af02317..f8ecb70a1889 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -1380,6 +1380,11 @@ bool PrinterController::getPapersizeFromSetup() const
return mpImplData->mbPapersizeFromSetup;
}
+Size& PrinterController::getPaperSizeSetup() const
+{
+ return mpImplData->maDefaultPageSize;
+}
+
void PrinterController::setPaperSizeFromUser( Size i_aUserSize )
{
mpImplData->mbPapersizeFromUser = true;
@@ -1389,6 +1394,16 @@ void PrinterController::setPaperSizeFromUser( Size i_aUserSize )
mpImplData->maUserPageSize = i_aUserSize;
}
+Size& PrinterController::getPaperSizeFromUser() const
+{
+ return mpImplData->maUserPageSize;
+}
+
+bool PrinterController::isPaperSizeFromUser() const
+{
+ return mpImplData->mbPapersizeFromUser;
+}
+
void PrinterController::setPrinterModified( bool i_bPrinterModified )
{
mpImplData->mbPrinterModified = i_bPrinterModified;
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index c15d0417f171..fd5fbbed9dd4 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -1038,11 +1038,36 @@ bool PrintDialog::hasOrientationChanged() const
|| (nOrientation == ORIENTATION_PORTRAIT && eOrientation == Orientation::Landscape);
}
-// Always use this function to set paper orientation in
-// order to update document orientation as well
+// make sure paper size matches paper orientation
+void PrintDialog::checkPaperSize( Size& rPaperSize )
+{
+ Orientation eOrientation = maPController->getPrinter()->GetOrientation();
+ if ( (eOrientation == Orientation::Portrait && rPaperSize.Width() > rPaperSize.Height()) ||
+ (eOrientation == Orientation::Landscape && rPaperSize.Width() < rPaperSize.Height()) )
+ {
+ rPaperSize = Size( rPaperSize.Height(), rPaperSize.Width() );
+ }
+}
+
+// Always use this function to set paper orientation to make sure everything behaves well
void PrintDialog::setPaperOrientation( Orientation eOrientation )
{
- maPController->getPrinter()->SetOrientation( eOrientation );
+ VclPtr<Printer> aPrt( maPController->getPrinter() );
+ aPrt->SetOrientation( eOrientation );
+
+ // check if it's necessary to swap width and height of paper
+ if ( maPController->isPaperSizeFromUser() )
+ {
+ Size& aPaperSize = maPController->getPaperSizeFromUser();
+ checkPaperSize( aPaperSize );
+ }
+ else if ( maPController->getPapersizeFromSetup() )
+ {
+ Size& aPaperSize = maPController->getPaperSizeSetup();
+ checkPaperSize( aPaperSize );
+ }
+
+ // used to sync printer paper orientation with document orientation
maPController->setValue( "IsLandscape",
makeAny( static_cast<sal_Int32>(eOrientation) ) );
}
@@ -2009,7 +2034,10 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
else
aPrt->SetPaper( mePaper );
- maPController->setPaperSizeFromUser( Size( aInfo.getWidth(), aInfo.getHeight() ) );
+ Size aPaperSize = Size( aInfo.getWidth(), aInfo.getHeight() );
+ checkPaperSize( aPaperSize );
+ maPController->setPaperSizeFromUser( aPaperSize );
+
preparePreview();
}
}