diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-03-20 03:08:22 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-03-20 19:07:20 +0100 |
commit | 0bf4e6e21101a66bb63778ab49006ee90c16ea94 (patch) | |
tree | 20721b904780f2f47c308c140dbc2c2fd5a5b822 /sw | |
parent | e7f65a0a989385a887f8b4e91336202e3e96eec5 (diff) |
make ClientIteratorBase only know about WriterListener
Change-Id: Ice6fb793e3f27abfbf000b4a290fd4f3309e1770
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/calbck.hxx | 47 | ||||
-rw-r--r-- | sw/source/core/fields/expfld.cxx | 2 |
2 files changed, 25 insertions, 24 deletions
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx index 2af23b7f9d17..4ff6cc71038f 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -98,6 +98,7 @@ class SW_DLLPUBLIC SwClient : ::sw::WriterListener // avoids making the details of the linked list and the callback method public friend class SwModify; friend class sw::ClientIteratorBase; + template<typename E, typename S> friend class SwIterator; SwModify *pRegisteredIn; ///< event source @@ -192,7 +193,7 @@ public: void Add(SwClient *pDepend); SwClient* Remove(SwClient *pDepend); - const SwClient* GetDepends() const { return static_cast<SwClient*>(pRoot); } + const sw::WriterListener* GetDepends() const { return pRoot; } // get information about attribute virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE; @@ -250,11 +251,11 @@ namespace sw protected: const SwModify& m_rRoot; // the current object in an iteration - SwClient* m_pCurrent; + WriterListener* m_pCurrent; // in case the current object is already removed, the next object in the list // 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; + WriterListener* m_pPosition; static SW_DLLPUBLIC ClientIteratorBase* our_pClientIters; ClientIteratorBase( const SwModify& rModify ) @@ -262,15 +263,15 @@ namespace sw { MoveTo(our_pClientIters); our_pClientIters = this; - m_pCurrent = m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends()); + m_pCurrent = m_pPosition = const_cast<WriterListener*>(m_rRoot.GetDepends()); } - SwClient* GetLeftOfPos() { return static_cast<SwClient*>(m_pPosition->m_pLeft); } - SwClient* GetRightOfPos() { return static_cast<SwClient*>(m_pPosition->m_pRight); } - SwClient* GoStart() + WriterListener* GetLeftOfPos() { return m_pPosition->m_pLeft; } + WriterListener* GetRightOfPos() { return m_pPosition->m_pRight; } + WriterListener* GoStart() { - if((m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends()))) + if((m_pPosition = const_cast<WriterListener*>(m_rRoot.GetDepends()))) while( m_pPosition->m_pLeft ) - m_pPosition = static_cast<SwClient*>(m_pPosition->m_pLeft); + m_pPosition = m_pPosition->m_pLeft; return m_pCurrent = m_pPosition; } ~ClientIteratorBase() SAL_OVERRIDE @@ -285,7 +286,7 @@ namespace sw // 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; } + WriterListener* Sync() { return m_pCurrent = m_pPosition; } }; } @@ -306,29 +307,29 @@ public: TElementType* Last() { if(!m_pPosition) - m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends()); + m_pPosition = const_cast<sw::WriterListener*>(m_rRoot.GetDepends()); if(!m_pPosition) - return PTR_CAST(TElementType,Sync()); + return PTR_CAST(TElementType,static_cast<SwClient*>(Sync())); while(GetRightOfPos()) m_pPosition = GetRightOfPos(); - if(m_pPosition->IsA(TYPE(TElementType))) - return PTR_CAST(TElementType,Sync()); + if(static_cast<SwClient*>(m_pPosition)->IsA(TYPE(TElementType))) + return PTR_CAST(TElementType,static_cast<SwClient*>(Sync())); return Previous(); } TElementType* Next() { if(!IsChanged()) m_pPosition = GetRightOfPos(); - while(m_pPosition && !m_pPosition->IsA( TYPE(TElementType) ) ) + while(m_pPosition && !static_cast<SwClient*>(m_pPosition)->IsA( TYPE(TElementType) ) ) m_pPosition = GetRightOfPos(); - return PTR_CAST(TElementType,Sync()); + return PTR_CAST(TElementType,static_cast<SwClient*>(Sync())); } TElementType* Previous() { m_pPosition = GetLeftOfPos(); - while(m_pPosition && !m_pPosition->IsA( TYPE(TElementType) ) ) + while(m_pPosition && !static_cast<SwClient*>(m_pPosition)->IsA( TYPE(TElementType) ) ) m_pPosition = GetLeftOfPos(); - return PTR_CAST(TElementType,Sync()); + return PTR_CAST(TElementType,static_cast<SwClient*>(Sync())); } using sw::ClientIteratorBase::IsChanged; }; @@ -339,27 +340,27 @@ template< typename TSource > class SwIterator<SwClient, TSource> SAL_FINAL : pri public: SwIterator( const TSource& rSrc ) : sw::ClientIteratorBase(rSrc) {} SwClient* First() - { return GoStart(); } + { return static_cast<SwClient*>(GoStart()); } SwClient* Last() { if(!m_pPosition) - m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends()); + m_pPosition = const_cast<sw::WriterListener*>(m_rRoot.GetDepends()); if(!m_pPosition) return m_pCurrent = nullptr; while(GetRightOfPos()) m_pPosition = GetRightOfPos(); - return Sync(); + return static_cast<SwClient*>(Sync()); } SwClient* Next() { if(!IsChanged()) m_pPosition = GetRightOfPos(); - return Sync(); + return static_cast<SwClient*>(Sync()); } SwClient* Previous() { m_pPosition = GetLeftOfPos(); - return Sync(); + return static_cast<SwClient*>(Sync()); } using sw::ClientIteratorBase::IsChanged; }; diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 24ba569756fd..80b9acecc5fe 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -528,7 +528,7 @@ sal_uLong SwSetExpFieldType::GetSeqFormat() if( !GetDepends() ) return SVX_NUM_ARABIC; - const SwField *pFld = static_cast<const SwFmtFld*>(GetDepends())->GetField(); + const SwField *pFld = SwIterator<SwFmtFld,SwSetExpFieldType>(*this).First()->GetField(); return pFld->GetFormat(); } |