* Fix bug ID #32308, rename PageNumber to PageIndex

git-svn-id: trunk@55731 -
This commit is contained in:
michael 2017-08-21 11:12:01 +00:00
parent b27d1511ab
commit bbfb00769c
4 changed files with 35 additions and 29 deletions

View File

@ -229,7 +229,7 @@ end;
procedure TFPreportPreviewForm.DoNextAction(Sender: TObject); procedure TFPreportPreviewForm.DoNextAction(Sender: TObject);
begin begin
FRender.PageNumber:=FRender.PageNumber+1 FRender.PageIndex:=FRender.PageIndex+1
end; end;
procedure TFPreportPreviewForm.DoPaintReport(Sender: TObject); procedure TFPreportPreviewForm.DoPaintReport(Sender: TObject);
@ -239,17 +239,17 @@ end;
procedure TFPreportPreviewForm.DoPreviousAction(Sender: TObject); procedure TFPreportPreviewForm.DoPreviousAction(Sender: TObject);
begin begin
FRender.PageNumber:=FRender.PageNumber-1; FRender.PageIndex:=FRender.PageIndex-1;
end; end;
procedure TFPreportPreviewForm.UpdateNextAction(Sender: TObject); procedure TFPreportPreviewForm.UpdateNextAction(Sender: TObject);
begin begin
(Sender as TAction).Enabled:=(FRender.PageNumber<ReportPages.Count-1); (Sender as TAction).Enabled:=(FRender.PageIndex<ReportPages.Count-1);
end; end;
procedure TFPreportPreviewForm.UpdatePreviousAction(Sender: TObject); procedure TFPreportPreviewForm.UpdatePreviousAction(Sender: TObject);
begin begin
(Sender as TAction).Enabled:=(FRender.PageNumber>0); (Sender as TAction).Enabled:=(FRender.PageIndex>0);
end; end;

View File

@ -89,7 +89,7 @@ type
FImageWidth: integer; FImageWidth: integer;
FImageHeight: integer; FImageHeight: integer;
FFonts : TFPObjectHashTable; FFonts : TFPObjectHashTable;
FPageNumber: Integer; FPageIndex : Integer;
FPages : TFPList; FPages : TFPList;
FVDPI: integer; FVDPI: integer;
FVertOffset: Integer; FVertOffset: Integer;
@ -102,7 +102,7 @@ type
function GetPageCount: Integer; function GetPageCount: Integer;
procedure PrepareCanvas; procedure PrepareCanvas;
procedure SetHyperlinksEnabled(AValue: Boolean); procedure SetHyperlinksEnabled(AValue: Boolean);
procedure SetPageNumber(AValue: Integer); procedure SetPageIndex(AValue: Integer);
protected protected
procedure RenderFrame(const AFrame: TFPReportFrame; const ARect: Trect; const ABackgroundColor: TColor); procedure RenderFrame(const AFrame: TFPReportFrame; const ARect: Trect; const ABackgroundColor: TColor);
Procedure RenderImage(aRect : TFPReportRect; var AImage: TFPCustomImage) ; override; Procedure RenderImage(aRect : TFPReportRect; var AImage: TFPCustomImage) ; override;
@ -153,7 +153,7 @@ type
property VDPI: integer read FVDPI write FVDPI; property VDPI: integer read FVDPI write FVDPI;
property Zoom : Double read FZoom write FZoom; property Zoom : Double read FZoom write FZoom;
Property Canvas : TCanvas Read FCanvas Write FCanvas; Property Canvas : TCanvas Read FCanvas Write FCanvas;
Property PageNumber : Integer Read FPageNumber Write SetPageNumber; Property PageIndex : Integer Read FPageIndex Write SetPageIndex;
Property PageCount : Integer Read GetPageCount; Property PageCount : Integer Read GetPageCount;
Property CurrentPage : TFPReportPage Read GetCurrentPage; Property CurrentPage : TFPReportPage Read GetCurrentPage;
Property HorzOffset : Integer Read FHorzOffset Write FHorzOffset; Property HorzOffset : Integer Read FHorzOffset Write FHorzOffset;
@ -176,7 +176,8 @@ uses
fpwritepng, fpwritepng,
math; math;
Resourcestring
SErrPageOutOfRange = 'Page index %d out of allowed range [0..%d]';
type type
@ -288,8 +289,8 @@ end;
function TFPReportExportCanvas.GetCurrentPage: TFPReportPage; function TFPReportExportCanvas.GetCurrentPage: TFPReportPage;
begin begin
if Assigned(FPages) and (PageNumber<FPages.Count) then if Assigned(FPages) and (PageIndex<FPages.Count) then
Result:=TFPReportPage(FPages[PageNumber]) Result:=TFPReportPage(FPages[PageIndex])
else else
Result:=Nil; Result:=Nil;
end; end;
@ -301,7 +302,10 @@ end;
function TFPReportExportCanvas.GetPageCount: Integer; function TFPReportExportCanvas.GetPageCount: Integer;
begin begin
Result:=FPages.Count; if Assigned(FPages) then
Result:=FPages.Count
else
Result:=0;
end; end;
function TFPReportExportCanvas.CoordToPoint(const APos: TFPReportPoint; function TFPReportExportCanvas.CoordToPoint(const APos: TFPReportPoint;
@ -890,10 +894,12 @@ begin
FreeAndNil(FHyperLinks); FreeAndNil(FHyperLinks);
end; end;
procedure TFPReportExportCanvas.SetPageNumber(AValue: Integer); procedure TFPReportExportCanvas.SetPageIndex(AValue: Integer);
begin begin
if FPageNumber=AValue then Exit; if FPageIndex=AValue then Exit;
FPageNumber:=AValue; FPageIndex:=AValue;
if Assigned(Report) and (FPageIndex<0) or (FPageIndex>=PageCount) then
Raise EReportError.CreateFmt(SErrPageOutOfRange,[FPageIndex,PageCount-1]);
RenderCurrentPage; RenderCurrentPage;
end; end;

View File

@ -90,10 +90,10 @@ type
procedure DoExport(Sender: TObject); procedure DoExport(Sender: TObject);
procedure ExportReport(REC: TFPReportExporterClass); procedure ExportReport(REC: TFPReportExporterClass);
procedure FillExportMenu; procedure FillExportMenu;
function GetPageNumber: Integer; function GetPageIndex: Integer;
procedure ResizePreview; procedure ResizePreview;
procedure SetCurrentZoom(AValue: Integer); procedure SetCurrentZoom(AValue: Integer);
procedure SetPageNumber(AValue: Integer); procedure SetPageIndex(AValue: Integer);
Protected Protected
function GetEnableHyperLinks: Boolean ; override; function GetEnableHyperLinks: Boolean ; override;
procedure SetEnableHyperLinks(AValue: Boolean); override; procedure SetEnableHyperLinks(AValue: Boolean); override;
@ -106,7 +106,7 @@ type
{ public declarations } { public declarations }
Property CurrentZoom : Integer Read FCurrentZoom Write SetCurrentZoom; Property CurrentZoom : Integer Read FCurrentZoom Write SetCurrentZoom;
// Zero based ! // Zero based !
Property PageNumber : Integer Read GetPageNumber Write SetPageNumber; Property PageIndex : Integer Read GetPageIndex Write SetPageIndex;
// If not set, the OpenURL method of LCL will be called. // If not set, the OpenURL method of LCL will be called.
Property OnOpenURL : TOpenURLEvent Read FOnOpenURL Write FOnOpenURL; Property OnOpenURL : TOpenURLEvent Read FOnOpenURL Write FOnOpenURL;
end; end;
@ -175,27 +175,27 @@ end;
procedure TFPReportPreviewForm.AExportPDFUpdate(Sender: TObject); procedure TFPReportPreviewForm.AExportPDFUpdate(Sender: TObject);
begin begin
(Sender as TAction).Enabled:=ReportExportManager.FindExporter(PDFExport)<>Nil;
end; end;
procedure TFPReportPreviewForm.ANextExecute(Sender: TObject); procedure TFPReportPreviewForm.ANextExecute(Sender: TObject);
begin begin
PageNumber:=PageNumber+1; PageIndex:=PageIndex+1;
end; end;
procedure TFPReportPreviewForm.ANextUpdate(Sender: TObject); procedure TFPReportPreviewForm.ANextUpdate(Sender: TObject);
begin begin
(Sender as TAction).Enabled:=FRender.PageNumber<ReportPages.Count; (Sender as TAction).Enabled:=PageIndex<ReportPages.Count-1;
end; end;
procedure TFPReportPreviewForm.APreviousExecute(Sender: TObject); procedure TFPReportPreviewForm.APreviousExecute(Sender: TObject);
begin begin
PageNumber:=PageNumber-1; PageIndex:=PageIndex-1;
end; end;
procedure TFPReportPreviewForm.APreviousUpdate(Sender: TObject); procedure TFPReportPreviewForm.APreviousUpdate(Sender: TObject);
begin begin
(Sender as TAction).Enabled:=FRender.PageNumber>0; (Sender as TAction).Enabled:=PageIndex>0;
end; end;
procedure TFPReportPreviewForm.APrintExecute(Sender: TObject); procedure TFPReportPreviewForm.APrintExecute(Sender: TObject);
@ -236,7 +236,7 @@ Var
begin begin
PN:=StrToIntDef(EPage.Text,-1); PN:=StrToIntDef(EPage.Text,-1);
if (PN<1) or (PN>FRender.PageCount) then exit; if (PN<1) or (PN>FRender.PageCount) then exit;
FRender.PageNumber:=PN-1; FRender.PageIndex:=PN-1;
end; end;
@ -251,14 +251,14 @@ begin
Frender.RenderCurrentPage; Frender.RenderCurrentPage;
end; end;
function TFPReportPreviewForm.GetPageNumber: Integer; function TFPReportPreviewForm.GetPageIndex: Integer;
begin begin
Result:=FRender.PageNumber; Result:=FRender.PageIndex;
end; end;
procedure TFPReportPreviewForm.SetPageNumber(AValue: Integer); procedure TFPReportPreviewForm.SetPageIndex(AValue: Integer);
begin begin
FRender.PageNumber:=AValue; FRender.PageIndex:=AValue;
EPage.Text:=IntToStr(AValue+1); EPage.Text:=IntToStr(AValue+1);
end; end;
@ -281,7 +281,7 @@ begin
FRender.Execute; FRender.Execute;
LPageCount.Caption:=Format(SPageCount,[FRender.PageCount]); LPageCount.Caption:=Format(SPageCount,[FRender.PageCount]);
EPage.Text:='1'; EPage.Text:='1';
PageNumber:=0; PageIndex:=0;
end; end;
end; end;

View File

@ -68,7 +68,7 @@ procedure TFPreportPrinterExport.PrintPage(P : TPrinter; E : TFPReportExportCanv
begin begin
E.Canvas:=P.Canvas; E.Canvas:=P.Canvas;
E.PageNumber:=PageNo; E.PageIndex:=PageNo;
E.Execute; E.Execute;
end; end;