diff options
author | Eike Rathke <erack@redhat.com> | 2015-07-24 18:22:20 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-07-24 18:26:00 +0200 |
commit | f790fbfb3e422b50fdb3cb607048939faef98149 (patch) | |
tree | 3a0060110cd742eda0bef2350831a983856e2ffa /sc | |
parent | fad158c87e99eeac9bcecca2d699e800878d5c82 (diff) |
enable FORMULA() to be used in array context
So {=FORMULA(B1:B3)} works instead of giving an array of #N/A.
Change-Id: I044a7032b3f79987ab70c03d25baee26f05063f8
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 49 | ||||
-rw-r--r-- | sc/source/core/tool/parclass.cxx | 1 |
2 files changed, 50 insertions, 0 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index ec7c41fdc0f2..f95d5ebbc024 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 bb19244976ec..7f6705fa7c06 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 }}, |