summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-10-08 13:47:49 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-08 15:48:12 -0400
commita7ff6e0a3fc5fccad33f06ae9d4ec7019f9ae156 (patch)
treeffbcb04443421c3175a8646e8e0d3ff6afda9437 /sc/source/core
parent0b4e68fddc9b259ad89505a5c4ad287b1b31f1e8 (diff)
Support for passing non-double formula results from group interpreter.
Change-Id: I1cbe6b32d8a9b86a575e9806802f7a2a45eee873
Diffstat (limited to 'sc/source/core')
-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
4 files changed, 45 insertions, 3 deletions
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())