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

move Ring to sw::Ring

Change-Id: I3109185f747b821ee94aae5c58f86768ca30713a
üst 6172730c
...@@ -155,7 +155,7 @@ void _InitPam(); ...@@ -155,7 +155,7 @@ void _InitPam();
class SwPaM; class SwPaM;
/// PaM is Point and Mark: a selection of the document model. /// PaM is Point and Mark: a selection of the document model.
class SW_DLLPUBLIC SwPaM : public Ring<SwPaM> class SW_DLLPUBLIC SwPaM : public sw::Ring<SwPaM>
{ {
SwPosition m_Bound1; SwPosition m_Bound1;
SwPosition m_Bound2; SwPosition m_Bound2;
......
...@@ -24,12 +24,14 @@ ...@@ -24,12 +24,14 @@
#include <boost/iterator/iterator_facade.hpp> #include <boost/iterator/iterator_facade.hpp>
#include <boost/intrusive/circular_list_algorithms.hpp> #include <boost/intrusive/circular_list_algorithms.hpp>
class Ring_node_traits; namespace sw
template <class T> class RingIterator;
template <class T>
class SW_DLLPUBLIC Ring
{ {
class Ring_node_traits;
template <class T> class RingIterator;
template <class T>
class SW_DLLPUBLIC Ring
{
struct Ring_node_traits struct Ring_node_traits
{ {
typedef T node; typedef T node;
...@@ -45,11 +47,11 @@ class SW_DLLPUBLIC Ring ...@@ -45,11 +47,11 @@ class SW_DLLPUBLIC Ring
T* pNext; T* pNext;
T* pPrev; ///< In order to speed up inserting and deleting. T* pPrev; ///< In order to speed up inserting and deleting.
protected: protected:
Ring() Ring()
{ algo::init_header(static_cast< T* >(this)); } { algo::init_header(static_cast< T* >(this)); }
Ring( T* ); Ring( T* );
public: public:
typedef RingIterator<T> iterator; typedef RingIterator<T> iterator;
typedef RingIterator<T> const_iterator; typedef RingIterator<T> const_iterator;
virtual ~Ring() virtual ~Ring()
...@@ -66,21 +68,21 @@ public: ...@@ -66,21 +68,21 @@ public:
sal_uInt32 numberOf() const sal_uInt32 numberOf() const
{ return algo::count(static_cast< const T* >(this)); } { return algo::count(static_cast< const T* >(this)); }
}; };
template <class T> template <class T>
inline Ring<T>::Ring( T* pObj ) inline Ring<T>::Ring( T* pObj )
{ {
T* pThis = static_cast< T* >(this); T* pThis = static_cast< T* >(this);
if( !pObj ) if( !pObj )
algo::init_header(pThis); algo::init_header(pThis);
else else
algo::link_before(pObj, pThis); algo::link_before(pObj, pThis);
} }
template <class T> template <class T>
inline void Ring<T>::MoveTo(T* pDestRing) inline void Ring<T>::MoveTo(T* pDestRing)
{ {
T* pThis = static_cast< T* >(this); T* pThis = static_cast< T* >(this);
// insert into "new" // insert into "new"
if( pDestRing ) if( pDestRing )
...@@ -92,22 +94,22 @@ inline void Ring<T>::MoveTo(T* pDestRing) ...@@ -92,22 +94,22 @@ inline void Ring<T>::MoveTo(T* pDestRing)
} }
else else
algo::unlink(pThis); algo::unlink(pThis);
} }
template <class T> template <class T>
inline void Ring<T>::MoveRingTo(T* pDestRing) inline void Ring<T>::MoveRingTo(T* pDestRing)
{ {
std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext)); std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
std::swap(*(&pPrev), *(&pDestRing->pPrev)); std::swap(*(&pPrev), *(&pDestRing->pPrev));
} }
template <class T> template <class T>
class RingIterator : public boost::iterator_facade< class RingIterator : public boost::iterator_facade<
RingIterator<T> RingIterator<T>
, T , T
, boost::forward_traversal_tag , boost::forward_traversal_tag
> >
{ {
public: public:
RingIterator() RingIterator()
: m_pCurrent(nullptr) : m_pCurrent(nullptr)
...@@ -130,16 +132,17 @@ class RingIterator : public boost::iterator_facade< ...@@ -130,16 +132,17 @@ class RingIterator : public boost::iterator_facade<
{ return m_pCurrent ? *m_pCurrent : * m_pStart; } { return m_pCurrent ? *m_pCurrent : * m_pStart; }
T* m_pCurrent; T* m_pCurrent;
T* m_pStart; T* m_pStart;
}; };
template <class T> template <class T>
inline typename Ring<T>::iterator Ring<T>::beginRing() inline typename Ring<T>::iterator Ring<T>::beginRing()
{ return Ring<T>::iterator(static_cast< T* >(this)); }; { return Ring<T>::iterator(static_cast< T* >(this)); };
template <class T> template <class T>
inline typename Ring<T>::iterator Ring<T>::endRing() inline typename Ring<T>::iterator Ring<T>::endRing()
{ return Ring<T>::iterator(static_cast< T* >(this), false); }; { return Ring<T>::iterator(static_cast< T* >(this), false); };
}
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -95,7 +95,7 @@ enum FrameControlType ...@@ -95,7 +95,7 @@ enum FrameControlType
typedef boost::shared_ptr<SwRootFrm> SwRootFrmPtr; typedef boost::shared_ptr<SwRootFrm> SwRootFrmPtr;
class SwViewShell; class SwViewShell;
class SW_DLLPUBLIC SwViewShell : public Ring<SwViewShell> class SW_DLLPUBLIC SwViewShell : public sw::Ring<SwViewShell>
{ {
friend void SetOutDev( SwViewShell *pSh, OutputDevice *pOut ); friend void SetOutDev( SwViewShell *pSh, OutputDevice *pOut );
friend void SetOutDevAndWin( SwViewShell *pSh, OutputDevice *pOut, friend void SetOutDevAndWin( SwViewShell *pSh, OutputDevice *pOut,
......
...@@ -1275,9 +1275,9 @@ void SwDocTest::testMarkMove() ...@@ -1275,9 +1275,9 @@ void SwDocTest::testMarkMove()
namespace namespace
{ {
struct TestRing : public Ring<TestRing> struct TestRing : public sw::Ring<TestRing>
{ {
TestRing() : Ring<TestRing>() {}; TestRing() : sw::Ring<TestRing>() {};
void debug() void debug()
{ {
SAL_DEBUG("TestRing at: " << this << " prev: " << GetPrev() << " next: " << GetNext()); SAL_DEBUG("TestRing at: " << this << " prev: " << GetPrev() << " next: " << GetNext());
......
...@@ -1828,7 +1828,7 @@ long SwDoc::CompareDoc( const SwDoc& rDoc ) ...@@ -1828,7 +1828,7 @@ long SwDoc::CompareDoc( const SwDoc& rDoc )
} }
class _SaveMergeRedlines; class _SaveMergeRedlines;
class _SaveMergeRedlines : public Ring<_SaveMergeRedlines> class _SaveMergeRedlines : public sw::Ring<_SaveMergeRedlines>
{ {
const SwRangeRedline* pSrcRedl; const SwRangeRedline* pSrcRedl;
SwRangeRedline* pDestRedl; SwRangeRedline* pDestRedl;
......
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