summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/column.hxx1
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/inc/table.hxx1
-rw-r--r--sc/source/core/data/column2.cxx26
-rw-r--r--sc/source/core/data/documen8.cxx9
-rw-r--r--sc/source/core/data/table1.cxx9
-rw-r--r--sc/source/core/tool/formulagroup.cxx4
7 files changed, 49 insertions, 3 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 3fb39ba42848..ec29627421e2 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -477,6 +477,7 @@ public:
void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2 ) const;
formula::VectorRefArray FetchVectorRefArray( sc::FormulaGroupContext& rCxt, SCROW nRow1, SCROW nRow2 );
void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
+ void SetFormulaResults( SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen );
void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index c1fdacbe4ec8..69c8bdc7b163 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1748,6 +1748,8 @@ public:
*/
void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen );
+ void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const formula::FormulaTokenRef* pResults, size_t nLen );
+
private:
ScDocument(const ScDocument& r); // disabled with no definition
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 6e095e214da8..5a216ae3d4d4 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -871,6 +871,7 @@ public:
void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen );
+ void SetFormulaResults( SCCOL nCol, SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen );
/**
* Have formula cells with NeedsListening() == true start listening to the
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index bb8cf5f7461f..ec3d475149ad 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2466,6 +2466,32 @@ void ScColumn::SetFormulaResults( SCROW nRow, const double* pResults, size_t nLe
}
}
+void ScColumn::SetFormulaResults( SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen )
+{
+ sc::CellStoreType::position_type aPos = maCells.position(nRow);
+ sc::CellStoreType::iterator it = aPos.first;
+ if (it->type != sc::element_type_formula)
+ // This is not a formula block.
+ return;
+
+ size_t nBlockLen = it->size - aPos.second;
+ if (nBlockLen < nLen)
+ // Result array is longer than the length of formula cells. Not good.
+ return;
+
+ sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
+ std::advance(itCell, aPos.second);
+
+ const formula::FormulaTokenRef* pResEnd = pResults + nLen;
+ for (; pResults != pResEnd; ++pResults, ++itCell)
+ {
+ ScFormulaCell& rCell = **itCell;
+ rCell.SetResultToken(pResults->get());
+ rCell.ResetDirty();
+ rCell.SetChanged(true);
+ }
+}
+
void ScColumn::SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat )
{
short eOldType = pDocument->GetFormatTable()->GetType(
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index d69e25b3d79e..c7e6a99104d0 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -454,8 +454,15 @@ void ScDocument::SetFormulaResults( const ScAddress& rTopPos, const double* pRes
pTab->SetFormulaResults(rTopPos.Col(), rTopPos.Row(), pResults, nLen);
}
+void ScDocument::SetFormulaResults(
+ const ScAddress& rTopPos, const formula::FormulaTokenRef* pResults, size_t nLen )
+{
+ ScTable* pTab = FetchTable(rTopPos.Tab());
+ if (!pTab)
+ return;
-//------------------------------------------------------------------------
+ pTab->SetFormulaResults(rTopPos.Col(), rTopPos.Row(), pResults, nLen);
+}
void ScDocument::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
bool bNumFormatChanged )
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 0c985fde6abf..851cf6c86b2c 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2231,6 +2231,15 @@ void ScTable::SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults,
aCol[nCol].SetFormulaResults(nRow, pResults, nLen);
}
+void ScTable::SetFormulaResults(
+ SCCOL nCol, SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen )
+{
+ if (!ValidCol(nCol))
+ return;
+
+ aCol[nCol].SetFormulaResults(nRow, pResults, nLen);
+}
+
#if DEBUG_COLUMN_STORAGE
void ScTable::DumpFormulaGroups( SCCOL nCol ) const
{
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 09076a831445..21edd7e4c591 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -141,7 +141,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
// the group.
ScAddress aTmpPos = rTopPos;
- std::vector<double> aResults;
+ std::vector<formula::FormulaTokenRef> aResults;
aResults.reserve(xGroup->mnLength);
CachedTokensType aCachedTokens;
@@ -256,7 +256,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
generateRPNCode(rDoc, aTmpPos, aCode2);
ScInterpreter aInterpreter(pDest, &rDoc, aTmpPos, aCode2);
aInterpreter.Interpret();
- aResults.push_back(aInterpreter.GetResultToken()->GetDouble());
+ aResults.push_back(aInterpreter.GetResultToken());
} // for loop end (xGroup->mnLength)
if (!aResults.empty())