summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-07-26 14:47:57 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-07-27 21:49:30 +0200
commitf3b221773c9a1afb88d4675c303f0f03a7ccaaea (patch)
tree21c9cc4bfd1dbed421e6f588e4bed184662577f7
parenta44843e8e324e00995dd4be0bd3244c85d91bd85 (diff)
Resolves: tdf#91502 handle ISFORMULA() in array context
Obtaining the usual matrix for iterated scalar values doesn't work here because we don't want the formulas' results but whether there are formulas at the referenced positions. Change-Id: I7912f9019d21b803ca327cb022df2014d3cc5c5a Reviewed-on: https://gerrit.libreoffice.org/58115 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit a44d1b8d47e0ef6645c7c5def1fe5d34d470ae0b) Reviewed-on: https://gerrit.libreoffice.org/58174 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/source/core/tool/interpr1.cxx46
-rw-r--r--sc/source/core/tool/parclass.cxx1
2 files changed, 47 insertions, 0 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index c83951d59b79..3eb8fab7b968 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2691,6 +2691,52 @@ void ScInterpreter::ScIsFormula()
switch ( GetStackType() )
{
case svDoubleRef :
+ if (bMatrixFormula || pCur->IsInForceArray())
+ {
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ SCTAB nTab1, nTab2;
+ PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
+ if (nGlobalError != FormulaError::NONE)
+ {
+ PushError( nGlobalError);
+ return;
+ }
+ if (nTab1 != nTab2)
+ {
+ PushIllegalArgument();
+ return;
+ }
+
+ ScMatrixRef pResMat = GetNewMat( static_cast<SCSIZE>(nCol2 - nCol1 + 1),
+ static_cast<SCSIZE>(nRow2 - nRow1 + 1), true);
+ if (!pResMat)
+ {
+ PushError( FormulaError::MatrixSize);
+ return;
+ }
+
+ /* TODO: we really should have a gap-aware cell iterator. */
+ SCSIZE i=0, j=0;
+ ScAddress aAdr( 0, 0, nTab1);
+ for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
+ {
+ aAdr.SetCol(nCol);
+ for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
+ {
+ aAdr.SetRow(nRow);
+ ScRefCellValue aCell(*pDok, aAdr);
+ pResMat->PutBoolean( (aCell.meType == CELLTYPE_FORMULA), i,j);
+ ++j;
+ }
+ ++i;
+ j = 0;
+ }
+
+ PushMatrix( pResMat);
+ return;
+ }
+ SAL_FALLTHROUGH;
case svSingleRef :
{
ScAddress aAdr;
diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx
index 7464dbf9a843..a4c3e7241087 100644
--- a/sc/source/core/tool/parclass.cxx
+++ b/sc/source/core/tool/parclass.cxx
@@ -158,6 +158,7 @@ const ScParameterClassification::RawData ScParameterClassification::pRawData[] =
{ ocIndirect, {{ Value, Value }, 0, Reference }},
{ ocIntercept, {{ ForceArray, ForceArray }, 0, Value }},
{ ocIntersect, {{ Reference, Reference }, 0, Reference }},
+ { ocIsFormula, {{ Reference }, 0, Value }},
{ ocIsRef, {{ Reference }, 0, Value }},
{ ocKurt, {{ Reference }, 1, Value }},
{ ocLCM, {{ Reference }, 1, Value }},