summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-13 02:57:07 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-14 02:23:41 +0100
commit9378fc5d1fadb10e078bb852144f5cc8b99cc342 (patch)
tree503e8a26aae49057378d495dec079ddcbc508cbd /sw
parent5a0d2a4e927ed0c13468febd814cd1d8cfc11112 (diff)
use sw::Ring<>
Change-Id: I1ad4425f557a52dec4e9b068995585b15f61466f
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/calbck.hxx8
-rw-r--r--sw/source/core/attr/calbck.cxx44
2 files changed, 17 insertions, 35 deletions
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 274bcf651830..64eafa8a26b5 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -23,6 +23,7 @@
#include <tools/rtti.hxx>
#include "swdllapi.h"
#include <boost/noncopyable.hpp>
+#include <ring.hxx>
class SwModify;
class SwClientIter;
@@ -202,7 +203,7 @@ protected:
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 void SwModify::Add(SwClient *pDepend); ///< for pointer adjustments
@@ -217,11 +218,6 @@ class SwClientIter
// this is necessary because iteration requires access to members of the current object
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
TypeId aSrchId;
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 17aabca25f08..8ca0630033a0 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -206,11 +206,10 @@ void SwModify::Add( SwClient* pDepend )
if(pDepend->pRegisteredIn != this )
{
#if OSL_DEBUG_LEVEL > 0
- SwClientIter* pTmp = pClientIters;
- while( pTmp )
+ if(pClientIters)
{
- OSL_ENSURE( &pTmp->GetModify() != pRoot, "Client added to active ClientIter" );
- pTmp = pTmp->pNxtIter;
+ for(auto& rIter : pClientIters->GetRingContainer())
+ OSL_ENSURE( &rIter.GetModify() != pRoot, "Client added to active ClientIter" );
}
#endif
// deregister new client in case it is already registered elsewhere
@@ -259,18 +258,18 @@ SwClient* SwModify::Remove( SwClient* pDepend )
pR->m_pLeft = pL;
// update ClientIters
- SwClientIter* pTmp = pClientIters;
- while( pTmp )
+ if(pClientIters)
{
- if( pTmp->pAct == pDepend || pTmp->pDelNext == pDepend )
+ for(auto& rIter : pClientIters->GetRingContainer())
{
- // if object being removed is the current or next object in an
- // iterator, advance this iterator
- pTmp->pDelNext = static_cast<SwClient*>(pR);
+ if( rIter.pAct == pDepend || rIter.pDelNext == pDepend )
+ {
+ // 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_pRight = nullptr;
}
@@ -365,32 +364,19 @@ bool SwDepend::GetInfo( SfxPoolItem& rInfo ) const
SwClientIter::SwClientIter( const SwModify& rModify )
: rRoot(rModify)
- , pNxtIter(nullptr)
, aSrchId(nullptr)
{
- if( pClientIters )
- pNxtIter = pClientIters;
+ MoveTo(pClientIters);
pClientIters = this;
-
pAct = pDelNext = const_cast<SwClient*>(rRoot.GetDepends());
}
SwClientIter::~SwClientIter()
{
assert(pClientIters);
- // reorganize list of ClientIters
- if( pClientIters == this )
- pClientIters = pNxtIter;
- else
- {
- SwClientIter* pTmp = pClientIters;
- while( pTmp->pNxtIter != this )
- {
- assert(pTmp);
- pTmp = pTmp->pNxtIter;
- }
- pTmp->pNxtIter = pNxtIter;
- }
+ if(pClientIters == this)
+ pClientIters = unique() ? nullptr : GetNextInRing();
+ MoveTo(nullptr);
}
SwClient* SwClientIter::operator++()