diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index adca7d577417..454cca8c1e01 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1753,6 +1753,9 @@ public: SvtListener* pListener ); void EndListeningCell( const ScAddress& rAddress, SvtListener* pListener ); + + void EndListeningFormulaCells( std::vector& rCells ); + void PutInFormulaTree( ScFormulaCell* pCell ); void RemoveFromFormulaTree( ScFormulaCell* pCell ); diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index dc26882f6cf4..1d5d14688a37 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -331,8 +331,7 @@ void ScColumn::DeleteRange( drawing undo. */ // cache all formula cells, they will be deleted at end of this function - typedef ::std::vector< ScFormulaCell* > FormulaCellVector; - FormulaCellVector aDelCells; + std::vector aDelCells; aDelCells.reserve( nEndIndex - nStartIndex + 1 ); typedef mdds::flat_segment_tree RemovedSegments_t; @@ -437,19 +436,8 @@ void ScColumn::DeleteRange( } } - // *** delete all formula cells *** - if (!aDelCells.empty()) - { - // First, all cells stop listening, may save unneeded broadcasts and - // recalcualtions. - // NOTE: this actually may remove ScNoteCell entries from maItems if - // the last listener is removed from a broadcaster. - for ( FormulaCellVector::iterator aIt = aDelCells.begin(), aEnd = aDelCells.end(); aIt != aEnd; ++aIt ) - { - (*aIt)->EndListeningTo( pDocument ); - (*aIt)->Delete(); - } - } + pDocument->EndListeningFormulaCells(aDelCells); + std::for_each(aDelCells.begin(), aDelCells.end(), ScDeleteObjectByPtr()); } void ScColumn::DeleteArea(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag) diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index 3a1d635beecf..6cc51cc42f3d 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -200,6 +200,15 @@ void ScDocument::EndListeningCell( const ScAddress& rAddress, maTabs[nTab]->EndListening( rAddress, pListener ); } +void ScDocument::EndListeningFormulaCells( std::vector& rCells ) +{ + if (rCells.empty()) + return; + + std::vector::iterator it = rCells.begin(), itEnd = rCells.end(); + for (; it != itEnd; ++it) + (*it)->EndListeningTo(this); +} void ScDocument::PutInFormulaTree( ScFormulaCell* pCell ) {