LCL+Printers, patch to allow cupsprinter to use another class of TPrinterCanvas, from Petr Kristan, issue #16101

git-svn-id: trunk@24216 -
This commit is contained in:
jesus 2010-03-25 21:21:55 +00:00
parent a74bc652d2
commit 14e8e2cf01
5 changed files with 21 additions and 8 deletions

View File

@ -699,7 +699,7 @@ end;
function TCUPSPrinter.GetCanvasRef: TPrinterCanvasRef; function TCUPSPrinter.GetCanvasRef: TPrinterCanvasRef;
begin begin
Result:=TPostscriptPrinterCanvas; Result:=CupsCanvasClass;
end; end;
//Override this methode for assign an //Override this methode for assign an
@ -735,7 +735,7 @@ begin
FOutputFileName := FOutputFileName + '.raw' FOutputFileName := FOutputFileName + '.raw'
else begin else begin
FOutputFileName := FOutputFileName + '.ps'; FOutputFileName := FOutputFileName + '.ps';
TPostscriptPrinterCanvas(Canvas).OutputFileName := FOutputFileName; TFilePrinterCanvas(Canvas).OutputFileName := FOutputFileName;
end; end;
end; end;
@ -760,7 +760,7 @@ begin
end; end;
end else end else
TPostscriptPrinterCanvas(Canvas).OutPutFileName:=''; TFilePrinterCanvas(Canvas).OutPutFileName:='';
if not aAborted and FileExistsUTF8(FOutputFileName) then begin if not aAborted and FileExistsUTF8(FOutputFileName) then begin
{$IFDEF LogPrintoutFile} {$IFDEF LogPrintoutFile}

View File

@ -166,3 +166,6 @@ type
property CupsPPD:Pppd_file_t read fcupsPPD; property CupsPPD:Pppd_file_t read fcupsPPD;
end; end;
Var
CupsCanvasClass : TFilePrinterCanvasClass = TPostscriptPrinterCanvas;

View File

@ -116,6 +116,7 @@ Patrick Chevalley
Paul Ishenin Paul Ishenin
Paul Michell Paul Michell
Pawel Trochimczuk Pawel Trochimczuk
Petr Kristan
Peter Dyson Peter Dyson
Philip J. Hess Philip J. Hess
Pierre Gillmann Pierre Gillmann

View File

@ -57,11 +57,10 @@ Type
TPsCanvasState = ( pcsPosValid, pcsClipping, pcsClipSaved ); TPsCanvasState = ( pcsPosValid, pcsClipping, pcsClipSaved );
TPsCanvasStatus = set of TPsCanvasState; TPsCanvasStatus = set of TPsCanvasState;
TPostScriptPrinterCanvas = Class(TPrinterCanvas) TPostScriptPrinterCanvas = Class(TFilePrinterCanvas)
private private
fHeader : TStringList; //Header document fHeader : TStringList; //Header document
fDocument : TstringList; //Current document fDocument : TstringList; //Current document
fFileName : String; //OutOut fileName
fBuffer : TStringList; //PostScript temporary buffer fBuffer : TStringList; //PostScript temporary buffer
@ -182,7 +181,6 @@ Type
const Style: TTextStyle); override; const Style: TTextStyle); override;
property OutPutFileName : string read fFileName write fFileName;
end; end;
TPostScriptCanvas = Class(TPostScriptPrinterCanvas) TPostScriptCanvas = Class(TPostScriptPrinterCanvas)
@ -1478,8 +1476,8 @@ begin
if I <> -1 then if I <> -1 then
FHeader[I] := '%%' + Format('Pages: %d', [PageNumber]); FHeader[I] := '%%' + Format('Pages: %d', [PageNumber]);
if Trim(fFileName)<>'' then if Trim(OutputFileName)<>'' then
SaveToFile(ExpandFileNameUTF8(fFileName)); SaveToFile(ExpandFileNameUTF8(OutputFileName));
if Assigned(fPsUnicode) then if Assigned(fPsUnicode) then
FreeAndNil(fPsUnicode); FreeAndNil(fPsUnicode);

View File

@ -115,6 +115,17 @@ type
TPrinterCanvasRef = Class of TPrinterCanvas; TPrinterCanvasRef = Class of TPrinterCanvas;
{ TFilePrinterCanvas }
TFilePrinterCanvas = class(TPrinterCanvas)
protected
FOutputFileName: string;
public
property OutputFileName : string read FOutputFileName write FOutputFileName;
end;
TFilePrinterCanvasClass = class of TFilePrinterCanvas;
TPaperRect = Record TPaperRect = Record
PhysicalRect : TRect; PhysicalRect : TRect;
WorkRect : TRect; WorkRect : TRect;