summaryrefslogtreecommitdiff
path: root/vcl/source/window/printdlg.cxx
diff options
context:
space:
mode:
authorDaniel <danielfaleirosilva@gmail.com>2018-08-12 17:32:30 -0300
committerDaniel Silva <danielfaleirosilva@gmail.com>2018-11-29 13:02:16 -0200
commit8cbdc6a068ad88fc43a98bd0f88fcb7c4ad3ebd9 (patch)
treed276ebbb6ab0cc974ce61c5d289091ca5cff068f /vcl/source/window/printdlg.cxx
parentfaf2b0f165e9d9e3160e5d54e3d2e9973facf0b8 (diff)
Resolves the mismatching behavior between page size and orientatin selection
Change-Id: I8482fa062441aac59fac7324b0987eb20face077 Reviewed-on: https://gerrit.libreoffice.org/58907 Tested-by: Jenkins Reviewed-by: Daniel Silva <danielfaleirosilva@gmail.com>
Diffstat (limited to 'vcl/source/window/printdlg.cxx')
-rw-r--r--vcl/source/window/printdlg.cxx36
1 files changed, 32 insertions, 4 deletions
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();
}
}