You've already forked lazarus-ccr
fpspreadsheet: Further integration of cell and worksheet protection in visual controls.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5813 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -859,15 +859,18 @@ type
|
||||
|
||||
{ Utilities }
|
||||
function ConvertUnits(AValue: Double; AFromUnits, AToUnits: TsSizeUnits): Double;
|
||||
procedure DisableNotifications;
|
||||
procedure EnableNotifications;
|
||||
function NotificationsEnabled: Boolean;
|
||||
procedure UpdateCaches;
|
||||
procedure GetLastRowColIndex(out ALastRow, ALastCol: Cardinal);
|
||||
|
||||
{ Protection }
|
||||
function IsProtected: Boolean;
|
||||
|
||||
{ Notification }
|
||||
procedure ChangedWorksheet(AWorksheet: TsWorksheet);
|
||||
procedure DisableNotifications;
|
||||
procedure EnableNotifications;
|
||||
function NotificationsEnabled: Boolean;
|
||||
|
||||
{ Error messages }
|
||||
procedure AddErrorMsg(const AMsg: String); overload;
|
||||
procedure AddErrorMsg(const AMsg: String; const Args: array of const); overload;
|
||||
@ -4116,8 +4119,7 @@ begin
|
||||
if AValue = FBiDiMode then
|
||||
exit;
|
||||
FBiDiMode := AValue;
|
||||
if (FWorkbook.FLockCount = 0) and Assigned(FWorkbook.FOnChangeWorksheet) then
|
||||
FWorkbook.FOnChangeWorksheet(FWorkbook, self);
|
||||
FWorkbook.ChangedWorksheet(Self);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
@ -4129,6 +4131,7 @@ begin
|
||||
if AEnable then
|
||||
Include(FOptions, soProtected) else
|
||||
Exclude(FOptions, soProtected);
|
||||
FWorkbook.ChangedWorksheet(self);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
@ -7958,6 +7961,19 @@ begin
|
||||
TsWorksheet(data).Free;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Notification of visual controls that some global data of a worksheet
|
||||
have changed.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbook.ChangedWorksheet(AWorksheet: TsWorksheet);
|
||||
begin
|
||||
if FReadWriteFlag = rwfRead then
|
||||
exit;
|
||||
|
||||
if NotificationsEnabled and Assigned(FOnChangeWorksheet)
|
||||
then OnChangeWorksheet(self, AWorksheet);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Helper method to disable notification of visual controls
|
||||
-------------------------------------------------------------------------------}
|
||||
|
@ -118,6 +118,7 @@ type
|
||||
property Zoom: Integer read FZoom write SetZoom default 100;
|
||||
end;
|
||||
|
||||
|
||||
{ --- Actions related to cell and cell selection formatting--- }
|
||||
|
||||
TsCopyItem = (ciFormat, ciValue, ciFormula, ciAll);
|
||||
@ -158,6 +159,8 @@ type
|
||||
end;
|
||||
|
||||
TsAutoFormatAction = class(TsCellAction)
|
||||
protected
|
||||
procedure UpdateTargetFromActiveCell;
|
||||
public
|
||||
procedure ExecuteTarget(Target: TObject); override;
|
||||
procedure UpdateTarget(Target: TObject); override;
|
||||
@ -928,19 +931,21 @@ begin
|
||||
end;
|
||||
|
||||
procedure TsAutoFormatAction.UpdateTarget(Target: TObject);
|
||||
begin
|
||||
Unused(Target);
|
||||
Enabled := inherited Enabled and (Worksheet <> nil) and (Length(GetSelection) > 0);
|
||||
if Enabled then
|
||||
UpdateTargetFromActiveCell;
|
||||
end;
|
||||
|
||||
procedure TsAutoFormatAction.UpdateTargetFromActiveCell;
|
||||
var
|
||||
cell: PCell;
|
||||
begin
|
||||
Unused(Target);
|
||||
|
||||
Enabled := inherited Enabled and (Worksheet <> nil) and (Length(GetSelection) > 0);
|
||||
if Enabled then
|
||||
begin
|
||||
cell := ActiveCell;
|
||||
if Worksheet.IsMerged(cell) then
|
||||
cell := Worksheet.FindMergeBase(cell);
|
||||
ExtractFromCell(cell);
|
||||
end;
|
||||
cell := ActiveCell;
|
||||
if Worksheet.IsMerged(cell) then
|
||||
cell := Worksheet.FindMergeBase(cell);
|
||||
ExtractFromCell(cell);
|
||||
end;
|
||||
|
||||
|
||||
@ -1195,7 +1200,7 @@ procedure TsCellProtectionAction.ApplyFormatToCell(ACell: PCell);
|
||||
var
|
||||
p: TsCellProtections;
|
||||
begin
|
||||
if not (Worksheet.IsProtected and (spCells in Worksheet.Protection)) then
|
||||
if (Worksheet.IsProtected and (spCells in Worksheet.Protection)) then
|
||||
exit;
|
||||
|
||||
p := Worksheet.ReadCellProtection(ACell);
|
||||
@ -1216,12 +1221,13 @@ begin
|
||||
end;
|
||||
p := Worksheet.ReadCellProtection(ACell);
|
||||
Checked := FProtection in p;
|
||||
Enabled := not (Worksheet.IsProtected and (spCells in Worksheet.Protection));
|
||||
end;
|
||||
|
||||
procedure TsCellProtectionAction.UpdateTarget(Target: TObject);
|
||||
begin
|
||||
inherited;
|
||||
Enabled := inherited Enabled and Worksheet.IsProtected and (spCells in Worksheet.Protection);
|
||||
Unused(Target);
|
||||
UpdateTargetFromActiveCell;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ interface
|
||||
uses
|
||||
Classes, Graphics, SysUtils, Controls, StdCtrls, ComCtrls, ValEdit, ActnList,
|
||||
LResources,
|
||||
fpstypes, fpspreadsheet, {%H-}fpsAllFormats;
|
||||
fpstypes, fpspreadsheet; //, {%H-}fpsAllFormats;
|
||||
|
||||
type
|
||||
{@@ Event handler procedure for displaying a message if an error or
|
||||
|
Reference in New Issue
Block a user