cui/source/options/optsave.cxx     |   12 ++-----
 include/unotools/saveopt.hxx       |    3 -
 sw/source/filter/xml/xmlimp.cxx    |    4 +-
 unotools/source/config/saveopt.cxx |   59 -------------------------------------
 4 files changed, 6 insertions(+), 72 deletions(-)

New commits:
commit 2b71e0683cf8a34aaddce3558b941ba62b1b4ec5
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sat Jul 24 14:23:54 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Jul 25 16:50:03 2021 +0200

    use officecfg to retrieve LoadUserSettings
    
    Change-Id: I9680c02207ff2d21785a20061b784066ead07a8b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119473
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx
index 3ac609d8e64f..208bf8289f2e 100644
--- a/cui/source/options/optsave.cxx
+++ b/cui/source/options/optsave.cxx
@@ -225,19 +225,14 @@ void SvxSaveTabPage::DetectHiddenControls()
 
 bool SvxSaveTabPage::FillItemSet( SfxItemSet* rSet )
 {
+    auto xChanges = comphelper::ConfigurationChanges::create();
     bool bModified = false;
     SvtSaveOptions aSaveOpt;
     if(m_xLoadUserSettingsCB->get_state_changed_from_saved())
-    {
-        aSaveOpt.SetLoadUserSettings(m_xLoadUserSettingsCB->get_active());
-    }
+        
officecfg::Office::Common::Load::UserDefinedSettings::set(m_xLoadUserSettingsCB->get_active(),
 xChanges);
 
     if ( m_xLoadDocPrinterCB->get_state_changed_from_saved() )
-    {
-        auto xChanges = comphelper::ConfigurationChanges::create();
         
officecfg::Office::Common::Save::Document::LoadPrinter::set(m_xLoadDocPrinterCB->get_active(),
 xChanges);
-        xChanges->commit();
-    }
 
     if ( m_xODFVersionLB->get_value_changed_from_saved() )
     {
@@ -329,6 +324,7 @@ bool SvxSaveTabPage::FillItemSet( SfxItemSet* rSet )
             pImpl->aDefaultArr[APP_WRITER_GLOBAL] != 
aModuleOpt.GetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERGLOBAL))
         
aModuleOpt.SetFactoryDefaultFilter(SvtModuleOptions::EFactory::WRITERGLOBAL, 
pImpl->aDefaultArr[APP_WRITER_GLOBAL]);
 
+    xChanges->commit();
     return bModified;
 }
 
@@ -369,7 +365,7 @@ static bool isODFFormat( const OUString& sFilter )
 void SvxSaveTabPage::Reset( const SfxItemSet* )
 {
     SvtSaveOptions aSaveOpt;
-    m_xLoadUserSettingsCB->set_active(aSaveOpt.IsLoadUserSettings());
+    
m_xLoadUserSettingsCB->set_active(officecfg::Office::Common::Load::UserDefinedSettings::get());
     m_xLoadUserSettingsCB->save_state();
     
m_xLoadUserSettingsCB->set_sensitive(!officecfg::Office::Common::Load::UserDefinedSettings::isReadOnly());
     m_xLoadDocPrinterCB->set_active( 
officecfg::Office::Common::Save::Document::LoadPrinter::get() );
diff --git a/include/unotools/saveopt.hxx b/include/unotools/saveopt.hxx
index 17fcf3affdfd..2793187ec621 100644
--- a/include/unotools/saveopt.hxx
+++ b/include/unotools/saveopt.hxx
@@ -77,9 +77,6 @@ public:
     SvtSaveOptions();
     virtual ~SvtSaveOptions() override;
 
-    void                    SetLoadUserSettings(bool b);
-    bool                IsLoadUserSettings() const;
-
     void                    SetODFDefaultVersion( ODFDefaultVersion eVersion );
     ODFDefaultVersion       GetODFDefaultVersion() const;
     ODFSaneDefaultVersion   GetODFSaneDefaultVersion() const;
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 4fd946b8f0e5..4e03cb1ae623 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -76,6 +76,7 @@
 #include <comphelper/servicehelper.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertysequence.hxx>
+#include <officecfg/Office/Common.hxx>
 
 #include <unordered_set>
 
@@ -1283,8 +1284,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence 
< PropertyValue > & aC
         "EmptyDbFieldHidesPara"
     };
 
-    SvtSaveOptions aSaveOpt;
-    bool bAreUserSettingsFromDocument = aSaveOpt.IsLoadUserSettings();
+    bool bAreUserSettingsFromDocument = 
officecfg::Office::Common::Load::UserDefinedSettings::get();
 
     // for some properties we don't want to use the application
     // default if they're missing. So we watch for them in the loop
diff --git a/unotools/source/config/saveopt.cxx 
b/unotools/source/config/saveopt.cxx
index 615cc033acd3..aa7e875e1d97 100644
--- a/unotools/source/config/saveopt.cxx
+++ b/unotools/source/config/saveopt.cxx
@@ -48,7 +48,6 @@ class SvtLoadOptions_Impl;
 struct SvtLoadSaveOptions_Impl
 {
     std::unique_ptr<SvtSaveOptions_Impl> pSaveOpt;
-    std::unique_ptr<SvtLoadOptions_Impl> pLoadOpt;
 };
 
 static std::unique_ptr<SvtLoadSaveOptions_Impl> pOptions;
@@ -233,51 +232,6 @@ void SvtSaveOptions_Impl::Notify( const 
Sequence<OUString>& )
 {
 }
 
-namespace {
-
-class SvtLoadOptions_Impl : public utl::ConfigItem
-{
-private:
-    bool                            bLoadUserDefinedSettings;
-
-    virtual void            ImplCommit() override;
-
-public:
-                            SvtLoadOptions_Impl();
-
-    virtual void            Notify( const css::uno::Sequence< OUString >& 
aPropertyNames ) override;
-
-    void                    SetLoadUserSettings(bool 
b){bLoadUserDefinedSettings = b; SetModified();}
-    bool                IsLoadUserSettings() const {return 
bLoadUserDefinedSettings;}
-};
-
-}
-
-constexpr OUStringLiteral cUserDefinedSettings = u"UserDefinedSettings";
-
-SvtLoadOptions_Impl::SvtLoadOptions_Impl()
-    : ConfigItem( "Office.Common/Load" )
-    , bLoadUserDefinedSettings( false )
-{
-    Sequence< OUString > aNames { cUserDefinedSettings };
-    Sequence< Any > aValues = GetProperties( aNames );
-    EnableNotification( aNames );
-    const Any* pValues = aValues.getConstArray();
-    DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties 
failed" );
-    pValues[0] >>= bLoadUserDefinedSettings;
-}
-
-void SvtLoadOptions_Impl::ImplCommit()
-{
-    PutProperties(
-        {cUserDefinedSettings}, {css::uno::Any(bLoadUserDefinedSettings)});
-}
-
-void SvtLoadOptions_Impl::Notify( const Sequence<OUString>& )
-{
-    SAL_WARN( "unotools.config", "properties have been changed" );
-}
-
 namespace
 {
     class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton >
@@ -293,7 +247,6 @@ SvtSaveOptions::SvtSaveOptions()
     {
         pOptions.reset(new SvtLoadSaveOptions_Impl);
         pOptions->pSaveOpt.reset(new SvtSaveOptions_Impl);
-        pOptions->pLoadOpt.reset( new SvtLoadOptions_Impl);
     }
     ++nRefCount;
     pImp = pOptions.get();
@@ -307,23 +260,11 @@ SvtSaveOptions::~SvtSaveOptions()
     {
         if ( pOptions->pSaveOpt->IsModified() )
             pOptions->pSaveOpt->Commit();
-        if ( pOptions->pLoadOpt->IsModified() )
-            pOptions->pLoadOpt->Commit();
 
         pOptions.reset();
     }
 }
 
-void SvtSaveOptions::SetLoadUserSettings(bool b)
-{
-    pImp->pLoadOpt->SetLoadUserSettings(b);
-}
-
-bool   SvtSaveOptions::IsLoadUserSettings() const
-{
-    return pImp->pLoadOpt->IsLoadUserSettings();
-}
-
 void SvtSaveOptions::SetODFDefaultVersion( SvtSaveOptions::ODFDefaultVersion 
eVersion )
 {
     pImp->pSaveOpt->SetODFDefaultVersion( eVersion );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to