vcl/source/window/printdlg.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
New commits: commit 4c656548afeda1bd5a2903b22a001fa24a8e6430 Author: Mike Kaganski <[email protected]> AuthorDate: Fri Feb 20 16:31:14 2026 +0500 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Feb 20 19:58:50 2026 +0100 tdf#170910: exact match can also be rotated For Microsoft XPS Document Writer printer, the paper list is very logn, and contains duplicates (e.g., two portrait Letter), as well as rotated variants (e.g., landscape Letter). The code that looks for matching paper in setPaperSizes would find all elelemts with matching Paper value, regardless of orientation; and would use the last match. It happened, that for A4 and Letter, the last matches were landscape, so the perfect portrait-oriented matches would get skipped. This change checks orientation for exact matches as well; and will prefer the first found best match. Change-Id: Iaa93292ef60b94ab1f807b21e8a3494099c0b002 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199841 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> (cherry picked from commit d8a3c74a10e70bae243162cb08572a9c2f2552a3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199889 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index f02c5137e920..4e024c491a03 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -864,6 +864,7 @@ void PrintDialog::setPaperSizes() #endif { int nExactMatch = -1; + int nExactRotatedMatch = -1; int nSizeMatch = -1; int nRotatedSizeMatch = -1; Size aSizeOfPaper = aPrt->GetSizeOfPaper(); @@ -901,8 +902,15 @@ void PrintDialog::setPaperSizes() mxPaperSizeBox->append_text(aPaperName); + // For exact match, check that paper orientation also matches if (ePaper != PAPER_USER && ePaper == mePaper) - nExactMatch = nPaper; + { + // Only get the first match, in case there are multiple papers with the same size + if (nExactMatch == -1 && aInfo.sloppyEqual(aPaperInfo)) + nExactMatch = nPaper; + else if (nExactRotatedMatch == -1 && aInfo.sloppyEqual(aRotatedPaperInfo)) + nExactRotatedMatch = nPaper; + } if (ePaper == PAPER_USER && aInfo.sloppyEqual(aPaperInfo)) nSizeMatch = nPaper; @@ -913,6 +921,8 @@ void PrintDialog::setPaperSizes() if (nExactMatch != -1) mxPaperSizeBox->set_active(nExactMatch); + else if (nExactRotatedMatch != -1) + mxPaperSizeBox->set_active(nExactRotatedMatch); else if (nSizeMatch != -1) mxPaperSizeBox->set_active(nSizeMatch); else if (nRotatedSizeMatch != -1)
