diff options
author | Eike Rathke <erack@redhat.com> | 2017-05-23 00:45:21 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-05-23 10:41:08 +0200 |
commit | b9ecc28533ed366bc6544303df763b6be29c2963 (patch) | |
tree | 43259b515d6bcdf99bd1c50fb16a773d3864eb05 /sc | |
parent | fe3fb5ecd3b66e32cc5aa64a2afffa572353740e (diff) |
Handle COUNTIF with array of references, tdf#58874
Change-Id: Id0325fba37cbf2cfea4a33e3e8110c5d85cf16a6
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 18 |
1 files changed, 16 insertions, 2 deletions
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); } } |