summaryrefslogtreecommitdiff
path: root/extras/contributed
diff options
context:
space:
mode:
authorJean-Marc Levecque <jean-marc.levecque@jmlesite.fr>2011-10-16 17:11:16 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-10-16 17:11:16 +0200
commita64ab297c65d7936248752f27559951c42aa3063 (patch)
tree8c5892af4d114fa51557e198239ff83cc3956ca4 /extras/contributed
parent9c0a644df44547bf6dd9cf0a1250084b237eeae4 (diff)
downloadfpGUI-a64ab297c65d7936248752f27559951c42aa3063.tar.xz
Various PDF reporting changes.
- Fixed some memory leaks by correctly freeing objects - Updated the PDF Demo to use a local reporting variable - Removed the global Imprime variable - Some various other changes
Diffstat (limited to 'extras/contributed')
-rw-r--r--extras/contributed/report_tool/demo/u_demo.pas155
-rw-r--r--extras/contributed/report_tool/reportengine/u_commande.pas58
-rw-r--r--extras/contributed/report_tool/reportengine/u_imprime.pas54
-rw-r--r--extras/contributed/report_tool/reportengine/u_pdf.pas37
4 files changed, 145 insertions, 159 deletions
diff --git a/extras/contributed/report_tool/demo/u_demo.pas b/extras/contributed/report_tool/demo/u_demo.pas
index 0759bbec..5f8d6cf4 100644
--- a/extras/contributed/report_tool/demo/u_demo.pas
+++ b/extras/contributed/report_tool/demo/u_demo.pas
@@ -10,11 +10,12 @@ uses
ShellApi,
{$endif}
fpg_main, fpg_base,
- fpg_form, fpg_button, fpg_label, fpg_dialogs, fpg_utils;
+ fpg_form, fpg_button, fpg_label, fpg_dialogs, fpg_utils, U_Imprime;
type
TF_Demo = class(TfpgForm)
private
+ FImprime: T_Imprime;
L_Pdf: TfpgLabel;
Bt_PdfEmptyPage: TfpgButton;
Bt_PdfSimpleText: TfpgButton;
@@ -107,7 +108,7 @@ var
implementation
uses
- U_Imprime, U_Commande, U_Pdf, U_ReportImages;
+ U_Commande, U_Pdf, U_ReportImages;
var
ChartValues: array[0..18] of Integer;
@@ -121,8 +122,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeEmptyPage(False);
@@ -173,8 +174,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeSimpleText(False);
@@ -225,8 +226,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeMultiPages(False);
@@ -277,8 +278,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeMultiSections(False);
@@ -329,8 +330,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeOutlines(False);
@@ -381,8 +382,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeCadres(False);
@@ -433,8 +434,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeColor(False);
@@ -485,8 +486,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeLines(False);
@@ -537,8 +538,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeGrid(False);
@@ -589,8 +590,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeGraph(False);
@@ -641,8 +642,8 @@ var
FichierPdf: string;
FluxFichier: TFileStream;
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
// Langue:= Version;
ImprimeSurf(False);
@@ -689,8 +690,8 @@ end;
procedure TF_Demo.Bt_VisuEmptyPageClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'EmptyPage.pdf';
@@ -701,8 +702,8 @@ end;
procedure TF_Demo.Bt_VisuSimpleTextClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'SimpleText.pdf';
@@ -713,8 +714,8 @@ end;
procedure TF_Demo.Bt_VisuMultiPagesClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'MultiPages.pdf';
@@ -725,8 +726,8 @@ end;
procedure TF_Demo.Bt_VisuMultiSectionsClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'MultiSections.pdf';
@@ -737,8 +738,8 @@ end;
procedure TF_Demo.Bt_VisuOutlinesClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'Outlines.pdf';
@@ -749,8 +750,8 @@ end;
procedure TF_Demo.Bt_VisuCadresClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'Cadres.pdf';
@@ -761,8 +762,8 @@ end;
procedure TF_Demo.Bt_VisuColorClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'Color.pdf';
@@ -773,8 +774,8 @@ end;
procedure TF_Demo.Bt_VisuLinesClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'Lines.pdf';
@@ -785,8 +786,8 @@ end;
procedure TF_Demo.Bt_VisuGridClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'Grid.pdf';
@@ -797,8 +798,8 @@ end;
procedure TF_Demo.Bt_VisuGraphClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'Graph.pdf';
@@ -809,8 +810,8 @@ end;
procedure TF_Demo.Bt_VisuSurfClick(Sender: TObject);
begin
-Imprime:= T_Imprime.Create;
-with Imprime do
+FImprime:= T_Imprime.Create;
+with FImprime do
begin
//Langue:= Version;
DefaultFile:= 'Surface.pdf';
@@ -881,7 +882,7 @@ end;
procedure TF_Demo.ImprimeEmptyPage(Preview: Boolean);
begin
-with Imprime do
+with FImprime do
begin
// define orientation, page format, measurement unit, language, preview (true) or print (false)
Debut(oPortrait,A4,msMM,Langue,Preview);
@@ -898,7 +899,7 @@ procedure TF_Demo.ImprimeSimpleText(Preview: Boolean);
var
FtTexte1,FtTexte2,FtTexte3: Integer;
begin
-with Imprime do
+with FImprime do
begin
// define orientation, page format, measurement unit, language, preview (true) or print (false)
Debut(oPortrait,A4,msMM,Langue,Preview);
@@ -926,7 +927,7 @@ var
FtTitre,FtTexte: Integer;
Cpt: Integer;
begin
-with Imprime do
+with FImprime do
begin
// define orientation, page format, measurement unit, language, preview (true) or print (false)
Debut(oPortrait,A4,msMM,Langue,Preview);
@@ -953,7 +954,7 @@ var
ColDefSect2: Integer;
Cpt: Integer;
begin
-with Imprime do
+with FImprime do
begin
// define orientation, page format, measurement unit, language, preview (true) or print (false)
Debut(oPortrait,A4,msMM,Langue,Preview);
@@ -1019,7 +1020,7 @@ var
ColDefSect2: Integer;
Cpt: Integer;
begin
-with Imprime do
+with FImprime do
begin
// define orientation, page format, measurement unit, language, preview (true) or print (false)
Debut(oPortrait,A4,msMM,Langue,Preview);
@@ -1085,7 +1086,7 @@ var
TsFin,TsNorm,TsEpais: Integer;
IlTitre,IlTexte: Integer;
begin
-with Imprime do
+with FImprime do
begin
// define orientation, page format, measurement unit, language, preview (true) or print (false)
Debut(oPortrait,A4,msMM,Langue,Preview);
@@ -1126,7 +1127,7 @@ var
Col1,Col2,Col3: Integer;
begin
-with Imprime do
+with FImprime do
begin
// define orientation, page format, measurement unit, language, preview (true) or print (false)
Debut(oPortrait,A4,msMM,Langue,Preview);
@@ -1186,7 +1187,7 @@ var
Col1,Col2,Col3: Integer;
BdRect,BdColn,BdFinCol: Integer;
begin
-with Imprime do
+with FImprime do
begin
// define orientation, page format, measurement unit, language, preview (true) or print (false)
Debut(oPortrait,A4,msMM,Langue,Preview);
@@ -1253,7 +1254,7 @@ const
Col5Pos= 165;
Col5Wid= 35;
begin
-with Imprime do
+with FImprime do
begin
// define orientation, page format, measurement unit, language, preview (true) or print (false)
Debut(oPortrait,A4,msMM,Langue,Preview);
@@ -1362,7 +1363,7 @@ var
const
Base= 150;
begin
-with Imprime do
+with FImprime do
begin
// define orientation, page format, measurement unit, language, preview (true) or print (false)
Debut(oPortrait,A4,msMM,Langue,Preview);
@@ -1413,29 +1414,29 @@ procedure TF_Demo.ImprimeSurf(Preview: Boolean);
var
FtTitre,FtTexte: Integer;
IlTitre,IlTexte: Integer;
+begin
+with FImprime do
begin
- with Imprime do
- begin
- // define orientation, page format, measurement unit, language, preview (true) or print (false)
- Debut(oPortrait,A4,msMM,Langue,Preview);
- // create a new section and define the margins with an additional one due to frames drawing
- Section(10,10,10,10);
- // create the fonts to be used (use one of the 14 Adobe PDF standard fonts)
- FtTitre:= Fonte('helvetica-15:bold',clBlack);
- FtTexte:= Fonte('helvetica-7',clBlack);
- // create line spacings to be used
- IlTitre:= Interligne(3,0,3);
- IlTexte:= Interligne(1,0,0);
- EcritEnTete(cnCenter,lnFin,'SHOWING SURFACE',ColDefaut,FtTitre,IlTitre);
- // write page number and total of pages on each page
- NumPagePied(cnRight,lnFin,'Page','of',True,ColDefaut,FtTexte,IlTexte);
- // paint some surfaces
- SurfPage([40,40,100],[50,110,80],clGreen);
- SurfPage([30,50,150,80,120,130],[120,180,180,160,140,120],clFuchsia);
- // preparation is finished, so create PDF objects
- Fin;
- end;
+ // define orientation, page format, measurement unit, language, preview (true) or print (false)
+ Debut(oPortrait,A4,msMM,Langue,Preview);
+ // create a new section and define the margins with an additional one due to frames drawing
+ Section(10,10,10,10);
+ // create the fonts to be used (use one of the 14 Adobe PDF standard fonts)
+ FtTitre:= Fonte('helvetica-15:bold',clBlack);
+ FtTexte:= Fonte('helvetica-7',clBlack);
+ // create line spacings to be used
+ IlTitre:= Interligne(3,0,3);
+ IlTexte:= Interligne(1,0,0);
+ EcritEnTete(cnCenter,lnFin,'SHOWING SURFACE',ColDefaut,FtTitre,IlTitre);
+ // write page number and total of pages on each page
+ NumPagePied(cnRight,lnFin,'Page','of',True,ColDefaut,FtTexte,IlTexte);
+ // paint some surfaces
+ SurfPage([40,40,100],[50,110,80],clGreen);
+ SurfPage([30,50,150,80,120,130],[120,180,180,160,140,120],clFuchsia);
+ // preparation is finished, so create PDF objects
+ Fin;
end;
+end;
constructor TF_Demo.Create(AOwner: TComponent);
var
diff --git a/extras/contributed/report_tool/reportengine/u_commande.pas b/extras/contributed/report_tool/reportengine/u_commande.pas
index 527b08db..0c35c44b 100644
--- a/extras/contributed/report_tool/reportengine/u_commande.pas
+++ b/extras/contributed/report_tool/reportengine/u_commande.pas
@@ -402,11 +402,33 @@ FColonnes:= TList.Create;
end;
destructor T_Section.Destroy;
+var
+ Cpt: Integer;
begin
+if FPages.Count> 0
+then
+ for Cpt:= 0 to Pred(FPages.Count) do
+ T_Page(FPages[Cpt]).Free;
FPages.Free;
+if FEntete.Count> 0
+then
+ for Cpt:= 0 to Pred(FEntete.Count) do
+ T_Commande(FEntete[Cpt]).Free;
FEnTete.Free;
+if FPied.Count> 0
+then
+ for Cpt:= 0 to Pred(FPied.Count) do
+ T_Commande(FPied[Cpt]).Free;
FPied.Free;
+if FCadres.Count> 0
+then
+ for Cpt:= 0 to Pred(FCadres.Count) do
+ T_Commande(FCadres[Cpt]).Free;
FCadres.Free;
+if FColonnes.Count> 0
+then
+ for Cpt:= 0 to Pred(FColonnes.Count) do
+ T_Commande(FColonnes[Cpt]).Free;
FColonnes.Free;
inherited Destroy;
end;
@@ -415,7 +437,7 @@ procedure T_Section.LoadPage(APageNum: Integer);
begin
Inc(FNbPages);
APage:= T_Page.Create(FNbPages,APageNum);
-Pages.Add(APage);
+FPages.Add(APage);
end;
procedure T_Section.LoadCmdEnTete;
@@ -433,7 +455,7 @@ var
Cpt: Integer;
begin
for Cpt:= 0 to Pred(ALigne.Commandes.Count) do
- T_Page(Pages[Pred(Pages.Count)]).Commandes.Add(ALigne.Commandes.Items[Cpt]);
+ T_Page(Pages[Pred(FPages.Count)]).Commandes.Add(ALigne.Commandes.Items[Cpt]);
ALigne.FHeight:= 0;
ALigne.Commandes.Clear;
end;
@@ -468,7 +490,7 @@ var
Cpt: Integer;
begin
for Cpt:= 0 to Pred(AGroupe.Commandes.Count) do
- T_Page(Pages[Pred(Pages.Count)]).Commandes.Add(AGroupe.Commandes.Items[Cpt]);
+ T_Page(Pages[Pred(FPages.Count)]).Commandes.Add(AGroupe.Commandes.Items[Cpt]);
AGroupe.FGroupeHeight:= 0;
AGroupe.Commandes.Clear;
end;
@@ -482,7 +504,7 @@ end;
procedure T_Section.LoadEspacePage(APosY: Single; AColonne: Integer; AHeight: Single; AFond: Integer);
begin
ACommande:= T_Espace.Create(APosY,AColonne,AHeight,AFond);
-T_Page(Pages[Pred(Pages.Count)]).Commandes.Add(ACommande);
+T_Page(Pages[Pred(FPages.Count)]).Commandes.Add(ACommande);
end;
procedure T_Section.LoadEspacePied(APosY: Single; AColonne: Integer; AHeight: Single; AFond: Integer);
@@ -505,7 +527,7 @@ end;
procedure T_Section.LoadTrait(APosXDeb,APosYDeb: Single; AColonne: Integer; APosXFin,APosYFin: Single; AStyle: Integer);
begin
ACommande:= T_Trait.Create(APosXDeb,APosYDeb,AColonne,AStyle,APosXFin,APosYFin);
-T_Page(Pages[Pred(Pages.Count)]).Commandes.Add(ACommande);
+T_Page(Pages[Pred(FPages.Count)]).Commandes.Add(ACommande);
end;
procedure T_Section.LoadTraitHorizEnTete(APosXDeb,APosYDeb: Single; AColonne: Integer; APosXFin,APosYFin: Single;
@@ -518,7 +540,7 @@ end;
procedure T_Section.LoadTraitHorizPage(APosXDeb,APosYDeb: Single; AColonne: Integer; APosXFin,APosYFin: Single; AStyle: Integer);
begin
ACommande:= T_Trait.Create(APosXDeb,APosYDeb,AColonne,AStyle,APosXFin,APosYFin);
-T_Page(Pages[Pred(Pages.Count)]).Commandes.Add(ACommande);
+T_Page(Pages[Pred(FPages.Count)]).Commandes.Add(ACommande);
end;
procedure T_Section.LoadTraitHorizPied(APosXDeb,APosYDeb: Single; AColonne: Integer; APosXFin,APosYFin: Single; AStyle: Integer);
@@ -535,7 +557,7 @@ end;
procedure T_Section.LoadSurf(APos: T_Points; AColor: TfpgColor);
begin
Acommande:= T_Surface.Create(APos,AColor);
-T_Page(Pages[Pred(Pages.Count)]).Commandes.Add(ACommande);
+T_Page(Pages[Pred(FPages.Count)]).Commandes.Add(ACommande);
end;
function T_Section.GetCmdPage(NumPage: Integer): TList;
@@ -551,7 +573,13 @@ FCommandes:= TList.Create;
end;
destructor T_Page.Destroy;
+var
+ Cpt: Integer;
begin
+if FCommandes.Count> 0
+then
+ for Cpt:= 0 to Pred(FCommandes.Count) do
+ T_Commande(FCommandes[Cpt]).Free;
FCommandes.Free;
inherited Destroy;
end;
@@ -560,12 +588,18 @@ constructor T_Groupe.Create;
begin
FLineHeight:= 0;
FGroupeHeight:= 0;
-Commandes:= TList.Create;
+FCommandes:= TList.Create;
end;
destructor T_Groupe.Destroy;
+var
+ Cpt: Integer;
begin
-Commandes.Free;
+if FCommandes.Count> 0
+then
+ for Cpt:= 0 to Pred(FCommandes.Count) do
+ T_Commande(FCommandes[Cpt]).Free;
+FCommandes.Free;
inherited Destroy;
end;
@@ -576,7 +610,13 @@ FCommandes:= TList.Create;
end;
destructor T_Ligne.Destroy;
+var
+ Cpt: Integer;
begin
+if FCommandes.Count> 0
+then
+ for Cpt:= 0 to Pred(FCommandes.Count) do
+ T_Commande(FCommandes[Cpt]).Free;
FCommandes.Free;
inherited Destroy;
end;
diff --git a/extras/contributed/report_tool/reportengine/u_imprime.pas b/extras/contributed/report_tool/reportengine/u_imprime.pas
index 87b304e1..9f706924 100644
--- a/extras/contributed/report_tool/reportengine/u_imprime.pas
+++ b/extras/contributed/report_tool/reportengine/u_imprime.pas
@@ -413,8 +413,6 @@ type
end;
var
- Imprime: T_Imprime;
-
Infos: record
Titre: string;
Auteur: string;
@@ -444,7 +442,6 @@ uses
const
PPI= 72;
InchToMM= 25.4;
- Cent= 100;
function T_Imprime.Dim2Pixels(Value: Single): Single;
begin
@@ -712,48 +709,6 @@ with F_Visu do
end;
end;
-procedure LibereCommandesPages(ACommandes: PPage);
-var
- Cpt: Integer;
-begin
-with T_Page(ACommandes) do
- if Commandes.Count> 0
- then
- begin
- for Cpt:= 0 to Pred(Commandes.Count) do
- T_Commande(Commandes[Cpt]).Free;
- Commandes.Free;
- end;
-end;
-
-procedure LiberePages(APageSect: PSection);
-var
- Cpt: Integer;
-begin
-with T_Section(APageSect) do
- if Pages.Count> 0
- then
- begin
- for Cpt:= 0 to Pred(Pages.Count) do
- LibereCommandesPages(Pages[Cpt]);
- Pages.Free;
- end;
-end;
-
-procedure LibereColonnes(AColSect: PSection);
-var
- Cpt: Integer;
-begin
-with T_Section(AColSect) do
- if Colonnes.Count> 0
- then
- begin
- for Cpt:= 0 to Pred(Colonnes.Count) do
- T_Colonne(Colonnes[Cpt]).Free;
- Colonnes.Free;
- end;
-end;
-
procedure T_Imprime.ImprimePage(PageNumero: Integer);
var
CptSect,CptPage,CptCmd: Integer;
@@ -2140,13 +2095,8 @@ var
begin
if Sections.Count> 0
then
- begin
for Cpt:= 0 to Pred(Sections.Count) do
- begin
- LiberePages(Sections[Cpt]);
- LibereColonnes(Sections[Cpt]);
- end;
- end;
+ T_Section(Sections[Cpt]).Free;
Sections.Free;
if Fontes.Count> 0
then
@@ -2736,8 +2686,6 @@ then
end;
procedure T_Imprime.FinGroupe(SautPage: Boolean= False);
-var
- Cpt: Integer;
begin
T_Section(Sections[Pred(Sections.Count)]).LoadCmdGroupeToPage;
FGroupe:= False;
diff --git a/extras/contributed/report_tool/reportengine/u_pdf.pas b/extras/contributed/report_tool/reportengine/u_pdf.pas
index ebb83603..facfd399 100644
--- a/extras/contributed/report_tool/reportengine/u_pdf.pas
+++ b/extras/contributed/report_tool/reportengine/u_pdf.pas
@@ -251,7 +251,7 @@ type
procedure CreatePreferences;
function CreatePages(Parent: Integer): Integer;
function CreatePage(Parent,Haut,Larg: Integer): Integer;
- function CreateOutlines(Parent: Integer): Integer;
+ function CreateOutlines: Integer;
function CreateOutline(Parent,SectNo,PageNo: Integer; SectTitre: string): Integer;
procedure CreateFont(NomFonte: string; NumFonte: Integer);
function CreateContents: Integer;
@@ -352,16 +352,6 @@ then
Result:= FontName+Chaine1;
end;
-function ColorToString(Couleur: Integer): string;
-var
- Red,Green,Blue: Integer;
-begin
-Red:= Couleur div 65535;
-Couleur:= Couleur mod 65535;
-Green:= Couleur div 255;
-Blue:= Couleur mod 255;
-end;
-
// object methods
constructor TPdfObjet.Create;
@@ -500,7 +490,13 @@ FArray:= TList.Create;
end;
destructor TPdfArray.Destroy;
+var
+ Cpt: Integer;
begin
+if FArray.Count> 0
+then
+ for Cpt:= 0 to Pred(FArray.Count) do
+ TPdfObjet(FArray[Cpt]).Free;
FArray.Free;
inherited;
end;
@@ -514,7 +510,7 @@ for Cpt:= 0 to Pred(FStream.Count) do
if TPdfObjet(FStream[Cpt]) is TPdfFonte
then
TPdfFonte(FStream[Cpt]).WriteFonte(AFlux);
- if TPdfColor(FStream[Cpt]) is TPdfColor
+ if TPdfObjet(FStream[Cpt]) is TPdfColor
then
TPdfColor(FStream[Cpt]).WriteColor(AFlux);
if TPdfObjet(FStream[Cpt]) is TPdfText
@@ -547,7 +543,13 @@ FStream:= TList.Create;
end;
destructor TPdfStream.Destroy;
+var
+ Cpt: Integer;
begin
+if FStream.Count> 0
+then
+ for Cpt:= 0 to Pred(FStream.Count) do
+ TPdfObjet(FStream[Cpt]).Free;
FStream.Free;
inherited;
end;
@@ -876,9 +878,7 @@ end;
procedure TPdfDocument.WriteObjet(const AObjet: Integer; const AFlux: TStream);
var
- Dictionaire: TPdfDictionary;
Long: TPdfInteger;
- Fin: Integer;
Flux: TMemoryStream;
begin
WriteChaine(IntToStr(AObjet)+' 0 obj'+CRLF,AFlux);
@@ -1095,10 +1095,9 @@ TPdfArray(TPdfDicElement(Dictionaire.FElement[Dictionaire.ElementParCle('ProcSet
Result:= Pred(FXRefObjets.Count);
end;
-function TPdfDocument.CreateOutlines(Parent: Integer): Integer;
+function TPdfDocument.CreateOutlines: Integer;
var
Outlines: TPdfXRef;
- XRefObjets: TPdfReference;
Nom: TPdfName;
Count: TPdfInteger;
begin
@@ -1308,12 +1307,11 @@ end;
constructor TPdfDocument.CreateDocument;
var
- Cpt,CptSect,CptPage,CptFont,NumFont,TreeRoot,ParentPage,PageNum,NumPage: Integer;
+ Cpt,CptSect,CptPage,NumFont,TreeRoot,ParentPage,PageNum,NumPage: Integer;
OutlineRoot,ParentOutline,PageOutline,NextOutline,NextSect,NewPage: Integer;
Dictionaire: TPdfDictionary;
XRefObjets,PrevOutline,PrevSect: TPdfReference;
Nom: TPdfName;
- Trouve: Boolean;
FontName: string;
begin
inherited Create;
@@ -1330,7 +1328,7 @@ then
if Outline
then
begin
- OutlineRoot:= CreateOutlines(ParentOutline);
+ OutlineRoot:= CreateOutlines;
// add outline reference to catalog dictionary
XRefObjets:= TPdfReference.CreateReference(Pred(FXRefObjets.Count));
TPdfDictionary(TPdfXRef(FXRefObjets[Catalogue]).FObjet).AddElement('Outlines',XRefObjets);
@@ -1441,7 +1439,6 @@ then
NumFont:= 0;
for Cpt:= 0 to Pred(Fontes.Count) do
begin
- Trouve:= False;
FontName:= ExtractBaseFontName(T_Fonte(Fontes[Cpt]).GetFonte.FontDesc);
CreateFont(FontName,NumFont);
Inc(NumFont);