fpspreadsheet: Add TsClearFormatAction to clear a cell format.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6492 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-06-13 09:20:10 +00:00
parent e5cb6ff0f7
commit f62d2b35d7
3 changed files with 24 additions and 0 deletions

View File

@ -9255,6 +9255,11 @@ end;
-------------------------------------------------------------------------------}
function TsWorkbook.GetPointerToCellFormat(AIndex: Integer): PsCellFormat;
begin
if FCellFormatList.Count = 0 then
raise Exception.Create('[TsWorkbook.GetPointerToCellFormat]: No format items.');
if (AIndex < 0) or (AIndex >= FCellFormatList.Count) then
AIndex := 0; // 0 is default format
Result := FCellFormatList.Items[AIndex];
end;

View File

@ -42,6 +42,7 @@ begin
TsWorksheetZoomAction,
// Cell or cell range formatting actions
TsCopyAction,
TsClearFormatAction,
TsFontStyleAction, TsFontDialogAction, TsBackgroundColorDialogAction,
TsHorAlignmentAction, TsVertAlignmentAction,
TsTextRotationAction, TsWordWrapAction,

View File

@ -180,6 +180,12 @@ type
property Visible;
end;
{ TsClearFormatAction }
TsClearFormatAction = class(TsAutoFormatAction)
protected
procedure ApplyFormatToCell(ACell: PCell); override;
end;
{ TsFontStyleAction }
TsFontStyleAction = class(TsAutoFormatAction)
private
@ -928,6 +934,18 @@ begin
end;
{ TsClearFormatAction }
procedure TsClearFormatAction.ApplyFormatToCell(ACell: PCell);
begin
if ACell <> nil then
begin
ACell^.FormatIndex := 0; // Default format
Worksheet.ChangedCell(ACell^.Row, ACell^.Col);
end;
end;
{ TsFontStyleAction }
constructor TsFontStyleAction.Create(AOwner: TComponent);