diff --git a/components/tvplanit/source/vpganttview.pas b/components/tvplanit/source/vpganttview.pas index 9d0200873..35c779b85 100644 --- a/components/tvplanit/source/vpganttview.pas +++ b/components/tvplanit/source/vpganttview.pas @@ -918,10 +918,13 @@ end; the number of day columns in the view. } function TVpGanttView.GetNumDays: Integer; begin + Result := 0; if (FRealStartDate <> NO_DATE) then - Result := trunc(FRealEndDate) - trunc(FRealStartDate) + 1 - else - Result := 0; + begin + Result := trunc(FRealEndDate) - trunc(FRealStartDate) + 1; + if Result < 0 then + Result := 0; + end; end; { Determines the number of events (= rows) to be displayed in the GanttView. } diff --git a/components/tvplanit/source/vpprtfmt.pas b/components/tvplanit/source/vpprtfmt.pas index 492d5daac..782230af5 100644 --- a/components/tvplanit/source/vpprtfmt.pas +++ b/components/tvplanit/source/vpprtfmt.pas @@ -286,6 +286,7 @@ type FDayInc: Integer; FDayIncUnits: TVpDayUnits; + FDefaultDayInc: Integer; FVisible: Boolean; protected @@ -302,6 +303,8 @@ type destructor Destroy; override; property Collection: TVpPrintFormat read FCollection write FCollection; + // Replacement value used for calculating start date on next page when DayInc is 0 + property DefaultDayInc: Integer read FDefaultDayInc write FDefaultDayInc; published property DayInc: Integer read FDayInc write SetDayInc; @@ -316,7 +319,6 @@ type TVpPrintFormat = class(TCollection) private FOwner: TPersistent; - protected function GetItem(Index: Integer): TVpPrintFormatItem; function GetOwner: TPersistent; override; @@ -326,10 +328,8 @@ type {$ENDIF} procedure SetItem(Index: Integer; Value: TVpPrintFormatItem); procedure Update(Item: TCollectionItem); override; - public constructor Create(AOwner: TPersistent); - property Items[Index: Integer]: TVpPrintFormatItem read GetItem write SetItem; end; @@ -1056,6 +1056,7 @@ begin FDescription := ''; FDayInc := 0; FDayIncUnits := duDay; + FDefaultDayInc := 1; FVisible := True; end; {=====} @@ -1555,6 +1556,7 @@ var Scale: Extended; StartLine: Integer; EndLine: Integer; + oldGanttStartDate, oldGanttEndDate: TDateTime; procedure GetMeasurements; begin @@ -1698,18 +1700,21 @@ var itGanttView: begin + oldGanttStartDate := TVpGanttView(RenderControl).StartDate; + TVpGanttView(RenderControl).StartDate := GetDate(Element); RenderControl.RenderToCanvas( ACanvas, Rect(StartX, StartY, StopX, StopY), Element.Rotation, Scale, - GetDate(Element), + TVpGanttView(RenderControl).StartDate, 0, // to be completed... 0, Granularity, true ); - Element.DayOffset := TvpGanttView(RenderControl).VisibleCols; + FPrintFormats.Items[CurFormat].DefaultDayInc := TVpGanttview(Rendercontrol).VisibleCols; + TVpGanttView(RenderControl).StartDate := oldGanttStartDate; end; else @@ -1854,6 +1859,8 @@ var end; end; + { Advances the date to the next page. The number of days per page is given by + the values of DayInc and DayIncUnits of the print format. } function GetNextDate(ADate: TDateTime): TDateTime; begin Result := ADate; @@ -1865,7 +1872,7 @@ var duYear : Result := IncYear(Result, PrintFormats.Items[CurFormat].DayInc); end; end else - Result := Result + 1; + Result := Result + PrintFormats.Items[CurFormat].DefaultDayInc; end; var @@ -2039,7 +2046,7 @@ var duYear : Result := IncYear(Result, PrintFormats.Items[CurFormat].DayInc); end; end else - Result := Result + 1; + Result := Result + PrintFormats.Items[CurFormat].DefaultDayInc; end; var