sc/inc/viewopti.hxx | 3 + sc/source/core/tool/viewopti.cxx | 100 +++++++++++++++++++++------------------ 2 files changed, 59 insertions(+), 44 deletions(-)
New commits: commit 127659cda6f4f84e20dabce8a23546c61b448990 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed Nov 27 09:40:32 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Nov 27 12:50:33 2024 +0100 make calc Grid config listen for changes Change-Id: I1015adf6f8a270569e48b8e66b141ef37f217a1b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177400 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx index 5850df5ed375..2b0a7ef725af 100644 --- a/sc/inc/viewopti.hxx +++ b/sc/inc/viewopti.hxx @@ -163,6 +163,9 @@ class ScViewCfg : public ScViewOptions DECL_LINK( LayoutCommitHdl, ScLinkConfigItem&, void ); DECL_LINK( DisplayCommitHdl, ScLinkConfigItem&, void ); DECL_LINK( GridCommitHdl, ScLinkConfigItem&, void ); + DECL_LINK( GridNotifyHdl, ScLinkConfigItem&, void ); + + void ReadGridCfg(); static css::uno::Sequence<OUString> GetLayoutPropertyNames(); static css::uno::Sequence<OUString> GetDisplayPropertyNames(); diff --git a/sc/source/core/tool/viewopti.cxx b/sc/source/core/tool/viewopti.cxx index 657fee90dc2c..bd2f110640d3 100644 --- a/sc/source/core/tool/viewopti.cxx +++ b/sc/source/core/tool/viewopti.cxx @@ -414,51 +414,10 @@ ScViewCfg::ScViewCfg() : } aDisplayItem.SetCommitLink( LINK( this, ScViewCfg, DisplayCommitHdl ) ); - ScGridOptions aGrid = GetGridOptions(); //TODO: initialization necessary? - aNames = GetGridPropertyNames(); - aValues = aGridItem.GetProperties(aNames); - aGridItem.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 SCGRIDOPT_RESOLU_X: - if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDrawX( nIntVal ); - break; - case SCGRIDOPT_RESOLU_Y: - if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDrawY( nIntVal ); - break; - case SCGRIDOPT_SUBDIV_X: - if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDivisionX( nIntVal ); - break; - case SCGRIDOPT_SUBDIV_Y: - if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDivisionY( nIntVal ); - break; - case SCGRIDOPT_SNAPTOGRID: - aGrid.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); - break; - case SCGRIDOPT_SYNCHRON: - aGrid.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); - break; - case SCGRIDOPT_VISIBLE: - aGrid.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); - break; - case SCGRIDOPT_SIZETOGRID: - aGrid.SetEqualGrid( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); - break; - } - } - } - } - SetGridOptions( aGrid ); + aGridItem.EnableNotification(GetGridPropertyNames()); + ReadGridCfg(); aGridItem.SetCommitLink( LINK( this, ScViewCfg, GridCommitHdl ) ); + aGridItem.SetNotifyLink( LINK( this, ScViewCfg, GridNotifyHdl ) ); } IMPL_LINK_NOARG(ScViewCfg, LayoutCommitHdl, ScLinkConfigItem&, void) @@ -557,6 +516,59 @@ IMPL_LINK_NOARG(ScViewCfg, DisplayCommitHdl, ScLinkConfigItem&, void) aDisplayItem.PutProperties(aNames, aValues); } +void ScViewCfg::ReadGridCfg() +{ + const Sequence<OUString> aNames = GetGridPropertyNames(); + const Sequence<Any> aValues = aGridItem.GetProperties(aNames); + OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if (aValues.getLength() != aNames.getLength()) + return; + + sal_Int32 nIntVal = 0; + + ScGridOptions aGrid = GetGridOptions(); //TODO: initialization necessary? + 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 SCGRIDOPT_RESOLU_X: + if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDrawX( nIntVal ); + break; + case SCGRIDOPT_RESOLU_Y: + if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDrawY( nIntVal ); + break; + case SCGRIDOPT_SUBDIV_X: + if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDivisionX( nIntVal ); + break; + case SCGRIDOPT_SUBDIV_Y: + if (pValues[nProp] >>= nIntVal) aGrid.SetFieldDivisionY( nIntVal ); + break; + case SCGRIDOPT_SNAPTOGRID: + aGrid.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + case SCGRIDOPT_SYNCHRON: + aGrid.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + case SCGRIDOPT_VISIBLE: + aGrid.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + case SCGRIDOPT_SIZETOGRID: + aGrid.SetEqualGrid( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + } + } + } + + SetGridOptions( aGrid ); +} + +IMPL_LINK_NOARG(ScViewCfg, GridNotifyHdl, ScLinkConfigItem&, void) { ReadGridCfg(); } + IMPL_LINK_NOARG(ScViewCfg, GridCommitHdl, ScLinkConfigItem&, void) { const ScGridOptions& rGrid = GetGridOptions();