From a5fead9c44e2965587919e675ab5fa5e9c4a6b7f Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Wed, 18 Mar 2015 15:01:34 +0100 Subject: specialize SwIterator Change-Id: I6d9457e8f005dffef5ce8969ad895b43e90efadd --- sw/inc/calbck.hxx | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'sw/inc/calbck.hxx') diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx index 8fa3ff5e8c26..0059a4c4c685 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -308,9 +308,8 @@ public: bool IsChanged() const { return m_pPosition != m_pCurrent; } }; -template< class TElementType, class TSource > class SwIterator SAL_FINAL +template< typename TElementType, typename TSource > class SwIterator SAL_FINAL { - static_assert(std::is_base_of::value, "TElementType needs to be derived from SwClient"); static_assert(std::is_base_of::value, "TSource needs to be derived from SwModify"); SwClientIter aClientIter; @@ -355,6 +354,44 @@ public: bool IsChanged() { return aClientIter.IsChanged(); } }; +template< typename TSource > class SwIterator +{ + static_assert(std::is_base_of::value, "TSource needs to be derived from SwModify"); + SwClientIter aClientIter; +public: + SwIterator( const TSource& rSrc ) : aClientIter(rSrc) {} + SwClient* First() + { + aClientIter.GoStart(); + if(!aClientIter.m_pPosition) + return nullptr; + aClientIter.m_pCurrent = nullptr; + return Next(); + } + SwClient* Last() + { + if(!aClientIter.m_pPosition) + aClientIter.m_pPosition = const_cast(aClientIter.m_rRoot.GetDepends()); + if(!aClientIter.m_pPosition) + return aClientIter.m_pCurrent = nullptr; + while(aClientIter.GetRighOfPos()) + aClientIter.m_pPosition = aClientIter.GetRighOfPos(); + return aClientIter.m_pCurrent = aClientIter.m_pPosition; + } + SwClient* Next() + { + if( aClientIter.m_pPosition == aClientIter.m_pCurrent ) + aClientIter.m_pPosition = aClientIter.GetRighOfPos(); + return aClientIter.m_pCurrent = aClientIter.m_pPosition; + } + SwClient* Previous() + { + aClientIter.m_pPosition = aClientIter.GetLeftOfPos(); + return aClientIter.m_pCurrent = aClientIter.m_pPosition; + } + bool IsChanged() { return aClientIter.IsChanged(); } +}; + SwClient::SwClient( SwModify* pToRegisterIn ) : pRegisteredIn( nullptr ) { -- cgit