sc/qa/unit/ucalc.hxx | 2 ++ sc/qa/unit/ucalc_formula.cxx | 26 ++++++++++++++++++++++++++ sc/source/core/tool/interpr1.cxx | 22 ++++++++++++++++++++-- 3 files changed, 48 insertions(+), 2 deletions(-)
New commits: commit 3e2bd1e4022e25b77bcc8eba5e02c1adc57008a1 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Wed Oct 15 20:07:33 2014 -0400 fdo#73080: Correctly count blank cells in COUNTBLANK. Especially when formula cells are involved. Change-Id: I40950e7108778821c17d08354f01bb157b1551e6 diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 358dab0..44c3ea6 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -4545,8 +4545,26 @@ void ScInterpreter::ScCountEmptyCells() ScCellIterator aIter( pDok, aRange, mnSubTotalFlags); for (bool bHas = aIter.first(); bHas; bHas = aIter.next()) { - if (!aIter.hasEmptyData()) - ++nCount; + const ScRefCellValue& rCell = aIter.getRefCellValue(); + switch (rCell.meType) + { + case CELLTYPE_VALUE: + case CELLTYPE_STRING: + case CELLTYPE_EDIT: + ++nCount; + break; + case CELLTYPE_FORMULA: + { + sc::FormulaResultValue aRes = rCell.mpFormula->GetResult(); + if (aRes.meType != sc::FormulaResultValue::String) + ++nCount; + else if (!aRes.maString.isEmpty()) + ++nCount; + } + break; + default: + ; + } } } } commit 27a2e19ed2c3203c9d63873796d7c9ec2f58dd3d Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Wed Oct 15 20:06:45 2014 -0400 fdo#73080: Write test for this first. Change-Id: Ia2a32f4be3ef2c09ac68fe03ee9a7c9d31aef7ed diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 259d0a2..d7f85f0 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -140,6 +140,7 @@ public: void testMultipleOperations(); void testFuncCOLUMN(); void testFuncCOUNT(); + void testFuncCOUNTBLANK(); void testFuncROW(); void testFuncSUM(); void testFuncPRODUCT(); @@ -429,6 +430,7 @@ public: CPPUNIT_TEST(testMultipleOperations); CPPUNIT_TEST(testFuncCOLUMN); CPPUNIT_TEST(testFuncCOUNT); + CPPUNIT_TEST(testFuncCOUNTBLANK); CPPUNIT_TEST(testFuncROW); CPPUNIT_TEST(testFuncSUM); CPPUNIT_TEST(testFuncPRODUCT); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 45112d1..5c5d6b0 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -2515,6 +2515,32 @@ void Test::testFuncCOUNT() m_pDoc->DeleteTab(0); } +void Test::testFuncCOUNTBLANK() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + m_pDoc->InsertTab(0, "Formula"); + + const char* aData[][4] = { + { "1", 0, "=B1", "=\"\"" }, + { "2", 0, "=B2", "=\"\"" }, + { "A", 0, "=B3", "=\"\"" }, + { "B", 0, "=B4", "=D3" }, + { 0, 0, "=B5", "=D4" }, + { "=COUNTBLANK(A1:A5)", "=COUNTBLANK(B1:B5)", "=COUNTBLANK(C1:C5)", "=COUNTBLANK(D1:D5)" } + }; + + ScAddress aPos(0,0,0); + ScRange aRange = insertRangeData(m_pDoc, aPos, aData, SAL_N_ELEMENTS(aData)); + CPPUNIT_ASSERT(aRange.aStart == aPos); + + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,5,0))); + CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(1,5,0))); + CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,5,0))); + CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(3,5,0))); + + m_pDoc->DeleteTab(0); +} + void Test::testFuncROW() { m_pDoc->InsertTab(0, "Formula"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits