summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-14 19:56:49 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-16 20:37:25 +0100
commitb0dae8c4c57aa50bbff7b3fd4d84476636bf1677 (patch)
tree75ea8968abeafc21be6d8cf8a244e90989332b0a
parent059b2b0385e632459c3f0a7c110b7a5ab6b6ce51 (diff)
Fixes for moving stuff to SwIterator
Change-Id: I834afb711920e480045a9f932770dab27dd1f3ad
-rw-r--r--sw/inc/calbck.hxx12
-rw-r--r--sw/inc/switerator.hxx18
2 files changed, 20 insertions, 10 deletions
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 5aab4dd9a255..88a9cb0f1f1f 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -257,6 +257,8 @@ class SwClientIter SAL_FINAL : public sw::Ring<SwClientIter>
// is marked down to become the current object in the next step
// this is necessary because iteration requires access to members of the current object
SwClient* m_pPosition;
+ SwClient* GetLeftOfPos() { return static_cast<SwClient*>(m_pPosition->m_pLeft); }
+ SwClient* GetRighOfPos() { return static_cast<SwClient*>(m_pPosition->m_pRight); }
// iterator can be limited to return only SwClient objects of a certain type
TypeId m_aSearchType;
@@ -330,8 +332,16 @@ SwClient::SwClient( SwModify* pToRegisterIn )
void SwModify::ModifyBroadcast( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, TypeId nType)
{
SwClientIter aIter(*this);
- for(aIter.First(nType); aIter; aIter.Next())
+ aIter.GoStart();
+ while(aIter)
+ {
+ if( aIter.m_pPosition == aIter.m_pCurrent )
+ aIter.m_pPosition = static_cast<SwClient*>(aIter.m_pPosition->m_pRight);
+ while(aIter.m_pPosition && !aIter.m_pPosition->IsA( nType ) )
+ aIter.m_pPosition = static_cast<SwClient*>(aIter.m_pPosition->m_pRight);
+ aIter.m_pCurrent = aIter.m_pPosition;
aIter->Modify( pOldValue, pNewValue );
+ }
}
void SwModify::CallSwClientNotify( const SfxHint& rHint ) const
diff --git a/sw/inc/switerator.hxx b/sw/inc/switerator.hxx
index 4a9f277b0afb..440c4e63a281 100644
--- a/sw/inc/switerator.hxx
+++ b/sw/inc/switerator.hxx
@@ -35,34 +35,34 @@ public:
if(!aClientIter.m_pPosition)
return nullptr;
aClientIter.m_pCurrent = nullptr;
- return PTR_CAST(TElementType,aClientIter.Next());
+ return Next();
}
TElementType* Last()
{
aClientIter.m_aSearchType = TYPE(TElementType);
- GoEnd();
+ aClientIter.GoEnd();
if(!aClientIter.m_pPosition)
return nullptr;
- if(aClientIter.m_pPosition->IsA(TYPE(TElementType))
+ if(aClientIter.m_pPosition->IsA(TYPE(TElementType)))
return PTR_CAST(TElementType,aClientIter.m_pPosition);
- return PTR_CAST(TElementType,aClientIter.Previous());
+ return Previous();
}
TElementType* Next()
{
if( aClientIter.m_pPosition == aClientIter.m_pCurrent )
- aClientIter.m_pPosition = static_cast<SwClient*>(aClientIter.m_pPosition->m_pRight);
+ aClientIter.m_pPosition = aClientIter.GetRighOfPos();
while(aClientIter.m_pPosition && !aClientIter.m_pPosition->IsA( TYPE(TElementType) ) )
- aClientIter.m_pPosition = static_cast<SwClient*>(aClientIter.m_pPosition->m_pRight);
+ aClientIter.m_pPosition = aClientIter.GetRighOfPos();
return PTR_CAST(TElementType,aClientIter.m_pCurrent = aClientIter.m_pPosition);
}
TElementType* Previous()
{
- aClientIter.m_pPosition = static_cast<SwClient*>(aClientIter.m_pPosition->m_pLeft);
+ aClientIter.m_pPosition = aClientIter.GetLeftOfPos();
while(aClientIter.m_pPosition && !aClientIter.m_pPosition->IsA( TYPE(TElementType) ) )
- aClientIter.m_pPosition = static_cast<SwClient*>(aClientIter.m_pPosition->m_pLeft);
+ aClientIter.m_pPosition = aClientIter.GetLeftOfPos();
return PTR_CAST(TElementType,aClientIter.m_pCurrent = aClientIter.m_pPosition);
}
- static TElementType* FirstElement( const TSource& rMod ) { SwClient* p = SwClientIter(rMod).First(TYPE(TElementType)); return PTR_CAST(TElementType,p); }
+ static TElementType* FirstElement( const TSource& rMod ) { return SwIterator<TElementType, TSource>(rMod).First(); }
bool IsChanged() { return aClientIter.IsChanged(); }
};