summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-18 17:36:44 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-20 02:25:03 +0100
commit16fdd721631b7c93880f601b0253ad4053865d77 (patch)
tree9162d65f195dbfca82d51a950fe05cd9e67e0272
parentb72b1011fe2548ff5d9507e39da1528a1c4c7503 (diff)
introduce Sync() helper
Change-Id: I9fbbb8fa1d0fee1b761143923c843658f3fd4053
-rw-r--r--sw/inc/calbck.hxx17
1 files changed, 9 insertions, 8 deletions
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 516d8ab6a4c0..713277a9e4b9 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -286,6 +286,8 @@ namespace sw
// adding objects to a client chain in iteration is forbidden
// SwModify::Add() asserts this
bool IsChanged() const { return m_pPosition != m_pCurrent; }
+ // ensures the iterator to point at a current client
+ SwClient* Sync() { return m_pCurrent = m_pPosition; }
};
}
@@ -294,7 +296,6 @@ template< typename TElementType, typename TSource > class SwIterator SAL_FINAL :
static_assert(std::is_base_of<SwClient,TElementType>::value, "TElementType needs to be derived from SwClient");
static_assert(std::is_base_of<SwModify,TSource>::value, "TSource needs to be derived from SwModify");
public:
-
SwIterator( const TSource& rSrc ) : sw::ClientIteratorBase(rSrc) {}
TElementType* First()
{
@@ -309,11 +310,11 @@ public:
if(!m_pPosition)
m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends());
if(!m_pPosition)
- return PTR_CAST(TElementType,m_pCurrent = nullptr);
+ return PTR_CAST(TElementType,Sync());
while(GetRightOfPos())
m_pPosition = GetRightOfPos();
if(m_pPosition->IsA(TYPE(TElementType)))
- return PTR_CAST(TElementType,m_pCurrent = m_pPosition);
+ return PTR_CAST(TElementType,Sync());
return Previous();
}
TElementType* Next()
@@ -322,14 +323,14 @@ public:
m_pPosition = GetRightOfPos();
while(m_pPosition && !m_pPosition->IsA( TYPE(TElementType) ) )
m_pPosition = GetRightOfPos();
- return PTR_CAST(TElementType,m_pCurrent = m_pPosition);
+ return PTR_CAST(TElementType,Sync());
}
TElementType* Previous()
{
m_pPosition = GetLeftOfPos();
while(m_pPosition && !m_pPosition->IsA( TYPE(TElementType) ) )
m_pPosition = GetLeftOfPos();
- return PTR_CAST(TElementType,m_pCurrent = m_pPosition);
+ return PTR_CAST(TElementType,Sync());
}
using sw::ClientIteratorBase::IsChanged;
};
@@ -349,18 +350,18 @@ public:
return m_pCurrent = nullptr;
while(GetRightOfPos())
m_pPosition = GetRightOfPos();
- return m_pCurrent = m_pPosition;
+ return Sync();
}
SwClient* Next()
{
if( m_pPosition == m_pCurrent )
m_pPosition = GetRightOfPos();
- return m_pCurrent = m_pPosition;
+ return Sync();
}
SwClient* Previous()
{
m_pPosition = GetLeftOfPos();
- return m_pCurrent = m_pPosition;
+ return Sync();
}
using sw::ClientIteratorBase::IsChanged;
};