From b9ecc28533ed366bc6544303df763b6be29c2963 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Tue, 23 May 2017 00:45:21 +0200 Subject: Handle COUNTIF with array of references, tdf#58874 Change-Id: Id0325fba37cbf2cfea4a33e3e8110c5d85cf16a6 --- sc/source/core/tool/interpr1.cxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'sc') diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index f80f49557d82..12aa11b97bbf 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -5444,6 +5444,10 @@ void ScInterpreter::ScCountIf() } double fCount = 0.0; short nParam = 1; + const SCSIZE nMatRows = GetRefListArrayMaxSize( nParam); + // There's either one RefList and nothing else, or none. + ScMatrixRef xResMat = (nMatRows ? GetNewMat( 1, nMatRows) : nullptr); + SCSIZE nRefListArrayPos = 0; size_t nRefInList = 0; while (nParam-- > 0) { @@ -5456,8 +5460,10 @@ void ScInterpreter::ScCountIf() ScMatrixRef pQueryMatrix; switch ( GetStackType() ) { - case svDoubleRef : case svRefList : + nRefListArrayPos = nRefInList; + SAL_FALLTHROUGH; + case svDoubleRef : { ScRange aRange; PopDoubleRef( aRange, nParam, nRefInList); @@ -5566,8 +5572,16 @@ void ScInterpreter::ScCountIf() PushIllegalParameter(); return; } + if (xResMat) + { + xResMat->PutDouble( fCount, 0, nRefListArrayPos); + fCount = 0.0; + } } - PushDouble(fCount); + if (xResMat) + PushMatrix( xResMat); + else + PushDouble(fCount); } } -- cgit