summaryrefslogtreecommitdiff
path: root/extras/contributed/report_tool/reportengine/u_pdf.pas
diff options
context:
space:
mode:
authorJean-Marc Levecque <jean-marc.levecque@jmlesite.fr>2011-01-20 10:32:17 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-01-20 10:32:17 +0200
commit3db3fc8cad32b4d84164b6089db196f955be721a (patch)
treea9368a9eccded273f9ab0b2d7e365d443fac0fe2 /extras/contributed/report_tool/reportengine/u_pdf.pas
parent9fd8c8491a9b1662e288e34058cb58f942f55a32 (diff)
downloadfpGUI-3db3fc8cad32b4d84164b6089db196f955be721a.tar.xz
PDF reporting: it is now possible to paint a surface delimited by a polygon.
Diffstat (limited to 'extras/contributed/report_tool/reportengine/u_pdf.pas')
-rw-r--r--extras/contributed/report_tool/reportengine/u_pdf.pas56
1 files changed, 55 insertions, 1 deletions
diff --git a/extras/contributed/report_tool/reportengine/u_pdf.pas b/extras/contributed/report_tool/reportengine/u_pdf.pas
index 07921e2d..00a1a1a8 100644
--- a/extras/contributed/report_tool/reportengine/u_pdf.pas
+++ b/extras/contributed/report_tool/reportengine/u_pdf.pas
@@ -160,6 +160,18 @@ type
destructor Destroy; override;
end;
+ T_Points = array of TPoint;
+
+ TPdfSurface = class(TPdfObjet)
+ private
+ FPoints: array of TPoint;
+ protected
+ procedure EcritSurface(const AFlux: TStream);
+ public
+ constructor CreateSurface(const APoints: T_Points);
+ destructor Destroy; override;
+ end;
+
TPdfLineStyle = class(TPdfObjet)
private
FDash: TfpgLineStyle;
@@ -512,6 +524,9 @@ for Cpt:= 0 to Pred(FStream.Count) do
if TPdfObjet(FStream[Cpt]) is TPdfLineStyle
then
TPdfLineStyle(FStream[Cpt]).EcritLineStyle(AFlux);
+ if TPdfObjet(FStream[Cpt]) is TPdfSurface
+ then
+ TPdfSurface(FStream[Cpt]).EcritSurface(AFlux);
end;
end;
@@ -638,6 +653,28 @@ begin
inherited;
end;
+procedure TPdfSurface.EcritSurface(const AFlux: TStream);
+var
+ Cpt: Integer;
+begin
+EcritChaine(IntToStr(FPoints[0].X)+' '+IntToStr(FPoints[0].Y)+' m'+CRLF,AFlux);
+for Cpt:= 1 to Pred(Length(FPoints)) do
+ EcritChaine(IntToStr(FPoints[Cpt].X)+' '+IntToStr(FPoints[Cpt].Y)+' l'+CRLF,AFlux);
+EcritChaine('h'+CRLF,AFlux);
+EcritChaine('f'+CRLF,AFlux);
+end;
+
+constructor TPdfSurface.CreateSurface(const APoints: T_Points);
+begin
+inherited Create;
+FPoints:= APoints;
+end;
+
+destructor TPdfSurface.Destroy;
+begin
+inherited;
+end;
+
procedure TPdfLineStyle.EcritLineStyle(const AFlux: TStream);
begin
EcritChaine('[',AFlux);
@@ -688,13 +725,18 @@ else
end;
constructor TPdfColor.CreateColor(const AStroke: Boolean; Couleur: Longint);
+var
+ OldSeparator: Char;
begin
inherited Create;
+OldSeparator:= DecimalSeparator;
+DecimalSeparator:= '.';
FBlue:= FormatFloat('0.##',Couleur mod 256/256);
Couleur:= Couleur div 256;
FGreen:= FormatFloat('0.##',Couleur mod 256/256);
FRed:= FormatFloat('0.##',Couleur div 256/256);
FStroke:= AStroke;
+DecimalSeparator:= OldSeparator;
end;
destructor TPdfColor.Destroy;
@@ -1184,6 +1226,7 @@ var
Fnt: TPdfFonte;
Rct: TPdfRectangle;
Lin: TPdfLigne;
+ Srf: TPdfSurface;
Sty: TpdfLineStyle;
begin
for Cpt:= 0 to Pred(PdfPage.Count) do
@@ -1249,6 +1292,17 @@ for Cpt:= 0 to Pred(PdfPage.Count) do
Lin:= TPdfLigne.CreateLigne(LineEpais,LineStartX,LineStartY,LineEndX,LineEndY);
TPdfStream(TPdfXRef(FXRefObjets[PageNum]).FStream).AddItem(Lin);
end;
+ if TPdfElement(PdfPage[Cpt]) is TPdfSurf
+ then
+ if TPdfSurf(PdfPage[Cpt]).PageId= NumeroPage
+ then
+ with TPdfSurf(PdfPage[Cpt]) do
+ begin
+ Clr:= TPdfColor.CreateColor(True,SurfColor);
+ TPdfStream(TPdfXRef(FXRefObjets[PageNum]).FStream).AddItem(Clr);
+ Srf:= TPdfSurface.CreateSurface(Points);
+ TPdfStream(TPdfXRef(FXRefObjets[PageNum]).FStream).AddItem(Srf);
+ end;
end;
end;
@@ -1330,7 +1384,7 @@ for CptSect:= 0 to Pred(Sections.Count) do
with T_Section(Sections[CptSect]) do
NewPage:= CreatePage(ParentPage,Paper.H,Paper.W);
Inc(NumPage);
- PageNum:= CreateContents; // pagenum = numéro d'objet dans le fichier PDF
+ PageNum:= CreateContents; // pagenum = object number in the pdf file
CreateStream(NumPage,PageNum);
if (Sections.Count> 1) and Outline
then