View Issue Details

IDProjectCategoryView StatusLast Update
0016101LazarusLCLpublic2011-07-11 17:11
ReporterPetr-K Assigned ToJesus Reyes  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version0.9.28.3 (SVN) 
Fixed in Version0.9.29 (SVN) 
Summary0016101: TCUPSPrinter - possibility to use alternative TPrinterCanvas implementation
DescriptionI'am working on TCairoCanvas and I need possibility to change
TCUPSPrinter.GetCanvasRef result to TCairoPsCanvas.
In order to TCUPSPrinter uses it for postscript rendering instead of TPostscriptPrinterCanvas.

Bacause my TCairoCanvas and TPostscriptPrinterCanvas needs OutPutFileName
property, I made them common ancestor TFilePrinterCanvas = class(TPrinterCanvas).

Patch is completely back compatible.
TagsNo tags attached.
Fixed in Revision24216
LazTarget-
Widgetset
Attached Files

Activities

2010-03-24 11:53

 

FilePrinterCanvas.patch (3,132 bytes)   
Index: components/printers/unix/cupsprinters_h.inc
===================================================================
--- components/printers/unix/cupsprinters_h.inc	(revision 24009)
+++ components/printers/unix/cupsprinters_h.inc	(working copy)
@@ -166,3 +166,6 @@
     property CupsPPD:Pppd_file_t read fcupsPPD;
   end;
 
+Var
+  CupsCanvasClass : TFilePrinterCanvasClass = TPostscriptPrinterCanvas;
+
Index: components/printers/unix/cupsprinters.inc
===================================================================
--- components/printers/unix/cupsprinters.inc	(revision 24009)
+++ components/printers/unix/cupsprinters.inc	(working copy)
@@ -699,7 +699,7 @@
 
 function TCUPSPrinter.GetCanvasRef: TPrinterCanvasRef;
 begin
-  Result:=TPostscriptPrinterCanvas;
+  Result:=CupsCanvasClass;
 end;
 
 //Override this methode for assign an
@@ -735,7 +735,7 @@
     FOutputFileName := FOutputFileName + '.raw'
   else begin
     FOutputFileName := FOutputFileName + '.ps';
-    TPostscriptPrinterCanvas(Canvas).OutputFileName := FOutputFileName;
+    TFilePrinterCanvas(Canvas).OutputFileName := FOutputFileName;
   end;
 end;
 
@@ -760,7 +760,7 @@
     end;
     
   end else
-    TPostscriptPrinterCanvas(Canvas).OutPutFileName:='';
+    TFilePrinterCanvas(Canvas).OutPutFileName:='';
   
   if not aAborted and FileExistsUTF8(FOutputFileName) then begin
     {$IFDEF LogPrintoutFile}
Index: lcl/postscriptcanvas.pas
===================================================================
--- lcl/postscriptcanvas.pas	(revision 24009)
+++ lcl/postscriptcanvas.pas	(working copy)
@@ -54,11 +54,10 @@
     fx,fy:single;
   end;
 
-  TPostScriptPrinterCanvas = Class(TPrinterCanvas)
+  TPostScriptPrinterCanvas = Class(TFilePrinterCanvas)
   private
     fHeader        : TStringList; //Header document
     fDocument      : TstringList; //Current document
-    fFileName      : String;      //OutOut fileName
 
     fBuffer        : TStringList; //PostScript temporary buffer
 
@@ -179,7 +178,6 @@
                        const Style: TTextStyle); override;
 
 
-    property OutPutFileName : string read fFileName write fFileName;
   end;
 
   TPostScriptCanvas = Class(TPostScriptPrinterCanvas)
@@ -1468,8 +1466,8 @@
   if I <> -1 then
     FHeader[I] := '%%' + Format('Pages: %d', [PageNumber]);
   
-  if Trim(fFileName)<>'' then
-    SaveToFile(ExpandFileNameUTF8(fFileName));
+  if Trim(FOutputFileName)<>'' then
+    SaveToFile(ExpandFileNameUTF8(FOutputFileName));
 
   if Assigned(fPsUnicode) then
     FreeAndNil(fPsUnicode);
Index: lcl/printers.pas
===================================================================
--- lcl/printers.pas	(revision 24009)
+++ lcl/printers.pas	(working copy)
@@ -115,6 +115,17 @@
 
   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
     PhysicalRect : TRect;
     WorkRect     : TRect;
FilePrinterCanvas.patch (3,132 bytes)   

Jesus Reyes

2010-03-25 22:22

developer   ~0036096

Applied, thanks.

Petr-K

2011-07-11 17:11

reporter   ~0049887

Ok

Issue History

Date Modified Username Field Change
2010-03-24 11:53 Petr-K New Issue
2010-03-24 11:53 Petr-K File Added: FilePrinterCanvas.patch
2010-03-24 18:59 Jesus Reyes Status new => assigned
2010-03-24 18:59 Jesus Reyes Assigned To => Jesus Reyes
2010-03-25 22:22 Jesus Reyes Fixed in Revision => 24216
2010-03-25 22:22 Jesus Reyes LazTarget => -
2010-03-25 22:22 Jesus Reyes Status assigned => resolved
2010-03-25 22:22 Jesus Reyes Fixed in Version => 0.9.29 (SVN)
2010-03-25 22:22 Jesus Reyes Resolution open => fixed
2010-03-25 22:22 Jesus Reyes Note Added: 0036096
2011-07-11 17:11 Petr-K Status resolved => closed
2011-07-11 17:11 Petr-K Note Added: 0049887