From 18931fadc25423869e9c35ee8aa9f5d92509316b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDeljan=20Rikalo?= Date: Tue, 2 Nov 2021 15:55:49 +0100 Subject: [PATCH] Qt/Qt5/Win32: fixed page size and name (qt) and page orientation mismatch under win32. Patch by Joeny Ang. issue #39449 (cherry picked from commit 5133009bc01482d1d64689933cbdc9097b2e2ca8) --- components/printers/qt/qtprinters.inc | 23 ++++++++++++++++------- components/printers/win32/winutilprn.pas | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/components/printers/qt/qtprinters.inc b/components/printers/qt/qtprinters.inc index f64db7a1af..cdbaa9a729 100644 --- a/components/printers/qt/qtprinters.inc +++ b/components/printers/qt/qtprinters.inc @@ -186,6 +186,7 @@ var if (pgSize > 30) then {$ENDIF} QtDefaultPrinter.PageSize := PgSize; + FPapers[i].PageSize := PgSize; FPapers[i].PageRect := QtDefaultPrinter.PageRect; FPapers[i].PaperRect := QtDefaultPrinter.PaperRect; if PaperName=DEFAULT_PAPER_NAME then @@ -502,13 +503,21 @@ begin Result := inherited DoGetPaperRect(aName,aPaperRc); i := IndexOfPaper(aName); if i >= 0 then - begin - {When we set QPrinter into FullPage, rect is not same - on all platforms, this is fixed with qt-4.4} - APaperRC.WorkRect := FPapers[i].PageRect; - APaperRC.PhysicalRect := FPapers[i].PaperRect; - Result := 1; - end; + with FPapers[i] do + begin + {When we set QPrinter into FullPage, rect is not same + on all platforms, this is fixed with qt-4.4} + if Orientation in [poPortrait, poReversePortrait] then begin + APaperRC.WorkRect := PageRect; + APaperRC.PhysicalRect := PaperRect; + end else begin + APaperRC.WorkRect := + Rect(PageRect.Top, PageRect.Left, PageRect.Bottom, PageRect.Right); + APaperRC.PhysicalRect := + Rect(PaperRect.Top, PaperRect.Left, PaperRect.Bottom, PaperRect.Right); + end; + Result := 1; + end; end; function TQtPrinters.DoSetPrinter(aName: string): Integer; diff --git a/components/printers/win32/winutilprn.pas b/components/printers/win32/winutilprn.pas index 906361181a..30ac812210 100644 --- a/components/printers/win32/winutilprn.pas +++ b/components/printers/win32/winutilprn.pas @@ -37,7 +37,7 @@ const const Win32Orientations: array [TPrinterOrientation] of SHORT = ( - DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE, DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE); + DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE, DMORIENT_LANDSCAPE, DMORIENT_PORTRAIT); DMPAPER_USER = 256; type