summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-03-05 22:03:27 +0100
committerEike Rathke <erack@redhat.com>2018-03-05 22:24:51 +0100
commita2a15163a6a381957f2cb2ed6fe659577ebde558 (patch)
tree4ea856c3a0e71d3f445d849c0360269982ee4c8e
parent2374028d637886fff1ccca84f57624d2aaa81a95 (diff)
Resolves: tdf#116216 array sort order of error values in LOOKUP and MATCH
Change-Id: I424de514b3a3729bc5f619814b6a4aab42569f82
-rw-r--r--sc/source/core/tool/interpr1.cxx25
1 files changed, 23 insertions, 2 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 1722ececce25..546f72a15332 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4531,11 +4531,20 @@ sal_Int32 lcl_CompareMatrix2Query(
bool bByString = rEntry.GetQueryItem().meType == ScQueryEntry::ByString;
if (rMat.IsValue(i))
{
+ const double nVal1 = rMat.GetDouble(i);
+ if (!rtl::math::isFinite(nVal1))
+ {
+ // XXX Querying for error values is not required, otherwise we'd
+ // need to check here.
+ return 1; // error always greater than numeric or string
+ }
+
if (bByString)
return -1; // numeric always less than string
- const double nVal1 = rMat.GetDouble(i);
const double nVal2 = rEntry.GetQueryItem().mfVal;
+ // XXX Querying for error values is not required, otherwise we'd need
+ // to check here and move that check before the bByString check.
if (nVal1 == nVal2)
return 0;
@@ -4775,6 +4784,10 @@ void ScInterpreter::ScMatch()
PushIllegalParameter();
return;
}
+
+ // Do not propagate errors from matrix while searching.
+ pMatSrc->SetErrorInterpreter( nullptr);
+
SCSIZE nMatCount = (nC == 1) ? nR : nC;
VectorMatrixAccessor aMatAcc(*pMatSrc, nC == 1);
@@ -6558,6 +6571,9 @@ void ScInterpreter::ScLookup()
SCSIZE nC, nR;
pDataMat->GetDimensions(nC, nR);
+ // Do not propagate errors from matrix while copying to vector.
+ pDataMat->SetErrorInterpreter( nullptr);
+
// In case of non-vector matrix, only search the first row or column.
ScMatrixRef pDataMat2;
if (bVertical)
@@ -6581,6 +6597,9 @@ void ScInterpreter::ScLookup()
pDataMat2 = pTempMat;
}
+ // Do not propagate errors from matrix while searching.
+ pDataMat2->SetErrorInterpreter( nullptr);
+
VectorMatrixAccessor aMatAcc2(*pDataMat2, bVertical);
// binary search for non-equality mode (the source data is
@@ -6703,7 +6722,9 @@ void ScInterpreter::ScLookup()
}
else
{
- // no result array. Use the data array to get the final value from.
+ // No result array. Use the data array to get the final value from.
+ // Propagate errors from matrix again.
+ pDataMat->SetErrorInterpreter( this);
if (bVertical)
{
if (pDataMat->IsValue(nC-1, nDelta))