From 7fcc800de05b09f757784a92b71d37ffaec29db0 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 14 Dec 2022 23:22:06 +0000 Subject: [PATCH] GridPrinter: Make sure that all printed pages have the same date/time in their header/footer, if applicable. Add xml docs for GrindPrinterActions. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8652 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../gridprinter/docs/xml/gridprnactions.xml | 23 +++++++++++++++++++ components/gridprinter/source/gridprn.pas | 10 ++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 components/gridprinter/docs/xml/gridprnactions.xml diff --git a/components/gridprinter/docs/xml/gridprnactions.xml b/components/gridprinter/docs/xml/gridprnactions.xml new file mode 100644 index 000000000..7a975c5e8 --- /dev/null +++ b/components/gridprinter/docs/xml/gridprnactions.xml @@ -0,0 +1,23 @@ + +Standard-Action which links to a GridPrinter and calls its Print method to print a grid + Inherited procedure which sets the internal FGridPrinter variable to nil when the GridPrinter is deleted. + Constructor of the TGridPrinterAction class + Executes the Print() method of the associated TGridPrinter instance if that matches with the Target parameter. + Returns true when the parameter Target is the associated GridPrinter + + Disables the action if no GridPrinter is associated with the action or if the grid associated with the GridPrinter is not visible. + Points to the TGridPrinter instance which is associated with the action. + Standard-Action which links to a GridPrintPreviewDialog and calls its Execute method to display a preview a grid to be printed by a GridPrinter. + Inherited procedure which sets the internal FPreviewDlg variable to nil when the associated PrintPreviewDialog is deleted. + Constructor of the TGridPrintPreviewAction class + Runs the Execute() method of the associated TGridPrintPreviewDialog instance if that matches with the Target parameter. + Returns true when the parameter Target is the associated GridPrintPreviewDialog + + Disables the action if no PreviewDialog is associated with the action or if that is not associated with a GridPrinterassigned to a visible grid. + Internal variable for the associated TGridPrinter instance. + Internal variable for the associated TGridPrintPreviewDialog instance. + Points to the TGridPrintPreviewDialog instance which is associated with the action. + + + + diff --git a/components/gridprinter/source/gridprn.pas b/components/gridprinter/source/gridprn.pas index 731688221..d6d6778c3 100644 --- a/components/gridprinter/source/gridprn.pas +++ b/components/gridprinter/source/gridprn.pas @@ -146,6 +146,7 @@ type FPageHeight: Integer; FPageWidth: Integer; FPreviewPercent: Integer; // Scaling factor for preview bitmap + FPrintDateTime: TDateTime; FPrintOrder: TGridPrnOrder; FPrintScaleFactor: Double; // Scaling factor for printing FPrintScaleToNumHorPages: Integer; @@ -277,6 +278,7 @@ type property Padding: Integer read FPadding; property PageCount: Integer read GetPageCount; property PageNumber: Integer read FPageNumber; + property PrintDateTime: TDateTime read FPrintDateTime; property PrintScaleToNumHorPages: Integer read FPrintScaleToNumHorPages write FPrintScaleToNumHorPages; property PrintScaleToNumVertPages: Integer read FPrintScaleToNumVertPages write FPrintScaleToNumVertPages; property PrintScalingMode: TGridPrnScalingMode read FPrintScalingMode write FPrintScalingMode; @@ -486,8 +488,8 @@ const begin Result := FSectionText[AIndex]; - Result := StringReplace(Result, '$DATE', DateToStr(Now), [rfReplaceAll, rfIgnoreCase]); - Result := StringReplace(Result, '$TIME', TimeToStr(Now), [rfReplaceAll, rfIgnoreCase]); + Result := StringReplace(Result, '$DATE', DateToStr(FOwner.PrintDateTime), [rfReplaceAll, rfIgnoreCase]); + Result := StringReplace(Result, '$TIME', TimeToStr(FOwner.PrintDateTime), [rfReplaceAll, rfIgnoreCase]); Replace('$PAGECOUNT'); Replace('$PAGE'); Replace('$FULL_FILENAME'); @@ -1087,6 +1089,10 @@ begin Measure(FPageWidth, FPageHeight, FPixelsPerInchX, FPixelsPerInchY); end; end; + + // Stores the current date/time so that all pages have the same date/time + // in the header/footer. + FPrintDateTime := Now(); end; procedure TGridPrinter.PrepareCanvas(ACanvas: TCanvas; ACol, ARow: Integer);