Kaydet (Commit) 9378fc5d authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

use sw::Ring<>

Change-Id: I1ad4425f557a52dec4e9b068995585b15f61466f
üst 5a0d2a4e
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <tools/rtti.hxx> #include <tools/rtti.hxx>
#include "swdllapi.h" #include "swdllapi.h"
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <ring.hxx>
class SwModify; class SwModify;
class SwClientIter; class SwClientIter;
...@@ -202,7 +203,7 @@ protected: ...@@ -202,7 +203,7 @@ protected:
virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) SAL_OVERRIDE; virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) SAL_OVERRIDE;
}; };
class SwClientIter class SwClientIter : public sw::Ring<SwClientIter>
{ {
friend SwClient* SwModify::Remove(SwClient *); ///< for pointer adjustments friend SwClient* SwModify::Remove(SwClient *); ///< for pointer adjustments
friend void SwModify::Add(SwClient *pDepend); ///< for pointer adjustments friend void SwModify::Add(SwClient *pDepend); ///< for pointer adjustments
...@@ -217,11 +218,6 @@ class SwClientIter ...@@ -217,11 +218,6 @@ class SwClientIter
// this is necessary because iteration requires access to members of the current object // this is necessary because iteration requires access to members of the current object
SwClient* pDelNext; SwClient* pDelNext;
// SwClientIter objects are tracked in linked list so that they can react
// when the current (pAct) or marked down (pDelNext) SwClient is removed
// from its SwModify
SwClientIter *pNxtIter;
// iterator can be limited to return only SwClient objects of a certain type // iterator can be limited to return only SwClient objects of a certain type
TypeId aSrchId; TypeId aSrchId;
......
...@@ -206,11 +206,10 @@ void SwModify::Add( SwClient* pDepend ) ...@@ -206,11 +206,10 @@ void SwModify::Add( SwClient* pDepend )
if(pDepend->pRegisteredIn != this ) if(pDepend->pRegisteredIn != this )
{ {
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
SwClientIter* pTmp = pClientIters; if(pClientIters)
while( pTmp )
{ {
OSL_ENSURE( &pTmp->GetModify() != pRoot, "Client added to active ClientIter" ); for(auto& rIter : pClientIters->GetRingContainer())
pTmp = pTmp->pNxtIter; OSL_ENSURE( &rIter.GetModify() != pRoot, "Client added to active ClientIter" );
} }
#endif #endif
// deregister new client in case it is already registered elsewhere // deregister new client in case it is already registered elsewhere
...@@ -259,18 +258,18 @@ SwClient* SwModify::Remove( SwClient* pDepend ) ...@@ -259,18 +258,18 @@ SwClient* SwModify::Remove( SwClient* pDepend )
pR->m_pLeft = pL; pR->m_pLeft = pL;
// update ClientIters // update ClientIters
SwClientIter* pTmp = pClientIters; if(pClientIters)
while( pTmp )
{ {
if( pTmp->pAct == pDepend || pTmp->pDelNext == pDepend ) for(auto& rIter : pClientIters->GetRingContainer())
{ {
// if object being removed is the current or next object in an if( rIter.pAct == pDepend || rIter.pDelNext == pDepend )
// iterator, advance this iterator {
pTmp->pDelNext = static_cast<SwClient*>(pR); // if object being removed is the current or next object in an
// iterator, advance this iterator
rIter.pDelNext = static_cast<SwClient*>(pR);
}
} }
pTmp = pTmp->pNxtIter;
} }
pDepend->m_pLeft = nullptr; pDepend->m_pLeft = nullptr;
pDepend->m_pRight = nullptr; pDepend->m_pRight = nullptr;
} }
...@@ -365,32 +364,19 @@ bool SwDepend::GetInfo( SfxPoolItem& rInfo ) const ...@@ -365,32 +364,19 @@ bool SwDepend::GetInfo( SfxPoolItem& rInfo ) const
SwClientIter::SwClientIter( const SwModify& rModify ) SwClientIter::SwClientIter( const SwModify& rModify )
: rRoot(rModify) : rRoot(rModify)
, pNxtIter(nullptr)
, aSrchId(nullptr) , aSrchId(nullptr)
{ {
if( pClientIters ) MoveTo(pClientIters);
pNxtIter = pClientIters;
pClientIters = this; pClientIters = this;
pAct = pDelNext = const_cast<SwClient*>(rRoot.GetDepends()); pAct = pDelNext = const_cast<SwClient*>(rRoot.GetDepends());
} }
SwClientIter::~SwClientIter() SwClientIter::~SwClientIter()
{ {
assert(pClientIters); assert(pClientIters);
// reorganize list of ClientIters if(pClientIters == this)
if( pClientIters == this ) pClientIters = unique() ? nullptr : GetNextInRing();
pClientIters = pNxtIter; MoveTo(nullptr);
else
{
SwClientIter* pTmp = pClientIters;
while( pTmp->pNxtIter != this )
{
assert(pTmp);
pTmp = pTmp->pNxtIter;
}
pTmp->pNxtIter = pNxtIter;
}
} }
SwClient* SwClientIter::operator++() SwClient* SwClientIter::operator++()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment