summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-18 15:01:34 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-19 23:41:07 +0100
commita5fead9c44e2965587919e675ab5fa5e9c4a6b7f (patch)
tree00c53c045ca58ec0d0f73e8e188622eee4ff5215 /sw/inc
parent25a99a65e8aa2962ed980ed750c349d7863eb87c (diff)
specialize SwIterator<SwClient, T>
Change-Id: I6d9457e8f005dffef5ce8969ad895b43e90efadd
Diffstat (limited to 'sw/inc')
-rw-r--r--sw/inc/calbck.hxx41
1 files changed, 39 insertions, 2 deletions
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<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");
SwClientIter aClientIter;
@@ -355,6 +354,44 @@ public:
bool IsChanged() { return aClientIter.IsChanged(); }
};
+template< typename TSource > class SwIterator<SwClient, TSource>
+{
+ static_assert(std::is_base_of<SwModify,TSource>::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<SwClient*>(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 )
{