sc/source/core/tool/interpr1.cxx |   46 +++++++++++++++++++++++++++++++++++++++
 sc/source/core/tool/parclass.cxx |    1 
 2 files changed, 47 insertions(+)

New commits:
commit a44d1b8d47e0ef6645c7c5def1fe5d34d470ae0b
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Thu Jul 26 14:47:57 2018 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Fri Jul 27 10:47:14 2018 +0200

    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 <er...@redhat.com>
    Tested-by: Jenkins

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 }},
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to