summaryrefslogtreecommitdiff
path: root/vcl/source/window
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-01-31 20:27:54 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-02-01 11:16:43 +0100
commitddaebfb270c4b52ddebaf678a9352312c75247fa (patch)
treee64bb9ecbcece35a7cd4adb4b8c66bfead2ddc0b /vcl/source/window
parentde5aa409353c839483df21d47254fd2a508ab7d9 (diff)
fix the orientation combobox in the print dialog
Changing the orientation value to anything else than 'Automatic' didn't do anything by default. This was because by default neither isPaperSizeFromUser() nor getPapersizeFromSetup() were set, so PrintDialog::setPaperOrientation() did nothing. It looks to me like 8cbdc6a068ad88fc43a98bd0f88 that introduced it was rather broken (not just this bug, but also e.g. the ugly modifying of the paper sizes by non-const reference from a const function). In fact this whole stuff still looks broken to me, why does it change paper size instead of just setting the orientation? It seems like the orientation gets reset, or maybe the setting was just a band-aid. I don't know how to fix that all though. Change-Id: If5fdf4c47e06f2b0797d27126d21b3451b8334cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129239 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/source/window')
-rw-r--r--vcl/source/window/printdlg.cxx37
1 files changed, 6 insertions, 31 deletions
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index e98afe8db92b..bb89ebbd5e9b 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -1025,35 +1025,12 @@ bool PrintDialog::hasOrientationChanged() const
|| (nOrientation == ORIENTATION_PORTRAIT && eOrientation == Orientation::Landscape);
}
-// 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()) )
- {
- // coverity[swapped-arguments : FALSE] - this is in the correct order
- 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 )
+void PrintDialog::setPaperOrientation( Orientation eOrientation, bool fromUser )
{
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 );
- }
+ maPController->setOrientationFromUser( eOrientation, fromUser );
}
void PrintDialog::checkControlDependencies()
@@ -1174,12 +1151,12 @@ void PrintDialog::updateNup( bool i_bMayUseCache )
if( aMultiSize.Width() > aMultiSize.Height() ) // fits better on landscape
{
aMPS.aPaperSize = maNupLandscapeSize;
- setPaperOrientation( Orientation::Landscape );
+ setPaperOrientation( Orientation::Landscape, false );
}
else
{
aMPS.aPaperSize = maNupPortraitSize;
- setPaperOrientation( Orientation::Portrait );
+ setPaperOrientation( Orientation::Portrait, false );
}
}
@@ -2000,7 +1977,7 @@ IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
{
int nOrientation = mxOrientationBox->get_active();
if ( nOrientation != ORIENTATION_AUTOMATIC )
- setPaperOrientation( static_cast<Orientation>( nOrientation - 1 ) );
+ setPaperOrientation( static_cast<Orientation>( nOrientation - 1 ), true );
updateNup( false );
}
@@ -2026,9 +2003,7 @@ IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
else
aPrt->SetPaper( mePaper );
- Size aPaperSize( aInfo.getWidth(), aInfo.getHeight() );
- checkPaperSize( aPaperSize );
- maPController->setPaperSizeFromUser( aPaperSize );
+ maPController->setPaperSizeFromUser( Size( aInfo.getWidth(), aInfo.getHeight() ) );
maUpdatePreviewIdle.Start();
}