summaryrefslogtreecommitdiff
path: root/sc/source/core/data/table3.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-11-27 23:43:09 +0100
committerEike Rathke <erack@redhat.com>2013-11-28 01:05:07 +0100
commit799ac18af53342597a5d3f14702de2204536c14b (patch)
treee1704082f878d4a3361daabfb34ac3d5ba6909ce /sc/source/core/data/table3.cxx
parenta7268371b105d3d2d1e3f1e1d0a68db08bbaa2ec (diff)
resolved fdo#71589 reimplemented horizontal range lookup
Regression introduced with ebdd9c300718bce454ef56a31d5d8fb699fc1822 (first eaea417bfdf8d06df2b7f2e42c904c32ce77e871) that removed the bMixedComparison member from ScQueryParam under the false assumption that is was only used to emulate a legacy Excel behavior. In fact it was also needed to do the at least horizontal range lookup in sorted mixed data, though didn't evaluate exactly the same conditions as Excel and defined in ODFF. Reimplemented a similar behavior for the new code structures but this time also checking for the additional condtion that a query ByString does not return the last numeric result and vice versa, which previously was missing. Change-Id: I46061777879ba5301bfcaca2d50cf87a994f93f2 (cherry picked from commit f0701470858f57a855ba57c0c2283e52953db327)
Diffstat (limited to 'sc/source/core/data/table3.cxx')
-rw-r--r--sc/source/core/data/table3.cxx42
1 files changed, 42 insertions, 0 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 05c43c3da09f..a92748568d2f 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1513,6 +1513,41 @@ public:
return std::pair<bool,bool>(bOk, bTestEqual);
}
+
+ // To be called only if both isQueryByValue() and isQueryByString()
+ // returned false and range lookup is wanted! In range lookup comparison
+ // numbers are less than strings. Nothing else is compared.
+ std::pair<bool,bool> compareByRangeLookup(
+ const ScRefCellValue& rCell, SCCOL nCol, SCROW nRow,
+ const ScQueryEntry& rEntry, const ScQueryEntry::Item& rItem)
+ {
+ bool bTestEqual = false;
+
+ if (rItem.meType == ScQueryEntry::ByString && rEntry.eOp != SC_LESS && rEntry.eOp != SC_LESS_EQUAL)
+ return std::pair<bool,bool>(false, bTestEqual);
+
+ if (rItem.meType != ScQueryEntry::ByString && rEntry.eOp != SC_GREATER && rEntry.eOp != SC_GREATER_EQUAL)
+ return std::pair<bool,bool>(false, bTestEqual);
+
+ if (!rCell.isEmpty())
+ {
+ if (rItem.meType == ScQueryEntry::ByString)
+ {
+ if (rCell.meType == CELLTYPE_FORMULA && rCell.mpFormula->GetErrCode())
+ // Error values are compared as string.
+ return std::pair<bool,bool>(false, bTestEqual);
+
+ return std::pair<bool,bool>(rCell.hasNumeric(), bTestEqual);
+ }
+
+ return std::pair<bool,bool>(!rCell.hasNumeric(), bTestEqual);
+ }
+
+ if (rItem.meType == ScQueryEntry::ByString)
+ return std::pair<bool,bool>(mrTab.HasValueData(nCol, nRow), bTestEqual);
+
+ return std::pair<bool,bool>(!mrTab.HasValueData(nCol, nRow), bTestEqual);
+ }
};
}
@@ -1578,6 +1613,13 @@ bool ScTable::ValidQuery(
aRes.first |= aThisRes.first;
aRes.second |= aThisRes.second;
}
+ else if (rParam.mbRangeLookup)
+ {
+ std::pair<bool,bool> aThisRes =
+ aEval.compareByRangeLookup(aCell, nCol, nRow, rEntry, *itr);
+ aRes.first |= aThisRes.first;
+ aRes.second |= aThisRes.second;
+ }
if (aRes.first && aRes.second)
break;