From c3a67dc5766a3e6915873da715c2f5be3d70be22 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 11 Aug 2018 10:39:34 +0000 Subject: [PATCH] spready: Add option for automatic row height calculation after file is loaded. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6593 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/spready/smain.lfm | 10 ++++++++++ applications/spready/smain.pas | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/applications/spready/smain.lfm b/applications/spready/smain.lfm index 24e8a1018..fb2d789ea 100644 --- a/applications/spready/smain.lfm +++ b/applications/spready/smain.lfm @@ -1928,6 +1928,12 @@ object MainForm: TMainForm Hint = 'Clear format' ImageIndex = 74 end + object AcSettingsAutoUpdateRowheights: TAction + Category = 'Settings' + AutoCheck = True + Caption = 'Update row heights after loading' + OnExecute = AcSettingsAutoUpdateRowheightsExecute + end end object ImageList: TImageList left = 176 @@ -4803,6 +4809,10 @@ object MainForm: TMainForm Action = AcSettingsReadFormulas AutoCheck = True end + object MenuItem192: TMenuItem + Action = AcSettingsAutoUpdateRowheights + AutoCheck = True + end end object MnuHelp: TMenuItem Caption = 'Help' diff --git a/applications/spready/smain.pas b/applications/spready/smain.pas index b27582c28..1e5e639d2 100644 --- a/applications/spready/smain.pas +++ b/applications/spready/smain.pas @@ -38,6 +38,7 @@ type AcRowHeight: TAction; AcColWidth: TAction; AcSettingsReadFormulas: TAction; + AcSettingsAutoUpdateRowheights: TAction; AcWorksheetProtection: TAction; AcWorksheetRTL: TAction; AcViewInspector: TAction; @@ -93,6 +94,7 @@ type MenuItem189: TMenuItem; MenuItem190: TMenuItem; MenuItem191: TMenuItem; + MenuItem192: TMenuItem; MenuItem2: TMenuItem; MenuItem3: TMenuItem; MenuItem4: TMenuItem; @@ -447,6 +449,7 @@ type procedure AcRowAddExecute(Sender: TObject); procedure AcRowDeleteExecute(Sender: TObject); procedure AcRowHeightExecute(Sender: TObject); + procedure AcSettingsAutoUpdateRowheightsExecute(Sender: TObject); procedure AcSettingsReadFormulasExecute(Sender: TObject); procedure AcSortColAscExecute(Sender: TObject); procedure AcSortExecute(Sender: TObject); @@ -493,6 +496,7 @@ type AWorksheet: TsWorksheet; ARow, ACol: Cardinal); procedure UpdateCaption; procedure UpdateInspectorColumns; + procedure UpdateRowHeights; protected procedure ReadFromIni; procedure WriteToIni; @@ -742,6 +746,12 @@ begin end; end; +procedure TMainForm.AcSettingsAutoUpdateRowheightsExecute(Sender: TObject); +begin + if AcSettingsAutoUpdateRowHeights.Checked then + UpdateRowHeights; +end; + procedure TMainForm.AcWorksheetRTLExecute(Sender: TObject); begin if AcWorksheetRTL.Checked then @@ -1124,6 +1134,8 @@ begin WorkbookSource.FileName := UTF8ToAnsi(AFileName); // this loads the file FMRUMenuManager.AddToRecent(AFileName); UpdateCaption; + if AcSettingsAutoUpdateRowHeights.Checked then + UpdateRowHeights; finally Screen.Cursor := crs; end; @@ -1174,6 +1186,8 @@ begin AcSettingsReadFormulas.Checked := ini.ReadBool('Settings', 'ReadFormulas', true); AcSettingsReadFormulasExecute(nil); + AcSettingsAutoUpdateRowHeights.Checked := ini.ReadBool('Settings', 'AutoUpdateRowHeights', false); + finally ini.Free; end; @@ -1233,6 +1247,11 @@ begin Inspector.DisplayOptions := Inspector.DisplayOptions - [doAutoColResize]; end; +procedure TMainForm.UpdateRowHeights; +begin + WorksheetGrid.UpdateRowHeights(-1, true); +end; + procedure TMainForm.WriteToIni; var ini: TCustomIniFile; @@ -1252,6 +1271,7 @@ begin ini.WriteBool('Inspector', 'Visible', InspectorTabControl.Visible); ini.WriteBool('Settings', 'ReadFormulas', AcSettingsReadFormulas.Checked); + ini.WriteBool('Settings', 'AutoUpdateRowHeights', AcSettingsAutoUpdateRowHeights.Checked); finally ini.Free; end;