[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Fri Jul 24 09:26:50 PDT 2015


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

New commits:
commit f790fbfb3e422b50fdb3cb607048939faef98149
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Jul 24 18:22:20 2015 +0200

    enable FORMULA() to be used in array context
    
    So {=FORMULA(B1:B3)} works instead of giving an array of #N/A.
    
    Change-Id: I044a7032b3f79987ab70c03d25baee26f05063f8

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index ec7c41f..f95d5eb 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2563,6 +2563,55 @@ void ScInterpreter::ScFormula()
     switch ( GetStackType() )
     {
         case svDoubleRef :
+            if (bMatrixFormula)
+            {
+                SCCOL nCol1, nCol2;
+                SCROW nRow1, nRow2;
+                SCTAB nTab1, nTab2;
+                PopDoubleRef( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
+                if (nGlobalError)
+                    break;
+
+                if (nTab1 != nTab2)
+                {
+                    SetError( errIllegalArgument);
+                    break;
+                }
+
+                ScMatrixRef pResMat = GetNewMat( nCol2 - nCol1 + 1, nRow2 - nRow1 + 1, true);
+                if (!pResMat)
+                    break;
+
+                /* TODO: use a column iterator instead? */
+                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;
+                        aCell.assign(*pDok, aAdr);
+                        switch (aCell.meType)
+                        {
+                            case CELLTYPE_FORMULA :
+                                aCell.mpFormula->GetFormula(aFormula);
+                                pResMat->PutString( mrStrPool.intern( aFormula), i,j);
+                                break;
+                            default:
+                                pResMat->PutError( NOTAVAILABLE, i,j);
+                        }
+                        ++j;
+                    }
+                    ++i;
+                    j = 0;
+                }
+
+                PushMatrix( pResMat);
+                return;
+            }
+            // fallthru
         case svSingleRef :
         {
             ScAddress aAdr;
diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx
index bb19244..7f6705f 100644
--- a/sc/source/core/tool/parclass.cxx
+++ b/sc/source/core/tool/parclass.cxx
@@ -105,6 +105,7 @@ const ScParameterClassification::RawData ScParameterClassification::pRawData[] =
     { ocDiv,             {{ Array, Array                                         }, 0 }},
     { ocEqual,           {{ Array, Array                                         }, 0 }},
     { ocForecast,        {{ Value, ForceArray, ForceArray                        }, 0 }},
+    { ocFormula,         {{ Reference                                            }, 0 }},
     { ocFrequency,       {{ Reference, Reference                                 }, 0 }},
     { ocFTest,           {{ ForceArray, ForceArray                               }, 0 }},
     { ocGeoMean,         {{ Reference                                            }, 1 }},


More information about the Libreoffice-commits mailing list