[Libreoffice-commits] core.git: sc/inc sc/source
Noel Power
noel.power at suse.com
Mon Aug 12 06:59:47 PDT 2013
sc/inc/formulaopt.hxx | 3 +++
sc/source/core/tool/formulaopt.cxx | 29 ++++++++++++++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
New commits:
commit c193d8a8ed3709036b7aedab0341df75ffa4067e
Author: Noel Power <noel.power at suse.com>
Date: Mon Aug 12 14:55:45 2013 +0100
listen for formula related configuration changes
Change-Id: Ia95dea3fab6bffeb1967096888a07e610b9bd858
diff --git a/sc/inc/formulaopt.hxx b/sc/inc/formulaopt.hxx
index caa45ea..70e533a 100644
--- a/sc/inc/formulaopt.hxx
+++ b/sc/inc/formulaopt.hxx
@@ -104,7 +104,10 @@ private:
class ScFormulaCfg : public ScFormulaOptions, public utl::ConfigItem
{
+ typedef std::map<OUString,sal_uInt16> PropsToIds;
com::sun::star::uno::Sequence<OUString> GetPropertyNames();
+ ScFormulaCfg::PropsToIds GetPropNamesToId();
+ void UpdateFromProperties( const com::sun::star::uno::Sequence<OUString>& rNames );
public:
ScFormulaCfg();
diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
index db35f93..e56478c 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -230,21 +230,41 @@ Sequence<OUString> ScFormulaCfg::GetPropertyNames()
return aNames;
}
+ScFormulaCfg::PropsToIds ScFormulaCfg::GetPropNamesToId()
+{
+ Sequence<OUString> aPropNames = GetPropertyNames();
+ static sal_uInt16 aVals[] = { SCFORMULAOPT_GRAMMAR, SCFORMULAOPT_ENGLISH_FUNCNAME, SCFORMULAOPT_SEP_ARG, SCFORMULAOPT_SEP_ARRAY_ROW, SCFORMULAOPT_SEP_ARRAY_COL, SCFORMULAOPT_STRING_REF_SYNTAX, SCFORMULAOPT_EMPTY_STRING_AS_ZERO, SCFORMULAOPT_OOXML_RECALC, SCFORMULAOPT_ODF_RECALC, SCFORMULAOPT_OPENCL_ENABLED };
+ OSL_ENSURE( SAL_N_ELEMENTS(aVals) == aPropNames.getLength(), "Properties and ids are out of Sync");
+ PropsToIds aPropIdMap;
+ for ( sal_uInt16 i; i<aPropNames.getLength(); ++i )
+ aPropIdMap[aPropNames[i]] = aVals[ i ];
+ return aPropIdMap;
+}
+
ScFormulaCfg::ScFormulaCfg() :
ConfigItem( OUString( CFGPATH_FORMULA ) )
{
Sequence<OUString> aNames = GetPropertyNames();
+ UpdateFromProperties( aNames );
+ EnableNotification( aNames );
+}
+
+void ScFormulaCfg::UpdateFromProperties( const Sequence<OUString>& aNames )
+{
Sequence<Any> aValues = GetProperties(aNames);
const Any* pValues = aValues.getConstArray();
OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ PropsToIds aPropMap = GetPropNamesToId();
if(aValues.getLength() == aNames.getLength())
{
sal_Int32 nIntVal = 0;
for(int nProp = 0; nProp < aNames.getLength(); nProp++)
{
- if(pValues[nProp].hasValue())
+ PropsToIds::iterator it_end = aPropMap.end();
+ PropsToIds::iterator it = aPropMap.find( aNames[nProp] );
+ if(pValues[nProp].hasValue() && it != it_end )
{
- switch(nProp)
+ switch(it->second)
{
case SCFORMULAOPT_GRAMMAR:
{
@@ -519,6 +539,9 @@ void ScFormulaCfg::SetOptions( const ScFormulaOptions& rNew )
SetModified();
}
-void ScFormulaCfg::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+void ScFormulaCfg::Notify( const ::com::sun::star::uno::Sequence< OUString >& rNames)
+{
+ UpdateFromProperties( rNames );
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list