From 3e2bd1e4022e25b77bcc8eba5e02c1adc57008a1 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 15 Oct 2014 20:07:33 -0400 Subject: fdo#73080: Correctly count blank cells in COUNTBLANK. Especially when formula cells are involved. Change-Id: I40950e7108778821c17d08354f01bb157b1551e6 --- sc/source/core/tool/interpr1.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 358dab006806..44c3ea622d13 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: + ; + } } } } -- cgit v1.2.3