You've already forked lazarus-ccr
fpspreadsheet: Fix new TsWorksheetGrid crashing without workbook.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3567 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -32,7 +32,7 @@ object Form1: TForm1
|
|||||||
Height = 25
|
Height = 25
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'Load'
|
Caption = 'Load...'
|
||||||
OnClick = BtnLoadClick
|
OnClick = BtnLoadClick
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
@ -41,7 +41,7 @@ object Form1: TForm1
|
|||||||
Height = 25
|
Height = 25
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'Save'
|
Caption = 'Save...'
|
||||||
OnClick = BtnSaveClick
|
OnClick = BtnSaveClick
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
|
@ -47,15 +47,19 @@ procedure TForm1.FormCreate(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
Grid := TsWorksheetGrid.Create(self);
|
Grid := TsWorksheetGrid.Create(self);
|
||||||
|
|
||||||
// Put the grid into the TabControl
|
// Put the grid into the TabControl and align it to fill the tabcontrol.
|
||||||
Grid.Parent := TabControl;
|
Grid.Parent := TabControl;
|
||||||
Grid.Align := alClient;
|
Grid.Align := alClient;
|
||||||
|
|
||||||
// Useful options
|
// Useful options
|
||||||
Grid.Options := Grid.Options + [goColSizing, goRowSizing, goEditing, goThumbTracking];
|
Grid.Options := Grid.Options + [goColSizing, goRowSizing,
|
||||||
Grid.AutoAdvance := aaDown;
|
goFixedColSizing, // useful if the spreadsheet contains frozen columns
|
||||||
Grid.MouseWheelOption := mwGrid;
|
goEditing, // needed for modifying cell content
|
||||||
Grid.TextOverflow := true;
|
goThumbTracking // see the grid scroll while you drag the scrollbar
|
||||||
|
];
|
||||||
|
Grid.AutoAdvance := aaDown; // move active cell down on ENTER
|
||||||
|
Grid.MouseWheelOption := mwGrid; // mouse wheel scrolls the grid, not the active cell
|
||||||
|
Grid.TextOverflow := true; // too long text extends into neighbor cells
|
||||||
|
|
||||||
// Create an empty worksheet
|
// Create an empty worksheet
|
||||||
Grid.NewWorkbook(26, 100);
|
Grid.NewWorkbook(26, 100);
|
||||||
|
@ -1469,7 +1469,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
sr := GetWorksheetRow(ARow);
|
sr := GetWorksheetRow(ARow);
|
||||||
gcLastUsed := GetGridCol(FWorksheet.GetLastOccupiedColIndex);
|
|
||||||
|
|
||||||
// Draw columns in this row
|
// Draw columns in this row
|
||||||
with GCache.VisibleGrid do
|
with GCache.VisibleGrid do
|
||||||
@ -1479,7 +1478,7 @@ begin
|
|||||||
// Because of possible cell overflow from cells left of the visible range
|
// Because of possible cell overflow from cells left of the visible range
|
||||||
// we have to seek to the left for the first occupied text cell
|
// we have to seek to the left for the first occupied text cell
|
||||||
// and start painting from here.
|
// and start painting from here.
|
||||||
if FTextOverflow and (sr <> Cardinal(-1)) then
|
if FTextOverflow and (sr <> Cardinal(-1)) and Assigned(FWorksheet) then
|
||||||
while (gc > FixedCols) do
|
while (gc > FixedCols) do
|
||||||
begin
|
begin
|
||||||
dec(gc);
|
dec(gc);
|
||||||
@ -1503,7 +1502,9 @@ begin
|
|||||||
// Now find the last column. Again text can overflow into the visible area
|
// Now find the last column. Again text can overflow into the visible area
|
||||||
// from cells to the right.
|
// from cells to the right.
|
||||||
gcLast := Right;
|
gcLast := Right;
|
||||||
if FTextOverflow and (sr <> Cardinal(-1)) then
|
if FTextOverflow and (sr <> Cardinal(-1)) and Assigned(FWorksheet) then
|
||||||
|
begin
|
||||||
|
gcLastUsed := GetGridCol(FWorksheet.GetLastOccupiedColIndex);
|
||||||
while (gcLast < ColCount-1) and (gcLast < gcLastUsed) do begin
|
while (gcLast < ColCount-1) and (gcLast < gcLastUsed) do begin
|
||||||
inc(gcLast);
|
inc(gcLast);
|
||||||
cell := FWorksheet.FindCell(sr, GetWorksheetCol(gcLast));
|
cell := FWorksheet.FindCell(sr, GetWorksheetCol(gcLast));
|
||||||
@ -1522,6 +1523,7 @@ begin
|
|||||||
gcLast := Right;
|
gcLast := Right;
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
while (gc <= gcLast) do begin
|
while (gc <= gcLast) do begin
|
||||||
gr := ARow;
|
gr := ARow;
|
||||||
@ -1530,7 +1532,7 @@ begin
|
|||||||
// it to avoid excessive calls to "FindCell".
|
// it to avoid excessive calls to "FindCell".
|
||||||
FDrawingCell := nil;
|
FDrawingCell := nil;
|
||||||
gcNext := gc + 1;
|
gcNext := gc + 1;
|
||||||
if (FWorksheet <> nil) and (gr >= FixedRows) and (gc >= FixedCols) then
|
if Assigned(FWorksheet) and (gr >= FixedRows) and (gc >= FixedCols) then
|
||||||
begin
|
begin
|
||||||
cell := FWorksheet.FindCell(GetWorksheetRow(gr), GetWorksheetCol(gc));
|
cell := FWorksheet.FindCell(GetWorksheetRow(gr), GetWorksheetCol(gc));
|
||||||
if (cell = nil) or (cell^.MergedNeighbors = []) then begin
|
if (cell = nil) or (cell^.MergedNeighbors = []) then begin
|
||||||
@ -1599,7 +1601,10 @@ begin
|
|||||||
// is this column within the ClipRect?
|
// is this column within the ClipRect?
|
||||||
if (rct.Left < rct.Right) and HorizontalIntersect(rct, clipArea) then
|
if (rct.Left < rct.Right) and HorizontalIntersect(rct, clipArea) then
|
||||||
begin
|
begin
|
||||||
FDrawingCell := FWorksheet.FindCell(GetWorksheetRow(gr), GetWorksheetCol(gc));
|
if Assigned(FWorksheet) then
|
||||||
|
FDrawingCell := FWorksheet.FindCell(GetWorksheetRow(gr), GetWorksheetCol(gc))
|
||||||
|
else
|
||||||
|
FDrawingCell := nil;
|
||||||
DoDrawCell(gc, gr);
|
DoDrawCell(gc, gr);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user