fpspreadsheet: Add new cell action TsCellProtectionAction.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5812 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-03-19 12:38:17 +00:00
parent 203d1907c8
commit a9f7b4fc20
3 changed files with 71 additions and 7 deletions

View File

@@ -107,7 +107,7 @@ type
end;
{ Action foz zooming the selected worksheet }
TsWorksheetZoomAction= class(TsWorksheetAction)
TsWorksheetZoomAction = class(TsWorksheetAction)
private
FZoom: Integer;
procedure SetZoom(AValue: Integer);
@@ -286,6 +286,21 @@ type
property Hint stored false;
end;
{ TsCellProtectionAction }
TsCellProtectionAction = class(TsAutoFormatAction)
private
FProtection: TsCellProtection;
protected
procedure ApplyFormatToCell(ACell: PCell); override;
procedure ExtractFromCell(ACell: PCell); override;
public
constructor Create(AOwner: TComponent); override;
procedure UpdateTarget(Target: TObject); override;
published
property AutoCheck default true;
property Protection: TsCellProtection read FProtection write FProtection default cpLockCell;
end;
{ TsCellBorderAction }
TsActionBorder = class(TPersistent)
private
@@ -555,6 +570,7 @@ begin
TsHorAlignmentAction, TsVertAlignmentAction,
TsTextRotationAction, TsWordWrapAction,
TsNumberFormatAction, TsDecimalsAction,
TsCellProtectionAction,
TsCellBorderAction, TsNoCellBordersAction,
TsCellCommentAction, TsCellHyperlinkAction,
TsMergeAction
@@ -1167,6 +1183,48 @@ begin
end;
{ TsCellProtectionAction }
constructor TsCellProtectionAction.Create(AOwner: TComponent);
begin
inherited;
AutoCheck := true;
end;
procedure TsCellProtectionAction.ApplyFormatToCell(ACell: PCell);
var
p: TsCellProtections;
begin
if not (Worksheet.IsProtected and (spCells in Worksheet.Protection)) then
exit;
p := Worksheet.ReadCellProtection(ACell);
if Checked then
Include(p, FProtection)
else
Exclude(p, FProtection);
Worksheet.WriteCellProtection(ACell, p);
end;
procedure TsCellProtectionAction.ExtractFromCell(ACell: PCell);
var
p: TsCellProtections;
begin
if ACell = nil then begin
Checked := FProtection = cpLockCell;
exit;
end;
p := Worksheet.ReadCellProtection(ACell);
Checked := FProtection in p;
end;
procedure TsCellProtectionAction.UpdateTarget(Target: TObject);
begin
inherited;
Enabled := inherited Enabled and Worksheet.IsProtected and (spCells in Worksheet.Protection);
end;
{ TsCellBorderAction }
function TsActionBorder.GetStyle: TsCellBorderStyle;