You've already forked lazarus-ccr
tvplanit: Fix duplicate last page in print-out of TaskList. Add some debugln code, maybe to be removed again later.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8516 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -83,17 +83,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
{$I vp.inc}
|
{$I vp.inc}
|
||||||
|
{$DEFINE DEBUG_VP_PRINTER}
|
||||||
|
|
||||||
unit VpPrtFmt;
|
unit VpPrtFmt;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
{$IFDEF LCL}
|
{$IFDEF LCL}
|
||||||
LCLProc, LCLType, LCLIntf,
|
{$IFDEF DEBUG_VP_PRINTER}LazLogger,{$ENDIF} LCLProc, LCLType, LCLIntf,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Windows,
|
Windows,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, Dialogs, SysUtils, Graphics, Forms, Printers,
|
Classes, Dialogs, SysUtils, Graphics, Forms, Printers,
|
||||||
VpBase, VpData, VpXParsr, VpCanvasUtils, VpSR, VpException;
|
VpBase, VpData, VpXParsr, VpCanvasUtils, VpSR, VpException;
|
||||||
|
|
||||||
@ -1679,6 +1680,9 @@ var
|
|||||||
True
|
True
|
||||||
);
|
);
|
||||||
FLastTask := RenderControl.GetLastPrintLine;
|
FLastTask := RenderControl.GetLastPrintLine;
|
||||||
|
{$IFDEF DEBUG_VP_PRINTER}
|
||||||
|
DebugLn('[TVpPrinter.PaintToCanvasRect.RenderItem] FLastTask = %d', [FLastTask]);
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
itContacts:
|
itContacts:
|
||||||
@ -1696,6 +1700,9 @@ var
|
|||||||
True
|
True
|
||||||
);
|
);
|
||||||
FLastContact := RenderControl.GetLastPrintLine;
|
FLastContact := RenderControl.GetLastPrintLine;
|
||||||
|
{$IFDEF DEBUG_VP_PRINTER}
|
||||||
|
DebugLn('[TVpPrinter.PaintToCanvasRect.RenderItem] FLastContact = %d', [FLastContact]);
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
itGanttView:
|
itGanttView:
|
||||||
@ -1745,6 +1752,10 @@ var
|
|||||||
elem: TVpPrintFormatElementItem;
|
elem: TVpPrintFormatElementItem;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF DEBUG_VP_PRINTER}
|
||||||
|
DebugLn('[TVpPrinter.PaintToCanvas] ENTER');
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
CheckPrintFormat;
|
CheckPrintFormat;
|
||||||
|
|
||||||
if not FPrintJob then begin
|
if not FPrintJob then begin
|
||||||
@ -1767,6 +1778,10 @@ begin
|
|||||||
if elem.ItemType = itGanttView then
|
if elem.ItemType = itGanttView then
|
||||||
elem.DayOffsetUnits := duDay;
|
elem.DayOffsetUnits := duDay;
|
||||||
|
|
||||||
|
{$IFDEF DEBUG_VP_PRINTER}
|
||||||
|
DebugLn('[TvpPrinter.PaintToCanvasRect] i = %d, elem.ElementName = %s', [i, elem.ElementName]);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
GetPrintRectangle(elem);
|
GetPrintRectangle(elem);
|
||||||
|
|
||||||
if elem.ItemType = itCaption then begin
|
if elem.ItemType = itCaption then begin
|
||||||
@ -1796,6 +1811,10 @@ begin
|
|||||||
end else
|
end else
|
||||||
RenderItem(elem);
|
RenderItem(elem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF DEBUG_VP_PRINTER}
|
||||||
|
DebugLn('[TVpPrinter.PaintToCanvas] EXIT');
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
@ -1883,6 +1902,10 @@ var
|
|||||||
Done: Boolean;
|
Done: Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF DEBUG_VP_PRINTER}
|
||||||
|
DebugLn('[TVpPrinter.Print] ENTER');
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
CheckPrintFormat;
|
CheckPrintFormat;
|
||||||
|
|
||||||
FHaveDate := False;
|
FHaveDate := False;
|
||||||
@ -1939,7 +1962,7 @@ begin
|
|||||||
This is a bit involved. If only dates, captions and shapes are in the
|
This is a bit involved. If only dates, captions and shapes are in the
|
||||||
print format, doneness is determined when the date passes the end date.
|
print format, doneness is determined when the date passes the end date.
|
||||||
If task lists or contact grids are on the format, then doneness occurs
|
If task lists or contact grids are on the format, then doneness occurs
|
||||||
when the date has bumped pass the last date and all the tasks and
|
when the date has bumped past the last date and all the tasks and
|
||||||
contacts have been printed. }
|
contacts have been printed. }
|
||||||
Done := True;
|
Done := True;
|
||||||
if FHaveDate and (CurDate <= RealEndDate) then
|
if FHaveDate and (CurDate <= RealEndDate) then
|
||||||
@ -1953,6 +1976,12 @@ begin
|
|||||||
with FOwner as TVpControlLink do
|
with FOwner as TVpControlLink do
|
||||||
TriggerOnPageEnd(Self, PageNum, CurDate, Done);
|
TriggerOnPageEnd(Self, PageNum, CurDate, Done);
|
||||||
|
|
||||||
|
{$IFDEF DEBUG_VP_PRINTER}
|
||||||
|
DebugLn('[TVpPrinter.Print] CurDate = %s (%.2f), LastTask = %d, LastContact = %d, Done = %s', [
|
||||||
|
DateToStr(CurDate), CurDate, FLastTask, FLastContact, BoolToStr(Done, true)
|
||||||
|
]);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
{ Go to the next page if not done }
|
{ Go to the next page if not done }
|
||||||
if not Done then begin
|
if not Done then begin
|
||||||
Printer.NewPage;
|
Printer.NewPage;
|
||||||
@ -1962,8 +1991,11 @@ begin
|
|||||||
finally
|
finally
|
||||||
FPrintJob := False;
|
FPrintJob := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF DEBUG_VP_PRINTER}
|
||||||
|
DebugLn('[TVpPrinter.Print] EXIT');
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
{=====}
|
|
||||||
|
|
||||||
procedure TVpPrinter.RegisterWatcher(Watcher: THandle);
|
procedure TVpPrinter.RegisterWatcher(Watcher: THandle);
|
||||||
var
|
var
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
unit VpTasklistPainter;
|
unit VpTasklistPainter;
|
||||||
|
|
||||||
{$I vp.inc}
|
{$I vp.inc}
|
||||||
|
{$DEFINE DEBUG_VP_TASKLISTPAINTER}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
{$IFDEF DEBUG_VP_TASKLISTPAINTER}LazLogger{$ENDIF},
|
||||||
SysUtils, LCLType, LCLIntf,
|
SysUtils, LCLType, LCLIntf,
|
||||||
Classes, Graphics, Types,
|
Classes, Graphics, Types,
|
||||||
VpConst, VpBase, VpTaskList, VpBasePainter;
|
VpConst, VpBase, VpTaskList, VpBasePainter;
|
||||||
@ -330,8 +332,13 @@ var
|
|||||||
CheckRect: TRect;
|
CheckRect: TRect;
|
||||||
DisplayStr: string;
|
DisplayStr: string;
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF DEBUG_VP_TASKLISTPAINTER}
|
||||||
|
DebugLn('[TVpTaskListPainter.DrawTasks] ENTER: StartLine = %d', [StartLine]);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
xLeft := RealLeft + 2;
|
xLeft := RealLeft + 2;
|
||||||
xRight := xLeft + RealWidth - 3;
|
xRight := xLeft + RealWidth - 3;
|
||||||
|
|
||||||
with TVpTaskListOpener(FTaskList) do begin
|
with TVpTaskListOpener(FTaskList) do begin
|
||||||
if (DataStore = nil) or
|
if (DataStore = nil) or
|
||||||
(DataStore.Resource = nil) or
|
(DataStore.Resource = nil) or
|
||||||
@ -374,8 +381,10 @@ begin
|
|||||||
{$IF VP_LCL_SCALING = 0}
|
{$IF VP_LCL_SCALING = 0}
|
||||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
for I := StartLine to pred(tlAllTaskList.Count) do begin
|
for I := StartLine to pred(tlAllTaskList.Count) do begin
|
||||||
task := tlAllTaskList[I];
|
task := tlAllTaskList[I];
|
||||||
|
// if (LineRect.Top + round(0.5 * RowHeight) <= RealBottom) then begin // wp: here the last row of the page could be truncated in height.
|
||||||
if (LineRect.Bottom <= RealBottom) then begin
|
if (LineRect.Bottom <= RealBottom) then begin
|
||||||
// If this is the selected task and we are not in edit mode,
|
// If this is the selected task and we are not in edit mode,
|
||||||
// then set background selection.
|
// then set background selection.
|
||||||
@ -446,18 +455,31 @@ begin
|
|||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if tlVisibleItems + tlItemsBefore = tlAllTaskList.Count then begin
|
|
||||||
|
{$IFDEF DEBUG_VP_TASKLISTPAINTER}
|
||||||
|
DebugLn('[TVpTaskListPainter.DrawTasks] tlVisibleItems = %d, tlItemsBefore = %d, tlAllTaskList.Count = %d', [
|
||||||
|
tlVisibleItems, tlItemsBefore, tlAllTaskList.Count
|
||||||
|
]);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
// if tlVisibleItems + tlItemsBefore = tlAllTaskList.Count then begin // wp: here the last page would be duplicate
|
||||||
|
if Startline + tlVisibleItems >= tlAllTaskList.Count then begin
|
||||||
FLastPrintLine := -2;
|
FLastPrintLine := -2;
|
||||||
tlItemsAfter := 0;
|
tlItemsAfter := 0;
|
||||||
end else begin
|
end else begin
|
||||||
tlItemsAfter := tlAllTaskList.Count - tlItemsBefore - tlVisibleItems;
|
tlItemsAfter := tlAllTaskList.Count - tlItemsBefore - tlVisibleItems;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ these are for the syncing the scrollbar }
|
// These are for syncing the scrollbar
|
||||||
if StartLine < 0 then
|
if StartLine < 0 then
|
||||||
tlItemsBefore := 0
|
tlItemsBefore := 0
|
||||||
else
|
else
|
||||||
tlItemsBefore := StartLine;
|
tlItemsBefore := StartLine;
|
||||||
|
|
||||||
|
{$IFDEF DEBUG_VP_TASKLISTPAINTER}
|
||||||
|
DebugLn('[TVpTaskListPainter.DrawTasks] EXIT: StartLine = %d, LastPrintLine = %d', [StartLine, FLastPrintLine]);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
end; // with TVpTaskListOpener(FTaskList)...
|
end; // with TVpTaskListOpener(FTaskList)...
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user