sc/inc/viewopti.hxx              |    2 
 sc/source/core/tool/viewopti.cxx |  152 +++++++++++++++++++++------------------
 2 files changed, 85 insertions(+), 69 deletions(-)

New commits:
commit 1e7c73f612d99f320390cbca4d83b32cec1075dc
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Feb 4 16:18:23 2025 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Tue Feb 4 20:26:41 2025 +0100

    make calc Display config listen for changes
    
    Change-Id: I36a9118f8a29ccd543da9510e9ecf11ebf02b2f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181131
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins

diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx
index 21c6b9f7f8fb..72553dcf81b9 100644
--- a/sc/inc/viewopti.hxx
+++ b/sc/inc/viewopti.hxx
@@ -163,9 +163,11 @@ class ScViewCfg : public ScViewOptions
 
     DECL_LINK( LayoutCommitHdl, ScLinkConfigItem&, void );
     DECL_LINK( DisplayCommitHdl, ScLinkConfigItem&, void );
+    DECL_LINK( DisplayNotifyHdl, ScLinkConfigItem&, void );
     DECL_LINK( GridCommitHdl, ScLinkConfigItem&, void );
     DECL_LINK( GridNotifyHdl, ScLinkConfigItem&, void );
 
+    void ReadDisplayCfg();
     void ReadGridCfg();
 
     static css::uno::Sequence<OUString> GetLayoutPropertyNames();
diff --git a/sc/source/core/tool/viewopti.cxx b/sc/source/core/tool/viewopti.cxx
index 5ec30bd7e7da..ac6c0390ebea 100644
--- a/sc/source/core/tool/viewopti.cxx
+++ b/sc/source/core/tool/viewopti.cxx
@@ -284,8 +284,6 @@ ScViewCfg::ScViewCfg() :
     aDisplayItem( CFGPATH_DISPLAY ),
     aGridItem( CFGPATH_GRID )
 {
-    sal_Int32 nIntVal = 0;
-
     Sequence<OUString> aNames = GetLayoutPropertyNames();
     Sequence<Any> aValues = aLayoutItem.GetProperties(aNames);
     aLayoutItem.EnableNotification(aNames);
@@ -346,73 +344,10 @@ ScViewCfg::ScViewCfg() :
     }
     aLayoutItem.SetCommitLink( LINK( this, ScViewCfg, LayoutCommitHdl ) );
 
-    aNames = GetDisplayPropertyNames();
-    aValues = aDisplayItem.GetProperties(aNames);
-    aDisplayItem.EnableNotification(aNames);
-    pValues = aValues.getConstArray();
-    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 SCDISPLAYOPT_FORMULA:
-                        SetOption( VOPT_FORMULAS, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
-                        break;
-                    case SCDISPLAYOPT_ZEROVALUE:
-                        SetOption( VOPT_NULLVALS, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
-                        break;
-                    case SCDISPLAYOPT_NOTETAG:
-                        SetOption( VOPT_NOTES, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
-                        break;
-                    case SCDISPLAYOPT_NOTEAUTHOR:
-                        SetOption( VOPT_NOTEAUTHOR, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
-                        break;
-                    case SCDISPLAYOPT_FORMULAMARK:
-                        SetOption( VOPT_FORMULAS_MARKS, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
-                        break;
-                    case SCDISPLAYOPT_VALUEHI:
-                        SetOption( VOPT_SYNTAX, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
-                        break;
-                    case SCDISPLAYOPT_ANCHOR:
-                        SetOption( VOPT_ANCHOR, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
-                        break;
-                    case SCDISPLAYOPT_OBJECTGRA:
-                        if ( pValues[nProp] >>= nIntVal )
-                        {
-                            //#i80528# adapt to new range eventually
-                            if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = 
sal_Int32(VOBJ_MODE_SHOW);
-
-                            SetObjMode( VOBJ_TYPE_OLE, 
static_cast<ScVObjMode>(nIntVal));
-                        }
-                        break;
-                    case SCDISPLAYOPT_CHART:
-                        if ( pValues[nProp] >>= nIntVal )
-                        {
-                            //#i80528# adapt to new range eventually
-                            if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = 
sal_Int32(VOBJ_MODE_SHOW);
-
-                            SetObjMode( VOBJ_TYPE_CHART, 
static_cast<ScVObjMode>(nIntVal));
-                        }
-                        break;
-                    case SCDISPLAYOPT_DRAWING:
-                        if ( pValues[nProp] >>= nIntVal )
-                        {
-                            //#i80528# adapt to new range eventually
-                            if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = 
sal_Int32(VOBJ_MODE_SHOW);
-
-                            SetObjMode( VOBJ_TYPE_DRAW, 
static_cast<ScVObjMode>(nIntVal));
-                        }
-                        break;
-                }
-            }
-        }
-    }
+    aDisplayItem.EnableNotification(GetDisplayPropertyNames());
+    ReadDisplayCfg();
     aDisplayItem.SetCommitLink( LINK( this, ScViewCfg, DisplayCommitHdl ) );
+    aDisplayItem.SetNotifyLink( LINK( this, ScViewCfg, DisplayNotifyHdl ) );
 
     aGridItem.EnableNotification(GetGridPropertyNames());
     ReadGridCfg();
@@ -471,6 +406,82 @@ IMPL_LINK_NOARG(ScViewCfg, LayoutCommitHdl, 
ScLinkConfigItem&, void)
     aLayoutItem.PutProperties(aNames, aValues);
 }
 
+void ScViewCfg::ReadDisplayCfg()
+{
+    const Sequence<OUString> aNames = GetDisplayPropertyNames();
+    const Sequence<Any> aValues = aDisplayItem.GetProperties(aNames);
+    OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties 
failed");
+    if (aValues.getLength() != aNames.getLength())
+        return;
+
+    sal_Int32 nIntVal = 0;
+
+    const Any* pValues = aValues.getConstArray();
+    for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+    {
+        OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
+        if(pValues[nProp].hasValue())
+        {
+            switch(nProp)
+            {
+                case SCDISPLAYOPT_FORMULA:
+                    SetOption( VOPT_FORMULAS, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
+                    break;
+                case SCDISPLAYOPT_ZEROVALUE:
+                    SetOption( VOPT_NULLVALS, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
+                    break;
+                case SCDISPLAYOPT_NOTETAG:
+                    SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( 
pValues[nProp] ) );
+                    break;
+                case SCDISPLAYOPT_NOTEAUTHOR:
+                    SetOption( VOPT_NOTEAUTHOR, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
+                    break;
+                case SCDISPLAYOPT_FORMULAMARK:
+                    SetOption( VOPT_FORMULAS_MARKS, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
+                    break;
+                case SCDISPLAYOPT_VALUEHI:
+                    SetOption( VOPT_SYNTAX, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
+                    break;
+                case SCDISPLAYOPT_ANCHOR:
+                    SetOption( VOPT_ANCHOR, 
ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
+                    break;
+                case SCDISPLAYOPT_OBJECTGRA:
+                    if ( pValues[nProp] >>= nIntVal )
+                    {
+                        //#i80528# adapt to new range eventually
+                        if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = 
sal_Int32(VOBJ_MODE_SHOW);
+
+                        SetObjMode( VOBJ_TYPE_OLE, 
static_cast<ScVObjMode>(nIntVal));
+                    }
+                    break;
+                case SCDISPLAYOPT_CHART:
+                    if ( pValues[nProp] >>= nIntVal )
+                    {
+                        //#i80528# adapt to new range eventually
+                        if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = 
sal_Int32(VOBJ_MODE_SHOW);
+
+                        SetObjMode( VOBJ_TYPE_CHART, 
static_cast<ScVObjMode>(nIntVal));
+                    }
+                    break;
+                case SCDISPLAYOPT_DRAWING:
+                    if ( pValues[nProp] >>= nIntVal )
+                    {
+                        //#i80528# adapt to new range eventually
+                        if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = 
sal_Int32(VOBJ_MODE_SHOW);
+
+                        SetObjMode( VOBJ_TYPE_DRAW, 
static_cast<ScVObjMode>(nIntVal));
+                    }
+                    break;
+            }
+        }
+    }
+}
+
+IMPL_LINK_NOARG(ScViewCfg, DisplayNotifyHdl, ScLinkConfigItem&, void)
+{
+    ReadDisplayCfg();
+}
+
 IMPL_LINK_NOARG(ScViewCfg, DisplayCommitHdl, ScLinkConfigItem&, void)
 {
     Sequence<OUString> aNames = GetDisplayPropertyNames();
@@ -567,7 +578,10 @@ void ScViewCfg::ReadGridCfg()
     SetGridOptions( aGrid );
 }
 
-IMPL_LINK_NOARG(ScViewCfg, GridNotifyHdl, ScLinkConfigItem&, void) { 
ReadGridCfg(); }
+IMPL_LINK_NOARG(ScViewCfg, GridNotifyHdl, ScLinkConfigItem&, void)
+{
+    ReadGridCfg();
+}
 
 IMPL_LINK_NOARG(ScViewCfg, GridCommitHdl, ScLinkConfigItem&, void)
 {

Reply via email to