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
|
||||
Top = 6
|
||||
Width = 75
|
||||
Caption = 'Load'
|
||||
Caption = 'Load...'
|
||||
OnClick = BtnLoadClick
|
||||
TabOrder = 1
|
||||
end
|
||||
@ -41,7 +41,7 @@ object Form1: TForm1
|
||||
Height = 25
|
||||
Top = 6
|
||||
Width = 75
|
||||
Caption = 'Save'
|
||||
Caption = 'Save...'
|
||||
OnClick = BtnSaveClick
|
||||
TabOrder = 2
|
||||
end
|
||||
|
@ -47,15 +47,19 @@ procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
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.Align := alClient;
|
||||
|
||||
// Useful options
|
||||
Grid.Options := Grid.Options + [goColSizing, goRowSizing, goEditing, goThumbTracking];
|
||||
Grid.AutoAdvance := aaDown;
|
||||
Grid.MouseWheelOption := mwGrid;
|
||||
Grid.TextOverflow := true;
|
||||
Grid.Options := Grid.Options + [goColSizing, goRowSizing,
|
||||
goFixedColSizing, // useful if the spreadsheet contains frozen columns
|
||||
goEditing, // needed for modifying cell content
|
||||
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
|
||||
Grid.NewWorkbook(26, 100);
|
||||
|
@ -1469,7 +1469,6 @@ begin
|
||||
end;
|
||||
|
||||
sr := GetWorksheetRow(ARow);
|
||||
gcLastUsed := GetGridCol(FWorksheet.GetLastOccupiedColIndex);
|
||||
|
||||
// Draw columns in this row
|
||||
with GCache.VisibleGrid do
|
||||
@ -1479,7 +1478,7 @@ begin
|
||||
// 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
|
||||
// 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
|
||||
begin
|
||||
dec(gc);
|
||||
@ -1503,7 +1502,9 @@ begin
|
||||
// Now find the last column. Again text can overflow into the visible area
|
||||
// from cells to the 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
|
||||
inc(gcLast);
|
||||
cell := FWorksheet.FindCell(sr, GetWorksheetCol(gcLast));
|
||||
@ -1522,6 +1523,7 @@ begin
|
||||
gcLast := Right;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
|
||||
while (gc <= gcLast) do begin
|
||||
gr := ARow;
|
||||
@ -1530,7 +1532,7 @@ begin
|
||||
// it to avoid excessive calls to "FindCell".
|
||||
FDrawingCell := nil;
|
||||
gcNext := gc + 1;
|
||||
if (FWorksheet <> nil) and (gr >= FixedRows) and (gc >= FixedCols) then
|
||||
if Assigned(FWorksheet) and (gr >= FixedRows) and (gc >= FixedCols) then
|
||||
begin
|
||||
cell := FWorksheet.FindCell(GetWorksheetRow(gr), GetWorksheetCol(gc));
|
||||
if (cell = nil) or (cell^.MergedNeighbors = []) then begin
|
||||
@ -1599,7 +1601,10 @@ begin
|
||||
// is this column within the ClipRect?
|
||||
if (rct.Left < rct.Right) and HorizontalIntersect(rct, clipArea) then
|
||||
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);
|
||||
end;
|
||||
end;
|
||||
|
Reference in New Issue
Block a user