[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Thu Mar 6 06:36:38 PST 2014


 sc/inc/formulagroup.hxx              |    3 ++
 sc/source/core/data/formulacell.cxx  |   44 ++++++++++++-----------------------
 sc/source/core/tool/formulagroup.cxx |    4 +++
 3 files changed, 23 insertions(+), 28 deletions(-)

New commits:
commit f62b4b6e45aa20b1b97d2ec0a0da5f9beb738d46
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Mar 5 18:47:07 2014 -0500

    Fix incorrect group calc state check.
    
    And the code in the else block is pretty dangerous as it passes an empty
    token array to the group interpreter whose effect is entirely unpredictable.
    
    Also, declare the destructor of CompiledFormula class to be virtual as it
    serves as a base class for DynamicKernel.
    
    Change-Id: I4e191550a4437ad6ebac55fcdeee4f3654722ff1
    (cherry picked from commit 95637452609260c97d8e5aaa7500531bb458a8bc)
    Reviewed-on: https://gerrit.libreoffice.org/8468
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index 602c4a4..a3f1891 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -81,6 +81,9 @@ struct FormulaGroupContext : boost::noncopyable
  */
 class SC_DLLPUBLIC CompiledFormula
 {
+public:
+    CompiledFormula();
+    virtual ~CompiledFormula();
 };
 
 /**
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index d733525..71d55f7 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3678,38 +3678,26 @@ bool ScFormulaCell::InterpretFormulaGroup()
     if (mxGroup->mbInvariant && false)
         return InterpretInvariantFormulaGroup();
 
-    if (mxGroup->meCalcState == sc::GroupCalcEnabled)
-    {
-        ScTokenArray aCode;
-        ScAddress aTopPos = aPos;
-        aTopPos.SetRow(mxGroup->mpTopCell->aPos.Row());
-        ScGroupTokenConverter aConverter(aCode, *pDocument, *this, mxGroup->mpTopCell->aPos);
-        if (!aConverter.convert(*pCode))
-        {
-            SAL_INFO("sc.opencl", "conversion of group " << this << " failed, disabling");
-            mxGroup->meCalcState = sc::GroupCalcDisabled;
-            return false;
-        }
-        mxGroup->meCalcState = sc::GroupCalcRunning;
-        if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aCode))
-        {
-            SAL_INFO("sc.opencl", "interpreting group " << mxGroup << " (state " << mxGroup->meCalcState << ") failed, disabling");
-            mxGroup->meCalcState = sc::GroupCalcDisabled;
-            return false;
-        }
-        mxGroup->meCalcState = sc::GroupCalcEnabled;
+    ScTokenArray aCode;
+    ScAddress aTopPos = aPos;
+    aTopPos.SetRow(mxGroup->mpTopCell->aPos.Row());
+    ScGroupTokenConverter aConverter(aCode, *pDocument, *this, mxGroup->mpTopCell->aPos);
+    if (!aConverter.convert(*pCode))
+    {
+        SAL_INFO("sc.opencl", "conversion of group " << this << " failed, disabling");
+        mxGroup->meCalcState = sc::GroupCalcDisabled;
+        return false;
     }
-    else
+
+    mxGroup->meCalcState = sc::GroupCalcRunning;
+    if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aCode))
     {
-        ScTokenArray aDummy;
-        if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aDummy))
-        {
-            SAL_INFO("sc.opencl", "interpreting group " << mxGroup << " (state " << mxGroup->meCalcState << ") failed, disabling");
-            mxGroup->meCalcState = sc::GroupCalcDisabled;
-            return false;
-        }
+        SAL_INFO("sc.opencl", "interpreting group " << mxGroup << " (state " << mxGroup->meCalcState << ") failed, disabling");
+        mxGroup->meCalcState = sc::GroupCalcDisabled;
+        return false;
     }
 
+    mxGroup->meCalcState = sc::GroupCalcEnabled;
     return true;
 }
 
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index f58f7dc..a611298 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -277,6 +277,10 @@ void fillMatrix( ScMatrix& rMat, size_t nCol, const double* pNums, rtl_uString**
 
 }
 
+CompiledFormula::CompiledFormula() {}
+
+CompiledFormula::~CompiledFormula() {}
+
 FormulaGroupInterpreterSoftware::FormulaGroupInterpreterSoftware() : FormulaGroupInterpreter()
 {
 }


More information about the Libreoffice-commits mailing list