sc/source/core/data/column3.cxx | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-)
New commits: commit 2ae8576f3f8ed90502c787113a75334975a8bc3f Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Apr 24 14:11:37 2013 -0400 Adding comment as I go along... Change-Id: I3f95b2a1a4b180c23e82bdeec8279707220532d5 diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 9ad0061..3eb4b17 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2094,6 +2094,7 @@ void ScColumn::RebuildFormulaGroups() !rCur.pCell || !rPrev.pCell || // paranoia rCur.pCell->GetCellType() != rPrev.pCell->GetCellType() ) // same type { + // Non-contiguous cell detected. Break the series. pLastDouble = NULL; continue; } commit c97c38747c03673282f6776371eb8b740614533b Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Apr 24 13:08:21 2013 -0400 Let's use std::for_each for this. Change-Id: I74f59ad697eb5ff28b81cd883db58ba9f19c086c diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index cb82b3c..9ad0061 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2051,6 +2051,23 @@ xub_StrLen ScColumn::GetMaxNumberStringLen( return nStringLen; } +namespace { + +struct CellGroupSetter : std::unary_function<ColEntry, void> +{ + ScFormulaCellGroupRef mxGroup; +public: + CellGroupSetter(const ScFormulaCellGroupRef& xGroup) : mxGroup(xGroup) {} + + void operator() (ColEntry& rEntry) + { + if (rEntry.pCell && rEntry.pCell->GetCellType() == CELLTYPE_FORMULA) + static_cast<ScFormulaCell*>(rEntry.pCell)->SetCellGroup(mxGroup); + } +}; + +} + // Very[!] slow way to look for and merge contiguous runs // of similar formulae into a formulagroup void ScColumn::RebuildFormulaGroups() @@ -2064,12 +2081,7 @@ void ScColumn::RebuildFormulaGroups() // clear previous groups ScFormulaCellGroupRef xNone; - for (size_t i = 0; i < maItems.size(); i++) - { - ColEntry &rCur = maItems[ i ]; - if ( rCur.pCell && rCur.pCell->GetCellType() == CELLTYPE_FORMULA ) - static_cast<ScFormulaCell *>( rCur.pCell )->SetCellGroup( xNone ); - } + std::for_each(maItems.begin(), maItems.end(), CellGroupSetter(xNone)); maFnGroups.clear(); // re-build groups commit 44b3b80400fb0e812cc4cce334df3c7f737469c5 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Apr 24 11:13:08 2013 -0400 Wrap inside smart pointer on instantiation, for exception safety. And boost::intrusive_ptr has a bool operator; no need to call get() in this case. Change-Id: I8ca965349c13dd0fedc16dc0d535b8c337fce52c diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index e69a8cc..cb82b3c 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2119,15 +2119,14 @@ void ScColumn::RebuildFormulaGroups() } ScFormulaCellGroupRef xGroup = pPrev->GetCellGroup(); - if ( !xGroup.get() ) + if (!xGroup) { // create a new group ... - ScFormulaCellGroup *pGroup = new ScFormulaCellGroup(); - pGroup->mpDelta = pDelta; - pGroup->mnStart = rPrev.nRow; - pGroup->mnLength = 2; + xGroup.reset(new ScFormulaCellGroup); + xGroup->mpDelta = pDelta; + xGroup->mnStart = rPrev.nRow; + xGroup->mnLength = 2; - xGroup.reset( pGroup ); maFnGroups.push_back( xGroup ); pCur->SetCellGroup( xGroup ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits