[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter' - sc/inc sc/source

Noel Power noel.power at suse.com
Mon Aug 12 07:18:04 PDT 2013


 sc/inc/formulaopt.hxx              |    3 +++
 sc/source/core/tool/formulaopt.cxx |   29 ++++++++++++++++++++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit 05e9a8f5fc208eef5c2d6d5bd0a3fd9ada214760
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 7584197..08a6f14 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 063deb9..e6966e1 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