summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-05-23 00:45:21 +0200
committerEike Rathke <erack@redhat.com>2017-05-23 10:41:08 +0200
commitb9ecc28533ed366bc6544303df763b6be29c2963 (patch)
tree43259b515d6bcdf99bd1c50fb16a773d3864eb05
parentfe3fb5ecd3b66e32cc5aa64a2afffa572353740e (diff)
Handle COUNTIF with array of references, tdf#58874
Change-Id: Id0325fba37cbf2cfea4a33e3e8110c5d85cf16a6
-rw-r--r--sc/source/core/tool/interpr1.cxx18
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);
}
}