diff --git a/applications/spready/readme.txt b/applications/spready/readme.txt index c58bfe6d5..ac7929f79 100644 --- a/applications/spready/readme.txt +++ b/applications/spready/readme.txt @@ -1,2 +1,7 @@ spready is a relatively complex demonstration of the fpspreadsheet library and its visual controls. + +Requirements: +- fpspreadsheet trunk version (packages laz_fpspreadsheet, + laz_fpspreadsheet_visual and laz_fpspreadsheet_crypto) +- dcpcrypt (needed for laz_fpspreadsheet_crypto) \ No newline at end of file diff --git a/applications/spready/smain.lfm b/applications/spready/smain.lfm index 43270875f..9a18994ad 100644 --- a/applications/spready/smain.lfm +++ b/applications/spready/smain.lfm @@ -1901,7 +1901,7 @@ object MainForm: TMainForm end object AcWorksheetProtection: TAction Category = 'Worksheet' - Caption = 'Protect worksheet...' + Caption = 'Worksheet protection...' ImageIndex = 73 OnExecute = AcWorksheetProtectionExecute OnUpdate = AcWorksheetProtectionUpdate diff --git a/applications/spready/smain.pas b/applications/spready/smain.pas index 14f2896ab..8e6880e80 100644 --- a/applications/spready/smain.pas +++ b/applications/spready/smain.pas @@ -883,22 +883,17 @@ procedure TMainForm.AcWorksheetProtectionExecute(Sender: TObject); var F: TWorksheetProtectionForm; begin - if WorkbookSource.Worksheet.IsProtected then - WorkbookSource.Worksheet.Protect(false) - else - begin - F := TWorksheetProtectionForm.Create(nil); - try - F.IsProtected := WorkbookSource.Worksheet.IsProtected; - F.Protection := WorkbookSource.Worksheet.Protection; - if F.ShowModal = mrOK then - begin - WorkbookSource.Worksheet.Protection := F.Protection; - WorkbookSource.Worksheet.Protect(F.IsProtected); - end; - finally - F.Free; + F := TWorksheetProtectionForm.Create(nil); + try + F.IsProtected := not WorkbookSource.Worksheet.IsProtected; + F.Protection := WorkbookSource.Worksheet.Protection; + if F.ShowModal = mrOK then + begin + WorkbookSource.Worksheet.Protection := F.Protection; + WorkbookSource.Worksheet.Protect(F.IsProtected); end; + finally + F.Free; end; end; diff --git a/applications/spready/sworksheetprotection.lfm b/applications/spready/sworksheetprotection.lfm index 6dfda782a..2a184a45f 100644 --- a/applications/spready/sworksheetprotection.lfm +++ b/applications/spready/sworksheetprotection.lfm @@ -37,7 +37,6 @@ object WorksheetProtectionForm: TWorksheetProtectionForm BorderSpacing.Top = 8 BorderSpacing.Bottom = 8 Caption = 'Protect worksheet and locked cells' - OnChange = CbProtectChange TabOrder = 1 end object LblProtectionItems: TLabel diff --git a/applications/spready/sworksheetprotection.pas b/applications/spready/sworksheetprotection.pas index 5e7bc8412..48088e385 100644 --- a/applications/spready/sworksheetprotection.pas +++ b/applications/spready/sworksheetprotection.pas @@ -20,7 +20,6 @@ type CbSelectUnlockedCells: TCheckBox; LblProtectionItems: TLabel; ItemsPanel: TPanel; - procedure CbProtectChange(Sender: TObject); procedure FormCreate(Sender: TObject); private function GetProtected: Boolean; @@ -40,16 +39,6 @@ implementation {$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); begin Constraints.MinHeight := ItemsPanel.Height + CbProtect.Height + @@ -64,12 +53,14 @@ end; function TWorksheetProtectionForm.GetProtections: TsWorksheetProtections; begin 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 - Include(Result, spSelectLockedCells) else - Exclude(Result, spSelectLockedCells); + Exclude(Result, spSelectLockedCells) else + Include(Result, spSelectLockedCells); if CbSelectUnlockedCells.Checked then - Include(Result, spSelectUnlockedCells) else - Exclude(Result, spSelectUnlockedCells); + Exclude(Result, spSelectUnlockedCells) else + Include(Result, spSelectUnlockedCells); end; procedure TWorksheetProtectionForm.SetProtected(AValue: Boolean); @@ -79,8 +70,8 @@ end; procedure TWorksheetProtectionForm.SetProtections(AValue: TsWorksheetProtections); begin - CbSelectLockedCells.Checked := spSelectLockedCells in AValue; - CbSelectUnlockedCells.Checked := spSelectUnlockedCells in AValue; + CbSelectLockedCells.Checked := not (spSelectLockedCells in AValue); + CbSelectUnlockedCells.Checked := not (spSelectUnlockedCells in AValue); end; end.