Qt/Qt5/Win32: fixed page size and name (qt) and page orientation mismatch under win32. Patch by Joeny Ang. issue #39449

This commit is contained in:
Željan Rikalo 2021-11-02 15:55:49 +01:00
parent 19feb31030
commit 5133009bc0
2 changed files with 17 additions and 8 deletions

View File

@ -186,6 +186,7 @@ var
if (pgSize > 30) then if (pgSize > 30) then
{$ENDIF} {$ENDIF}
QtDefaultPrinter.PageSize := PgSize; QtDefaultPrinter.PageSize := PgSize;
FPapers[i].PageSize := PgSize;
FPapers[i].PageRect := QtDefaultPrinter.PageRect; FPapers[i].PageRect := QtDefaultPrinter.PageRect;
FPapers[i].PaperRect := QtDefaultPrinter.PaperRect; FPapers[i].PaperRect := QtDefaultPrinter.PaperRect;
if PaperName=DEFAULT_PAPER_NAME then if PaperName=DEFAULT_PAPER_NAME then
@ -502,13 +503,21 @@ begin
Result := inherited DoGetPaperRect(aName,aPaperRc); Result := inherited DoGetPaperRect(aName,aPaperRc);
i := IndexOfPaper(aName); i := IndexOfPaper(aName);
if i >= 0 then if i >= 0 then
begin with FPapers[i] do
{When we set QPrinter into FullPage, rect is not same begin
on all platforms, this is fixed with qt-4.4} {When we set QPrinter into FullPage, rect is not same
APaperRC.WorkRect := FPapers[i].PageRect; on all platforms, this is fixed with qt-4.4}
APaperRC.PhysicalRect := FPapers[i].PaperRect; if Orientation in [poPortrait, poReversePortrait] then begin
Result := 1; APaperRC.WorkRect := PageRect;
end; 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; end;
function TQtPrinters.DoSetPrinter(aName: string): Integer; function TQtPrinters.DoSetPrinter(aName: string): Integer;

View File

@ -37,7 +37,7 @@ const
const const
Win32Orientations: array [TPrinterOrientation] of SHORT = ( Win32Orientations: array [TPrinterOrientation] of SHORT = (
DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE, DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE); DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE, DMORIENT_LANDSCAPE, DMORIENT_PORTRAIT);
DMPAPER_USER = 256; DMPAPER_USER = 256;
type type