[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Thu Apr 24 16:44:30 PDT 2014
sc/qa/unit/ucalc_formula.cxx | 17 +++++++++++++++--
sc/source/core/tool/queryparam.cxx | 14 ++++++++------
2 files changed, 23 insertions(+), 8 deletions(-)
New commits:
commit 50708577850544920c746ebc382d47275452a761
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Apr 24 19:42:30 2014 -0400
fdo#77039: Fill the match string even if the raw string is empty.
And in case of an empty string, call svl::SharedString::getEmptyString()
to get an empty shared string instance.
Change-Id: I0923e59f03468790270de8ef22323c0cedad002f
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index c9d7e29..487a577 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -173,14 +173,16 @@ void ScQueryParamBase::FillInExcelSyntax(
svl::SharedStringPool& rPool, const OUString& rStr, SCSIZE nIndex)
{
const OUString aCellStr = rStr;
- if (!aCellStr.isEmpty())
- {
- if ( nIndex >= maEntries.size() )
- Resize( nIndex+1 );
+ if (nIndex >= maEntries.size())
+ Resize(nIndex+1);
- ScQueryEntry& rEntry = GetEntry(nIndex);
- ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ ScQueryEntry& rEntry = GetEntry(nIndex);
+ ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ if (aCellStr.isEmpty())
+ rItem.maString = svl::SharedString::getEmptyString();
+ else
+ {
rEntry.bDoQuery = true;
// Operatoren herausfiltern
if (aCellStr[0] == '<')
commit 380631d0e24d8bf90a5431b3e3c5fb36f21dbcf0
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Apr 24 19:15:38 2014 -0400
fdo#77039: Write test for this.
Change-Id: If34291ffb9705c413a451091ac70d7f2c7ea8f63
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 254962e..e3283db 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2294,6 +2294,8 @@ void Test::testFuncN()
void Test::testFuncCOUNTIF()
{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
// COUNTIF (test case adopted from OOo i#36381)
OUString aTabName("foo");
@@ -2345,7 +2347,6 @@ void Test::testFuncCOUNTIF()
SCROW nRow = 20 + i;
m_pDoc->SetString(0, nRow, 0, OUString::createFromAscii(aChecks[i].pFormula));
}
- m_pDoc->CalcAll();
for (SCROW i = 0; i < nRows; ++i)
{
@@ -2368,11 +2369,23 @@ void Test::testFuncCOUNTIF()
m_pDoc->SetString(0, 0, 0, OUString("=\"\""));
m_pDoc->SetString(0, 1, 0, OUString("=COUNTIF(A1;1)"));
- m_pDoc->CalcAll();
double result = m_pDoc->GetValue(0, 1, 0);
CPPUNIT_ASSERT_MESSAGE("We shouldn't count empty string as valid number.", result == 0.0);
+ // Another test case adopted from fdo#77039.
+ clearSheet(m_pDoc, 0);
+
+ // Set formula cells with blank results in A1:A4.
+ for (SCROW i = 0; i <=3; ++i)
+ m_pDoc->SetString(ScAddress(0,i,0), "=\"\"");
+
+ // Insert formula into A5 to count all cells with empty strings.
+ m_pDoc->SetString(ScAddress(0,4,0), "=COUNTIF(A1:A4;\"\"");
+
+ // We should correctly count with empty string key.
+ CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(0,4,0)));
+
m_pDoc->DeleteTab(0);
}
More information about the Libreoffice-commits
mailing list