summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-11-22 14:57:28 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2011-11-22 14:58:53 -0500
commit264e5034688a9c3105b3d29c7083ef2565afaec6 (patch)
tree1710dc50249160320e2fbda1a8a65b4890dd4fd7
parent543d3bf035ea42cf7b16f394e58795f532a69151 (diff)
fdo#43154: Fixed incorrectly query validation.
It was due to a simple mis-placement of an operator. No idea how the compiler may have parsed that statement...
-rw-r--r--sc/qa/unit/ucalc.cxx12
-rw-r--r--sc/source/core/data/table3.cxx2
2 files changed, 13 insertions, 1 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index c4848c2b2ed7..975737a17bbd 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -433,6 +433,18 @@ void testFuncCOUNTIF(ScDocument* pDoc)
CPPUNIT_ASSERT_MESSAGE("Unexpected result for COUNTIF", false);
}
}
+
+ // Don't count empty strings when searching for a number.
+
+ // Clear A1:A2.
+ clearRange(pDoc, ScRange(0, 0, 0, 0, 1, 0));
+
+ pDoc->SetString(0, 0, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=\"\"")));
+ pDoc->SetString(0, 1, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=COUNTIF(A1;1)")));
+ pDoc->CalcAll();
+
+ double result = pDoc->GetValue(0, 1, 0);
+ CPPUNIT_ASSERT_MESSAGE("We shouldn't count empty string as valid number.", result == 0.0);
}
void testFuncVLOOKUP(ScDocument* pDoc)
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index f2dc39947dbb..cb37e165de9b 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1349,7 +1349,7 @@ public:
// Simple string matching i.e. no regexp match.
if (isTextMatchOp(rEntry))
{
- if (!rItem.meType != ScQueryEntry::ByString && rItem.maString.isEmpty())
+ if (rItem.meType != ScQueryEntry::ByString && rItem.maString.isEmpty())
{
// #i18374# When used from functions (match, countif, sumif, vlookup, hlookup, lookup),
// the query value is assigned directly, and the string is empty. In that case,