mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 02:29:21 +02:00
LazReport, try further to match a paper on reports created on Windows and opened on *nix for the*same printer
git-svn-id: trunk@40479 -
This commit is contained in:
parent
3311913a0e
commit
f27ebb416f
@ -42,7 +42,7 @@ type
|
|||||||
procedure SetPrinter(Value: TPrinter);
|
procedure SetPrinter(Value: TPrinter);
|
||||||
procedure SetPrinterIndex(Value: Integer);
|
procedure SetPrinterIndex(Value: Integer);
|
||||||
function GetPaperNames: TStringList;
|
function GetPaperNames: TStringList;
|
||||||
|
function MatchPrinterPaper(const aWidth, aHeight: Integer): integer;
|
||||||
public
|
public
|
||||||
Orientation: TPrinterOrientation;
|
Orientation: TPrinterOrientation;
|
||||||
PaperSize: Integer;
|
PaperSize: Integer;
|
||||||
@ -891,12 +891,26 @@ begin
|
|||||||
DebugLn('SetCustomPaperSize REQUESTED, not yet supported...');
|
DebugLn('SetCustomPaperSize REQUESTED, not yet supported...');
|
||||||
end else begin
|
end else begin
|
||||||
// Standard paper sizes are handled here
|
// Standard paper sizes are handled here
|
||||||
|
n := -1;
|
||||||
for i:=0 to PaperSizesNum-1 do
|
for i:=0 to PaperSizesNum-1 do
|
||||||
if PaperSizes[i]=PaperSize then begin
|
if PaperSizes[i]=PaperSize then begin
|
||||||
n:=i;
|
n:=i;
|
||||||
FPrinter.PaperSize.PaperName := PaperNames[i];
|
FPrinter.PaperSize.PaperName := PaperNames[i];
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
if (n<0) and (PaperWidth>1) and (PaperHeight>1) then
|
||||||
|
begin
|
||||||
|
// this standard paperSize was not found by number
|
||||||
|
// try to find a suitable paper size within the list
|
||||||
|
// of printer papers based on Paper's width and height
|
||||||
|
n := MatchPrinterPaper(PaperWidth, PaperHeight);
|
||||||
|
if n>=0 then begin
|
||||||
|
FPrinter.PaperSize.PaperName := FPrinter.PaperSize.SupportedPapers[n];
|
||||||
|
// actually PaperSize is a better choice than PaperSizes[n], Update it
|
||||||
|
PaperSizes[n] := PaperSize;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{$IFDEF DbgPrinter}
|
{$IFDEF DbgPrinter}
|
||||||
DebugLn(['PaperSize standard requested: PaperSize=', PaperSize,' i=',i,' Paper=', FPrinter.PaperSize.PaperName]);
|
DebugLn(['PaperSize standard requested: PaperSize=', PaperSize,' i=',i,' Paper=', FPrinter.PaperSize.PaperName]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1061,6 +1075,32 @@ begin
|
|||||||
result := FPaperNames;
|
result := FPaperNames;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TfrPrinter.MatchPrinterPaper(const aWidth, aHeight: Integer): integer;
|
||||||
|
var
|
||||||
|
i,dw,dh: Integer;
|
||||||
|
begin
|
||||||
|
result := -1;
|
||||||
|
if FPrinter=nil then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
with FPrinter.PaperSize do
|
||||||
|
for i:=0 to SupportedPapers.Count-1 do
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
with PaperRectOf[SupportedPapers[i]].PhysicalRect do
|
||||||
|
begin
|
||||||
|
dw := round((Right-Left)*72/FPrinter.XDPI) - aWidth;
|
||||||
|
dh := round((Bottom-Top)*72/FPrinter.YDPI) - aHeight;
|
||||||
|
if (dw>=0)and(dw<=6) and (dh>=0)and(dh<=6) then begin
|
||||||
|
result := i;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TfrPrinter.SetPrinter(Value: TPrinter);
|
procedure TfrPrinter.SetPrinter(Value: TPrinter);
|
||||||
begin
|
begin
|
||||||
FPrinters.Clear;
|
FPrinters.Clear;
|
||||||
|
Loading…
Reference in New Issue
Block a user