From e192e1542a84b26cb0685860b84339019021de96 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 23 Jul 2021 21:03:27 +0200 Subject: [PATCH] use officecfg to retrieve UserAutoSave Change-Id: I11f45c43bed9ea9a380026d84a91f48629dffac7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119461 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cui/source/options/optsave.cxx | 5 +++-- include/unotools/saveopt.hxx | 6 +----- sfx2/source/appl/appcfg.cxx | 10 +++++++--- unotools/source/config/saveopt.cxx | 32 ------------------------------ 4 files changed, 11 insertions(+), 42 deletions(-) diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx index b13f88b10ab3..51a1a77b177d 100644 --- a/cui/source/options/optsave.cxx +++ b/cui/source/options/optsave.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -438,8 +439,8 @@ void SvxSaveTabPage::Reset( const SfxItemSet* ) m_xAutoSaveCB->set_active(officecfg::Office::Common::Save::Document::AutoSave::get()); m_xAutoSaveCB->set_sensitive(!officecfg::Office::Common::Save::Document::AutoSave::isReadOnly()); - m_xUserAutoSaveCB->set_active(aSaveOpt.IsUserAutoSave()); - m_xUserAutoSaveCB->set_sensitive(!aSaveOpt.IsReadOnly(SvtSaveOptions::EOption::UserAutoSave)); + m_xUserAutoSaveCB->set_active(officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get()); + m_xUserAutoSaveCB->set_sensitive(!officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::isReadOnly()); m_xWarnAlienFormatCB->set_active(aSaveOpt.IsWarnAlienFormat()); m_xWarnAlienFormatCB->set_sensitive(!aSaveOpt.IsReadOnly(SvtSaveOptions::EOption::WarnAlienFormat)); diff --git a/include/unotools/saveopt.hxx b/include/unotools/saveopt.hxx index 5a8abe03a22f..c0bec6866287 100644 --- a/include/unotools/saveopt.hxx +++ b/include/unotools/saveopt.hxx @@ -36,8 +36,7 @@ public: Backup, WarnAlienFormat, LoadDocPrinter, - OdfDefaultVersion, - UserAutoSave, + OdfDefaultVersion }; /** Keep enum values sorted that a less or greater compare maps to older @@ -92,9 +91,6 @@ public: void SetBackup( bool b ); bool IsBackup() const; - void SetUserAutoSave( bool b ); - bool IsUserAutoSave() const; - void SetLoadUserSettings(bool b); bool IsLoadUserSettings() const; diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index 7f2767107c94..4a71912fae0e 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -186,8 +187,9 @@ void SfxApplication::GetOptions( SfxItemSet& rSet ) case SID_ATTR_USERAUTOSAVE : { bRet = true; - if (!aSaveOptions.IsReadOnly(SvtSaveOptions::EOption::UserAutoSave)) - if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_USERAUTOSAVE ), aSaveOptions.IsUserAutoSave()))) + if (!officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::isReadOnly()) + if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_USERAUTOSAVE ), + officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get() ))) bRet = false; } break; @@ -481,7 +483,9 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_USERAUTOSAVE), true, &pItem)) { DBG_ASSERT(dynamic_cast< const SfxBoolItem *>( pItem ) != nullptr, "BoolItem expected"); - aSaveOptions.SetUserAutoSave( static_cast(pItem)->GetValue() ); + officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::set( + static_cast(pItem)->GetValue(), + batch); } // DocInfo diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx index f1ccc712e810..a8ffe9d01c23 100644 --- a/unotools/source/config/saveopt.cxx +++ b/unotools/source/config/saveopt.cxx @@ -62,7 +62,6 @@ class SvtSaveOptions_Impl : public utl::ConfigItem bool bUseUserData, bBackup, bAutoSave, - bUserAutoSave, bWarnAlienFormat, bLoadDocPrinter; @@ -71,7 +70,6 @@ class SvtSaveOptions_Impl : public utl::ConfigItem bool bROAutoSaveTime, bROUseUserData, bROBackup, - bROUserAutoSave, bROWarnAlienFormat, bROLoadDocPrinter, bROODFDefaultVersion; @@ -86,7 +84,6 @@ public: sal_Int32 GetAutoSaveTime() const { return nAutoSaveTime; } bool IsUseUserData() const { return bUseUserData; } bool IsBackup() const { return bBackup; } - bool IsUserAutoSave() const { return bUserAutoSave; } bool IsWarnAlienFormat() const { return bWarnAlienFormat; } bool IsLoadDocPrinter() const { return bLoadDocPrinter; } @@ -96,7 +93,6 @@ public: void SetAutoSaveTime( sal_Int32 n ); void SetUseUserData( bool b ); void SetBackup( bool b ); - void SetUserAutoSave( bool b ); void SetWarnAlienFormat( bool _bDoPP ); void SetLoadDocPrinter( bool bNew ); void SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion eNew ); @@ -134,16 +130,6 @@ void SvtSaveOptions_Impl::SetBackup( bool b ) } } -void SvtSaveOptions_Impl::SetUserAutoSave( bool b ) -{ - if (!bROUserAutoSave && bUserAutoSave!=b) - { - bUserAutoSave = b; - SetModified(); - Commit(); - } -} - void SvtSaveOptions_Impl::SetWarnAlienFormat( bool _bDoPP ) { if (!bROWarnAlienFormat && bWarnAlienFormat!=_bDoPP) @@ -185,9 +171,6 @@ bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) const case SvtSaveOptions::EOption::Backup : bReadOnly = bROBackup; break; - case SvtSaveOptions::EOption::UserAutoSave : - bReadOnly = bROUserAutoSave; - break; case SvtSaveOptions::EOption::WarnAlienFormat : bReadOnly = bROWarnAlienFormat; break; @@ -236,14 +219,12 @@ SvtSaveOptions_Impl::SvtSaveOptions_Impl() , nAutoSaveTime( 0 ) , bUseUserData( false ) , bBackup( false ) - , bUserAutoSave( false ) , bWarnAlienFormat( true ) , bLoadDocPrinter( true ) , eODFDefaultVersion( SvtSaveOptions::ODFVER_LATEST ) , bROAutoSaveTime( CFG_READONLY_DEFAULT ) , bROUseUserData( CFG_READONLY_DEFAULT ) , bROBackup( CFG_READONLY_DEFAULT ) - , bROUserAutoSave( CFG_READONLY_DEFAULT ) , bROWarnAlienFormat( CFG_READONLY_DEFAULT ) , bROLoadDocPrinter( CFG_READONLY_DEFAULT ) , bROODFDefaultVersion( CFG_READONLY_DEFAULT ) @@ -339,13 +320,11 @@ SvtSaveOptions_Impl::SvtSaveOptions_Impl() { bAutoSave = officecfg::Office::Recovery::AutoSave::Enabled::get(); nAutoSaveTime = officecfg::Office::Recovery::AutoSave::TimeIntervall::get(); - bUserAutoSave = officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get(); } else { bAutoSave = false; nAutoSaveTime = 0; - bUserAutoSave = false; } } @@ -430,7 +409,6 @@ void SvtSaveOptions_Impl::ImplCommit() comphelper::ConfigurationChanges::create()); officecfg::Office::Recovery::AutoSave::TimeIntervall::set(nAutoSaveTime, batch); officecfg::Office::Recovery::AutoSave::Enabled::set(bAutoSave, batch); - officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::set(bUserAutoSave, batch); batch->commit(); } @@ -549,16 +527,6 @@ bool SvtSaveOptions::IsBackup() const return pImp->pSaveOpt->IsBackup(); } -void SvtSaveOptions::SetUserAutoSave( bool b ) -{ - pImp->pSaveOpt->SetUserAutoSave( b ); -} - -bool SvtSaveOptions::IsUserAutoSave() const -{ - return pImp->pSaveOpt->IsUserAutoSave(); -} - void SvtSaveOptions::SetLoadUserSettings(bool b) { pImp->pLoadOpt->SetLoadUserSettings(b);