fpspreadsheet: Fix worksheetGrid to expand itself if new cells are created beyout the current grid extent.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4234 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2015-07-31 16:23:59 +00:00
parent abaae03afa
commit 9f775a09d6
2 changed files with 19 additions and 0 deletions

View File

@ -1519,6 +1519,7 @@ begin
if CellUsedInFormula(ARow, ACol) then if CellUsedInFormula(ARow, ACol) then
CalcFormulas; CalcFormulas;
end; end;
if Assigned(FOnChangeCell) then if Assigned(FOnChangeCell) then
FOnChangeCell(Self, ARow, ACol); FOnChangeCell(Self, ARow, ACol);
end; end;

View File

@ -3491,6 +3491,7 @@ procedure TsCustomWorksheetGrid.ListenerNotification(AChangedItems: TsNotificati
AData: Pointer = nil); AData: Pointer = nil);
var var
grow, gcol: Integer; grow, gcol: Integer;
cell: PCell;
begin begin
Unused(AData); Unused(AData);
@ -3519,13 +3520,28 @@ begin
// Cell value or format changed // Cell value or format changed
if (lniCell in AChangedItems) then if (lniCell in AChangedItems) then
begin
cell := PCell(AData);
if (cell <> nil) then begin
grow := GetGridRow(cell^.Row);
gcol := GetGridCol(cell^.Col);
if grow >= RowCount then
RowCount := grow + 1;
if gcol >= ColCount then
ColCount := gcol + 1;
end;
Invalidate; Invalidate;
end;
// Selection changed // Selection changed
if (lniSelection in AChangedItems) and (Worksheet <> nil) then if (lniSelection in AChangedItems) and (Worksheet <> nil) then
begin begin
grow := GetGridRow(Worksheet.ActiveCellRow); grow := GetGridRow(Worksheet.ActiveCellRow);
gcol := GetGridCol(Worksheet.ActiveCellCol); gcol := GetGridCol(Worksheet.ActiveCellCol);
if grow >= RowCount then
RowCount := grow + 1;
if gcol >= ColCount then
ColCount := gcol + 1;
if (grow <> Row) or (gcol <> Col) then if (grow <> Row) or (gcol <> Col) then
MoveExtend(false, gcol, grow); MoveExtend(false, gcol, grow);
end; end;
@ -3541,6 +3557,8 @@ begin
if (lniRow in AChangedItems) and (Worksheet <> nil) then if (lniRow in AChangedItems) and (Worksheet <> nil) then
begin begin
grow := GetGridRow({%H-}PtrInt(AData)); grow := GetGridRow({%H-}PtrInt(AData));
if grow >= RowCount then
RowCount := grow + 1;
RowHeights[grow] := CalcAutoRowHeight(grow); RowHeights[grow] := CalcAutoRowHeight(grow);
end; end;
end; end;