fpspreadsheet: Implement TsWorksheet.Clear (removes all content from sheet). Called by new TsWorksheetGrid.Clear.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4674 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-05-31 14:18:46 +00:00
parent e7871cc95b
commit c1c54a5ee1
2 changed files with 26 additions and 2 deletions

View File

@ -400,6 +400,7 @@ type
procedure CopyValue(AFromCell, AToCell: PCell); overload; procedure CopyValue(AFromCell, AToCell: PCell); overload;
procedure CopyValue(AValueCell: PCell; AToRow, AToCol: Cardinal); overload; procedure CopyValue(AValueCell: PCell; AToRow, AToCol: Cardinal); overload;
procedure Clear;
procedure DeleteCell(ACell: PCell); procedure DeleteCell(ACell: PCell);
procedure EraseCell(ACell: PCell); procedure EraseCell(ACell: PCell);
@ -1855,6 +1856,20 @@ begin
CopyValue(AValueCell, GetCell(AToRow, AToCol)); CopyValue(AValueCell, GetCell(AToRow, AToCol));
end; end;
procedure TsWorksheet.Clear;
begin
FCells.Clear;
FComments.Clear;
FHyperlinks.Clear;
FMergedCells.Clear;
RemoveAllImages;
RemoveAllRows;
RemoveAllCols;
ChangedCell(0, 0);
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Deletes a specified cell. If the cell belongs to a merged block its content Deletes a specified cell. If the cell belongs to a merged block its content
and formatting is erased. Otherwise the cell is destroyed and its memory is and formatting is erased. Otherwise the cell is destroyed and its memory is

View File

@ -274,6 +274,7 @@ type
procedure BeginUpdate; procedure BeginUpdate;
function CellRect(ACol1, ARow1, ACol2, ARow2: Integer): TRect; overload; function CellRect(ACol1, ARow1, ACol2, ARow2: Integer): TRect; overload;
procedure Clear;
procedure DefaultDrawCell(ACol, ARow: Integer; var ARect: TRect; AState: TGridDrawState); override; procedure DefaultDrawCell(ACol, ARow: Integer; var ARect: TRect; AState: TGridDrawState); override;
procedure DeleteCol(AGridCol: Integer); reintroduce; procedure DeleteCol(AGridCol: Integer); reintroduce;
procedure DeleteRow(AGridRow: Integer); reintroduce; procedure DeleteRow(AGridRow: Integer); reintroduce;
@ -1373,6 +1374,14 @@ begin
end; end;
end; end;
{@@ ----------------------------------------------------------------------------
Clears the grid contents
-------------------------------------------------------------------------------}
procedure TsCustomWorksheetGrid.Clear;
begin
if (Worksheet <> nil) then Worksheet.Clear;
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Converts a spreadsheet font to a font used for painting (TCanvas.Font). Converts a spreadsheet font to a font used for painting (TCanvas.Font).
@ -4322,11 +4331,11 @@ begin
if FLockSetup > 0 then if FLockSetup > 0 then
exit; exit;
{
if not HandleAllocated then if not HandleAllocated then
//Avoid crash when accessing the canvas, e.g. in GetDefaultHeaderColWidth //Avoid crash when accessing the canvas, e.g. in GetDefaultHeaderColWidth
exit; exit;
}
if (Worksheet = nil) or (Worksheet.GetCellCount = 0) then begin if (Worksheet = nil) or (Worksheet.GetCellCount = 0) then begin
FixedCols := FFrozenCols + FHeaderCount; FixedCols := FFrozenCols + FHeaderCount;
FixedRows := FFrozenRows + FHeaderCount; FixedRows := FFrozenRows + FHeaderCount;