summaryrefslogtreecommitdiff
path: root/vcl
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
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')
-rw-r--r--vcl/inc/printdlg.hxx1
-rw-r--r--vcl/source/gdi/print3.cxx15
-rw-r--r--vcl/source/window/printdlg.cxx36
3 files changed, 48 insertions, 4 deletions
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();
}
}