sc/inc/inputopt.hxx | 6 ++---- sc/source/core/tool/inputopt.cxx | 37 +++++++++++++------------------------ sc/source/ui/app/scmod.cxx | 31 ++++++++++++++++--------------- sc/source/ui/unoobj/appluno.cxx | 2 +- 4 files changed, 32 insertions(+), 44 deletions(-)
New commits: commit b2c56ac95b15b675b9fabed889e7f9709bdc793f Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Nov 28 15:03:40 2021 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Nov 28 22:13:34 2021 +0100 Refactor ScInputCfg a little Make ScInputOptions a private ancestor. This allows to drop OptionsChanged, and avoid potential way to change settings without committing to configuration. Drop ScInputOptions::SetDefaults, and use ctor for that. Change-Id: I8abb7309a72e84ac7c83592f3758f0264cd1cc4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125905 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sc/inc/inputopt.hxx b/sc/inc/inputopt.hxx index 6a3261701cff..05e59aad5716 100644 --- a/sc/inc/inputopt.hxx +++ b/sc/inc/inputopt.hxx @@ -41,8 +41,6 @@ private: public: ScInputOptions(); - void SetDefaults(); - void SetMoveDir(sal_uInt16 nNew) { nMoveDir = nNew; } sal_uInt16 GetMoveDir() const { return nMoveDir; } void SetMoveSelection(bool bSet) { bMoveSelection = bSet; } @@ -73,7 +71,7 @@ public: // CfgItem for input options -class ScInputCfg final : public ScInputOptions, +class ScInputCfg final : private ScInputOptions, public utl::ConfigItem { static css::uno::Sequence<OUString> GetPropertyNames(); @@ -83,8 +81,8 @@ class ScInputCfg final : public ScInputOptions, public: ScInputCfg(); + const ScInputOptions& GetOptions() const { return *this; } void SetOptions( const ScInputOptions& rNew ); - void OptionsChanged(); // after direct access to SetOptions base class virtual void Notify( const css::uno::Sequence<OUString>& aPropertyNames ) override; }; diff --git a/sc/source/core/tool/inputopt.cxx b/sc/source/core/tool/inputopt.cxx index aa5179bb25ec..c36fceee499a 100644 --- a/sc/source/core/tool/inputopt.cxx +++ b/sc/source/core/tool/inputopt.cxx @@ -31,25 +31,20 @@ using namespace com::sun::star::uno; // ScInputOptions - input options ScInputOptions::ScInputOptions() + : nMoveDir(DIR_BOTTOM) + , bMoveSelection(true) + , bEnterEdit(false) + , bExtendFormat(false) + , bRangeFinder(true) + , bExpandRefs(false) + , mbSortRefUpdate(true) + , bMarkHeader(true) + , bUseTabCol(false) + , bTextWysiwyg(false) + , bReplCellsWarn(true) + , bLegacyCellSelection(false) + , bEnterPasteMode(false) { - SetDefaults(); -} - -void ScInputOptions::SetDefaults() -{ - nMoveDir = DIR_BOTTOM; - bMoveSelection = true; - bEnterEdit = false; - bExtendFormat = false; - bRangeFinder = true; - bExpandRefs = false; - mbSortRefUpdate = true; - bMarkHeader = true; - bUseTabCol = false; - bTextWysiwyg = false; - bReplCellsWarn = true; - bLegacyCellSelection = false; - bEnterPasteMode = false; } // Config Item containing input options @@ -165,10 +160,4 @@ void ScInputCfg::SetOptions( const ScInputOptions& rNew ) Commit(); } -void ScInputCfg::OptionsChanged() -{ - SetModified(); - Commit(); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index d97a10248115..2a3685488cb9 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -777,7 +777,7 @@ const ScInputOptions& ScModule::GetInputOptions() if ( !m_pInputCfg ) m_pInputCfg.reset( new ScInputCfg ); - return *m_pInputCfg; + return m_pInputCfg->GetOptions(); } void ScModule::SetPrintOptions( const ScPrintOptions& rOpt ) @@ -1128,73 +1128,74 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) } // InputOptions + ScInputOptions aInputOptions = m_pInputCfg->GetOptions(); if ( rOptSet.HasItem(SID_SC_INPUT_SELECTIONPOS,&pItem) ) { - m_pInputCfg->SetMoveDir( static_cast<const SfxUInt16Item*>(pItem)->GetValue() ); + aInputOptions.SetMoveDir( static_cast<const SfxUInt16Item*>(pItem)->GetValue() ); bSaveInputOptions = true; } if ( rOptSet.HasItem(SID_SC_INPUT_SELECTION,&pItem) ) { - m_pInputCfg->SetMoveSelection( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + aInputOptions.SetMoveSelection( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); bSaveInputOptions = true; } if ( rOptSet.HasItem(SID_SC_INPUT_EDITMODE,&pItem) ) { - m_pInputCfg->SetEnterEdit( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + aInputOptions.SetEnterEdit( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); bSaveInputOptions = true; } if ( rOptSet.HasItem(SID_SC_INPUT_FMT_EXPAND,&pItem) ) { - m_pInputCfg->SetExtendFormat( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + aInputOptions.SetExtendFormat( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); bSaveInputOptions = true; } if ( rOptSet.HasItem(SID_SC_INPUT_RANGEFINDER,&pItem) ) { - m_pInputCfg->SetRangeFinder( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + aInputOptions.SetRangeFinder( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); bSaveInputOptions = true; } if ( rOptSet.HasItem(SID_SC_INPUT_REF_EXPAND,&pItem) ) { - m_pInputCfg->SetExpandRefs( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + aInputOptions.SetExpandRefs( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); bSaveInputOptions = true; } if (rOptSet.HasItem(SID_SC_OPT_SORT_REF_UPDATE, &pItem)) { - m_pInputCfg->SetSortRefUpdate(static_cast<const SfxBoolItem*>(pItem)->GetValue()); + aInputOptions.SetSortRefUpdate(static_cast<const SfxBoolItem*>(pItem)->GetValue()); bSaveInputOptions = true; } if ( rOptSet.HasItem(SID_SC_INPUT_MARK_HEADER,&pItem) ) { - m_pInputCfg->SetMarkHeader( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + aInputOptions.SetMarkHeader( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); bSaveInputOptions = true; bUpdateMarks = true; } if ( rOptSet.HasItem(SID_SC_INPUT_TEXTWYSIWYG,&pItem) ) { bool bNew = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if ( bNew != m_pInputCfg->GetTextWysiwyg() ) + if ( bNew != aInputOptions.GetTextWysiwyg() ) { - m_pInputCfg->SetTextWysiwyg( bNew ); + aInputOptions.SetTextWysiwyg( bNew ); bSaveInputOptions = true; bUpdateRefDev = true; } } if( rOptSet.HasItem( SID_SC_INPUT_REPLCELLSWARN, &pItem ) ) { - m_pInputCfg->SetReplaceCellsWarn( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + aInputOptions.SetReplaceCellsWarn( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); bSaveInputOptions = true; } if( rOptSet.HasItem( SID_SC_INPUT_LEGACY_CELL_SELECTION, &pItem ) ) { - m_pInputCfg->SetLegacyCellSelection( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + aInputOptions.SetLegacyCellSelection( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); bSaveInputOptions = true; } if( rOptSet.HasItem( SID_SC_INPUT_ENTER_PASTE_MODE, &pItem ) ) { - m_pInputCfg->SetEnterPasteMode( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + aInputOptions.SetEnterPasteMode( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); bSaveInputOptions = true; } @@ -1212,7 +1213,7 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) m_pAppCfg->OptionsChanged(); if ( bSaveInputOptions ) - m_pInputCfg->OptionsChanged(); + m_pInputCfg->SetOptions(aInputOptions); // Kick off recalculation? if (pDoc && bCompileErrorCells) diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx index 9c551ac8f0b4..7421dbfa7b76 100644 --- a/sc/source/ui/unoobj/appluno.cxx +++ b/sc/source/ui/unoobj/appluno.cxx @@ -291,7 +291,7 @@ uno::Any SAL_CALL ScSpreadsheetSettings::getPropertyValue( const OUString& aProp ScModule* pScMod = SC_MOD(); ScAppOptions aAppOpt = pScMod->GetAppOptions(); - ScInputOptions aInpOpt = pScMod->GetInputOptions(); + const ScInputOptions& aInpOpt = pScMod->GetInputOptions(); // print options aren't loaded until needed if (aPropertyName == SC_UNONAME_DOAUTOCP) aRet <<= aAppOpt.GetAutoComplete();