[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Sep 9 11:23:51 PDT 2013


 sc/source/core/data/column2.cxx      |    9 ++++++---
 sc/source/core/tool/formulagroup.cxx |   14 +++++++++++++-
 sc/source/core/tool/interpr6.cxx     |    2 +-
 3 files changed, 20 insertions(+), 5 deletions(-)

New commits:
commit 7611a40ef8d2a92bcc2f080a3725cccb7ffe871f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Sep 9 14:24:10 2013 -0400

    Correctly handle empty cells in group calculation (software interpreter).
    
    Store NaN's to represent empty cells rather than storing 0's. Storing 0's
    would mess up COUNT(), for example.
    
    Change-Id: I8e350e1fe31358b844dd44451ed8659172fda1cb

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 9d0130c..5f7f843 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2055,6 +2055,9 @@ bool appendDouble(
     sc::CellStoreType::iterator it, const sc::CellStoreType::iterator& itEnd )
 {
     size_t nLenRemain = nLen;
+    double fNan;
+    rtl::math::setNan(&fNan);
+
     for (; it != itEnd; ++it)
     {
         switch (it->type)
@@ -2119,15 +2122,15 @@ bool appendDouble(
             break;
             case sc::element_type_empty:
             {
-                // Fill it with 0's.
+                // Fill it with NaN's.
                 if (nLenRemain >= it->size)
                 {
-                    rArray.resize(rArray.size() + it->size, 0);
+                    rArray.resize(rArray.size() + it->size, fNan);
                     nLenRemain -= it->size;
                 }
                 else
                 {
-                    rArray.resize(rArray.size() + nLenRemain, 0);
+                    rArray.resize(rArray.size() + nLenRemain, fNan);
                     nLenRemain = 0;
                 }
             }
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 6c930e5..ca888dc 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -50,6 +50,9 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
     aResults.reserve(xGroup->mnLength);
     CachedTokensType aCachedTokens;
 
+    double fNan;
+    rtl::math::setNan(&fNan);
+
     for (SCROW i = 0; i < xGroup->mnLength; ++i, aTmpPos.IncRow())
     {
         ScTokenArray aCode2;
@@ -70,7 +73,16 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
                     const formula::SingleVectorRefToken* p2 = static_cast<const formula::SingleVectorRefToken*>(p);
                     const formula::VectorRefArray& rArray = p2->GetArray();
                     if (rArray.mbNumeric)
-                        aCode2.AddDouble(static_cast<size_t>(i) < p2->GetArrayLength() ? rArray.mpNumericArray[i] : 0.0);
+                    {
+                        double fVal = fNan;
+                        if (static_cast<size_t>(i) < p2->GetArrayLength())
+                            fVal = rArray.mpNumericArray[i];
+
+                        if (rtl::math::isNan(fVal))
+                            aCode2.AddToken(ScEmptyCellToken(false, false));
+                        else
+                            aCode2.AddDouble(fVal);
+                    }
                     else
                         aCode2.AddString(static_cast<size_t>(i) < p2->GetArrayLength() ? rArray.mpStringArray[i] : OUString());
                 }
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 4dbbf1d..470c8d8 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -880,7 +880,7 @@ void ScInterpreter::ScCount()
 
     while (nParamCount-- > 0)
     {
-        switch (GetStackType())
+        switch (GetRawStackType())
         {
             case svString:
             {


More information about the Libreoffice-commits mailing list