You've already forked lazarus-ccr
spready: Minor improvements of worksheet protection. Add information on required packages to readme.txt.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5816 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,2 +1,7 @@
|
|||||||
spready is a relatively complex demonstration of the fpspreadsheet library
|
spready is a relatively complex demonstration of the fpspreadsheet library
|
||||||
and its visual controls.
|
and its visual controls.
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
- fpspreadsheet trunk version (packages laz_fpspreadsheet,
|
||||||
|
laz_fpspreadsheet_visual and laz_fpspreadsheet_crypto)
|
||||||
|
- dcpcrypt (needed for laz_fpspreadsheet_crypto)
|
@ -1901,7 +1901,7 @@ object MainForm: TMainForm
|
|||||||
end
|
end
|
||||||
object AcWorksheetProtection: TAction
|
object AcWorksheetProtection: TAction
|
||||||
Category = 'Worksheet'
|
Category = 'Worksheet'
|
||||||
Caption = 'Protect worksheet...'
|
Caption = 'Worksheet protection...'
|
||||||
ImageIndex = 73
|
ImageIndex = 73
|
||||||
OnExecute = AcWorksheetProtectionExecute
|
OnExecute = AcWorksheetProtectionExecute
|
||||||
OnUpdate = AcWorksheetProtectionUpdate
|
OnUpdate = AcWorksheetProtectionUpdate
|
||||||
|
@ -883,22 +883,17 @@ procedure TMainForm.AcWorksheetProtectionExecute(Sender: TObject);
|
|||||||
var
|
var
|
||||||
F: TWorksheetProtectionForm;
|
F: TWorksheetProtectionForm;
|
||||||
begin
|
begin
|
||||||
if WorkbookSource.Worksheet.IsProtected then
|
F := TWorksheetProtectionForm.Create(nil);
|
||||||
WorkbookSource.Worksheet.Protect(false)
|
try
|
||||||
else
|
F.IsProtected := not WorkbookSource.Worksheet.IsProtected;
|
||||||
begin
|
F.Protection := WorkbookSource.Worksheet.Protection;
|
||||||
F := TWorksheetProtectionForm.Create(nil);
|
if F.ShowModal = mrOK then
|
||||||
try
|
begin
|
||||||
F.IsProtected := WorkbookSource.Worksheet.IsProtected;
|
WorkbookSource.Worksheet.Protection := F.Protection;
|
||||||
F.Protection := WorkbookSource.Worksheet.Protection;
|
WorkbookSource.Worksheet.Protect(F.IsProtected);
|
||||||
if F.ShowModal = mrOK then
|
|
||||||
begin
|
|
||||||
WorkbookSource.Worksheet.Protection := F.Protection;
|
|
||||||
WorkbookSource.Worksheet.Protect(F.IsProtected);
|
|
||||||
end;
|
|
||||||
finally
|
|
||||||
F.Free;
|
|
||||||
end;
|
end;
|
||||||
|
finally
|
||||||
|
F.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ object WorksheetProtectionForm: TWorksheetProtectionForm
|
|||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
Caption = 'Protect worksheet and locked cells'
|
Caption = 'Protect worksheet and locked cells'
|
||||||
OnChange = CbProtectChange
|
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object LblProtectionItems: TLabel
|
object LblProtectionItems: TLabel
|
||||||
|
@ -20,7 +20,6 @@ type
|
|||||||
CbSelectUnlockedCells: TCheckBox;
|
CbSelectUnlockedCells: TCheckBox;
|
||||||
LblProtectionItems: TLabel;
|
LblProtectionItems: TLabel;
|
||||||
ItemsPanel: TPanel;
|
ItemsPanel: TPanel;
|
||||||
procedure CbProtectChange(Sender: TObject);
|
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
private
|
private
|
||||||
function GetProtected: Boolean;
|
function GetProtected: Boolean;
|
||||||
@ -40,16 +39,6 @@ implementation
|
|||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
procedure TWorksheetProtectionForm.CbProtectChange(Sender: TObject);
|
|
||||||
var
|
|
||||||
unlocked: Boolean;
|
|
||||||
begin
|
|
||||||
unlocked := not IsProtected;
|
|
||||||
LblProtectionItems.Enabled := unlocked;
|
|
||||||
CbSelectLockedCells.Enabled := unlocked;
|
|
||||||
CbSelectUnlockedCells.Enabled := unlocked;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TWorksheetProtectionForm.FormCreate(Sender: TObject);
|
procedure TWorksheetProtectionForm.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Constraints.MinHeight := ItemsPanel.Height + CbProtect.Height +
|
Constraints.MinHeight := ItemsPanel.Height + CbProtect.Height +
|
||||||
@ -64,12 +53,14 @@ end;
|
|||||||
function TWorksheetProtectionForm.GetProtections: TsWorksheetProtections;
|
function TWorksheetProtectionForm.GetProtections: TsWorksheetProtections;
|
||||||
begin
|
begin
|
||||||
Result := DEFAULT_SHEET_PROTECTION;
|
Result := DEFAULT_SHEET_PROTECTION;
|
||||||
|
// NOTE: There's negative logic - if an option is checked it is ALLOWED, but
|
||||||
|
// the set of protections contains the items which are FORBIDDEN.
|
||||||
if CbSelectLockedCells.Checked then
|
if CbSelectLockedCells.Checked then
|
||||||
Include(Result, spSelectLockedCells) else
|
Exclude(Result, spSelectLockedCells) else
|
||||||
Exclude(Result, spSelectLockedCells);
|
Include(Result, spSelectLockedCells);
|
||||||
if CbSelectUnlockedCells.Checked then
|
if CbSelectUnlockedCells.Checked then
|
||||||
Include(Result, spSelectUnlockedCells) else
|
Exclude(Result, spSelectUnlockedCells) else
|
||||||
Exclude(Result, spSelectUnlockedCells);
|
Include(Result, spSelectUnlockedCells);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWorksheetProtectionForm.SetProtected(AValue: Boolean);
|
procedure TWorksheetProtectionForm.SetProtected(AValue: Boolean);
|
||||||
@ -79,8 +70,8 @@ end;
|
|||||||
|
|
||||||
procedure TWorksheetProtectionForm.SetProtections(AValue: TsWorksheetProtections);
|
procedure TWorksheetProtectionForm.SetProtections(AValue: TsWorksheetProtections);
|
||||||
begin
|
begin
|
||||||
CbSelectLockedCells.Checked := spSelectLockedCells in AValue;
|
CbSelectLockedCells.Checked := not (spSelectLockedCells in AValue);
|
||||||
CbSelectUnlockedCells.Checked := spSelectUnlockedCells in AValue;
|
CbSelectUnlockedCells.Checked := not (spSelectUnlockedCells in AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user