summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2014-06-13 14:16:11 +0200
committerEike Rathke <erack@redhat.com>2014-06-13 14:21:36 +0200
commita288bebbcec0b16e1ced09a601de5ffbb6b1bbe0 (patch)
treef530349350263dd548433026c9bcfcc90a00c619
parentc9d037e5e8e5850e9c69372580e7a506b573fc2a (diff)
resolved fdo#79978 propagate error through DoubleArray of matrix
Regression introduced with 83f77ab0661df992f241e5f9ecb1aa8f8eaeafec. Interpreter errors are transported using NaN coded doubles, using simple setNan()/isNan() to flag and ignore non-numeric values skips all error values. Change-Id: I0d3cb30262bc5ba7ee77e53a2bc45e56569fbc4b
-rw-r--r--include/formula/errorcodes.hxx4
-rw-r--r--sc/source/core/tool/interpr1.cxx2
-rw-r--r--sc/source/core/tool/interpr5.cxx16
-rw-r--r--sc/source/core/tool/scmatrix.cxx10
4 files changed, 24 insertions, 8 deletions
diff --git a/include/formula/errorcodes.hxx b/include/formula/errorcodes.hxx
index cea578786014..a92372c6681d 100644
--- a/include/formula/errorcodes.hxx
+++ b/include/formula/errorcodes.hxx
@@ -74,6 +74,10 @@ const sal_uInt16 errNotNumericString = 534;
// ScInterpreter internal: jump matrix already has a result at this position,
// do not overwrite in case of empty code path.
const sal_uInt16 errJumpMatHasResult = 535;
+// ScInterpreter internal: (matrix) element is not a numeric value, i.e.
+// string or empty, to be distinguished from the general errNoValue NAN and not
+// to be used as result.
+const sal_uInt16 errElementNaN = 536;
// Interpreter: NA() not available condition, not a real error
const sal_uInt16 NOTAVAILABLE = 0x7fff;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 83393ca22fc2..8c86e56a7839 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5613,7 +5613,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc )
continue;
fVal = *itMain;
- if (rtl::math::isNan(fVal))
+ if (GetDoubleErrorValue(fVal) == errElementNaN)
continue;
++fCount;
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index a49e87c3847e..944a0ce053d5 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1657,13 +1657,25 @@ namespace {
class SumValues : std::unary_function<double, void>
{
double mfSum;
+ bool mbError;
public:
- SumValues() : mfSum(0.0) {}
+ SumValues() : mfSum(0.0), mbError(false) {}
void operator() (double f)
{
- if (!rtl::math::isNan(f))
+ if (mbError)
+ return;
+
+ sal_uInt16 nErr = GetDoubleErrorValue(f);
+ if (!nErr)
mfSum += f;
+ else if (nErr != errElementNaN)
+ {
+ // Propagate the first error encountered, ignore "this is not a
+ // number" elements.
+ mfSum = f;
+ mbError = true;
+ }
}
double getValue() const { return mfSum; }
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 84e3c2a02470..8874218e677e 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -1507,7 +1507,7 @@ public:
ToDoubleArray( size_t nSize, bool bEmptyAsZero ) :
maArray(nSize, 0.0), miPos(maArray.begin()), mbEmptyAsZero(bEmptyAsZero)
{
- rtl::math::setNan(&mfNaN);
+ mfNaN = CreateDoubleError( errElementNaN);
}
void operator() (const MatrixImplType::element_block_node_type& node)
@@ -1578,7 +1578,7 @@ class MergeDoubleArrayFunc : std::unary_function<MatrixImplType::element_block_t
public:
MergeDoubleArrayFunc(std::vector<double>& rArray) : mrArray(rArray), miPos(mrArray.begin())
{
- rtl::math::setNan(&mfNaN);
+ mfNaN = CreateDoubleError( errElementNaN);
}
void operator() (const MatrixImplType::element_block_node_type& node)
@@ -1594,7 +1594,7 @@ public:
numeric_element_block::const_iterator itEnd = numeric_element_block::end(*node.data);
for (; it != itEnd; ++it, ++miPos)
{
- if (rtl::math::isNan(*miPos))
+ if (GetDoubleErrorValue(*miPos) == errElementNaN)
continue;
*miPos = op(*miPos, *it);
@@ -1607,7 +1607,7 @@ public:
boolean_element_block::const_iterator itEnd = boolean_element_block::end(*node.data);
for (; it != itEnd; ++it, ++miPos)
{
- if (rtl::math::isNan(*miPos))
+ if (GetDoubleErrorValue(*miPos) == errElementNaN)
continue;
*miPos = op(*miPos, *it ? 1.0 : 0.0);
@@ -1625,7 +1625,7 @@ public:
// Empty element is equivalent of having a numeric value of 0.0.
for (size_t i = 0; i < node.size; ++i, ++miPos)
{
- if (rtl::math::isNan(*miPos))
+ if (GetDoubleErrorValue(*miPos) == errElementNaN)
continue;
*miPos = op(*miPos, 0.0);