[Libreoffice-commits] core.git: cui/source include/unotools sw/source unotools/source

2021-07-25 Thread Noel Grandin (via logerrit)
 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 
AuthorDate: Sat Jul 24 14:23:54 2021 +0200
Commit: Noel Grandin 
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 

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;
 
-voidSetLoadUserSettings(bool b);
-boolIsLoadUserSettings() const;
-
 voidSetODFDefaultVersion( 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 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -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 pSaveOpt;
-std::unique_ptr pLoadOpt;
 };
 
 static std::unique_ptr pOptions;
@@ -233,51 +232,6 @@ void SvtSaveOptions_Impl::Notify( const 
Sequence& )
 {
 }
 
-namespace {
-
-class SvtLoadOptions_Impl : public utl::ConfigItem
-{
-private:
-boolbLoadUserDefinedSettings;
-
-virtual voidImplCommit() override;
-
-public:
-SvtLoadOptions_Impl();
-
-virtual voidNotify( const css::uno::Sequence< OUString >& 
aPropertyNames ) override;
-
-voidSetLoadUserSettings(bool 

[Libreoffice-commits] core.git: cui/source include/unotools sw/source unotools/source

2017-01-26 Thread Vitaliy Anderson
 cui/source/options/optgdlg.cxx|2 
 include/unotools/compatibility.hxx|  243 +
 sw/source/core/doc/DocumentSettingManager.cxx |   24 
 sw/source/ui/config/optcomp.cxx   |  338 
 unotools/source/config/compatibility.cxx  |  697 ++
 5 files changed, 444 insertions(+), 860 deletions(-)

New commits:
commit 91ccb4dbf7cbe7e684c7a8183863e597d7205e57
Author: Vitaliy Anderson 
Date:   Thu Jan 19 02:09:04 2017 -0800

Compatibility options refactoring. Part 1

It relate to reduce the nubmer of copy-paste the same code
and simplify adding compability options.
Also using enum class instead enum can eliminate to occurrence
an error relate to access to out of range an array.

Change-Id: I07b862aac5f88da4a98e2273cb14daa09e70eacb
Reviewed-on: https://gerrit.libreoffice.org/33543
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index 8f4412a..f8244f5 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -1426,7 +1426,7 @@ bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet )
 SvtScriptType nNewType = SvtLanguageOptions::GetScriptTypeOfLanguage( 
eNewLocale );
 bool bNewCJK = bool( nNewType & SvtScriptType::ASIAN );
 SvtCompatibilityOptions aCompatOpts;
-aCompatOpts.SetDefault( COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE, 
!bNewCJK );
+aCompatOpts.SetDefault( SvtCompatibilityEntry::Index::ExpandWordSpace, 
!bNewCJK );
 }
 
 if(m_pDecimalSeparatorCB->IsValueChangedFromSaved())
diff --git a/include/unotools/compatibility.hxx 
b/include/unotools/compatibility.hxx
index 551627b..8d18092 100644
--- a/include/unotools/compatibility.hxx
+++ b/include/unotools/compatibility.hxx
@@ -19,54 +19,152 @@
 #ifndef INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
 #define INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
-enum CompatibilityOptions
-{
-COPT_USE_PRINTERDEVICE = 0,
-COPT_ADD_SPACING,
-COPT_ADD_SPACING_AT_PAGES,
-COPT_USE_OUR_TABSTOPS,
-COPT_NO_EXTLEADING,
-COPT_USE_LINESPACING,
-COPT_ADD_TABLESPACING,
-COPT_USE_OBJECTPOSITIONING,
-COPT_USE_OUR_TEXTWRAPPING,
-COPT_CONSIDER_WRAPPINGSTYLE,
-COPT_EXPAND_WORDSPACE,
-COPT_PROTECT_FORM,
-COPT_MS_WORD_COMP_TRAILING_BLANKS
-};
-
 
/*-
-@descr  The method GetList() returns a list of property values.
-Use follow defines to separate values by names.
+@descr  Struct to hold information about one compatibility entry
 
*//*-*/
-#define COMPATIBILITY_PROPERTYNAME_NAME "Name"
-#define COMPATIBILITY_PROPERTYNAME_MODULE   "Module"
-#define COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS"UsePrinterMetrics"
-#define COMPATIBILITY_PROPERTYNAME_ADDSPACING   "AddSpacing"
-#define COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES"AddSpacingAtPages"
-#define COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS   
"UseOurTabStopFormat"
-#define COMPATIBILITY_PROPERTYNAME_NOEXTLEADING "NoExternalLeading"
-#define COMPATIBILITY_PROPERTYNAME_USELINESPACING   "UseLineSpacing"
-#define COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING  "AddTableSpacing"
-#define COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING 
"UseObjectPositioning"
-#define COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING   
"UseOurTextWrapping"
-#define COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE
"ConsiderWrappingStyle"
-#define COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE  "ExpandWordSpace"
-#define COMPATIBILITY_PROPERTYNAME_PROTECTFORM  "ProtectForm"
-#define COMPATIBILITY_PROPERTYNAME_MSWORDTRAILINGBLANKS 
"MsWordCompTrailingBlanks"
-
-#define COMPATIBILITY_DEFAULT_NAME  "_default"
-
-//  forward declarations
+class UNOTOOLS_DLLPUBLIC SvtCompatibilityEntry
+{
+public:
+
/*-
+@descr  The method SvtCompatibilityOptions::GetList() 
returns a list of property values.
+Use follow enum class to separate values by names.
+Sync it with sPropertyName in 
SvtCompatibilityEntry::getName()
+
*//*-*/
+enum class Index
+{
+/* Should be in the start.