vcl/source/gdi/print3.cxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
New commits: commit 30b36f1c1526833bcbcc75a329d9a5c8f559b6ab Author: Justin Luth <[email protected]> AuthorDate: Thu Oct 23 15:08:21 2025 -0400 Commit: Miklos Vajna <[email protected]> CommitDate: Wed Nov 19 10:47:24 2025 +0100 tdf#166185 vcl PrinterController: auto orient in getRealPaperSize This patch fixes the situation when you print a landscape-page-styled document and chose a different paper size (i.e Letter -> Legal) 'automatic orientation' no longer is portrait. This also allows some pages being in landscape mode while other pages are portrait. Change-Id: Iec22ab7a196a775a2a589ae3e9f76114e50db1c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192926 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194148 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 75d28ca69688..d3e257849699 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -236,15 +236,25 @@ public: size = maMultiPage.aPaperSize; else size = i_rPageSize; + + bool bSwap = false; + const bool bSizeIsLandscape = size.Width() > size.Height(); if(mbOrientationFromUser) { - if ( (meUserOrientation == Orientation::Portrait && size.Width() > size.Height()) || - (meUserOrientation == Orientation::Landscape && size.Width() < size.Height()) ) - { - // coverity[swapped_arguments : FALSE] - this is in the correct order - size = Size( size.Height(), size.Width() ); - } + bSwap = (bSizeIsLandscape && Orientation::Portrait == meUserOrientation) + || (!bSizeIsLandscape && Orientation::Landscape == meUserOrientation); + } + else if (mbPapersizeFromUser || mbPapersizeFromSetup) // automatic orientation + { + const bool bDocumentPageIsLandscape = i_rPageSize.Width() > i_rPageSize.Height(); + bSwap = bDocumentPageIsLandscape != bSizeIsLandscape; + } + if (bSwap) + { + // coverity[swapped_arguments : FALSE] - this is in the correct order + size = Size(size.Height(), size.Width()); } + return size; } PrinterController::PageSize modifyJobSetup( const css::uno::Sequence< css::beans::PropertyValue >& i_rProps );
