Kaydet (Commit) a65e98af authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

Revert "Revert "make ClientIteratorBase only know about WriterListener""

This reverts commit 5fb7f222.

Conflicts:
	sw/inc/calbck.hxx

Change-Id: If25df4d2bbb77328cbb59c003d56eb0f88c73c67
üst 1e120b0b
...@@ -98,6 +98,7 @@ class SW_DLLPUBLIC SwClient : ::sw::WriterListener ...@@ -98,6 +98,7 @@ class SW_DLLPUBLIC SwClient : ::sw::WriterListener
// avoids making the details of the linked list and the callback method public // avoids making the details of the linked list and the callback method public
friend class SwModify; friend class SwModify;
friend class sw::ClientIteratorBase; friend class sw::ClientIteratorBase;
template<typename E, typename S> friend class SwIterator;
SwModify *pRegisteredIn; ///< event source SwModify *pRegisteredIn; ///< event source
...@@ -192,7 +193,7 @@ public: ...@@ -192,7 +193,7 @@ public:
void Add(SwClient *pDepend); void Add(SwClient *pDepend);
SwClient* Remove(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 // get information about attribute
virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE; virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
...@@ -250,11 +251,11 @@ namespace sw ...@@ -250,11 +251,11 @@ namespace sw
protected: protected:
const SwModify& m_rRoot; const SwModify& m_rRoot;
// the current object in an iteration // 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 // 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 // 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 // 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; static SW_DLLPUBLIC ClientIteratorBase* our_pClientIters;
ClientIteratorBase( const SwModify& rModify ) ClientIteratorBase( const SwModify& rModify )
...@@ -262,15 +263,15 @@ namespace sw ...@@ -262,15 +263,15 @@ namespace sw
{ {
MoveTo(our_pClientIters); MoveTo(our_pClientIters);
our_pClientIters = this; 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); } WriterListener* GetLeftOfPos() { return m_pPosition->m_pLeft; }
SwClient* GetRightOfPos() { return static_cast<SwClient*>(m_pPosition->m_pRight); } WriterListener* GetRightOfPos() { return m_pPosition->m_pRight; }
SwClient* GoStart() 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 ) 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; return m_pCurrent = m_pPosition;
} }
~ClientIteratorBase() SAL_OVERRIDE ~ClientIteratorBase() SAL_OVERRIDE
...@@ -285,7 +286,7 @@ namespace sw ...@@ -285,7 +286,7 @@ namespace sw
// SwModify::Add() asserts this // SwModify::Add() asserts this
bool IsChanged() const { return m_pPosition != m_pCurrent; } bool IsChanged() const { return m_pPosition != m_pCurrent; }
// ensures the iterator to point at a current client // ensures the iterator to point at a current client
SwClient* Sync() { return m_pCurrent = m_pPosition; } WriterListener* Sync() { return m_pCurrent = m_pPosition; }
}; };
} }
...@@ -306,12 +307,12 @@ public: ...@@ -306,12 +307,12 @@ public:
TElementType* Last() TElementType* Last()
{ {
if(!m_pPosition) if(!m_pPosition)
m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends()); m_pPosition = const_cast<sw::WriterListener*>(m_rRoot.GetDepends());
if(!m_pPosition) if(!m_pPosition)
return static_cast<TElementType*>(Sync()); return static_cast<TElementType*>(Sync());
while(GetRightOfPos()) while(GetRightOfPos())
m_pPosition = GetRightOfPos(); m_pPosition = GetRightOfPos();
if(m_pPosition->IsA(TYPE(TElementType))) if(static_cast<SwClient*>(m_pPosition)->IsA(TYPE(TElementType)))
return static_cast<TElementType*>(Sync()); return static_cast<TElementType*>(Sync());
return Previous(); return Previous();
} }
...@@ -319,14 +320,14 @@ public: ...@@ -319,14 +320,14 @@ public:
{ {
if(!IsChanged()) if(!IsChanged())
m_pPosition = GetRightOfPos(); 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(); m_pPosition = GetRightOfPos();
return static_cast<TElementType*>(Sync()); return static_cast<TElementType*>(Sync());
} }
TElementType* Previous() TElementType* Previous()
{ {
m_pPosition = GetLeftOfPos(); 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(); m_pPosition = GetLeftOfPos();
return static_cast<TElementType*>(Sync()); return static_cast<TElementType*>(Sync());
} }
...@@ -339,27 +340,27 @@ template< typename TSource > class SwIterator<SwClient, TSource> SAL_FINAL : pri ...@@ -339,27 +340,27 @@ template< typename TSource > class SwIterator<SwClient, TSource> SAL_FINAL : pri
public: public:
SwIterator( const TSource& rSrc ) : sw::ClientIteratorBase(rSrc) {} SwIterator( const TSource& rSrc ) : sw::ClientIteratorBase(rSrc) {}
SwClient* First() SwClient* First()
{ return GoStart(); } { return static_cast<SwClient*>(GoStart()); }
SwClient* Last() SwClient* Last()
{ {
if(!m_pPosition) if(!m_pPosition)
m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends()); m_pPosition = const_cast<sw::WriterListener*>(m_rRoot.GetDepends());
if(!m_pPosition) if(!m_pPosition)
return m_pCurrent = nullptr; return m_pCurrent = nullptr;
while(GetRightOfPos()) while(GetRightOfPos())
m_pPosition = GetRightOfPos(); m_pPosition = GetRightOfPos();
return Sync(); return static_cast<SwClient*>(Sync());
} }
SwClient* Next() SwClient* Next()
{ {
if(!IsChanged()) if(!IsChanged())
m_pPosition = GetRightOfPos(); m_pPosition = GetRightOfPos();
return Sync(); return static_cast<SwClient*>(Sync());
} }
SwClient* Previous() SwClient* Previous()
{ {
m_pPosition = GetLeftOfPos(); m_pPosition = GetLeftOfPos();
return Sync(); return static_cast<SwClient*>(Sync());
} }
using sw::ClientIteratorBase::IsChanged; using sw::ClientIteratorBase::IsChanged;
}; };
......
...@@ -528,7 +528,7 @@ sal_uLong SwSetExpFieldType::GetSeqFormat() ...@@ -528,7 +528,7 @@ sal_uLong SwSetExpFieldType::GetSeqFormat()
if( !GetDepends() ) if( !GetDepends() )
return SVX_NUM_ARABIC; 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(); return pFld->GetFormat();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment