sc/inc/column.hxx | 1 + sc/inc/document.hxx | 2 ++ sc/inc/table.hxx | 1 + sc/source/core/data/column2.cxx | 26 ++++++++++++++++++++++++++ sc/source/core/data/documen8.cxx | 9 ++++++++- sc/source/core/data/table1.cxx | 9 +++++++++ sc/source/core/tool/formulagroup.cxx | 4 ++-- 7 files changed, 49 insertions(+), 3 deletions(-)
New commits: commit 229904a43c7406c4193e5e8c165e20f6a6a5bc44 Author: Kohei Yoshida <[email protected]> Date: Tue Oct 8 13:47:49 2013 -0400 Support for passing non-double formula results from group interpreter. Change-Id: I1cbe6b32d8a9b86a575e9806802f7a2a45eee873 diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index f81ad71..25d2a83 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 54fd457..c0de4b5f 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1749,6 +1749,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 6e095e2..5a216ae 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 bb8cf5f..ec3d475 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 d69e25b..c7e6a99 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 0c985fd..851cf6c 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 09076a8..21edd7e 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()) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
