sc/inc/column.hxx | 3 - sc/source/core/data/column.cxx | 74 --------------------------------------- sc/source/core/tool/interpr6.cxx | 65 +++++++++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 79 deletions(-)
New commits: commit 9e802714b3c1e6d618c833ff0bc89016afed2131 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Tue Jul 2 16:02:59 2013 -0400 Move this code from the column code back into the interpreter code. Change-Id: I7830cdf3f09ed7b6ae6221212bfb84abcdeac523 diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 359b8ac..62e1ddf 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -409,9 +409,6 @@ public: void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark ); void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark ); - double SumNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const; - size_t CountNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const; - long GetNeededSize( SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY, diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 61f57ab..6a2dbd3 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -466,80 +466,6 @@ void ScColumn::ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark ) } } -namespace { - -class NumericCellAccumulator -{ - double mfSum; -public: - NumericCellAccumulator() : mfSum(0.0) {} - - void operator() (size_t, double fVal) - { - mfSum += fVal; - } - - void operator() (size_t, const ScFormulaCell* pCell) - { - ScFormulaCell& rCell = const_cast<ScFormulaCell&>(*pCell); - if (rCell.IsValue()) - mfSum += rCell.GetValue(); - } - - double getSum() const { return mfSum; } -}; - -class NumericCellCounter -{ - size_t mnCount; -public: - NumericCellCounter() : mnCount(0) {} - - void operator() (const sc::CellStoreType::value_type& rNode, size_t nOffset, size_t nDataSize) - { - switch (rNode.type) - { - case sc::element_type_numeric: - mnCount += nDataSize; - break; - case sc::element_type_formula: - { - sc::formula_block::const_iterator it = sc::formula_block::begin(*rNode.data); - std::advance(it, nOffset); - sc::formula_block::const_iterator itEnd = it; - std::advance(itEnd, nDataSize); - for (; it != itEnd; ++it) - { - ScFormulaCell& rCell = const_cast<ScFormulaCell&>(**it); - if (rCell.IsValueNoError()) - ++mnCount; - } - } - break; - default: - ; - } - } - - size_t getCount() const { return mnCount; } -}; - -} - -double ScColumn::SumNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const -{ - NumericCellAccumulator aFunc; - rPos.miCellPos = sc::ParseFormulaNumeric(rPos.miCellPos, maCells, nRow1, nRow2, aFunc); - return aFunc.getSum(); -} - -size_t ScColumn::CountNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const -{ - NumericCellCounter aFunc; - rPos.miCellPos = sc::ParseBlock(rPos.miCellPos, maCells, aFunc, nRow1, nRow2); - return aFunc.getCount(); -} - void ScColumn::ClearSelectionItems( const sal_uInt16* pWhich,const ScMarkData& rMark ) { SCROW nTop; diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index e31a062..03d87a9 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -24,6 +24,7 @@ #include "document.hxx" #include "cellvalue.hxx" #include "dociter.hxx" +#include "mtvcellfunc.hxx" #include "formula/token.hxx" #include <rtl/logfile.hxx> @@ -213,6 +214,62 @@ double ScInterpreter::GetGammaDist( double fX, double fAlpha, double fLambda ) namespace { +class NumericCellAccumulator +{ + double mfSum; +public: + NumericCellAccumulator() : mfSum(0.0) {} + + void operator() (size_t, double fVal) + { + mfSum += fVal; + } + + void operator() (size_t, const ScFormulaCell* pCell) + { + ScFormulaCell& rCell = const_cast<ScFormulaCell&>(*pCell); + if (rCell.IsValue()) + mfSum += rCell.GetValue(); + } + + double getSum() const { return mfSum; } +}; + +class NumericCellCounter +{ + size_t mnCount; +public: + NumericCellCounter() : mnCount(0) {} + + void operator() (const sc::CellStoreType::value_type& rNode, size_t nOffset, size_t nDataSize) + { + switch (rNode.type) + { + case sc::element_type_numeric: + mnCount += nDataSize; + break; + case sc::element_type_formula: + { + sc::formula_block::const_iterator it = sc::formula_block::begin(*rNode.data); + std::advance(it, nOffset); + sc::formula_block::const_iterator itEnd = it; + std::advance(itEnd, nDataSize); + for (; it != itEnd; ++it) + { + ScFormulaCell& rCell = const_cast<ScFormulaCell&>(**it); + if (rCell.IsValueNoError()) + ++mnCount; + } + } + break; + default: + ; + } + } + + size_t getCount() const { return mnCount; } +}; + class FuncCount : public sc::ColumnSpanSet::ColumnAction { sc::ColumnBlockConstPosition maPos; @@ -234,7 +291,9 @@ public: if (!bVal) return; - mnCount += mpCol->CountNumericCells(maPos, nRow1, nRow2); + NumericCellCounter aFunc; + maPos.miCellPos = sc::ParseBlock(maPos.miCellPos, mpCol->GetCellStore(), aFunc, nRow1, nRow2); + mnCount += aFunc.getCount(); mnNumFmt = mpCol->GetNumberFormat(nRow2); }; @@ -263,7 +322,9 @@ public: if (!bVal) return; - mfSum += mpCol->SumNumericCells(maPos, nRow1, nRow2); + NumericCellAccumulator aFunc; + maPos.miCellPos = sc::ParseFormulaNumeric(maPos.miCellPos, mpCol->GetCellStore(), nRow1, nRow2, aFunc); + mfSum += aFunc.getSum(); mnNumFmt = mpCol->GetNumberFormat(nRow2); }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits