sc/inc/appoptio.hxx                       |   20 +
 sc/inc/optutil.hxx                        |    2 
 sc/source/core/tool/appoptio.cxx          |  424 ++++++++++++------------------
 sc/source/core/tool/optutil.cxx           |    7 
 sc/source/ui/app/scmod.cxx                |   14 
 test/source/sheet/globalsheetsettings.cxx |   49 ---
 6 files changed, 227 insertions(+), 289 deletions(-)

New commits:
commit 8810812e58f1b014d3156235c1ab5a2d6c73c828
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Nov 28 23:58:40 2021 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Nov 29 03:54:26 2021 +0100

    tdf#132145: Synchronize ScAppCfg with configuration
    
    Change-Id: Iadf5ff86d043f63355fd30816a9e2011479465c0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125990
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx
index 09e3a8455916..793dc707a67f 100644
--- a/sc/inc/appoptio.hxx
+++ b/sc/inc/appoptio.hxx
@@ -103,7 +103,7 @@ private:
 
 //  Config Item containing app options
 
-class ScAppCfg : public ScAppOptions
+class ScAppCfg : private ScAppOptions
 {
     //  spread about 5 config paths
     //! split ScAppOptions into different classes
@@ -116,6 +116,14 @@ class ScAppCfg : public ScAppOptions
     ScLinkConfigItem    aMiscItem;
     ScLinkConfigItem    aCompatItem;
 
+    void ReadLayoutCfg();
+    void ReadInputCfg();
+    void ReadRevisionCfg();
+    void ReadContentCfg();
+    void ReadSortListCfg();
+    void ReadMiscCfg();
+    void ReadCompatCfg();
+
     DECL_LINK( LayoutCommitHdl, ScLinkConfigItem&, void );
     DECL_LINK( InputCommitHdl, ScLinkConfigItem&, void );
     DECL_LINK( RevisionCommitHdl, ScLinkConfigItem&, void );
@@ -124,6 +132,14 @@ class ScAppCfg : public ScAppOptions
     DECL_LINK( MiscCommitHdl, ScLinkConfigItem&, void );
     DECL_LINK( CompatCommitHdl, ScLinkConfigItem&, void );
 
+    DECL_LINK( LayoutNotifyHdl, ScLinkConfigItem&, void );
+    DECL_LINK( InputNotifyHdl, ScLinkConfigItem&, void );
+    DECL_LINK( RevisionNotifyHdl, ScLinkConfigItem&, void );
+    DECL_LINK( ContentNotifyHdl, ScLinkConfigItem&, void );
+    DECL_LINK( SortListNotifyHdl, ScLinkConfigItem&, void );
+    DECL_LINK( MiscNotifyHdl, ScLinkConfigItem&, void );
+    DECL_LINK( CompatNotifyHdl, ScLinkConfigItem&, void );
+
     static css::uno::Sequence<OUString> GetLayoutPropertyNames();
     static css::uno::Sequence<OUString> GetInputPropertyNames();
     static css::uno::Sequence<OUString> GetRevisionPropertyNames();
@@ -135,8 +151,8 @@ class ScAppCfg : public ScAppOptions
 public:
             ScAppCfg();
 
+    const ScAppOptions& GetOptions() const { return *this; }
     void    SetOptions( const ScAppOptions& rNew );
-    void    OptionsChanged();   // after direct access to ScAppOptions base 
class
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/optutil.hxx b/sc/inc/optutil.hxx
index 65d199d859f4..8f31df90517b 100644
--- a/sc/inc/optutil.hxx
+++ b/sc/inc/optutil.hxx
@@ -37,11 +37,13 @@ public:
 class SC_DLLPUBLIC ScLinkConfigItem final : public utl::ConfigItem
 {
     Link<ScLinkConfigItem&,void>  aCommitLink;
+    Link<ScLinkConfigItem&,void>  aNotifyLink;
 
 public:
             ScLinkConfigItem( const OUString& rSubTree );
             ScLinkConfigItem( const OUString& rSubTree, ConfigItemMode nMode );
     void    SetCommitLink( const Link<ScLinkConfigItem&,void>& rLink );
+    void    SetNotifyLink( const Link<ScLinkConfigItem&,void>& rLink );
 
     virtual void    Notify( const css::uno::Sequence<OUString>& aPropertyNames 
) override;
     virtual void    ImplCommit() override;
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index df16580e2e2b..244f4ffc777e 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -24,7 +24,7 @@
 #include <userlist.hxx>
 #include <formula/compiler.hxx>
 #include <miscuno.hxx>
-#include <memory>
+#include <vector>
 #include <osl/diagnose.h>
 
 using namespace utl;
@@ -121,24 +121,6 @@ void ScAppOptions::SetLRUFuncList( const sal_uInt16* 
pList, const sal_uInt16 nCo
 
 //  Config Item containing app options
 
-static void lcl_SetLastFunctions( ScAppOptions& rOpt, const Any& rValue )
-{
-    Sequence<sal_Int32> aSeq;
-    if ( !(rValue >>= aSeq) )
-        return;
-
-    sal_Int32 nCount = aSeq.getLength();
-    if ( nCount < SAL_MAX_UINT16 )
-    {
-        const sal_Int32* pArray = aSeq.getConstArray();
-        std::unique_ptr<sal_uInt16[]> pUShorts(new sal_uInt16[nCount]);
-        for (sal_Int32 i=0; i<nCount; i++)
-            pUShorts[i] = static_cast<sal_uInt16>(pArray[i]);
-
-        rOpt.SetLRUFuncList( pUShorts.get(), 
sal::static_int_cast<sal_uInt16>(nCount) );
-    }
-}
-
 static void lcl_GetLastFunctions( Any& rDest, const ScAppOptions& rOpt )
 {
     tools::Long nCount = rOpt.GetLRUFuncListCount();
@@ -155,34 +137,6 @@ static void lcl_GetLastFunctions( Any& rDest, const 
ScAppOptions& rOpt )
         rDest <<= Sequence<sal_Int32>(0);   // empty
 }
 
-static void lcl_SetSortList( const Any& rValue )
-{
-    Sequence<OUString> aSeq;
-    if ( !(rValue >>= aSeq) )
-        return;
-
-    tools::Long nCount = aSeq.getLength();
-    const OUString* pArray = aSeq.getConstArray();
-    ScUserList aList;
-
-    //  if setting is "default", keep default values from ScUserList ctor
-    //TODO: mark "default" in a safe way
-    bool bDefault = ( nCount == 1 && pArray[0] == "NULL" );
-
-    if (!bDefault)
-    {
-        aList.clear();
-
-        for (const auto& rStr : std::as_const(aSeq))
-        {
-            ScUserListData* pNew = new ScUserListData( rStr );
-            aList.push_back(pNew);
-        }
-    }
-
-    ScGlobal::SetUserList( &aList );
-}
-
 static void lcl_GetSortList( Any& rDest )
 {
     const ScUserList* pUserList = ScGlobal::GetUserList();
@@ -316,227 +270,191 @@ ScAppCfg::ScAppCfg() :
     aMiscItem( CFGPATH_MISC ),
     aCompatItem( CFGPATH_COMPAT )
 {
-    sal_Int32 nIntVal = 0;
+    aLayoutItem.EnableNotification(GetLayoutPropertyNames());
+    ReadLayoutCfg();
+    aLayoutItem.SetCommitLink( LINK( this, ScAppCfg, LayoutCommitHdl ) );
+    aLayoutItem.SetNotifyLink( LINK( this, ScAppCfg, LayoutNotifyHdl ) );
 
-    Sequence<OUString> aNames;
-    Sequence<Any> aValues;
-    const Any* pValues = nullptr;
+    aInputItem.EnableNotification(GetInputPropertyNames());
+    ReadInputCfg();
+    aInputItem.SetCommitLink( LINK( this, ScAppCfg, InputCommitHdl ) );
+    aInputItem.SetNotifyLink( LINK( this, ScAppCfg, InputNotifyHdl ) );
 
-    aNames = GetLayoutPropertyNames();
-    aValues = aLayoutItem.GetProperties(aNames);
-    aLayoutItem.EnableNotification(aNames);
-    pValues = aValues.getConstArray();
+    aRevisionItem.EnableNotification(GetRevisionPropertyNames());
+    ReadRevisionCfg();
+    aRevisionItem.SetCommitLink( LINK( this, ScAppCfg, RevisionCommitHdl ) );
+    aRevisionItem.SetNotifyLink( LINK( this, ScAppCfg, RevisionNotifyHdl ) );
+
+    aContentItem.EnableNotification(GetContentPropertyNames());
+    ReadContentCfg();
+    aContentItem.SetCommitLink( LINK( this, ScAppCfg, ContentCommitHdl ) );
+    aContentItem.SetNotifyLink( LINK( this, ScAppCfg, ContentNotifyHdl ) );
+
+    aSortListItem.EnableNotification(GetSortListPropertyNames());
+    ReadSortListCfg();
+    aSortListItem.SetCommitLink( LINK( this, ScAppCfg, SortListCommitHdl ) );
+    aSortListItem.SetNotifyLink( LINK( this, ScAppCfg, SortListNotifyHdl ) );
+
+    aMiscItem.EnableNotification(GetMiscPropertyNames());
+    ReadMiscCfg();
+    aMiscItem.SetCommitLink( LINK( this, ScAppCfg, MiscCommitHdl ) );
+    aMiscItem.SetNotifyLink( LINK( this, ScAppCfg, MiscNotifyHdl ) );
+
+    aCompatItem.EnableNotification(GetCompatPropertyNames());
+    ReadCompatCfg();
+    aCompatItem.SetCommitLink( LINK(this, ScAppCfg, CompatCommitHdl) );
+    aCompatItem.SetNotifyLink( LINK(this, ScAppCfg, CompatNotifyHdl) );
+}
+
+void ScAppCfg::ReadLayoutCfg()
+{
+    const Sequence<OUString> aNames = GetLayoutPropertyNames();
+    const Sequence<Any> aValues = aLayoutItem.GetProperties(aNames);
     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties 
failed");
-    if(aValues.getLength() == aNames.getLength())
-    {
-        sal_uInt32 nStatusBarFuncSingle = 0;
-        sal_uInt32 nStatusBarFuncMulti = 0;
-        sal_uInt32 nUIntValTmp = 0;
-        for(int nProp = 0; nProp < aNames.getLength(); nProp++)
-        {
-            OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
-            if(pValues[nProp].hasValue())
-            {
-                switch(nProp)
-                {
-                    case SCLAYOUTOPT_MEASURE:
-                        if (pValues[nProp] >>= nIntVal) SetAppMetric( 
static_cast<FieldUnit>(nIntVal) );
-                        break;
-                    case SCLAYOUTOPT_STATUSBAR:
-                        if ( pValues[SCLAYOUTOPT_STATUSBAR] >>= nUIntValTmp )
-                            nStatusBarFuncSingle = nUIntValTmp;
-                        break;
-                    case SCLAYOUTOPT_STATUSBARMULTI:
-                        if ( pValues[SCLAYOUTOPT_STATUSBARMULTI] >>= 
nUIntValTmp )
-                            nStatusBarFuncMulti = nUIntValTmp;
-                        break;
-                    case SCLAYOUTOPT_ZOOMVAL:
-                        if (pValues[nProp] >>= nIntVal) SetZoom( 
static_cast<sal_uInt16>(nIntVal) );
-                        break;
-                    case SCLAYOUTOPT_ZOOMTYPE:
-                        if (pValues[nProp] >>= nIntVal) SetZoomType( 
static_cast<SvxZoomType>(nIntVal) );
-                        break;
-                    case SCLAYOUTOPT_SYNCZOOM:
-                        SetSynchronizeZoom( 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
-                        break;
-                }
-            }
-        }
+    if (aValues.getLength() != aNames.getLength())
+        return;
 
-        if ( nStatusBarFuncMulti != SCLAYOUTOPT_STATUSBARMULTI_DEFAULTVAL )
-            SetStatusFunc( nStatusBarFuncMulti );
-        else if ( nStatusBarFuncSingle != SCLAYOUTOPT_STATUSBAR_DEFAULTVAL &&
-                  nStatusBarFuncSingle != 
SCLAYOUTOPT_STATUSBAR_DEFAULTVAL_LEGACY )
-        {
-            if ( nStatusBarFuncSingle )
-                SetStatusFunc( 1 << nStatusBarFuncSingle );
-            else
-                SetStatusFunc( 0 );
-        }
+    sal_uInt32 nStatusBarFuncSingle = 0;
+    sal_uInt32 nStatusBarFuncMulti = 0;
+
+    if (sal_Int32 nIntVal; aValues[SCLAYOUTOPT_MEASURE] >>= nIntVal)
+        SetAppMetric(static_cast<FieldUnit>(nIntVal));
+    if (sal_uInt32 nUIntVal; aValues[SCLAYOUTOPT_STATUSBAR] >>= nUIntVal)
+        nStatusBarFuncSingle = nUIntVal;
+    if (sal_uInt32 nUIntVal; aValues[SCLAYOUTOPT_STATUSBARMULTI] >>= nUIntVal)
+        nStatusBarFuncMulti = nUIntVal;
+    if (sal_Int32 nIntVal; aValues[SCLAYOUTOPT_ZOOMVAL] >>= nIntVal)
+        SetZoom(static_cast<sal_uInt16>(nIntVal));
+    if (sal_Int32 nIntVal; aValues[SCLAYOUTOPT_ZOOMTYPE] >>= nIntVal)
+        SetZoomType(static_cast<SvxZoomType>(nIntVal));
+    
SetSynchronizeZoom(ScUnoHelpFunctions::GetBoolFromAny(aValues[SCLAYOUTOPT_SYNCZOOM]));
+
+    if (nStatusBarFuncMulti != SCLAYOUTOPT_STATUSBARMULTI_DEFAULTVAL)
+        SetStatusFunc(nStatusBarFuncMulti);
+    else if (nStatusBarFuncSingle != SCLAYOUTOPT_STATUSBAR_DEFAULTVAL
+             && nStatusBarFuncSingle != 
SCLAYOUTOPT_STATUSBAR_DEFAULTVAL_LEGACY)
+    {
+        if (nStatusBarFuncSingle)
+            SetStatusFunc(1 << nStatusBarFuncSingle);
         else
-            SetStatusFunc( SCLAYOUTOPT_STATUSBARMULTI_DEFAULTVAL );
+            SetStatusFunc(0);
     }
-    aLayoutItem.SetCommitLink( LINK( this, ScAppCfg, LayoutCommitHdl ) );
+    else
+        SetStatusFunc(SCLAYOUTOPT_STATUSBARMULTI_DEFAULTVAL);
+}
 
-    aNames = GetInputPropertyNames();
-    aValues = aInputItem.GetProperties(aNames);
-    aInputItem.EnableNotification(aNames);
-    pValues = aValues.getConstArray();
+void ScAppCfg::ReadInputCfg()
+{
+    const Sequence<OUString> aNames = GetInputPropertyNames();
+    const Sequence<Any> aValues = aInputItem.GetProperties(aNames);
     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties 
failed");
-    if(aValues.getLength() == aNames.getLength())
+    if (aValues.getLength() != aNames.getLength())
+        return;
+
+    if (Sequence<sal_Int32> aSeq; aValues[SCINPUTOPT_LASTFUNCS] >>= aSeq)
     {
-        for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+        sal_Int32 nCount = aSeq.getLength();
+        if (nCount < SAL_MAX_UINT16)
         {
-            OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
-            if(pValues[nProp].hasValue())
-            {
-                switch(nProp)
-                {
-                    case SCINPUTOPT_LASTFUNCS:
-                        lcl_SetLastFunctions( *this, pValues[nProp] );
-                        break;
-                    case SCINPUTOPT_AUTOINPUT:
-                        SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( 
pValues[nProp] ) );
-                        break;
-                    case SCINPUTOPT_DET_AUTO:
-                        SetDetectiveAuto( ScUnoHelpFunctions::GetBoolFromAny( 
pValues[nProp] ) );
-                        break;
-                }
-            }
+            std::vector<sal_uInt16> pUShorts(nCount);
+            for (sal_Int32 i = 0; i < nCount; i++)
+                pUShorts[i] = aSeq[i];
+
+            SetLRUFuncList(pUShorts.data(), nCount);
         }
     }
-    aInputItem.SetCommitLink( LINK( this, ScAppCfg, InputCommitHdl ) );
+    
SetAutoComplete(ScUnoHelpFunctions::GetBoolFromAny(aValues[SCINPUTOPT_AUTOINPUT]));
+    
SetDetectiveAuto(ScUnoHelpFunctions::GetBoolFromAny(aValues[SCINPUTOPT_DET_AUTO]));
+}
 
-    aNames = GetRevisionPropertyNames();
-    aValues = aRevisionItem.GetProperties(aNames);
-    aRevisionItem.EnableNotification(aNames);
-    pValues = aValues.getConstArray();
+void ScAppCfg::ReadRevisionCfg()
+{
+    const Sequence<OUString> aNames = GetRevisionPropertyNames();
+    const Sequence<Any> aValues = aRevisionItem.GetProperties(aNames);
     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties 
failed");
-    if(aValues.getLength() == aNames.getLength())
-    {
-        for(int nProp = 0; nProp < aNames.getLength(); nProp++)
-        {
-            OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
-            if(pValues[nProp].hasValue())
-            {
-                switch(nProp)
-                {
-                    case SCREVISOPT_CHANGE:
-                        if (pValues[nProp] >>= nIntVal) SetTrackContentColor( 
Color(ColorTransparency, nIntVal) );
-                        break;
-                    case SCREVISOPT_INSERTION:
-                        if (pValues[nProp] >>= nIntVal) SetTrackInsertColor( 
Color(ColorTransparency, nIntVal) );
-                        break;
-                    case SCREVISOPT_DELETION:
-                        if (pValues[nProp] >>= nIntVal) SetTrackDeleteColor( 
Color(ColorTransparency, nIntVal) );
-                        break;
-                    case SCREVISOPT_MOVEDENTRY:
-                        if (pValues[nProp] >>= nIntVal) SetTrackMoveColor( 
Color(ColorTransparency, nIntVal) );
-                        break;
-                }
-            }
-        }
-    }
-    aRevisionItem.SetCommitLink( LINK( this, ScAppCfg, RevisionCommitHdl ) );
+    if (aValues.getLength() != aNames.getLength())
+        return;
+
+    if (sal_Int32 nIntVal; aValues[SCREVISOPT_CHANGE] >>= nIntVal)
+        SetTrackContentColor(Color(ColorTransparency, nIntVal));
+    if (sal_Int32 nIntVal; aValues[SCREVISOPT_INSERTION] >>= nIntVal)
+        SetTrackInsertColor(Color(ColorTransparency, nIntVal));
+    if (sal_Int32 nIntVal; aValues[SCREVISOPT_DELETION] >>= nIntVal)
+        SetTrackDeleteColor(Color(ColorTransparency, nIntVal));
+    if (sal_Int32 nIntVal; aValues[SCREVISOPT_MOVEDENTRY] >>= nIntVal)
+        SetTrackMoveColor(Color(ColorTransparency, nIntVal));
+}
 
-    aNames = GetContentPropertyNames();
-    aValues = aContentItem.GetProperties(aNames);
-    aContentItem.EnableNotification(aNames);
-    pValues = aValues.getConstArray();
+void ScAppCfg::ReadContentCfg()
+{
+    const Sequence<OUString> aNames = GetContentPropertyNames();
+    const Sequence<Any> aValues = aContentItem.GetProperties(aNames);
     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties 
failed");
-    if(aValues.getLength() == aNames.getLength())
-    {
-        for(int nProp = 0; nProp < aNames.getLength(); nProp++)
-        {
-            OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
-            if(pValues[nProp].hasValue())
-            {
-                switch(nProp)
-                {
-                    case SCCONTENTOPT_LINK:
-                        if (pValues[nProp] >>= nIntVal) SetLinkMode( 
static_cast<ScLkUpdMode>(nIntVal) );
-                        break;
-                }
-            }
-        }
-    }
-    aContentItem.SetCommitLink( LINK( this, ScAppCfg, ContentCommitHdl ) );
+    if (aValues.getLength() != aNames.getLength())
+        return;
+
+    if (sal_Int32 nIntVal; aValues[SCCONTENTOPT_LINK] >>= nIntVal)
+        SetLinkMode(static_cast<ScLkUpdMode>(nIntVal));
+}
 
-    aNames = GetSortListPropertyNames();
-    aValues = aSortListItem.GetProperties(aNames);
-    aSortListItem.EnableNotification(aNames);
-    pValues = aValues.getConstArray();
+void ScAppCfg::ReadSortListCfg()
+{
+    const Sequence<OUString> aNames = GetSortListPropertyNames();
+    const Sequence<Any> aValues = aSortListItem.GetProperties(aNames);
     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties 
failed");
-    if(aValues.getLength() == aNames.getLength())
+    if (aValues.getLength() != aNames.getLength())
+        return;
+
+    if (Sequence<OUString> aSeq; aValues[SCSORTLISTOPT_LIST] >>= aSeq)
     {
-        for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+        ScUserList aList;
+
+        //  if setting is "default", keep default values from ScUserList ctor
+        //TODO: mark "default" in a safe way
+        const bool bDefault = (aSeq.getLength() == 1 && aSeq[0] == "NULL");
+
+        if (!bDefault)
         {
-            OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
-            if(pValues[nProp].hasValue())
+            for (const OUString& rStr : std::as_const(aSeq))
             {
-                switch(nProp)
-                {
-                    case SCSORTLISTOPT_LIST:
-                        lcl_SetSortList( pValues[nProp] );
-                        break;
-                }
+                ScUserListData* pNew = new ScUserListData(rStr);
+                aList.push_back(pNew);
             }
         }
+
+        ScGlobal::SetUserList(&aList);
     }
-    aSortListItem.SetCommitLink( LINK( this, ScAppCfg, SortListCommitHdl ) );
+}
 
-    aNames = GetMiscPropertyNames();
-    aValues = aMiscItem.GetProperties(aNames);
-    aMiscItem.EnableNotification(aNames);
-    pValues = aValues.getConstArray();
+void ScAppCfg::ReadMiscCfg()
+{
+    const Sequence<OUString> aNames = GetMiscPropertyNames();
+    const Sequence<Any> aValues = aMiscItem.GetProperties(aNames);
     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties 
failed");
-    if(aValues.getLength() == aNames.getLength())
-    {
-        for(int nProp = 0; nProp < aNames.getLength(); nProp++)
-        {
-            OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
-            if(pValues[nProp].hasValue())
-            {
-                switch(nProp)
-                {
-                    case SCMISCOPT_DEFOBJWIDTH:
-                        if (pValues[nProp] >>= nIntVal) 
SetDefaultObjectSizeWidth( nIntVal );
-                        break;
-                    case SCMISCOPT_DEFOBJHEIGHT:
-                        if (pValues[nProp] >>= nIntVal) 
SetDefaultObjectSizeHeight( nIntVal );
-                        break;
-                    case SCMISCOPT_SHOWSHAREDDOCWARN:
-                        SetShowSharedDocumentWarning( 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
-                        break;
-                }
-            }
-        }
-    }
-    aMiscItem.SetCommitLink( LINK( this, ScAppCfg, MiscCommitHdl ) );
+    if (aValues.getLength() != aNames.getLength())
+        return;
 
-    aNames = GetCompatPropertyNames();
-    aValues = aCompatItem.GetProperties(aNames);
-    aCompatItem.EnableNotification(aNames);
-    pValues = aValues.getConstArray();
-    if (aValues.getLength() == aNames.getLength())
-    {
-        for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
-        {
-            switch (nProp)
-            {
-                case SCCOMPATOPT_KEY_BINDING:
-                {
-                    nIntVal = 0; // 0 = 'Default'
-                    pValues[nProp] >>= nIntVal;
-                    
SetKeyBindingType(static_cast<ScOptionsUtil::KeyBindingType>(nIntVal));
-                }
-                break;
-            }
-        }
-    }
-    aCompatItem.SetCommitLink( LINK(this, ScAppCfg, CompatCommitHdl) );
+    if (sal_Int32 nIntVal; aValues[SCMISCOPT_DEFOBJWIDTH] >>= nIntVal)
+        SetDefaultObjectSizeWidth(nIntVal);
+    if (sal_Int32 nIntVal; aValues[SCMISCOPT_DEFOBJHEIGHT] >>= nIntVal)
+        SetDefaultObjectSizeHeight(nIntVal);
+    SetShowSharedDocumentWarning(
+        
ScUnoHelpFunctions::GetBoolFromAny(aValues[SCMISCOPT_SHOWSHAREDDOCWARN]));
 }
- IMPL_LINK_NOARG(ScAppCfg, LayoutCommitHdl, ScLinkConfigItem&, void)
+
+void ScAppCfg::ReadCompatCfg()
+{
+    const Sequence<OUString> aNames = GetCompatPropertyNames();
+    const Sequence<Any> aValues = aCompatItem.GetProperties(aNames);
+    if (aValues.getLength() != aNames.getLength())
+        return;
+
+    sal_Int32 nIntVal = 0; // 0 = 'Default'
+    aValues[SCCOMPATOPT_KEY_BINDING] >>= nIntVal;
+    SetKeyBindingType(static_cast<ScOptionsUtil::KeyBindingType>(nIntVal));
+}
+
+IMPL_LINK_NOARG(ScAppCfg, LayoutCommitHdl, ScLinkConfigItem&, void)
 {
     Sequence<OUString> aNames = GetLayoutPropertyNames();
     Sequence<Any> aValues(aNames.getLength());
@@ -569,6 +487,8 @@ ScAppCfg::ScAppCfg() :
     aLayoutItem.PutProperties(aNames, aValues);
 }
 
+IMPL_LINK_NOARG(ScAppCfg, LayoutNotifyHdl, ScLinkConfigItem&, void) { 
ReadLayoutCfg(); }
+
 IMPL_LINK_NOARG(ScAppCfg, InputCommitHdl, ScLinkConfigItem&, void)
 {
     Sequence<OUString> aNames = GetInputPropertyNames();
@@ -593,6 +513,8 @@ IMPL_LINK_NOARG(ScAppCfg, InputCommitHdl, 
ScLinkConfigItem&, void)
     aInputItem.PutProperties(aNames, aValues);
 }
 
+IMPL_LINK_NOARG(ScAppCfg, InputNotifyHdl, ScLinkConfigItem&, void) { 
ReadInputCfg(); }
+
 IMPL_LINK_NOARG(ScAppCfg, RevisionCommitHdl, ScLinkConfigItem&, void)
 {
     Sequence<OUString> aNames = GetRevisionPropertyNames();
@@ -620,6 +542,8 @@ IMPL_LINK_NOARG(ScAppCfg, RevisionCommitHdl, 
ScLinkConfigItem&, void)
     aRevisionItem.PutProperties(aNames, aValues);
 }
 
+IMPL_LINK_NOARG(ScAppCfg, RevisionNotifyHdl, ScLinkConfigItem&, void) { 
ReadRevisionCfg(); }
+
 IMPL_LINK_NOARG(ScAppCfg, ContentCommitHdl, ScLinkConfigItem&, void)
 {
     Sequence<OUString> aNames = GetContentPropertyNames();
@@ -638,6 +562,8 @@ IMPL_LINK_NOARG(ScAppCfg, ContentCommitHdl, 
ScLinkConfigItem&, void)
     aContentItem.PutProperties(aNames, aValues);
 }
 
+IMPL_LINK_NOARG(ScAppCfg, ContentNotifyHdl, ScLinkConfigItem&, void) { 
ReadContentCfg(); }
+
 IMPL_LINK_NOARG(ScAppCfg, SortListCommitHdl, ScLinkConfigItem&, void)
 {
     Sequence<OUString> aNames = GetSortListPropertyNames();
@@ -656,6 +582,8 @@ IMPL_LINK_NOARG(ScAppCfg, SortListCommitHdl, 
ScLinkConfigItem&, void)
     aSortListItem.PutProperties(aNames, aValues);
 }
 
+IMPL_LINK_NOARG(ScAppCfg, SortListNotifyHdl, ScLinkConfigItem&, void) { 
ReadSortListCfg(); }
+
 IMPL_LINK_NOARG(ScAppCfg, MiscCommitHdl, ScLinkConfigItem&, void)
 {
     Sequence<OUString> aNames = GetMiscPropertyNames();
@@ -680,6 +608,8 @@ IMPL_LINK_NOARG(ScAppCfg, MiscCommitHdl, ScLinkConfigItem&, 
void)
     aMiscItem.PutProperties(aNames, aValues);
 }
 
+IMPL_LINK_NOARG(ScAppCfg, MiscNotifyHdl, ScLinkConfigItem&, void) { 
ReadMiscCfg(); }
+
 IMPL_LINK_NOARG(ScAppCfg, CompatCommitHdl, ScLinkConfigItem&, void)
 {
     Sequence<OUString> aNames = GetCompatPropertyNames();
@@ -698,14 +628,12 @@ IMPL_LINK_NOARG(ScAppCfg, CompatCommitHdl, 
ScLinkConfigItem&, void)
     aCompatItem.PutProperties(aNames, aValues);
 }
 
+IMPL_LINK_NOARG(ScAppCfg, CompatNotifyHdl, ScLinkConfigItem&, void) { 
ReadCompatCfg(); }
+
 void ScAppCfg::SetOptions( const ScAppOptions& rNew )
 {
     *static_cast<ScAppOptions*>(this) = rNew;
-    OptionsChanged();
-}
 
-void ScAppCfg::OptionsChanged()
-{
     aLayoutItem.SetModified();
     aInputItem.SetModified();
     aRevisionItem.SetModified();
@@ -713,6 +641,14 @@ void ScAppCfg::OptionsChanged()
     aSortListItem.SetModified();
     aMiscItem.SetModified();
     aCompatItem.SetModified();
+
+    aLayoutItem.Commit();
+    aInputItem.Commit();
+    aRevisionItem.Commit();
+    aContentItem.Commit();
+    aSortListItem.Commit();
+    aMiscItem.Commit();
+    aCompatItem.Commit();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/optutil.cxx b/sc/source/core/tool/optutil.cxx
index 2d32b9814e5d..8f3e1fec9d93 100644
--- a/sc/source/core/tool/optutil.cxx
+++ b/sc/source/core/tool/optutil.cxx
@@ -49,9 +49,14 @@ void ScLinkConfigItem::SetCommitLink( const 
Link<ScLinkConfigItem&,void>& rLink
     aCommitLink = rLink;
 }
 
+void ScLinkConfigItem::SetNotifyLink( const Link<ScLinkConfigItem&,void>& 
rLink )
+{
+    aNotifyLink = rLink;
+}
+
 void ScLinkConfigItem::Notify( const css::uno::Sequence<OUString>& /* 
aPropertyNames */ )
 {
-    //TODO: not implemented yet...
+    aNotifyLink.Call(*this);
 }
 
 void ScLinkConfigItem::ImplCommit()
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 2a3685488cb9..8463e67618a0 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -729,7 +729,7 @@ const ScAppOptions& ScModule::GetAppOptions()
     if ( !m_pAppCfg )
         m_pAppCfg.reset( new ScAppCfg );
 
-    return *m_pAppCfg;
+    return m_pAppCfg->GetOptions();
 }
 
 void ScModule::SetDefaultsOptions( const ScDefaultsOptions& rOpt )
@@ -898,11 +898,13 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
 
     //  SfxGetpApp()->SetOptions( rOptSet );
 
+    ScAppOptions aAppOptions = m_pAppCfg->GetOptions();
+
     // No more linguistics
     if (rOptSet.HasItem(SID_ATTR_METRIC, &pItem))
     {
         PutItem( *pItem );
-        m_pAppCfg->SetAppMetric( static_cast<FieldUnit>(static_cast<const 
SfxUInt16Item*>(pItem)->GetValue()) );
+        aAppOptions.SetAppMetric( static_cast<FieldUnit>(static_cast<const 
SfxUInt16Item*>(pItem)->GetValue()) );
         bSaveAppOptions = true;
     }
 
@@ -914,18 +916,18 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
 
     if (rOptSet.HasItem(SID_SC_OPT_SYNCZOOM, &pItem))
     {
-        m_pAppCfg->SetSynchronizeZoom( static_cast<const 
SfxBoolItem*>(pItem)->GetValue() );
+        aAppOptions.SetSynchronizeZoom( static_cast<const 
SfxBoolItem*>(pItem)->GetValue() );
         bSaveAppOptions = true;
     }
 
     if (rOptSet.HasItem(SID_SC_OPT_KEY_BINDING_COMPAT, &pItem))
     {
         sal_uInt16 nVal = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
-        ScOptionsUtil::KeyBindingType eOld = m_pAppCfg->GetKeyBindingType();
+        ScOptionsUtil::KeyBindingType eOld = aAppOptions.GetKeyBindingType();
         ScOptionsUtil::KeyBindingType eNew = 
static_cast<ScOptionsUtil::KeyBindingType>(nVal);
         if (eOld != eNew)
         {
-            m_pAppCfg->SetKeyBindingType(eNew);
+            aAppOptions.SetKeyBindingType(eNew);
             bSaveAppOptions = true;
             ScDocShell::ResetKeyBindings(eNew);
         }
@@ -1210,7 +1212,7 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
     }
 
     if ( bSaveAppOptions )
-        m_pAppCfg->OptionsChanged();
+        m_pAppCfg->SetOptions(aAppOptions);
 
     if ( bSaveInputOptions )
         m_pInputCfg->SetOptions(aInputOptions);
diff --git a/test/source/sheet/globalsheetsettings.cxx 
b/test/source/sheet/globalsheetsettings.cxx
index b707a770f921..c1e527158794 100644
--- a/test/source/sheet/globalsheetsettings.cxx
+++ b/test/source/sheet/globalsheetsettings.cxx
@@ -83,18 +83,21 @@ void 
GlobalSheetSettings::testGlobalSheetSettingsProperties()
     DoCheck("UsePrinterMetrics", false, true, node, "UsePrinterMetrics");
     DoCheck("ReplaceCellsWarning", true, false, node, "ReplaceCellsWarning");
 
-    OUString propName;
-    uno::Any aNewValue;
+    node = "/org.openoffice.Office.Calc/Layout/Other/MeasureUnit";
+    DoCheck("Metric", sal_Int16(8), sal_Int16(1), node, "NonMetric"); // Test 
uses en-US locale
 
-    propName = "Metric";
-    sal_Int16 aMetric = 42;
-    CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= 
aMetric);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue Metric", 
sal_Int16(8), aMetric);
+    node = "/org.openoffice.Office.Calc/Input";
+    DoCheck("DoAutoComplete", true, false, node, "AutoInput");
 
-    aNewValue <<= sal_Int16(1);
-    xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
-    CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= 
aMetric);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Metric", 
sal_Int16(1), aMetric);
+    node = "/org.openoffice.Office.Calc/Content/Update";
+    DoCheck("LinkUpdateMode", sal_Int16(2), sal_Int16(1), node, "Link");
+
+    node = "/org.openoffice.Office.Calc/Print/";
+    DoCheck("PrintAllSheets", false, true, node + "Other", "AllSheets");
+    DoCheck("PrintEmptyPages", false, true, node + "Page", "EmptyPages");
+
+    OUString propName;
+    uno::Any aNewValue;
 
     propName = "Scale";
     sal_Int16 aScale = 42;
@@ -106,16 +109,6 @@ void 
GlobalSheetSettings::testGlobalSheetSettingsProperties()
     CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= 
aScale);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Scale", 
sal_Int16(-1), aScale);
 
-    propName = "DoAutoComplete";
-    bool aDoAutoComplete = false;
-    CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= 
aDoAutoComplete);
-    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue DoAutoComplete", 
aDoAutoComplete);
-
-    aNewValue <<= false;
-    xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
-    CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= 
aDoAutoComplete);
-    CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue DoAutoComplete", 
!aDoAutoComplete);
-
     propName = "StatusBarFunction";
     sal_Int16 aStatusBarFunction = 42;
     CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= 
aStatusBarFunction);
@@ -151,22 +144,6 @@ void 
GlobalSheetSettings::testGlobalSheetSettingsProperties()
     xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
     CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= 
aUserLists);
     CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue UserLists", 
!aUserLists.hasElements());
-
-    propName = "LinkUpdateMode";
-    sal_Int16 aLinkUpdateMode = 42;
-    CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= 
aLinkUpdateMode);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue LinkUpdateMode", 
sal_Int16(2),
-                                 aLinkUpdateMode);
-
-    aNewValue <<= sal_Int16(1);
-    xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
-    CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= 
aLinkUpdateMode);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue LinkUpdateMode", 
sal_Int16(1),
-                                 aLinkUpdateMode);
-
-    node = "/org.openoffice.Office.Calc/Print/";
-    DoCheck("PrintAllSheets", false, true, node + "Other", "AllSheets");
-    DoCheck("PrintEmptyPages", false, true, node + "Page", "EmptyPages");
 }
 }
 

Reply via email to