From 037908f9ee16156cc251a444a0d82142e27a7d34 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 2 Apr 2012 18:48:16 -0400 Subject: We can now access the nodes directly from EditDoc. --- editeng/source/editeng/editdoc.cxx | 27 ++++++++++++++++++++------- editeng/source/editeng/editdoc.hxx | 2 +- editeng/source/editeng/impedit2.cxx | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) (limited to 'editeng') diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 15d3cd5799ff..f593893947f2 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -1704,19 +1704,32 @@ EditDoc::~EditDoc() SfxItemPool::Free(pItemPool); } -void EditDoc::ImplDestroyContents() +namespace { + +class RemoveEachItemFromPool : std::unary_function { - for ( sal_uInt16 nNode = Count(); nNode; ) - RemoveItemsFromPool( GetObject( --nNode ) ); + EditDoc& mrDoc; +public: + RemoveEachItemFromPool(EditDoc& rDoc) : mrDoc(rDoc) {} + void operator() (const ContentNode& rNode) + { + mrDoc.RemoveItemsFromPool(rNode); + } +}; + +} +void EditDoc::ImplDestroyContents() +{ + std::for_each(maContents.begin(), maContents.end(), RemoveEachItemFromPool(*this)); maContents.clear(); } -void EditDoc::RemoveItemsFromPool( ContentNode* pNode ) +void EditDoc::RemoveItemsFromPool(const ContentNode& rNode) { - for ( sal_uInt16 nAttr = 0; nAttr < pNode->GetCharAttribs().Count(); nAttr++ ) + for (size_t nAttr = 0; nAttr < rNode.GetCharAttribs().Count(); ++nAttr) { - const EditCharAttrib& rAttr = pNode->GetCharAttribs().GetAttribs()[nAttr]; + const EditCharAttrib& rAttr = rNode.GetCharAttribs().GetAttribs()[nAttr]; GetItemPool().Remove(*rAttr.GetItem()); } } @@ -2143,7 +2156,7 @@ EditPaM EditDoc::ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight ) *pLeft += *pRight; // the one to the right disappears. - RemoveItemsFromPool( pRight ); + RemoveItemsFromPool(*pRight); sal_uInt16 nRight = GetPos( pRight ); Remove( nRight ); diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 3dc13cc63d41..b1e7f561df0c 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -777,7 +777,7 @@ public: SfxItemPool& GetItemPool() { return *pItemPool; } const SfxItemPool& GetItemPool() const { return *pItemPool; } - void RemoveItemsFromPool( ContentNode* pNode ); + void RemoveItemsFromPool(const ContentNode& rNode); void InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd ); void InsertAttrib( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem ); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 9bab5db9673a..3a6613c3bc36 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -2503,7 +2503,7 @@ void ImpEditEngine::ImpRemoveParagraph( sal_uInt16 nPara ) InsertUndo( new EditUndoDelContent( this, pNode, nPara ) ); else { - aEditDoc.RemoveItemsFromPool( pNode ); + aEditDoc.RemoveItemsFromPool(*pNode); if ( pNode->GetStyleSheet() ) EndListening( *pNode->GetStyleSheet(), sal_False ); delete pNode; -- cgit