diff --git a/components/powerpdf/PdfDoc.pas b/components/powerpdf/PdfDoc.pas index 0d7638b49..24b37e6c3 100644 --- a/components/powerpdf/PdfDoc.pas +++ b/components/powerpdf/PdfDoc.pas @@ -53,8 +53,6 @@ uses SysUtils, Classes {$IFDEF UNIX} , Types - {$ELSE} - , Windows {$ENDIF} {$IFDEF LAZ_POWERPDF} , LCLProc @@ -275,7 +273,7 @@ type TPdfXref = class(TPdfObjectMgr) private - FXrefEntries: TList; + FXrefEntries: TFpList; function GetItem(ObjectID: integer): TPdfXrefEntry; function GetItemCount: integer; protected @@ -309,8 +307,8 @@ type FXref: TPdfXref; FInfo: TPdfInfo; FHasDoc: boolean; - FFontList: TList; - FObjectList: TList; + FFontList: TFpList; + FObjectList: TFpList; FOutlineRoot: TPdfOutlineRoot; FXObjectList: TPdfArray; FDefaultPageWidth: Word; @@ -325,21 +323,21 @@ type procedure CreateInfo; procedure CreateOutlines; function CreateCatalog: TPdfDictionary; - function CreateFont(FontName: string): TPdfFont; + function CreateFont(const FontName: string): TPdfFont; function CreatePages(Parent: TPdfDictionary): TPdfDictionary; public - procedure RegisterXObject(AObject: TPdfXObject; AName: string); + procedure RegisterXObject(AObject: TPdfXObject; const AName: string); constructor Create; destructor Destroy; override; procedure NewDoc; procedure FreeDoc; procedure AddPage; - procedure AddXObject(AName: string; AXObject: TPdfXObject); + procedure AddXObject(const AName: string; AXObject: TPdfXObject); procedure SaveToStream(AStream: TStream); procedure SetVirtualMode; - function GetFont(FontName: string): TPdfFont; - function GetXObject(AName: string): TPdfXObject; - function CreateAnnotation(AType: TPdfAnnotationSubType; ARect: TPdfRect): TPdfDictionary; + function GetFont(const FontName: string): TPdfFont; + function GetXObject(const AName: string): TPdfXObject; + function CreateAnnotation(AType: TPdfAnnotationSubType; const ARect: TPdfRect): TPdfDictionary; function CreateDestination: TPdfDestination; property HasDoc: boolean read FHasDoc; property Canvas: TPdfCanvas read GetCanvas; @@ -392,7 +390,7 @@ type FIsVirtual: boolean; procedure SetPageWidth(AValue: integer); procedure SetPageHeight(AValue: integer); - procedure WriteString(S: string); + procedure WriteString(const S: string); function GetDoc: TPdfDoc; function GetPage: TPdfDictionary; function GetPageWidth: Integer; @@ -441,7 +439,7 @@ type procedure SetWordSpace(wordSpace: Single); { Tw } procedure SetHorizontalScaling(hScaling: Word); { Tz } procedure SetLeading(leading: Single); { TL } - procedure SetFontAndSize(fontname: string; size: Single); { Tf } + procedure SetFontAndSize(const fontname: string; size: Single); { Tf } procedure SetTextRenderingMode(mode: TTextRenderingMode); { Tr } procedure SetTextRise(rise: Word); { Ts } procedure BeginText; { BT } @@ -449,11 +447,11 @@ type procedure MoveTextPoint(tx, ty: Single); { Td } procedure SetTextMatrix(a, b, c, d, x, y: Single); { Tm } procedure MoveToNextLine; { T* } - procedure ShowText(s: string); { Tj } - procedure ShowTextNextLine(s: string); { ' } + procedure ShowText(const s: string); { Tj } + procedure ShowTextNextLine(const s: string); { ' } {* external objects *} - procedure ExecuteXObject(xObject: string); { Do } + procedure ExecuteXObject(const xObject: string); { Do } {* Device-dependent color space operators *} procedure SetRGBFillColor(Value: TPdfColor); { rg } @@ -461,16 +459,16 @@ type {* utility routines *} procedure SetPage(APage: TPdfDictionary); - procedure SetFont(AName: string; ASize: Single); - procedure TextOut(X, Y: Single; Text: string); + procedure SetFont(const AName: string; ASize: Single); + procedure TextOut(X, Y: Single; const Text: string); procedure TextRect(ARect: TPdfRect; Text: string; Alignment: TPdfAlignment; Clipping: boolean); procedure MultilineTextRect(ARect: TPdfRect; - Text: string; WordWrap: boolean); + const Text: string; WordWrap: boolean); procedure DrawXObject(X, Y, AWidth, AHeight: Single; - AXObjectName: string); + const AXObjectName: string); procedure DrawXObjectEx(X, Y, AWidth, AHeight: Single; - ClipX, ClipY, ClipWidth, ClipHeight: Single; AXObjectName: string); + ClipX, ClipY, ClipWidth, ClipHeight: Single; const AXObjectName: string); procedure Ellipse(x, y, width, height: Single); procedure RoundRect(x, y, width, height, rx, ry: Single; SqrCorners:TPdfCorners=[]); function TextWidth(Text: string): Single; @@ -485,7 +483,7 @@ type property PageHeight: integer read GetPageHeight write SetPageHeight; {* Text rotated up *} - procedure TextOutRotatedUp(X, Y: Single; Text: string); + procedure TextOutRotatedUp(X, Y: Single; const Text: string); end; TPdfDictionaryWrapper = class(TPersistent) @@ -502,17 +500,17 @@ type TPdfInfo = class(TPdfDictionaryWrapper) private function GetAuthor: string; - procedure SetAuthor(Value: string); + procedure SetAuthor(const Value: string); function GetCreationDate: TDateTime; procedure SetCreationDate(Value: TDateTime); function GetCreator: string; - procedure SetCreator(Value: string); + procedure SetCreator(const Value: string); function GetKeywords: string; - procedure SetKeywords(Value: string); + procedure SetKeywords(const Value: string); function GetSubject: string; - procedure SetSubject(Value: string); + procedure SetSubject(const Value: string); function GetTitle: string; - procedure SetTitle(Value: string); + procedure SetTitle(const Value: string); function GetModDate: TDateTime; procedure SetModDate(Value: TDateTime); public @@ -562,8 +560,8 @@ type procedure AddStrElements(ADic: TPdfDictionary; ATable: array of TPDF_STR_TBL); procedure AddIntElements(ADic: TPdfDictionary; ATable: array of TPDF_INT_TBL); public - constructor Create(AXref: TPdfXref; AName: string); virtual; - function GetCharWidth(AText: string; APos: integer): integer; virtual; + constructor Create(AXref: TPdfXref; const AName: string); virtual; + function GetCharWidth(const AText: string; APos: integer): integer; virtual; property Name: string read FName; property UnderlinePosition: Integer read FUnderlinePosition write FUnderlinePosition; property UnderlineThickness: Integer read FUnderlineThickness write FUnderlineThickness; @@ -754,7 +752,7 @@ constructor TPdfXref.Create; var RootEntry: TPdfXrefEntry; begin - FXrefEntries := TList.Create; + FXrefEntries := TFpList.Create; RootEntry := TPdfXrefEntry.Create(nil); RootEntry.GenerationNumber := PDF_MAX_GENERATION_NUM; FXrefEntries.Add(RootEntry); @@ -890,7 +888,7 @@ begin end; // CreateFont -function TPdfDoc.CreateFont(FontName: string): TPdfFont; +function TPdfDoc.CreateFont(const FontName: string): TPdfFont; var PdfFont: TPdfFont; begin @@ -910,7 +908,7 @@ begin end; // RegisterXObject -procedure TPdfDoc.RegisterXObject(AObject: TPdfXObject; AName: string); +procedure TPdfDoc.RegisterXObject(AObject: TPdfXObject; const AName: string); begin // check object and register it. if AObject = nil then @@ -969,7 +967,7 @@ begin end; // GetFont -function TPdfDoc.GetFont(FontName: string): TPdfFont; +function TPdfDoc.GetFont(const FontName: string): TPdfFont; var FFont: TPdfFont; i :integer; @@ -993,7 +991,7 @@ begin end; // GetXObject -function TPdfDoc.GetXObject(AName: string): TPdfXObject; +function TPdfDoc.GetXObject(const AName: string): TPdfXObject; var FXObject: TPdfXObject; i :integer; @@ -1012,7 +1010,7 @@ begin end; // CreateAnnotation -function TPdfDoc.CreateAnnotation(AType: TPdfAnnotationSubType; ARect: TPdfRect): TPdfDictionary; +function TPdfDoc.CreateAnnotation(AType: TPdfAnnotationSubType; const ARect: TPdfRect): TPdfDictionary; var FAnnotation: TPdfDictionary; FArray: TPdfArray; @@ -1069,9 +1067,9 @@ begin FXref := TPdfXref.Create; FHeader := TPdfHeader.Create; FTrailer := TPdfTrailer.Create(FXref); - FFontList := TList.Create; + FFontList := TFpList.Create; FXObjectList := TPdfArray.CreateArray(FXref); - FObjectList := TList.Create; + FObjectList := TFpList.Create; FRoot := TPdfCatalog.Create; FRoot.SetData(CreateCatalog); @@ -1090,7 +1088,7 @@ begin end; // AddXObject -procedure TPdfDoc.AddXObject(AName: string; AXObject: TPdfXObject); +procedure TPdfDoc.AddXObject(const AName: string; AXObject: TPdfXObject); begin if GetXObject(AName) <> nil then raise Exception.CreateFmt('AddImage --the image named %s is already exists..', [AName]); @@ -1402,7 +1400,7 @@ begin end; // WriteString -procedure TPdfCanvas.WriteString(S: string); +procedure TPdfCanvas.WriteString(const S: string); begin if (not FIsVirtual) and (FContents <> nil) then _WriteString(S, FContents.Stream); @@ -1502,7 +1500,7 @@ begin end; // SetFont -procedure TPdfCanvas.SetFont(AName: string; ASize: Single); +procedure TPdfCanvas.SetFont(const AName: string; ASize: Single); var FFont: TPdfFont; FFontList: TPdfDictionary; @@ -1523,7 +1521,7 @@ begin end; // TextOut -procedure TPdfCanvas.TextOut(X, Y: Single; Text: string); +procedure TPdfCanvas.TextOut(X, Y: Single; const Text: string); var UPos, UWidth: Single; begin @@ -1595,7 +1593,7 @@ begin end; // MultilineTextRect -procedure TPdfCanvas.MultilineTextRect(ARect: TPdfRect; Text: string; +procedure TPdfCanvas.MultilineTextRect(ARect: TPdfRect; const Text: string; WordWrap: boolean); var i: integer; @@ -1702,7 +1700,7 @@ end; // DrawXObject procedure TPdfCanvas.DrawXObject(X, Y, AWidth, AHeight: Single; - AXObjectName: string); + const AXObjectName: string); var XObject: TPdfXObject; FXObjectList: TPdfDictionary; @@ -1724,7 +1722,7 @@ end; // DrawXObjectEx procedure TPdfCanvas.DrawXObjectEx(X, Y, AWidth, AHeight: Single; - ClipX, ClipY, ClipWidth, ClipHeight: Single; AXObjectName: string); + ClipX, ClipY, ClipWidth, ClipHeight: Single; const AXObjectName: string); var XObject: TPdfXObject; FXObjectList: TPdfDictionary; @@ -2015,7 +2013,7 @@ begin end; // SetFontAndSize -procedure TPdfCanvas.SetFontAndSize(fontname: string; size: Single); +procedure TPdfCanvas.SetFontAndSize(const fontname: string; size: Single); var S: string; begin @@ -2079,7 +2077,7 @@ begin end; // ShowText -procedure TPdfCanvas.ShowText(s: string); +procedure TPdfCanvas.ShowText(const s: string); var FString: string; begin @@ -2091,7 +2089,7 @@ begin end; // ShowTextNextLine -procedure TPdfCanvas.ShowTextNextLine(s: string); +procedure TPdfCanvas.ShowTextNextLine(const s: string); var FString: string; begin @@ -2105,7 +2103,7 @@ end; {* external objects *} // ExecuteXObject -procedure TPdfCanvas.ExecuteXObject(xObject: string); +procedure TPdfCanvas.ExecuteXObject(const xObject: string); var S: string; begin @@ -2262,7 +2260,7 @@ begin Index := i + 1; end; -procedure TPdfCanvas.TextOutRotatedUp(X, Y: Single; Text: string); +procedure TPdfCanvas.TextOutRotatedUp(X, Y: Single; const Text: string); begin BeginText; SetTextMatrix(0, 1, -1, 0, X, Y); // down to up @@ -2297,7 +2295,7 @@ end; { TPdfInfo } // SetAuthor -procedure TPdfInfo.SetAuthor(Value: string); +procedure TPdfInfo.SetAuthor(const Value: string); begin FData.AddItem('Author', TPdfText.CreateText(Value)); end; @@ -2315,25 +2313,25 @@ begin end; // SetCreator -procedure TPdfInfo.SetCreator(Value: string); +procedure TPdfInfo.SetCreator(const Value: string); begin FData.AddItem('Creator', TPdfText.CreateText(Value)); end; // SetTitle -procedure TPdfInfo.SetTitle(Value: string); +procedure TPdfInfo.SetTitle(const Value: string); begin FData.AddItem('Title', TPdfText.CreateText(Value)); end; // SetSubject -procedure TPdfInfo.SetSubject(Value: string); +procedure TPdfInfo.SetSubject(const Value: string); begin FData.AddItem('Subject', TPdfText.CreateText(Value)); end; // SetKeywords -procedure TPdfInfo.SetKeywords(Value: string); +procedure TPdfInfo.SetKeywords(const Value: string); begin FData.AddItem('Keywords', TPdfText.CreateText(Value)); end; @@ -2653,13 +2651,13 @@ begin end; // GetCharWidth -function TPdfFont.GetCharWidth(AText: string; APos: integer): integer; +function TPdfFont.GetCharWidth(const AText: string; APos: integer): integer; begin result := 0; end; // Create -constructor TPdfFont.Create(AXref: TPdfXref; AName: string); +constructor TPdfFont.Create(AXref: TPdfXref; const AName: string); begin inherited Create; FName := AName; diff --git a/components/powerpdf/PdfFonts.pas b/components/powerpdf/PdfFonts.pas index 8f1369ecf..86be45c74 100644 --- a/components/powerpdf/PdfFonts.pas +++ b/components/powerpdf/PdfFonts.pas @@ -500,78 +500,78 @@ type FArray: array[0..255] of Word; public procedure SetData(Value: TPdfDictionary); override; - function GetCharWidth(AText: string; APos: integer): integer; override; + function GetCharWidth(const AText: string; APos: integer): integer; override; end; TPdfFixedWidth = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfFixedWidthBold = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfFixedWidthItalic = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfFixedWidthBoldItalic = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfArial = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfArialBold = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfArialItalic = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfArialBoldItalic = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfTimesRoman = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfTimesBold = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfTimesItalic = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfTimesBoldItalic = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfScript = class(TPdfType1Font) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; implementation { TPdfType1Font } -function TPdfType1Font.GetCharWidth(AText: string; APos: integer): integer; +function TPdfType1Font.GetCharWidth(const AText: string; APos: integer): integer; begin result := FArray[ord(AText[APos])]; end; @@ -604,7 +604,7 @@ begin end; { FixedWidth } -constructor TPdfFixedWidth.Create(AXref: TPdfXref; AName: string); +constructor TPdfFixedWidth.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -628,7 +628,7 @@ begin end; { FixedWidthBold } -constructor TPdfFixedWidthBold.Create(AXref: TPdfXref; AName: string); +constructor TPdfFixedWidthBold.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -648,7 +648,7 @@ begin end; { FixedWidthItalic } -constructor TPdfFixedWidthItalic.Create(AXref: TPdfXref; AName: string); +constructor TPdfFixedWidthItalic.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -668,7 +668,7 @@ begin end; { FixedWidthBoldItalic } -constructor TPdfFixedWidthBoldItalic.Create(AXref: TPdfXref; AName: string); +constructor TPdfFixedWidthBoldItalic.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -688,7 +688,7 @@ begin end; { Arial } -constructor TPdfArial.Create(AXref: TPdfXref; AName: string); +constructor TPdfArial.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -710,7 +710,7 @@ begin end; { Arial-Bold } -constructor TPdfArialBold.Create(AXref: TPdfXref; AName: string); +constructor TPdfArialBold.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -733,7 +733,7 @@ begin end; { Arial-Italic } -constructor TPdfArialItalic.Create(AXref: TPdfXref; AName: string); +constructor TPdfArialItalic.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -755,7 +755,7 @@ begin end; { Arial-BoldItalic } -constructor TPdfArialBoldItalic.Create(AXref: TPdfXref; AName: string); +constructor TPdfArialBoldItalic.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -778,7 +778,7 @@ begin end; { TPdfTimesRoman } -constructor TPdfTimesRoman.Create(AXref: TPdfXref; AName: string); +constructor TPdfTimesRoman.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -798,7 +798,7 @@ begin end; { TPdfTimesBold } -constructor TPdfTimesBold.Create(AXref: TPdfXref; AName: string); +constructor TPdfTimesBold.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -818,7 +818,7 @@ begin end; { TPdfTimesItalic } -constructor TPdfTimesItalic.Create(AXref: TPdfXref; AName: string); +constructor TPdfTimesItalic.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -838,7 +838,7 @@ begin end; { TPdfTimesBoldItalic } -constructor TPdfTimesBoldItalic.Create(AXref: TPdfXref; AName: string); +constructor TPdfTimesBoldItalic.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFont: TPdfDictionary; @@ -858,7 +858,7 @@ begin end; { TPdfScript } -constructor TPdfScript.Create(AXref: TPdfXref; AName: string); +constructor TPdfScript.Create(AXref: TPdfXref; const AName: string); var FWidths: TPdfArray; FFontDescriptor: TPdfDictionary; diff --git a/components/powerpdf/PdfGBFonts.pas b/components/powerpdf/PdfGBFonts.pas index 678d1ffc4..53d765d73 100644 --- a/components/powerpdf/PdfGBFonts.pas +++ b/components/powerpdf/PdfGBFonts.pas @@ -65,14 +65,14 @@ type procedure AddDescendantFontItem(ADescendantFont: TPdfDictionary); virtual; function GetFontName: string; virtual; public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfGBFixedFont = class(TPdfGBFont) protected procedure AddDescendantFontItem(ADescendantFont: TPdfDictionary); override; public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfChinese = class(TPdfGBFixedFont) @@ -115,7 +115,7 @@ begin end; // Create -constructor TPdfGBFont.Create(AXref: TPdfXref; AName: string); +constructor TPdfGBFont.Create(AXref: TPdfXref; const AName: string); var FFontDescriptor: TPdfDictionary; FFont: TPdfDictionary; @@ -179,7 +179,7 @@ begin ADescendantFont.AddItem('W', FWidths); end; -constructor TPdfGBFixedFont.Create(AXref: TPdfXref; AName: string); +constructor TPdfGBFixedFont.Create(AXref: TPdfXref; const AName: string); begin inherited Create(AXref, AName); AddStrElements(Data, TYPE0_GB_FONT_STR_TABLE); diff --git a/components/powerpdf/PdfJPFonts.pas b/components/powerpdf/PdfJPFonts.pas index 71d4421fe..bc029b884 100644 --- a/components/powerpdf/PdfJPFonts.pas +++ b/components/powerpdf/PdfJPFonts.pas @@ -223,7 +223,7 @@ type TPdfType0Font = class(TPdfFont) private FCharToCMap: TCharToCMap; - FArray: TList; + FArray: TFpList; FDW: Word; FMissingWidth: Word; protected @@ -232,7 +232,7 @@ type destructor Destroy; override; procedure SetData(AData: TPdfDictionary); override; procedure SetCharToCMap(AFunc: TCharToCMap); virtual; - function GetCharWidth(AText: string; APos: integer): integer; override; + function GetCharWidth(const AText: string; APos: integer): integer; override; end; TPdfJpFont = class(TPdfType0Font) @@ -241,14 +241,14 @@ type procedure AddDescendantFontItem(ADescendantFont: TPdfDictionary); virtual; function GetFontName: string; virtual; public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfJpFixedFont = class(TPdfJpFont) protected procedure AddDescendantFontItem(ADescendantFont: TPdfDictionary); override; public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfGothic = class(TPdfJpFixedFont) @@ -301,7 +301,7 @@ type TPdfJpProportionalFont = class(TPdfJpFont) public - constructor Create(AXref: TPdfXref; AName: string); override; + constructor Create(AXref: TPdfXref; const AName: string); override; end; TPdfPGothic = class(TPdfJpProportionalFont) @@ -380,7 +380,7 @@ begin FDW := DescendantFont.PdfNumberByName('DW').Value; Discriptor := DescendantFont.PdfDictionaryByName('FontDescriptor'); FMissingWidth := Discriptor.PdfNumberByName('MissingWidth').Value; - FArray := TList.Create; + FArray := TFpList.Create; WidthsRoot := DescendantFont.PdfArrayByName('W'); // create widths array from "W"attribute. @@ -451,7 +451,7 @@ begin end; // GetCharWidth -function TPdfType0Font.GetCharWidth(AText: string; APos: integer): integer; +function TPdfType0Font.GetCharWidth(const AText: string; APos: integer): integer; var CID: integer; begin @@ -506,7 +506,7 @@ begin end; // Create -constructor TPdfJpFont.Create(AXref: TPdfXref; AName: string); +constructor TPdfJpFont.Create(AXref: TPdfXref; const AName: string); var FFontDescriptor: TPdfDictionary; FFont: TPdfDictionary; @@ -570,7 +570,7 @@ begin ADescendantFont.AddItem('W', FWidths); end; -constructor TPdfJpFixedFont.Create(AXref: TPdfXref; AName: string); +constructor TPdfJpFixedFont.Create(AXref: TPdfXref; const AName: string); begin inherited Create(AXref, AName); AddStrElements(Data, TYPE0_JP_FONT_STR_TABLE); @@ -765,7 +765,7 @@ end; { TPdfJpProportionalFont } // Create -constructor TPdfJpProportionalFont.Create(AXref: TPdfXref; AName: string); +constructor TPdfJpProportionalFont.Create(AXref: TPdfXref; const AName: string); begin inherited Create(AXref, AName); AddStrElements(Data, TYPE0_JPP_FONT_STR_TABLE); diff --git a/components/powerpdf/PdfTypes.pas b/components/powerpdf/PdfTypes.pas index 6b01fdf76..da5d1395b 100644 --- a/components/powerpdf/PdfTypes.pas +++ b/components/powerpdf/PdfTypes.pas @@ -160,7 +160,7 @@ type protected procedure InternalWriteStream(const AStream: TStream); override; public - constructor CreateString(AValue: string); + constructor CreateString(const AValue: string); property Value: string read FValue write FValue; end; @@ -170,7 +170,7 @@ type protected procedure InternalWriteStream(const AStream: TStream); override; public - constructor CreateText(AValue: string); + constructor CreateText(const AValue: string); property Value: String read FValue write FValue; end; @@ -187,7 +187,7 @@ type TPdfArray = class(TPdfObject) private - FArray: TList; + FArray: TFpList; FObjectMgr: TPdfObjectMgr; function GetItems(Index: integer): TPdfObject; function GetItemCount: integer; @@ -198,8 +198,8 @@ type constructor CreateNumArray(AObjectMgr: TPdfObjectMgr; AArray: array of Integer); destructor Destroy; override; procedure AddItem(AItem: TPdfObject); - function FindName(AName: string): TPdfName; - function RemoveName(AName: string): boolean; + function FindName(const AName: string): TPdfName; + function RemoveName(const AName: string): boolean; property Items[Index: integer]: TPdfObject read GetItems; property ItemCount: integer read GetItemCount; property ObjectMgr: TPdfObjectMgr read FObjectMgr; @@ -212,8 +212,8 @@ type FIsInternal: boolean; function GetKey: string; public - constructor Create(AKey: string; AValue: TPdfObject); - constructor CreateAsInternal(AKey: string; AValue: TPdfObject; AVoid: Pointer); + constructor Create(const AKey: string; AValue: TPdfObject); + constructor CreateAsInternal(const AKey: string; AValue: TPdfObject; AVoid: Pointer); destructor Destroy; override; property Key: string read GetKey; property Value: TPdfObject read FValue; @@ -222,7 +222,7 @@ type TPdfDictionary = class(TPdfObject) private - FArray: TList; + FArray: TFpList; FObjectMgr: TPdfObjectMgr; function GetItems(Index: integer): TPdfDictionaryElement; function GetItemCount: integer; @@ -231,20 +231,20 @@ type public constructor CreateDictionary(AObjectMgr: TPdfObjectMgr); destructor Destroy; override; - function ValueByName(AKey: string): TPdfObject; - function PdfBooleanByName(AKey: string): TPdfBoolean; - function PdfNumberByName(AKey: string): TPdfNumber; - function PdfTextByName(AKey: string): TPdfText; - function PdfRealByName(AKey: string): TPdfReal; - function PdfStringByName(AKey: string): TPdfString; - function PdfNameByName(AKey: string): TPdfName; - function PdfDictionaryByName(AKey: string): TPdfDictionary; - function PdfArrayByName(AKey: string): TPdfArray; - procedure AddItem(AKey: string; AValue: TPdfObject); - procedure AddNumberItem(AKey: string; AValue: Integer); - procedure AddNameItem(AKey: string; AValue: string); - procedure AddInternalItem(AKey: string; AValue: TPdfObject); - procedure RemoveItem(AKey: string); + function ValueByName(const AKey: string): TPdfObject; + function PdfBooleanByName(const AKey: string): TPdfBoolean; + function PdfNumberByName(const AKey: string): TPdfNumber; + function PdfTextByName(const AKey: string): TPdfText; + function PdfRealByName(const AKey: string): TPdfReal; + function PdfStringByName(const AKey: string): TPdfString; + function PdfNameByName(const AKey: string): TPdfName; + function PdfDictionaryByName(const AKey: string): TPdfDictionary; + function PdfArrayByName(const AKey: string): TPdfArray; + procedure AddItem(const AKey: string; AValue: TPdfObject); + procedure AddNumberItem(const AKey: string; AValue: Integer); + procedure AddNameItem(const AKey: string; AValue: string); + procedure AddInternalItem(const AKey: string; AValue: TPdfObject); + procedure RemoveItem(const AKey: string); property Items[Index: integer]: TPdfDictionaryElement read GetItems; property ItemCount: integer read GetItemCount; property ObjectMgr: TPdfObjectMgr read FObjectMgr; @@ -298,13 +298,13 @@ type function _FloatToStrR(Value: Extended): string; function _GetUnicodeHeader: string; function _PdfRect(Left, Top, Right, Bottom: Single): TPdfRect; - function _GetCharCount(Text: string): integer; + function _GetCharCount(const Text: string): integer; {$IFDEF LAZ_POWERPDF} function _UTF8StrToUnicodeHex(const Value:string): string; function _UTF8ToWinAnsi(const value:string; InvalidChar:char='?'): string; - procedure PdfLazRegisterClassAlias(aClass: TPersistentClass; Alias: string); - function PdfLazFindClass(aClassName: string):TPersistentClass; + procedure PdfLazRegisterClassAlias(aClass: TPersistentClass; const Alias: string); + function PdfLazFindClass(const aClassName: string):TPersistentClass; {$ENDIF} implementation @@ -470,7 +470,7 @@ begin end; // CreateString -constructor TPdfString.CreateString(AValue: string); +constructor TPdfString.CreateString(const AValue: string); begin Create; Value := AValue; @@ -493,7 +493,7 @@ begin end; // CreateText -constructor TPdfText.CreateText(AValue: string); +constructor TPdfText.CreateText(const AValue: string); begin Create; Value := AValue; @@ -575,7 +575,7 @@ end; constructor TPdfArray.CreateArray(AObjectMgr: TPdfObjectMgr); begin inherited Create; - FArray := TList.Create; + FArray := TFpList.Create; FObjectMgr := AObjectMgr; end; @@ -585,7 +585,7 @@ var i: integer; begin inherited Create; - FArray := TList.Create; + FArray := TFpList.Create; FObjectMgr := AObjectMgr; for i := 0 to High(AArray) do @@ -621,7 +621,7 @@ begin end; // FindName -function TPdfArray.FindName(AName: string): TPdfName; +function TPdfArray.FindName(const AName: string): TPdfName; var i: integer; FPdfName: TPdfName; @@ -641,7 +641,7 @@ begin end; // RemoveName -function TPdfArray.RemoveName(AName: string): boolean; +function TPdfArray.RemoveName(const AName: string): boolean; var AObject: TPdfObject; begin @@ -665,7 +665,7 @@ begin end; // Create -constructor TPdfDictionaryElement.Create(AKey: string; AValue: TPdfObject); +constructor TPdfDictionaryElement.Create(const AKey: string; AValue: TPdfObject); begin FKey := TPdfName.Create; FKey.Value := AKey; @@ -676,7 +676,7 @@ begin end; // CreateAsInternal -constructor TPdfDictionaryElement.CreateAsInternal(AKey: string; AValue: TPdfObject; AVoid: Pointer); +constructor TPdfDictionaryElement.CreateAsInternal(const AKey: string; AValue: TPdfObject; AVoid: Pointer); begin Create(AKey, AValue); FIsInternal := true; @@ -729,7 +729,7 @@ end; constructor TPdfDictionary.CreateDictionary(AObjectMgr: TPdfObjectMgr); begin inherited Create; - FArray := TList.Create; + FArray := TFpList.Create; FObjectMgr := AObjectMgr; end; @@ -751,7 +751,7 @@ begin end; // ValueByName -function TPdfDictionary.ValueByName(AKey: string): TPdfObject; +function TPdfDictionary.ValueByName(const AKey: string): TPdfObject; var i: integer; FElement: TPdfDictionaryElement; @@ -774,55 +774,55 @@ begin end; // PdfNumberByName -function TPdfDictionary.PdfNumberByName(AKey: string): TPdfNumber; +function TPdfDictionary.PdfNumberByName(const AKey: string): TPdfNumber; begin result := TPdfNumber(ValueByName(AKey)); end; // PdfTextByName -function TPdfDictionary.PdfTextByName(AKey: string): TPdfText; +function TPdfDictionary.PdfTextByName(const AKey: string): TPdfText; begin result := TPdfText(ValueByName(AKey)); end; // PdfRealByName -function TPdfDictionary.PdfRealByName(AKey: string): TPdfReal; +function TPdfDictionary.PdfRealByName(const AKey: string): TPdfReal; begin result := TPdfReal(ValueByName(AKey)); end; // PdfStringByName -function TPdfDictionary.PdfStringByName(AKey: string): TPdfString; +function TPdfDictionary.PdfStringByName(const AKey: string): TPdfString; begin result := TPdfString(ValueByName(AKey)); end; // PdfNameByName -function TPdfDictionary.PdfNameByName(AKey: string): TPdfName; +function TPdfDictionary.PdfNameByName(const AKey: string): TPdfName; begin result := TPdfName(ValueByName(AKey)); end; // PdfDictionaryByName -function TPdfDictionary.PdfDictionaryByName(AKey: string): TPdfDictionary; +function TPdfDictionary.PdfDictionaryByName(const AKey: string): TPdfDictionary; begin result := TPdfDictionary(ValueByName(AKey)); end; // PdfArrayByName -function TPdfDictionary.PdfArrayByName(AKey: string): TPdfArray; +function TPdfDictionary.PdfArrayByName(const AKey: string): TPdfArray; begin result := TPdfArray(ValueByName(AKey)); end; // PdfBooleanByName -function TPdfDictionary.PdfBooleanByName(AKey: string): TPdfBoolean; +function TPdfDictionary.PdfBooleanByName(const AKey: string): TPdfBoolean; begin result := TPdfBoolean(ValueByName(AKey)); end; // AddItem -procedure TPdfDictionary.AddItem(AKey: string; AValue: TPdfObject); +procedure TPdfDictionary.AddItem(const AKey: string; AValue: TPdfObject); var FItem: TPdfDictionaryElement; FTmpObject: TPdfVirtualObject; @@ -841,19 +841,19 @@ begin end; // AddNumberItem -procedure TPdfDictionary.AddNumberItem(AKey: string; AValue: Integer); +procedure TPdfDictionary.AddNumberItem(const AKey: string; AValue: Integer); begin AddItem(AKey, TPdfNumber.CreateNumber(AValue)); end; // AddNameItem -procedure TPdfDictionary.AddNameItem(AKey: string; AValue: string); +procedure TPdfDictionary.AddNameItem(const AKey: string; AValue: string); begin AddItem(AKey, TPdfName.CreateName(AValue)); end; // AddInternalItem -procedure TPdfDictionary.AddInternalItem(AKey: string; AValue: TPdfObject); +procedure TPdfDictionary.AddInternalItem(const AKey: string; AValue: TPdfObject); var FItem: TPdfDictionaryElement; FTmpObject: TPdfVirtualObject; @@ -872,7 +872,7 @@ begin end; // RemoveItem -procedure TPdfDictionary.RemoveItem(AKey: string); +procedure TPdfDictionary.RemoveItem(const AKey: string); var i: integer; FElement: TPdfDictionaryElement; @@ -1178,7 +1178,7 @@ begin end; // _GetCharCount -function _GetCharCount(Text: string): integer; +function _GetCharCount(const Text: string): integer; var i: integer; begin @@ -1214,7 +1214,7 @@ begin result := result + CP1252(word(w[i]), InvalidChar); end; -procedure PdfLazRegisterClassAlias(aClass: TPersistentClass; Alias: string); +procedure PdfLazRegisterClassAlias(aClass: TPersistentClass; const Alias: string); begin Classes.RegisterClass(aClass); if AliasList=nil then @@ -1222,7 +1222,7 @@ begin AliasList.AddObject(Alias, TObject(aClass)); end; -function PdfLazFindClass(aClassName: String): TPersistentClass; +function PdfLazFindClass(const aClassName: String): TPersistentClass; var i: Integer; begin