summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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,