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 <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2026-02-20 16:23:19 +01:00
parent 6171ccd8e6
commit d8a3c74a10
+11 -1
View File
@@ -825,6 +825,7 @@ void PrintDialog::setPaperSizes()
#endif
{
int nExactMatch = -1;
int nExactRotatedMatch = -1;
int nSizeMatch = -1;
int nRotatedSizeMatch = -1;
Size aSizeOfPaper = aPrt->GetSizeOfPaper();
@@ -862,8 +863,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;
@@ -874,6 +882,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)