summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-05-20 21:30:41 +0200
committerEike Rathke <erack@redhat.com>2017-05-22 11:00:56 +0200
commit17dd13922c01a864e5124afc97c9b19f0e29b44c (patch)
tree86e819493377336274c7d55e14fe18d193b149a6
parent1e70dedee1c7be912e4aaa2ff12b046dbd364a86 (diff)
Factor out to ScInterpreter::GetRefListArrayMaxSize(), tdf#58874
Change-Id: Ie08c37ff66faaaba8f8945503e3d212943d324d7
-rw-r--r--sc/source/core/inc/interpre.hxx3
-rw-r--r--sc/source/core/tool/interpr6.cxx34
2 files changed, 22 insertions, 15 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 9ddf9e2c1900..3586d21c317f 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -568,6 +568,9 @@ void ScUnicode();
void ScUnichar();
void ScMin( bool bTextAsZero = false );
void ScMax( bool bTextAsZero = false );
+/** Check for array of references to determine the maximum size of a return
+ column vector if in array context. */
+size_t GetRefListArrayMaxSize( short nParamCount );
void IterateParameters( ScIterFunc, bool bTextAsZero = false );
void ScSumSQ();
void ScSum();
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 0b36b129b48f..d0cb8a14b82f 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -459,6 +459,24 @@ void IterateMatrix(
}
}
+size_t ScInterpreter::GetRefListArrayMaxSize( short nParamCount )
+{
+ size_t nSize = 0;
+ if (bMatrixFormula || pCur->IsInForceArray())
+ {
+ for (short i=1; i <= nParamCount; ++i)
+ {
+ if (GetStackType(i) == svRefList)
+ {
+ const ScRefListToken* p = dynamic_cast<const ScRefListToken*>(pStack[sp - i]);
+ if (p && p->IsArrayResult() && p->GetRefList()->size() > nSize)
+ nSize = p->GetRefList()->size();
+ }
+ }
+ }
+ return nSize;
+}
+
static double lcl_IterResult( ScIterFunc eFunc, double fRes, double fMem, sal_uLong nCount )
{
switch( eFunc )
@@ -486,21 +504,7 @@ static double lcl_IterResult( ScIterFunc eFunc, double fRes, double fMem, sal_uL
void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
{
short nParamCount = GetByte();
- SCSIZE nMatRows = 0;
- if (bMatrixFormula || pCur->IsInForceArray())
- {
- // Check for arrays of references to determine the maximum size of a
- // return column vector.
- for (short i=1; i <= nParamCount; ++i)
- {
- if (GetStackType(i) == svRefList)
- {
- const ScRefListToken* p = dynamic_cast<const ScRefListToken*>(pStack[sp - i]);
- if (p && p->IsArrayResult() && p->GetRefList()->size() > nMatRows)
- nMatRows = p->GetRefList()->size();
- }
- }
- }
+ SCSIZE nMatRows = GetRefListArrayMaxSize( nParamCount);
ScMatrixRef xResMat, xResCount;
double fRes = ( eFunc == ifPRODUCT ) ? 1.0 : 0.0;
double fVal = 0.0;