[Libreoffice-commits] core.git: 14 commits - sw/inc sw/Library_sw.mk sw/qa sw/source

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Mon Dec 1 15:38:33 PST 2014


 sw/Library_sw.mk                  |    1 
 sw/inc/edimp.hxx                  |   21 +----
 sw/inc/pam.hxx                    |    3 
 sw/inc/ring.hxx                   |  139 ++++++++++++++++++++++++++++++++++----
 sw/inc/viewsh.hxx                 |    3 
 sw/qa/core/uwriter.cxx            |   54 ++++++++++++++
 sw/source/core/access/accpara.cxx |    2 
 sw/source/core/bastyp/ring.cxx    |   88 ------------------------
 sw/source/core/crsr/crsrsh.cxx    |    2 
 sw/source/core/crsr/findattr.cxx  |   11 +--
 sw/source/core/crsr/findtxt.cxx   |    9 +-
 sw/source/core/crsr/unocrsr.cxx   |    2 
 sw/source/core/doc/doccomp.cxx    |    9 +-
 sw/source/core/doc/doccorr.cxx    |   71 +++++++------------
 sw/source/core/doc/docnew.cxx     |    2 
 sw/source/core/edit/acorrect.cxx  |   10 +-
 sw/source/core/edit/autofmt.cxx   |    5 -
 17 files changed, 245 insertions(+), 187 deletions(-)

New commits:
commit 2d28ed7b0ef302b9f6923ad02822882357b6d1aa
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 20:50:33 2014 +0100

    kill FOREACHPAM_START_CONST
    
    it was used for iterations with non-const operations only anyway
    
    Change-Id: I63b0c1b3a58ff940820f469e586369cb2a255df7

diff --git a/sw/inc/edimp.hxx b/sw/inc/edimp.hxx
index 5d2e813..9f22e64 100644
--- a/sw/inc/edimp.hxx
+++ b/sw/inc/edimp.hxx
@@ -31,15 +31,10 @@ class SwNodeIndex;
 #define PCURCRSR (static_cast<SwPaM *>(&__r))
 
 #define FOREACHPAM_START(pCURSH) \
-    BOOST_FOREACH(SwPaM& __r, std::make_pair(static_cast< SwPaM* >(pCURSH)->beginRing(), static_cast< SwPaM* >(pCURSH)->endRing())) \
-    {
-
-#define FOREACHPAM_START_CONST(pCURSH) \
-    BOOST_FOREACH(SwPaM& __r, std::make_pair(pCURSH->beginRing(), pCURSH->endRing())) \
+    BOOST_FOREACH(SwPaM& __r, std::make_pair((pCURSH)->beginRing(), (pCURSH)->endRing())) \
     {
 
 #define FOREACHPAM_END() }
-#define FOREACHPAM_END_CONST() }
 
 struct SwPamRange
 {
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 2698a9a..67f6c95 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -261,9 +261,11 @@ void PaMCorrRel( const SwNodeIndex &rOldNode,
                 } while ( (_pStkCrsr != 0 ) &&
                     ((_pStkCrsr = static_cast<SwPaM *>(_pStkCrsr->GetNext())) != pCrsrShell->GetStkCrsr()) );
 
-            FOREACHPAM_START_CONST( pCrsrShell->_GetCrsr() )
-                lcl_PaMCorrRel1( PCURCRSR, pOldNode, aNewPos, nCntIdx);
-            FOREACHPAM_END()
+            SwPaM* pStartPaM = pCrsrShell->_GetCrsr();
+            BOOST_FOREACH(SwPaM& rPaM, std::make_pair(pStartPaM->beginRing(), pStartPaM->endRing()))
+            {
+                lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx);
+            }
 
             if( pCrsrShell->IsTableMode() )
                 lcl_PaMCorrRel1( pCrsrShell->GetTblCrs(), pOldNode, aNewPos, nCntIdx );
commit d57baa3d5d197c6620078104cca57fd8104012f6
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 20:37:40 2014 +0100

    const iterators
    
    Change-Id: I129b51c2e736e04287141c0eae8c212c179a3475

diff --git a/sw/inc/edimp.hxx b/sw/inc/edimp.hxx
index a6dbcaf..5d2e813 100644
--- a/sw/inc/edimp.hxx
+++ b/sw/inc/edimp.hxx
@@ -34,7 +34,9 @@ class SwNodeIndex;
     BOOST_FOREACH(SwPaM& __r, std::make_pair(static_cast< SwPaM* >(pCURSH)->beginRing(), static_cast< SwPaM* >(pCURSH)->endRing())) \
     {
 
-#define FOREACHPAM_START_CONST(pCURSH) FOREACHPAM_START(pCURSH)
+#define FOREACHPAM_START_CONST(pCURSH) \
+    BOOST_FOREACH(SwPaM& __r, std::make_pair(pCURSH->beginRing(), pCURSH->endRing())) \
+    {
 
 #define FOREACHPAM_END() }
 #define FOREACHPAM_END_CONST() }
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index d5eb30b..b4d4043 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -53,7 +53,7 @@ namespace sw
         Ring( T* );
     public:
         typedef RingIterator<T> iterator;
-        typedef RingIterator<T> const_iterator;
+        typedef RingIterator<const T> const_iterator;
         virtual ~Ring()
             { algo::unlink(static_cast< T* >(this)); };
         void MoveTo( T* pDestRing );
@@ -65,6 +65,8 @@ namespace sw
         // also derive from other STL containers (which is bad anyway, but ...)
         iterator beginRing();
         iterator endRing();
+        const_iterator beginRing() const;
+        const_iterator endRing() const;
 
         sal_uInt32 numberOf() const
             { return algo::count(static_cast< const T* >(this)); }
@@ -142,6 +144,13 @@ namespace sw
     inline typename Ring<T>::iterator Ring<T>::endRing()
         { return Ring<T>::iterator(static_cast< T* >(this), false); };
 
+    template <class T>
+    inline typename Ring<T>::const_iterator Ring<T>::beginRing() const
+        { return Ring<T>::const_iterator(static_cast< const T* >(this)); };
+
+    template <class T>
+    inline typename Ring<T>::const_iterator Ring<T>::endRing() const
+        { return Ring<T>::const_iterator(static_cast< const T* >(this), false); };
 }
 #endif
 
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 6f9d1a2..2698a9a 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -33,29 +33,6 @@
 #include <hints.hxx>
 #include <edimp.hxx>
 
-/*
- * Macros to iterate over all CrsrShells
- */
-
-#define PCURSH_CONST static_cast<const SwCrsrShell*>(_pStartShell)
-
-#define FOREACHSHELL_START( pEShell ) \
-    {\
-        SwViewShell const *_pStartShell = pEShell; \
-        do { \
-            if( _pStartShell->IsA( TYPE( SwCrsrShell )) ) \
-            {
-
-#define FOREACHSHELL_END( pEShell ) \
-            } \
-        } while((_pStartShell = static_cast<SwViewShell const*>(_pStartShell->GetNext()))!= pEShell ); \
-    }
-
-#define FOREACHSHELL_END_CONST( pEShell ) \
-            } \
-        } while((_pStartShell = static_cast<SwViewShell const*>(_pStartShell->GetNext()))!= pEShell ); \
-    }
-
 namespace
 {
     /// find the relevant section in which the SwUnoCrsr may wander.
@@ -122,22 +99,25 @@ void PaMCorrAbs( const SwPaM& rRange,
 
     if( pShell )
     {
-        FOREACHSHELL_START( pShell )
-            SwPaM *_pStkCrsr = PCURSH_CONST->GetStkCrsr();
+        BOOST_FOREACH(const SwViewShell& rShell, std::make_pair(pShell->beginRing(), pShell->endRing()))
+        {
+            if(!rShell.IsA( TYPE( SwCrsrShell )))
+                continue;
+            const SwCrsrShell* pCrsrShell = static_cast<const SwCrsrShell*>(&rShell);
+            SwPaM *_pStkCrsr = pCrsrShell->GetStkCrsr();
             if( _pStkCrsr )
                 do {
                     lcl_PaMCorrAbs( *_pStkCrsr, aStart, aEnd, aNewPos );
                 } while ( (_pStkCrsr != 0 ) &&
-                    ((_pStkCrsr = static_cast<SwPaM *>(_pStkCrsr->GetNext())) != PCURSH_CONST->GetStkCrsr()) );
-
-            FOREACHPAM_START_CONST( const_cast< SwShellCrsr* >(PCURSH_CONST->_GetCrsr()) )
-                lcl_PaMCorrAbs( const_cast<SwPaM &>(*PCURCRSR), aStart, aEnd, aNewPos );
-            FOREACHPAM_END_CONST()
+                    ((_pStkCrsr = static_cast<SwPaM *>(_pStkCrsr->GetNext())) != pCrsrShell->GetStkCrsr()) );
 
-            if( PCURSH_CONST->IsTableMode() )
-                lcl_PaMCorrAbs( const_cast<SwPaM &>(*PCURSH_CONST->GetTblCrs()), aStart, aEnd, aNewPos );
+            FOREACHPAM_START( const_cast<SwShellCrsr*>(pCrsrShell->_GetCrsr()) )
+                lcl_PaMCorrAbs( *PCURCRSR, aStart, aEnd, aNewPos );
+            FOREACHPAM_END()
 
-        FOREACHSHELL_END_CONST( pShell )
+            if( pCrsrShell->IsTableMode() )
+                lcl_PaMCorrAbs( const_cast<SwPaM &>(*pCrsrShell->GetTblCrs()), aStart, aEnd, aNewPos );
+        }
     }
     {
         SwUnoCrsrTbl& rTbl = const_cast<SwUnoCrsrTbl&>(pDoc->GetUnoCrsrTbl());
@@ -269,22 +249,25 @@ void PaMCorrRel( const SwNodeIndex &rOldNode,
     SwCrsrShell const* pShell = pDoc->GetEditShell();
     if( pShell )
     {
-        FOREACHSHELL_START( pShell )
-            SwPaM *_pStkCrsr = PCURSH_CONST->GetStkCrsr();
+        BOOST_FOREACH(const SwViewShell& rShell, std::make_pair(pShell->beginRing(), pShell->endRing()))
+        {
+            if(!rShell.IsA( TYPE( SwCrsrShell )))
+                continue;
+            SwCrsrShell* pCrsrShell = const_cast<SwCrsrShell*>(static_cast<const SwCrsrShell*>(&rShell));
+            SwPaM *_pStkCrsr = pCrsrShell->GetStkCrsr();
             if( _pStkCrsr )
                 do {
                     lcl_PaMCorrRel1( _pStkCrsr, pOldNode, aNewPos, nCntIdx );
                 } while ( (_pStkCrsr != 0 ) &&
-                    ((_pStkCrsr = static_cast<SwPaM *>(_pStkCrsr->GetNext())) != PCURSH_CONST->GetStkCrsr()) );
+                    ((_pStkCrsr = static_cast<SwPaM *>(_pStkCrsr->GetNext())) != pCrsrShell->GetStkCrsr()) );
 
-            FOREACHPAM_START_CONST( const_cast< SwShellCrsr* >(PCURSH_CONST->_GetCrsr()) )
-                lcl_PaMCorrRel1( const_cast<SwPaM *>(PCURCRSR), pOldNode, aNewPos, nCntIdx);
+            FOREACHPAM_START_CONST( pCrsrShell->_GetCrsr() )
+                lcl_PaMCorrRel1( PCURCRSR, pOldNode, aNewPos, nCntIdx);
             FOREACHPAM_END()
 
-            if( PCURSH_CONST->IsTableMode() )
-                lcl_PaMCorrRel1( const_cast<SwPaM *>(PCURSH_CONST->GetTblCrs()), pOldNode, aNewPos, nCntIdx );
-
-        FOREACHSHELL_END( pShell )
+            if( pCrsrShell->IsTableMode() )
+                lcl_PaMCorrRel1( pCrsrShell->GetTblCrs(), pOldNode, aNewPos, nCntIdx );
+       }
     }
     {
         SwUnoCrsrTbl& rTbl = (SwUnoCrsrTbl&)pDoc->GetUnoCrsrTbl();
commit 7902e30aab21968648d53356d9d3533bbac17172
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 19:53:31 2014 +0100

    move Ring to sw::Ring
    
    Change-Id: I3109185f747b821ee94aae5c58f86768ca30713a

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 7594210..9e696d8 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -155,7 +155,7 @@ void _InitPam();
 
 class SwPaM;
 /// 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_Bound2;
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index cef2eef..d5eb30b 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -24,122 +24,125 @@
 #include <boost/iterator/iterator_facade.hpp>
 #include <boost/intrusive/circular_list_algorithms.hpp>
 
-class Ring_node_traits;
-template <class T> class RingIterator;
-
-template <class T>
-class SW_DLLPUBLIC Ring
+namespace sw
 {
-    struct Ring_node_traits
-    {
-        typedef T node;
-        typedef T* node_ptr;
-        typedef const T* const_node_ptr;
-        static node_ptr get_next(const_node_ptr n) { return n->GetNext(); };
-        static void set_next(node_ptr n, node_ptr next) { n->pNext = next; };
-        static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); };
-        static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; };
-    };
-    friend class Ring_node_traits;
-    typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
-    T* pNext;
-    T* pPrev;    ///< In order to speed up inserting and deleting.
+    class Ring_node_traits;
+    template <class T> class RingIterator;
 
-protected:
-    Ring()
-        { algo::init_header(static_cast< T* >(this)); }
-    Ring( T* );
-public:
-    typedef RingIterator<T> iterator;
-    typedef RingIterator<T> const_iterator;
-    virtual ~Ring()
-        { algo::unlink(static_cast< T* >(this)); };
-    void MoveTo( T* pDestRing );
-    void MoveRingTo( T* pDestRing );
+    template <class T>
+    class SW_DLLPUBLIC Ring
+    {
+        struct Ring_node_traits
+        {
+            typedef T node;
+            typedef T* node_ptr;
+            typedef const T* const_node_ptr;
+            static node_ptr get_next(const_node_ptr n) { return n->GetNext(); };
+            static void set_next(node_ptr n, node_ptr next) { n->pNext = next; };
+            static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); };
+            static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; };
+        };
+        friend class Ring_node_traits;
+        typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
+        T* pNext;
+        T* pPrev;    ///< In order to speed up inserting and deleting.
 
-    T* GetNext() const       { return pNext; }
-    T* GetPrev() const       { return pPrev; }
-    // unfortunately we cant name these STL-conforming, as some derived classes
-    // also derive from other STL containers (which is bad anyway, but ...)
-    iterator beginRing();
-    iterator endRing();
+    protected:
+        Ring()
+            { algo::init_header(static_cast< T* >(this)); }
+        Ring( T* );
+    public:
+        typedef RingIterator<T> iterator;
+        typedef RingIterator<T> const_iterator;
+        virtual ~Ring()
+            { algo::unlink(static_cast< T* >(this)); };
+        void MoveTo( T* pDestRing );
+        void MoveRingTo( T* pDestRing );
 
-    sal_uInt32 numberOf() const
-        { return algo::count(static_cast< const T* >(this)); }
-};
+        T* GetNext() const       { return pNext; }
+        T* GetPrev() const       { return pPrev; }
+        // unfortunately we cant name these STL-conforming, as some derived classes
+        // also derive from other STL containers (which is bad anyway, but ...)
+        iterator beginRing();
+        iterator endRing();
 
-template <class T>
-inline Ring<T>::Ring( T* pObj )
-{
-    T* pThis = static_cast< T* >(this);
-    if( !pObj )
-        algo::init_header(pThis);
-    else
-        algo::link_before(pObj, pThis);
-}
+        sal_uInt32 numberOf() const
+            { return algo::count(static_cast< const T* >(this)); }
+    };
 
-template <class T>
-inline void Ring<T>::MoveTo(T* pDestRing)
-{
-    T* pThis = static_cast< T* >(this);
-    // insert into "new"
-    if( pDestRing )
+    template <class T>
+    inline Ring<T>::Ring( T* pObj )
     {
-        if(algo::unique(pThis))
-            algo::link_before(pDestRing, pThis);
+        T* pThis = static_cast< T* >(this);
+        if( !pObj )
+            algo::init_header(pThis);
         else
-            algo::transfer(pDestRing, pThis);
+            algo::link_before(pObj, pThis);
     }
-    else
-        algo::unlink(pThis);
-}
-
-template <class T>
-inline void Ring<T>::MoveRingTo(T* pDestRing)
-{
-    std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
-    std::swap(*(&pPrev), *(&pDestRing->pPrev));
-}
 
-template <class T>
-class RingIterator : public boost::iterator_facade<
-      RingIterator<T>
-    , T
-    , boost::forward_traversal_tag
-    >
-{
-    public:
-        RingIterator()
-            : m_pCurrent(nullptr)
-            , m_pStart(nullptr)
-        {}
-        explicit RingIterator(T* pRing, bool bStart = true)
-            : m_pCurrent(nullptr)
-            , m_pStart(pRing)
+    template <class T>
+    inline void Ring<T>::MoveTo(T* pDestRing)
+    {
+        T* pThis = static_cast< T* >(this);
+        // insert into "new"
+        if( pDestRing )
         {
-            if(!bStart)
-                m_pCurrent = m_pStart;
+            if(algo::unique(pThis))
+                algo::link_before(pDestRing, pThis);
+            else
+                algo::transfer(pDestRing, pThis);
         }
-    private:
-        friend class boost::iterator_core_access;
-        void increment()
-            { m_pCurrent = m_pCurrent ? m_pCurrent->GetNext() : m_pStart->GetNext(); }
-        bool equal(RingIterator const& other) const
-            { return m_pCurrent == other.m_pCurrent && m_pStart == m_pStart; }
-        T& dereference() const
-            { return m_pCurrent ? *m_pCurrent : * m_pStart; }
-        T* m_pCurrent;
-        T* m_pStart;
-};
+        else
+            algo::unlink(pThis);
+    }
 
-template <class T>
-inline typename Ring<T>::iterator Ring<T>::beginRing()
-    { return Ring<T>::iterator(static_cast< T* >(this)); };
+    template <class T>
+    inline void Ring<T>::MoveRingTo(T* pDestRing)
+    {
+        std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
+        std::swap(*(&pPrev), *(&pDestRing->pPrev));
+    }
+
+    template <class T>
+    class RingIterator : public boost::iterator_facade<
+          RingIterator<T>
+        , T
+        , boost::forward_traversal_tag
+        >
+    {
+        public:
+            RingIterator()
+                : m_pCurrent(nullptr)
+                , m_pStart(nullptr)
+            {}
+            explicit RingIterator(T* pRing, bool bStart = true)
+                : m_pCurrent(nullptr)
+                , m_pStart(pRing)
+            {
+                if(!bStart)
+                    m_pCurrent = m_pStart;
+            }
+        private:
+            friend class boost::iterator_core_access;
+            void increment()
+                { m_pCurrent = m_pCurrent ? m_pCurrent->GetNext() : m_pStart->GetNext(); }
+            bool equal(RingIterator const& other) const
+                { return m_pCurrent == other.m_pCurrent && m_pStart == m_pStart; }
+            T& dereference() const
+                { return m_pCurrent ? *m_pCurrent : * m_pStart; }
+            T* m_pCurrent;
+            T* m_pStart;
+    };
+
+    template <class T>
+    inline typename Ring<T>::iterator Ring<T>::beginRing()
+        { return Ring<T>::iterator(static_cast< T* >(this)); };
 
-template <class T>
-inline typename Ring<T>::iterator Ring<T>::endRing()
-    { return Ring<T>::iterator(static_cast< T* >(this), false); };
+    template <class T>
+    inline typename Ring<T>::iterator Ring<T>::endRing()
+        { return Ring<T>::iterator(static_cast< T* >(this), false); };
 
+}
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index d5608ce..6896e9e 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -95,7 +95,7 @@ enum FrameControlType
 typedef boost::shared_ptr<SwRootFrm> SwRootFrmPtr;
 
 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 SetOutDevAndWin( SwViewShell *pSh, OutputDevice *pOut,
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 36e8e9a..d2cfaed 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1275,9 +1275,9 @@ void SwDocTest::testMarkMove()
 
 namespace
 {
-    struct TestRing : public Ring<TestRing>
+    struct TestRing : public sw::Ring<TestRing>
     {
-        TestRing() : Ring<TestRing>() {};
+        TestRing() : sw::Ring<TestRing>() {};
         void debug()
         {
             SAL_DEBUG("TestRing at: " << this << " prev: " << GetPrev() << " next: " << GetNext());
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 380caef..729323b 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1828,7 +1828,7 @@ long SwDoc::CompareDoc( const SwDoc& rDoc )
 }
 
 class _SaveMergeRedlines;
-class _SaveMergeRedlines : public Ring<_SaveMergeRedlines>
+class _SaveMergeRedlines : public sw::Ring<_SaveMergeRedlines>
 {
     const SwRangeRedline* pSrcRedl;
     SwRangeRedline* pDestRedl;
commit 6172730c6465c02a925ed07fbce7add390c437fc
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 19:53:02 2014 +0100

    no need to use Ring here anymore
    
    Change-Id: I868ba712561b10eec91bf254c3fb1cadd5fdb282

diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index 6a70795..ff341f8 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -1144,10 +1144,10 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion,
         const sal_Int32 nSttCnt = rSttCntIdx.GetIndex();
 
         // add to shell-cursor-ring so that the regions will be moved enventually
-        Ring<SwPaM>* pPrevRing(nullptr);
+        SwPaM* pPrevRing(nullptr);
         if( bRegExp )
         {
-            pPrevRing = pRegion->GetPrev();
+            pPrevRing = const_cast< SwPaM* >(pRegion)->GetPrev();
             const_cast< SwPaM* >(pRegion)->MoveRingTo( &rCursor );
         }
 
commit 66fc18538b544d62bc51f2fc485cf997433ff990
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 19:01:26 2014 +0100

    use new typesafer implementation
    
    Change-Id: I2228b2d421987c71e9738e32d138eccab02ea1db

diff --git a/sw/inc/edimp.hxx b/sw/inc/edimp.hxx
index b3240b9..a6dbcaf 100644
--- a/sw/inc/edimp.hxx
+++ b/sw/inc/edimp.hxx
@@ -31,12 +31,10 @@ class SwNodeIndex;
 #define PCURCRSR (static_cast<SwPaM *>(&__r))
 
 #define FOREACHPAM_START(pCURSH) \
-    BOOST_FOREACH(Ring& __r, std::make_pair(static_cast<Ring*>(pCURSH)->beginRing(), static_cast<Ring*>(pCURSH)->endRing())) \
+    BOOST_FOREACH(SwPaM& __r, std::make_pair(static_cast< SwPaM* >(pCURSH)->beginRing(), static_cast< SwPaM* >(pCURSH)->endRing())) \
     {
 
-#define FOREACHPAM_START_CONST(pCURSH) \
-    BOOST_FOREACH(Ring& __r, std::make_pair(const_cast<Ring*>(static_cast<const Ring*>(pCURSH))->beginRing(), const_cast<Ring*>(static_cast<const Ring*>(pCURSH))->endRing())) \
-    {
+#define FOREACHPAM_START_CONST(pCURSH) FOREACHPAM_START(pCURSH)
 
 #define FOREACHPAM_END() }
 #define FOREACHPAM_END_CONST() }
diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 8614453..7594210 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -153,8 +153,9 @@ extern SwGoInDoc fnGoCntntCellsSkipHidden;
 
 void _InitPam();
 
+class SwPaM;
 /// PaM is Point and Mark: a selection of the document model.
-class SW_DLLPUBLIC SwPaM : public Ring
+class SW_DLLPUBLIC SwPaM : public Ring<SwPaM>
 {
     SwPosition   m_Bound1;
     SwPosition   m_Bound2;
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index 90e3465..cef2eef 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -25,15 +25,16 @@
 #include <boost/intrusive/circular_list_algorithms.hpp>
 
 class Ring_node_traits;
-class RingIterator;
+template <class T> class RingIterator;
 
+template <class T>
 class SW_DLLPUBLIC Ring
 {
     struct Ring_node_traits
     {
-        typedef Ring node;
-        typedef Ring* node_ptr;
-        typedef const Ring* const_node_ptr;
+        typedef T node;
+        typedef T* node_ptr;
+        typedef const T* const_node_ptr;
         static node_ptr get_next(const_node_ptr n) { return n->GetNext(); };
         static void set_next(node_ptr n, node_ptr next) { n->pNext = next; };
         static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); };
@@ -41,64 +42,69 @@ class SW_DLLPUBLIC Ring
     };
     friend class Ring_node_traits;
     typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
-    Ring* pNext;
-    Ring* pPrev;    ///< In order to speed up inserting and deleting.
+    T* pNext;
+    T* pPrev;    ///< In order to speed up inserting and deleting.
 
 protected:
     Ring()
-        { algo::init_header(this); }
-    Ring( Ring * );
+        { algo::init_header(static_cast< T* >(this)); }
+    Ring( T* );
 public:
-    typedef RingIterator iterator;
-    typedef RingIterator const_iterator;
+    typedef RingIterator<T> iterator;
+    typedef RingIterator<T> const_iterator;
     virtual ~Ring()
-        { algo::unlink(this); };
-    void MoveTo( Ring *pDestRing );
-    void MoveRingTo( Ring *pDestRing );
+        { algo::unlink(static_cast< T* >(this)); };
+    void MoveTo( T* pDestRing );
+    void MoveRingTo( T* pDestRing );
 
-    Ring* GetNext() const       { return pNext; }
-    Ring* GetPrev() const       { return pPrev; }
+    T* GetNext() const       { return pNext; }
+    T* GetPrev() const       { return pPrev; }
     // unfortunately we cant name these STL-conforming, as some derived classes
     // also derive from other STL containers (which is bad anyway, but ...)
     iterator beginRing();
     iterator endRing();
 
     sal_uInt32 numberOf() const
-        { return algo::count(this); }
+        { return algo::count(static_cast< const T* >(this)); }
 };
 
-inline Ring::Ring( Ring *pObj )
+template <class T>
+inline Ring<T>::Ring( T* pObj )
 {
+    T* pThis = static_cast< T* >(this);
     if( !pObj )
-        algo::init_header(this);
+        algo::init_header(pThis);
     else
-        algo::link_before(pObj, this);
+        algo::link_before(pObj, pThis);
 }
 
-inline void Ring::MoveTo(Ring *pDestRing)
+template <class T>
+inline void Ring<T>::MoveTo(T* pDestRing)
 {
+    T* pThis = static_cast< T* >(this);
     // insert into "new"
     if( pDestRing )
     {
-        if(algo::unique(this))
-            algo::link_before(pDestRing, this);
+        if(algo::unique(pThis))
+            algo::link_before(pDestRing, pThis);
         else
-            algo::transfer(pDestRing, this);
+            algo::transfer(pDestRing, pThis);
     }
     else
-        algo::unlink(this);
-
+        algo::unlink(pThis);
 }
 
-inline void Ring::MoveRingTo(Ring *pDestRing)
+template <class T>
+inline void Ring<T>::MoveRingTo(T* pDestRing)
 {
     std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
     std::swap(*(&pPrev), *(&pDestRing->pPrev));
 }
 
+template <class T>
 class RingIterator : public boost::iterator_facade<
-      RingIterator
-    , Ring
+      RingIterator<T>
+    , T
     , boost::forward_traversal_tag
     >
 {
@@ -107,7 +113,7 @@ class RingIterator : public boost::iterator_facade<
             : m_pCurrent(nullptr)
             , m_pStart(nullptr)
         {}
-        explicit RingIterator(Ring* pRing, bool bStart = true)
+        explicit RingIterator(T* pRing, bool bStart = true)
             : m_pCurrent(nullptr)
             , m_pStart(pRing)
         {
@@ -120,17 +126,19 @@ class RingIterator : public boost::iterator_facade<
             { m_pCurrent = m_pCurrent ? m_pCurrent->GetNext() : m_pStart->GetNext(); }
         bool equal(RingIterator const& other) const
             { return m_pCurrent == other.m_pCurrent && m_pStart == m_pStart; }
-        Ring& dereference() const
+        T& dereference() const
             { return m_pCurrent ? *m_pCurrent : * m_pStart; }
-        Ring* m_pCurrent;
-        Ring* m_pStart;
+        T* m_pCurrent;
+        T* m_pStart;
 };
 
-inline Ring::iterator Ring::beginRing()
-    { return Ring::iterator(this); };
+template <class T>
+inline typename Ring<T>::iterator Ring<T>::beginRing()
+    { return Ring<T>::iterator(static_cast< T* >(this)); };
 
-inline Ring::iterator Ring::endRing()
-    { return Ring::iterator(this, false); };
+template <class T>
+inline typename Ring<T>::iterator Ring<T>::endRing()
+    { return Ring<T>::iterator(static_cast< T* >(this), false); };
 
 #endif
 
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 7eab337..d5608ce 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -94,7 +94,8 @@ enum FrameControlType
 #define VSHELLFLAG_SHARELAYOUT          ((long)0x2)
 typedef boost::shared_ptr<SwRootFrm> SwRootFrmPtr;
 
-class SW_DLLPUBLIC SwViewShell : public Ring
+class SwViewShell;
+class SW_DLLPUBLIC SwViewShell : public Ring<SwViewShell>
 {
     friend void SetOutDev( SwViewShell *pSh, OutputDevice *pOut );
     friend void SetOutDevAndWin( SwViewShell *pSh, OutputDevice *pOut,
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index d8da67b..36e8e9a 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1275,9 +1275,9 @@ void SwDocTest::testMarkMove()
 
 namespace
 {
-    struct TestRing : public Ring
+    struct TestRing : public Ring<TestRing>
     {
-        TestRing() : Ring() {};
+        TestRing() : Ring<TestRing>() {};
         void debug()
         {
             SAL_DEBUG("TestRing at: " << this << " prev: " << GetPrev() << " next: " << GetNext());
@@ -1312,12 +1312,12 @@ void SwDocTest::testIntrusiveRing()
         std::vector<TestRing*>::iterator ppNext = ppRing+1;
         if(ppNext==vRings.end())
             ppNext = vRings.begin();
-        CPPUNIT_ASSERT_EQUAL((*ppRing)->GetNext(), static_cast<Ring*>(*ppNext));
-        CPPUNIT_ASSERT_EQUAL((*ppNext)->GetPrev(), static_cast<Ring*>(*ppRing));
+        CPPUNIT_ASSERT_EQUAL((*ppRing)->GetNext(), *ppNext);
+        CPPUNIT_ASSERT_EQUAL((*ppNext)->GetPrev(), *ppRing);
     }
-    BOOST_FOREACH(Ring& r, std::make_pair(aRing1.beginRing(), aRing1.endRing()))
+    BOOST_FOREACH(TestRing& r, std::make_pair(aRing1.beginRing(), aRing1.endRing()))
     {
-        TestRing* pRing = dynamic_cast<TestRing*>(&r);
+        TestRing* pRing = &r;
         CPPUNIT_ASSERT(pRing);
         //pRing->debug();
     }
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 5978f87..b26e61c 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -3441,7 +3441,7 @@ sal_Bool SAL_CALL SwAccessibleParagraph::removeSelection( sal_Int32 selectionInd
                 {
                     if( nSelected == 0 )
                     {
-                        pCrsr->MoveTo((Ring*)0);
+                        pCrsr->MoveTo(nullptr);
                         delete pCrsr;
                         bRet = true;
                     }
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 5f6fd0e..33b21d1 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2406,7 +2406,7 @@ bool SwCrsrShell::IsOverReadOnlyPos( const Point& rPt ) const
 */
 sal_uInt16 SwCrsrShell::GetCrsrCnt( bool bAll ) const
 {
-    Ring* pTmp = GetCrsr()->GetNext();
+    SwPaM* pTmp = GetCrsr()->GetNext();
     sal_uInt16 n = (bAll || ( m_pCurCrsr->HasMark() &&
                     *m_pCurCrsr->GetPoint() != *m_pCurCrsr->GetMark())) ? 1 : 0;
     while( pTmp != m_pCurCrsr )
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index f7a3165..6a70795 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -1144,11 +1144,11 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion,
         const sal_Int32 nSttCnt = rSttCntIdx.GetIndex();
 
         // add to shell-cursor-ring so that the regions will be moved enventually
-        Ring *pPrevRing = 0;
+        Ring<SwPaM>* pPrevRing(nullptr);
         if( bRegExp )
         {
             pPrevRing = pRegion->GetPrev();
-            const_cast<Ring*>(static_cast<const Ring*>(pRegion))->MoveRingTo( &rCursor );
+            const_cast< SwPaM* >(pRegion)->MoveRingTo( &rCursor );
         }
 
         boost::scoped_ptr<OUString> pRepl( (bRegExp) ?
@@ -1161,11 +1161,12 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion,
         if( bRegExp )
         {
             // and remove region again
-            Ring *p, *pNext = (Ring*)pRegion;
+            SwPaM* p;
+            SwPaM* pNext = const_cast<SwPaM*>(pRegion);
             do {
                 p = pNext;
                 pNext = p->GetNext();
-                p->MoveTo( (Ring*)pRegion );
+                p->MoveTo( const_cast<SwPaM*>(pRegion) );
             } while( p != pPrevRing );
         }
         rSttCntIdx = nSttCnt;
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index d9536ec..66143b3 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -575,11 +575,11 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove,
         SwIndex& rSttCntIdx = pCrsr->Start()->nContent;
         const sal_Int32 nSttCnt = rSttCntIdx.GetIndex();
         // add to shell-cursor-ring so that the regions will be moved enventually
-        Ring *pPrev(0);
+        SwPaM* pPrev(nullptr);
         if( bRegExp )
         {
             pPrev = pRegion->GetPrev();
-            const_cast<Ring*>(static_cast<const Ring*>(pRegion))->MoveRingTo( &rCursor );
+            const_cast<SwPaM*>(pRegion)->MoveRingTo( &rCursor );
         }
 
         boost::scoped_ptr<OUString> pRepl( (bRegExp)
@@ -592,11 +592,12 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove,
         if( bRegExp )
         {
             // and remove region again
-            Ring *p, *pNext = (Ring*)pRegion;
+            SwPaM* p;
+            SwPaM* pNext(const_cast<SwPaM*>(pRegion));
             do {
                 p = pNext;
                 pNext = p->GetNext();
-                p->MoveTo( (Ring*)pRegion );
+                p->MoveTo( const_cast<SwPaM*>(pRegion) );
             } while( p != pPrev );
         }
         pCrsr->Start()->nContent = nSttCnt;
diff --git a/sw/source/core/crsr/unocrsr.cxx b/sw/source/core/crsr/unocrsr.cxx
index 49785a0..69b7821 100644
--- a/sw/source/core/crsr/unocrsr.cxx
+++ b/sw/source/core/crsr/unocrsr.cxx
@@ -50,7 +50,7 @@ SwUnoCrsr::~SwUnoCrsr()
     while( GetNext() != this )
     {
         Ring* pNxt = GetNext();
-        pNxt->MoveTo( 0 ); // remove from chain
+        pNxt->MoveTo(nullptr); // remove from chain
         delete pNxt;       // and delete
     }
 }
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index d6fdf69..380caef 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1827,19 +1827,20 @@ long SwDoc::CompareDoc( const SwDoc& rDoc )
     return nRet;
 }
 
-class _SaveMergeRedlines : public Ring
+class _SaveMergeRedlines;
+class _SaveMergeRedlines : public Ring<_SaveMergeRedlines>
 {
     const SwRangeRedline* pSrcRedl;
     SwRangeRedline* pDestRedl;
 public:
     _SaveMergeRedlines( const SwNode& rDstNd,
-                        const SwRangeRedline& rSrcRedl, Ring* pRing );
+                        const SwRangeRedline& rSrcRedl, _SaveMergeRedlines* pRing );
     sal_uInt16 InsertRedline();
 };
 
 _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
-                        const SwRangeRedline& rSrcRedl, Ring* pRing )
-    : Ring( pRing ), pSrcRedl( &rSrcRedl )
+                        const SwRangeRedline& rSrcRedl, _SaveMergeRedlines* pRing )
+    : Ring<_SaveMergeRedlines>( pRing ), pSrcRedl( &rSrcRedl )
 {
     SwPosition aPos( rDstNd );
 
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 981b7da..6f9d1a2 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -130,7 +130,7 @@ void PaMCorrAbs( const SwPaM& rRange,
                 } while ( (_pStkCrsr != 0 ) &&
                     ((_pStkCrsr = static_cast<SwPaM *>(_pStkCrsr->GetNext())) != PCURSH_CONST->GetStkCrsr()) );
 
-            FOREACHPAM_START_CONST( PCURSH_CONST->_GetCrsr() )
+            FOREACHPAM_START_CONST( const_cast< SwShellCrsr* >(PCURSH_CONST->_GetCrsr()) )
                 lcl_PaMCorrAbs( const_cast<SwPaM &>(*PCURCRSR), aStart, aEnd, aNewPos );
             FOREACHPAM_END_CONST()
 
@@ -277,7 +277,7 @@ void PaMCorrRel( const SwNodeIndex &rOldNode,
                 } while ( (_pStkCrsr != 0 ) &&
                     ((_pStkCrsr = static_cast<SwPaM *>(_pStkCrsr->GetNext())) != PCURSH_CONST->GetStkCrsr()) );
 
-            FOREACHPAM_START_CONST( PCURSH_CONST->_GetCrsr() )
+            FOREACHPAM_START_CONST( const_cast< SwShellCrsr* >(PCURSH_CONST->_GetCrsr()) )
                 lcl_PaMCorrRel1( const_cast<SwPaM *>(PCURCRSR), pOldNode, aNewPos, nCntIdx);
             FOREACHPAM_END()
 
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index c6d353b..ced0f2b 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -486,7 +486,7 @@ SwDoc::~SwDoc()
 
     if( mpExtInputRing )
     {
-        Ring* pTmp = mpExtInputRing;
+        SwPaM* pTmp = mpExtInputRing;
         mpExtInputRing = 0;
         while( pTmp->GetNext() != pTmp )
             delete pTmp->GetNext();
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 6c738e1..440510e 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -41,9 +41,10 @@ class _PaMIntoCrsrShellRing
 {
     SwCrsrShell& rSh;
     SwPaM &rDelPam, &rCrsr;
-    Ring *pPrevDelPam, *pPrevCrsr;
+    SwPaM* pPrevDelPam;
+    SwPaM* pPrevCrsr;
 
-    void RemoveFromRing( SwPaM& rPam, Ring* pPrev );
+    void RemoveFromRing( SwPaM& rPam, SwPaM* pPrev );
 public:
     _PaMIntoCrsrShellRing( SwCrsrShell& rSh, SwPaM& rCrsr, SwPaM& rPam );
     ~_PaMIntoCrsrShellRing();
@@ -69,9 +70,10 @@ _PaMIntoCrsrShellRing::~_PaMIntoCrsrShellRing()
     RemoveFromRing( rCrsr, pPrevCrsr );
 }
 
-void _PaMIntoCrsrShellRing::RemoveFromRing( SwPaM& rPam, Ring* pPrev )
+void _PaMIntoCrsrShellRing::RemoveFromRing( SwPaM& rPam, SwPaM* pPrev )
 {
-    Ring *p, *pNext = (Ring*)&rPam;
+    SwPaM* p;
+    SwPaM* pNext = &rPam;
     do {
         p = pNext;
         pNext = p->GetNext();
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 6b0fada..b639009 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1087,13 +1087,14 @@ void SwAutoFormat::DeleteSel( SwPaM& rDelPam )
         SwPaM* pShCrsr = m_pEditShell->_GetCrsr();
         SwPaM aTmp( *m_pCurTxtNd, 0, pShCrsr );
 
-        Ring *pPrev = rDelPam.GetPrev();
+        SwPaM* pPrev = rDelPam.GetPrev();
         rDelPam.MoveRingTo( pShCrsr );
 
         m_pEditShell->DeleteSel( rDelPam );
 
         // and remove Pam again:
-        Ring *p, *pNext = (Ring*)&rDelPam;
+        SwPaM* p;
+        SwPaM* pNext = &rDelPam;
         do {
             p = pNext;
             pNext = p->GetNext();
commit ef5051b59270b324968cb91304fb25f622b80329
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 16:40:54 2014 +0100

    make ring header only
    
    Change-Id: If8a52d12cb145120be4477ee79f8cdc55329c36c

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index d51615b..c475315 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -129,7 +129,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/core/bastyp/checkit \
     sw/source/core/bastyp/index \
     sw/source/core/bastyp/init \
-    sw/source/core/bastyp/ring \
     sw/source/core/bastyp/swcache \
     sw/source/core/bastyp/swrect \
     sw/source/core/bastyp/swregion \
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index 4dc0330..90e3465 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -22,23 +22,37 @@
 #include <swdllapi.h>
 #include <swtypes.hxx>
 #include <boost/iterator/iterator_facade.hpp>
+#include <boost/intrusive/circular_list_algorithms.hpp>
 
 class Ring_node_traits;
 class RingIterator;
 
 class SW_DLLPUBLIC Ring
 {
+    struct Ring_node_traits
+    {
+        typedef Ring node;
+        typedef Ring* node_ptr;
+        typedef const Ring* const_node_ptr;
+        static node_ptr get_next(const_node_ptr n) { return n->GetNext(); };
+        static void set_next(node_ptr n, node_ptr next) { n->pNext = next; };
+        static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); };
+        static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; };
+    };
     friend class Ring_node_traits;
+    typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
     Ring* pNext;
     Ring* pPrev;    ///< In order to speed up inserting and deleting.
 
 protected:
-    Ring();
+    Ring()
+        { algo::init_header(this); }
     Ring( Ring * );
 public:
     typedef RingIterator iterator;
     typedef RingIterator const_iterator;
-    virtual ~Ring();
+    virtual ~Ring()
+        { algo::unlink(this); };
     void MoveTo( Ring *pDestRing );
     void MoveRingTo( Ring *pDestRing );
 
@@ -49,9 +63,39 @@ public:
     iterator beginRing();
     iterator endRing();
 
-    sal_uInt32 numberOf() const;
+    sal_uInt32 numberOf() const
+        { return algo::count(this); }
 };
 
+inline Ring::Ring( Ring *pObj )
+{
+    if( !pObj )
+        algo::init_header(this);
+    else
+        algo::link_before(pObj, this);
+}
+
+inline void Ring::MoveTo(Ring *pDestRing)
+{
+    // insert into "new"
+    if( pDestRing )
+    {
+        if(algo::unique(this))
+            algo::link_before(pDestRing, this);
+        else
+            algo::transfer(pDestRing, this);
+    }
+    else
+        algo::unlink(this);
+
+}
+
+inline void Ring::MoveRingTo(Ring *pDestRing)
+{
+    std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
+    std::swap(*(&pPrev), *(&pDestRing->pPrev));
+}
+
 class RingIterator : public boost::iterator_facade<
       RingIterator
     , Ring
@@ -88,8 +132,6 @@ inline Ring::iterator Ring::beginRing()
 inline Ring::iterator Ring::endRing()
     { return Ring::iterator(this, false); };
 
-
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/bastyp/ring.cxx b/sw/source/core/bastyp/ring.cxx
deleted file mode 100644
index b7ce9c0..0000000
--- a/sw/source/core/bastyp/ring.cxx
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "ring.hxx"
-#include <boost/intrusive/circular_list_algorithms.hpp>
-
-struct Ring_node_traits
-{
-    typedef Ring node;
-    typedef Ring* node_ptr;
-    typedef const Ring* const_node_ptr;
-    static node_ptr get_next(const_node_ptr n) { return n->GetNext(); };
-    static void set_next(node_ptr n, node_ptr next) { n->pNext = next; };
-    static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); };
-    static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; };
-};
-typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
-
-
-Ring::Ring()
-{
-    algo::init_header(this);
-}
-
-Ring::Ring( Ring *pObj )
-{
-    if( !pObj )
-        algo::init_header(this);
-    else
-        algo::link_before(pObj, this);
-}
-
-Ring::~Ring()
-{
-    algo::unlink(this);
-}
-
-void Ring::MoveTo(Ring *pDestRing)
-{
-    // insert into "new"
-    if( pDestRing )
-    {
-        if(algo::unique(this))
-            algo::link_before(pDestRing, this);
-        else
-            algo::transfer(pDestRing, this);
-    }
-    else
-        algo::unlink(this);
-
-}
-
-void Ring::MoveRingTo(Ring *pDestRing)
-{
-    std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
-    std::swap(*(&pPrev), *(&pDestRing->pPrev));
-}
-
-sal_uInt32 Ring::numberOf() const
-{
-    return algo::count(this);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 02e2e6df7f089b121bc3599c8e267ffa7f9e46fb
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 12:04:31 2014 +0100

    use macro in macro
    
    Change-Id: Iadc70ec4ddfced07eeb761302c9d8485263c114b

diff --git a/sw/inc/edimp.hxx b/sw/inc/edimp.hxx
index 29aea41..b3240b9 100644
--- a/sw/inc/edimp.hxx
+++ b/sw/inc/edimp.hxx
@@ -22,30 +22,24 @@
 
 #include <tools/solar.h>
 #include <o3tl/sorted_vector.hxx>
+#include <boost/foreach.hpp>
 
 class SwPaM;
 class SwNodeIndex;
 
 // Macros to iterate over all ranges.
-#define PCURCRSR (_pStartCrsr)
+#define PCURCRSR (static_cast<SwPaM *>(&__r))
 
 #define FOREACHPAM_START(pCURSH) \
-    {\
-        SwPaM *_pStartCrsr = (pCURSH), *__pStartCrsr = _pStartCrsr; \
-        do {
-
-#define FOREACHPAM_END() \
-        } while( (_pStartCrsr=static_cast<SwPaM *>(_pStartCrsr->GetNext())) != __pStartCrsr ); \
-    }
+    BOOST_FOREACH(Ring& __r, std::make_pair(static_cast<Ring*>(pCURSH)->beginRing(), static_cast<Ring*>(pCURSH)->endRing())) \
+    {
 
 #define FOREACHPAM_START_CONST(pCURSH) \
-    {\
-        const SwPaM *_pStartCrsr = (pCURSH), *__pStartCrsr = _pStartCrsr; \
-        do {
+    BOOST_FOREACH(Ring& __r, std::make_pair(const_cast<Ring*>(static_cast<const Ring*>(pCURSH))->beginRing(), const_cast<Ring*>(static_cast<const Ring*>(pCURSH))->endRing())) \
+    {
 
-#define FOREACHPAM_END_CONST() \
-        } while( (_pStartCrsr=static_cast<const SwPaM *>(_pStartCrsr->GetNext())) != __pStartCrsr ); \
-    }
+#define FOREACHPAM_END() }
+#define FOREACHPAM_END_CONST() }
 
 struct SwPamRange
 {
commit 4f9ed32cb81d9664683c55025d1c6b3e2e524125
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 11:08:38 2014 +0100

    some test tweaking
    
    Change-Id: I45f60a0c37471a24219c95cf916b9cbfe0fc4c43

diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 21a3d4d..d8da67b 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1288,6 +1288,12 @@ namespace
 void SwDocTest::testIntrusiveRing()
 {
     TestRing aRing1, aRing2, aRing3, aRing4, aRing5;
+    std::vector<TestRing*> vRings;
+    vRings.push_back(&aRing1);
+    vRings.push_back(&aRing2);
+    vRings.push_back(&aRing3);
+    vRings.push_back(&aRing4);
+    vRings.push_back(&aRing5);
     CPPUNIT_ASSERT_EQUAL(aRing1.numberOf(), static_cast<sal_uInt32>(1));
     aRing2.MoveTo(&aRing1);
     aRing3.MoveTo(&aRing1);
@@ -1297,24 +1303,23 @@ void SwDocTest::testIntrusiveRing()
     aRing5.MoveTo(&aRing4);
     CPPUNIT_ASSERT_EQUAL(aRing4.numberOf(), static_cast<sal_uInt32>(2));
     aRing4.MoveRingTo(&aRing1);
-    CPPUNIT_ASSERT_EQUAL(aRing1.numberOf(), static_cast<sal_uInt32>(5));
-    CPPUNIT_ASSERT_EQUAL(aRing4.numberOf(), static_cast<sal_uInt32>(5));
-    CPPUNIT_ASSERT_EQUAL(aRing1.GetNext(), static_cast<Ring*>(&aRing2));
-    CPPUNIT_ASSERT_EQUAL(aRing2.GetNext(), static_cast<Ring*>(&aRing3));
-    CPPUNIT_ASSERT_EQUAL(aRing3.GetNext(), static_cast<Ring*>(&aRing4));
-    CPPUNIT_ASSERT_EQUAL(aRing4.GetNext(), static_cast<Ring*>(&aRing5));
-    CPPUNIT_ASSERT_EQUAL(aRing5.GetNext(), static_cast<Ring*>(&aRing1));
-    CPPUNIT_ASSERT_EQUAL(aRing2.GetPrev(), static_cast<Ring*>(&aRing1));
-    CPPUNIT_ASSERT_EQUAL(aRing3.GetPrev(), static_cast<Ring*>(&aRing2));
-    CPPUNIT_ASSERT_EQUAL(aRing4.GetPrev(), static_cast<Ring*>(&aRing3));
-    CPPUNIT_ASSERT_EQUAL(aRing5.GetPrev(), static_cast<Ring*>(&aRing4));
-    CPPUNIT_ASSERT_EQUAL(aRing1.GetPrev(), static_cast<Ring*>(&aRing5));
-    //std::pair<Ring::iterator, Ring::iterator> foo();
+    BOOST_FOREACH(TestRing* pRing, vRings)
+    {
+        CPPUNIT_ASSERT_EQUAL(pRing->numberOf(), static_cast<sal_uInt32>(5));
+    }
+    for(std::vector<TestRing*>::iterator ppRing = vRings.begin(); ppRing != vRings.end(); ++ppRing)
+    {
+        std::vector<TestRing*>::iterator ppNext = ppRing+1;
+        if(ppNext==vRings.end())
+            ppNext = vRings.begin();
+        CPPUNIT_ASSERT_EQUAL((*ppRing)->GetNext(), static_cast<Ring*>(*ppNext));
+        CPPUNIT_ASSERT_EQUAL((*ppNext)->GetPrev(), static_cast<Ring*>(*ppRing));
+    }
     BOOST_FOREACH(Ring& r, std::make_pair(aRing1.beginRing(), aRing1.endRing()))
-    //for(Ring::iterator it = aRing1.beginRing(); it != aRing1.endRing(); ++it)
     {
         TestRing* pRing = dynamic_cast<TestRing*>(&r);
-        pRing->debug();
+        CPPUNIT_ASSERT(pRing);
+        //pRing->debug();
     }
 }
 
commit 57a2acc3c2a8b31c36eb285870b19f00683c9293
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 10:38:25 2014 +0100

    test FOREACH
    
    Change-Id: Iaa63f0fb1be5efe0659f56bf15bfa13c48f3ab81

diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index b0751c7..21a3d4d 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1310,10 +1310,10 @@ void SwDocTest::testIntrusiveRing()
     CPPUNIT_ASSERT_EQUAL(aRing5.GetPrev(), static_cast<Ring*>(&aRing4));
     CPPUNIT_ASSERT_EQUAL(aRing1.GetPrev(), static_cast<Ring*>(&aRing5));
     //std::pair<Ring::iterator, Ring::iterator> foo();
-    //BOOST_FOREACH(Ring& r, foo)
-    for(Ring::iterator it = aRing1.beginRing(); it != aRing1.endRing(); ++it)
+    BOOST_FOREACH(Ring& r, std::make_pair(aRing1.beginRing(), aRing1.endRing()))
+    //for(Ring::iterator it = aRing1.beginRing(); it != aRing1.endRing(); ++it)
     {
-        TestRing* pRing = dynamic_cast<TestRing*>(&(*it));
+        TestRing* pRing = dynamic_cast<TestRing*>(&r);
         pRing->debug();
     }
 }
commit 0e6221e51f8572552021873aa4d6624365607ede
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 03:36:23 2014 +0100

    some more iteration
    
    Change-Id: I5ca9b79b2992b8499beec04ebe86d82ae14b0ee2

diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index cec5284..4dc0330 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -29,8 +29,6 @@ class RingIterator;
 class SW_DLLPUBLIC Ring
 {
     friend class Ring_node_traits;
-    typedef RingIterator iterator;
-    typedef RingIterator const_iterator;
     Ring* pNext;
     Ring* pPrev;    ///< In order to speed up inserting and deleting.
 
@@ -38,12 +36,18 @@ protected:
     Ring();
     Ring( Ring * );
 public:
+    typedef RingIterator iterator;
+    typedef RingIterator const_iterator;
     virtual ~Ring();
     void MoveTo( Ring *pDestRing );
     void MoveRingTo( Ring *pDestRing );
 
     Ring* GetNext() const       { return pNext; }
     Ring* GetPrev() const       { return pPrev; }
+    // unfortunately we cant name these STL-conforming, as some derived classes
+    // also derive from other STL containers (which is bad anyway, but ...)
+    iterator beginRing();
+    iterator endRing();
 
     sal_uInt32 numberOf() const;
 };
@@ -78,6 +82,14 @@ class RingIterator : public boost::iterator_facade<
         Ring* m_pStart;
 };
 
+inline Ring::iterator Ring::beginRing()
+    { return Ring::iterator(this); };
+
+inline Ring::iterator Ring::endRing()
+    { return Ring::iterator(this, false); };
+
+
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 0a38d79..b0751c7 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -10,6 +10,7 @@
 #include <sal/config.h>
 #include <test/bootstrapfixture.hxx>
 
+#include <boost/foreach.hpp>
 #include <rtl/strbuf.hxx>
 #include <osl/file.hxx>
 
@@ -1308,6 +1309,13 @@ void SwDocTest::testIntrusiveRing()
     CPPUNIT_ASSERT_EQUAL(aRing4.GetPrev(), static_cast<Ring*>(&aRing3));
     CPPUNIT_ASSERT_EQUAL(aRing5.GetPrev(), static_cast<Ring*>(&aRing4));
     CPPUNIT_ASSERT_EQUAL(aRing1.GetPrev(), static_cast<Ring*>(&aRing5));
+    //std::pair<Ring::iterator, Ring::iterator> foo();
+    //BOOST_FOREACH(Ring& r, foo)
+    for(Ring::iterator it = aRing1.beginRing(); it != aRing1.endRing(); ++it)
+    {
+        TestRing* pRing = dynamic_cast<TestRing*>(&(*it));
+        pRing->debug();
+    }
 }
 
 void SwDocTest::setUp()
commit 4a5928ee4ca55d22a0fa122886ecc7d6a55e9247
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 1 02:27:14 2014 +0100

    more testing and initial iterators

diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index 8b65d72..cec5284 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -21,12 +21,16 @@
 
 #include <swdllapi.h>
 #include <swtypes.hxx>
+#include <boost/iterator/iterator_facade.hpp>
 
 class Ring_node_traits;
+class RingIterator;
 
 class SW_DLLPUBLIC Ring
 {
     friend class Ring_node_traits;
+    typedef RingIterator iterator;
+    typedef RingIterator const_iterator;
     Ring* pNext;
     Ring* pPrev;    ///< In order to speed up inserting and deleting.
 
@@ -44,6 +48,36 @@ public:
     sal_uInt32 numberOf() const;
 };
 
+class RingIterator : public boost::iterator_facade<
+      RingIterator
+    , Ring
+    , boost::forward_traversal_tag
+    >
+{
+    public:
+        RingIterator()
+            : m_pCurrent(nullptr)
+            , m_pStart(nullptr)
+        {}
+        explicit RingIterator(Ring* pRing, bool bStart = true)
+            : m_pCurrent(nullptr)
+            , m_pStart(pRing)
+        {
+            if(!bStart)
+                m_pCurrent = m_pStart;
+        }
+    private:
+        friend class boost::iterator_core_access;
+        void increment()
+            { m_pCurrent = m_pCurrent ? m_pCurrent->GetNext() : m_pStart->GetNext(); }
+        bool equal(RingIterator const& other) const
+            { return m_pCurrent == other.m_pCurrent && m_pStart == m_pStart; }
+        Ring& dereference() const
+            { return m_pCurrent ? *m_pCurrent : * m_pStart; }
+        Ring* m_pCurrent;
+        Ring* m_pStart;
+};
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index cb6b1b7..0a38d79 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -57,6 +57,7 @@
 #include "modeltoviewhelper.hxx"
 #include "scriptinfo.hxx"
 #include "IMark.hxx"
+#include "ring.hxx"
 
 typedef tools::SvRef<SwDocShell> SwDocShellRef;
 
@@ -100,7 +101,7 @@ public:
     void testGraphicAnchorDeletion();
     void testTransliterate();
     void testMarkMove();
-    void testInstrusiveList();
+    void testIntrusiveRing();
 
     CPPUNIT_TEST_SUITE(SwDocTest);
     CPPUNIT_TEST(testTransliterate);
@@ -128,7 +129,7 @@ public:
     CPPUNIT_TEST(testUserPerceivedCharCount);
     CPPUNIT_TEST(testGraphicAnchorDeletion);
     CPPUNIT_TEST(testMarkMove);
-    CPPUNIT_TEST(testInstrusiveList);
+    CPPUNIT_TEST(testIntrusiveRing);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1271,8 +1272,42 @@ void SwDocTest::testMarkMove()
         pBM3->GetMarkEnd().nNode.GetIndex());
 }
 
-void SwDocTest::testInstrusiveList()
+namespace
 {
+    struct TestRing : public Ring
+    {
+        TestRing() : Ring() {};
+        void debug()
+        {
+            SAL_DEBUG("TestRing at: " << this << " prev: " << GetPrev() << " next: " << GetNext());
+        }
+    };
+}
+
+void SwDocTest::testIntrusiveRing()
+{
+    TestRing aRing1, aRing2, aRing3, aRing4, aRing5;
+    CPPUNIT_ASSERT_EQUAL(aRing1.numberOf(), static_cast<sal_uInt32>(1));
+    aRing2.MoveTo(&aRing1);
+    aRing3.MoveTo(&aRing1);
+    CPPUNIT_ASSERT_EQUAL(aRing1.numberOf(), static_cast<sal_uInt32>(3));
+    CPPUNIT_ASSERT_EQUAL(aRing2.numberOf(), static_cast<sal_uInt32>(3));
+    CPPUNIT_ASSERT_EQUAL(aRing3.numberOf(), static_cast<sal_uInt32>(3));
+    aRing5.MoveTo(&aRing4);
+    CPPUNIT_ASSERT_EQUAL(aRing4.numberOf(), static_cast<sal_uInt32>(2));
+    aRing4.MoveRingTo(&aRing1);
+    CPPUNIT_ASSERT_EQUAL(aRing1.numberOf(), static_cast<sal_uInt32>(5));
+    CPPUNIT_ASSERT_EQUAL(aRing4.numberOf(), static_cast<sal_uInt32>(5));
+    CPPUNIT_ASSERT_EQUAL(aRing1.GetNext(), static_cast<Ring*>(&aRing2));
+    CPPUNIT_ASSERT_EQUAL(aRing2.GetNext(), static_cast<Ring*>(&aRing3));
+    CPPUNIT_ASSERT_EQUAL(aRing3.GetNext(), static_cast<Ring*>(&aRing4));
+    CPPUNIT_ASSERT_EQUAL(aRing4.GetNext(), static_cast<Ring*>(&aRing5));
+    CPPUNIT_ASSERT_EQUAL(aRing5.GetNext(), static_cast<Ring*>(&aRing1));
+    CPPUNIT_ASSERT_EQUAL(aRing2.GetPrev(), static_cast<Ring*>(&aRing1));
+    CPPUNIT_ASSERT_EQUAL(aRing3.GetPrev(), static_cast<Ring*>(&aRing2));
+    CPPUNIT_ASSERT_EQUAL(aRing4.GetPrev(), static_cast<Ring*>(&aRing3));
+    CPPUNIT_ASSERT_EQUAL(aRing5.GetPrev(), static_cast<Ring*>(&aRing4));
+    CPPUNIT_ASSERT_EQUAL(aRing1.GetPrev(), static_cast<Ring*>(&aRing5));
 }
 
 void SwDocTest::setUp()
diff --git a/sw/source/core/bastyp/ring.cxx b/sw/source/core/bastyp/ring.cxx
index 5db41f5..b7ce9c0 100644
--- a/sw/source/core/bastyp/ring.cxx
+++ b/sw/source/core/bastyp/ring.cxx
@@ -55,7 +55,12 @@ void Ring::MoveTo(Ring *pDestRing)
 {
     // insert into "new"
     if( pDestRing )
-        algo::transfer(pDestRing, this);
+    {
+        if(algo::unique(this))
+            algo::link_before(pDestRing, this);
+        else
+            algo::transfer(pDestRing, this);
+    }
     else
         algo::unlink(this);
 
@@ -63,7 +68,8 @@ void Ring::MoveTo(Ring *pDestRing)
 
 void Ring::MoveRingTo(Ring *pDestRing)
 {
-    algo::transfer(pDestRing, this, this);
+    std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
+    std::swap(*(&pPrev), *(&pDestRing->pPrev));
 }
 
 sal_uInt32 Ring::numberOf() const
commit efddd4b6e0e80bdbdb74ea43654d258dedb7d13d
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sun Nov 30 17:31:46 2014 +0100

    private pointer
    
    Change-Id: I2c5b2a5d99236f3d3887bba994acd1cf77ae83ba

diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index 9695a8f..8b65d72 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -22,15 +22,18 @@
 #include <swdllapi.h>
 #include <swtypes.hxx>
 
+class Ring_node_traits;
+
 class SW_DLLPUBLIC Ring
 {
+    friend class Ring_node_traits;
+    Ring* pNext;
+    Ring* pPrev;    ///< In order to speed up inserting and deleting.
 
 protected:
     Ring();
     Ring( Ring * );
 public:
-    Ring* pNext;
-    Ring* pPrev;    ///< In order to speed up inserting and deleting.
     virtual ~Ring();
     void MoveTo( Ring *pDestRing );
     void MoveRingTo( Ring *pDestRing );
diff --git a/sw/source/core/bastyp/ring.cxx b/sw/source/core/bastyp/ring.cxx
index 25bac99..5db41f5 100644
--- a/sw/source/core/bastyp/ring.cxx
+++ b/sw/source/core/bastyp/ring.cxx
@@ -20,20 +20,17 @@
 #include "ring.hxx"
 #include <boost/intrusive/circular_list_algorithms.hpp>
 
-namespace
+struct Ring_node_traits
 {
-    struct Ring_node_traits
-    {
-        typedef Ring node;
-        typedef Ring* node_ptr;
-        typedef const Ring* const_node_ptr;
-        static node_ptr get_next(const_node_ptr n) { return n->GetNext(); };
-        static void set_next(node_ptr n, node_ptr next) { n->pNext = next; };
-        static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); };
-        static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; };
-    };
-    typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
-}
+    typedef Ring node;
+    typedef Ring* node_ptr;
+    typedef const Ring* const_node_ptr;
+    static node_ptr get_next(const_node_ptr n) { return n->GetNext(); };
+    static void set_next(node_ptr n, node_ptr next) { n->pNext = next; };
+    static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); };
+    static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; };
+};
+typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
 
 
 Ring::Ring()
commit 2353618ff955cf5504ab7a69eaf2b7e5593b666b
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sun Nov 30 17:04:22 2014 +0100

    use boost
    
    Change-Id: Ic5ded259912eb4d6b367ea294dc3a372fcd44195

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index f74b797..b59cc50 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -39,7 +39,6 @@
 #include <vector>
 #include <set>
 #include <swundo.hxx>
-#include <ring.hxx>
 #include <svtools/embedhlp.hxx>
 #include <boost/ptr_container/ptr_vector.hpp>
 
@@ -139,12 +138,9 @@ typedef boost::ptr_vector<SwGetINetAttr> SwGetINetAttrs;
 #define CNT_HasGrf(USH) ((USH)&CNT_GRF)
 #define CNT_HasOLE(USH) ((USH)&CNT_OLE)
 
-typedef boost::intrusive::member_hook<Ring, boost::intrusive::list_member_hook<>, &Ring::m_aHook> MemberHookOption;
-typedef boost::intrusive::list<Ring, MemberHookOption> RingList;
 class SW_DLLPUBLIC SwEditShell: public SwCrsrShell
 {
     static SvxSwAutoFmtFlags* pAutoFmtFlags;
-    RingList m_aList;
 
     /// For the private methods DelRange and those of AutoCorrect.
     friend class SwAutoFormat;
diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index b5a7357..8614453 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -154,7 +154,7 @@ extern SwGoInDoc fnGoCntntCellsSkipHidden;
 void _InitPam();
 
 /// PaM is Point and Mark: a selection of the document model.
-class SW_DLLPUBLIC SwPaM : public Ring 
+class SW_DLLPUBLIC SwPaM : public Ring
 {
     SwPosition   m_Bound1;
     SwPosition   m_Bound2;
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index 25697c9..9695a8f 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -21,17 +21,16 @@
 
 #include <swdllapi.h>
 #include <swtypes.hxx>
-#include <boost/intrusive/list.hpp>
 
 class SW_DLLPUBLIC Ring
 {
-    Ring *pNext;
-    Ring* pPrev;    ///< In order to speed up inserting and deleting.
 
 protected:
-    Ring()          { pNext = this; pPrev = this; }
+    Ring();
     Ring( Ring * );
 public:
+    Ring* pNext;
+    Ring* pPrev;    ///< In order to speed up inserting and deleting.
     virtual ~Ring();
     void MoveTo( Ring *pDestRing );
     void MoveRingTo( Ring *pDestRing );
@@ -40,7 +39,6 @@ public:
     Ring* GetPrev() const       { return pPrev; }
 
     sal_uInt32 numberOf() const;
-    boost::intrusive::list_member_hook<> m_aHook;
 };
 
 #endif
diff --git a/sw/source/core/bastyp/ring.cxx b/sw/source/core/bastyp/ring.cxx
index a25c086..25bac99 100644
--- a/sw/source/core/bastyp/ring.cxx
+++ b/sw/source/core/bastyp/ring.cxx
@@ -18,71 +18,60 @@
  */
 
 #include "ring.hxx"
+#include <boost/intrusive/circular_list_algorithms.hpp>
+
+namespace
+{
+    struct Ring_node_traits
+    {
+        typedef Ring node;
+        typedef Ring* node_ptr;
+        typedef const Ring* const_node_ptr;
+        static node_ptr get_next(const_node_ptr n) { return n->GetNext(); };
+        static void set_next(node_ptr n, node_ptr next) { n->pNext = next; };
+        static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); };
+        static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; };
+    };
+    typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
+}
+
+
+Ring::Ring()
+{
+    algo::init_header(this);
+}
 
 Ring::Ring( Ring *pObj )
 {
     if( !pObj )
-    {
-        pNext = this, pPrev = this;
-    }
+        algo::init_header(this);
     else
-    {
-        pNext = pObj;
-        pPrev = pObj->pPrev;
-        pObj->pPrev = this;
-        pPrev->pNext = this;
-    }
+        algo::link_before(pObj, this);
 }
 
 Ring::~Ring()
 {
-    pNext->pPrev = pPrev;
-    pPrev->pNext = pNext;
+    algo::unlink(this);
 }
 
 void Ring::MoveTo(Ring *pDestRing)
 {
-    // delete from "old"
-    pNext->pPrev = pPrev;
-    pPrev->pNext = pNext;
-
     // insert into "new"
     if( pDestRing )
-    {
-        pNext = pDestRing;
-        pPrev = pDestRing->pPrev;
-        pDestRing->pPrev = this;
-        pPrev->pNext = this;
-    }
+        algo::transfer(pDestRing, this);
     else
-    {
-        pNext = pPrev = this;
-    }
+        algo::unlink(this);
 
 }
 
 void Ring::MoveRingTo(Ring *pDestRing)
 {
-    // insert the whole ring into DestRing
-    Ring* pMyPrev = pPrev;
-    Ring* pDestPrev = pDestRing->pPrev;
-
-    pMyPrev->pNext = pDestRing;
-    pDestPrev->pNext = this;
-    pDestRing->pPrev = pMyPrev;
-    pPrev = pDestPrev;
+    algo::transfer(pDestRing, this, this);
 }
 
 sal_uInt32 Ring::numberOf() const
 {
-    sal_uInt32 nRet = 1;
-    const Ring* pNxt = pNext;
-    while( pNxt != this )
-    {
-        ++nRet;
-        pNxt = pNxt->GetNext();
-    }
-    return nRet;
+    return algo::count(this);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 9e4e7b2f454a5a3ccd619e9789461d474c2dacc7
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sun Nov 30 01:27:26 2014 +0100

    test intrusive

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index b59cc50..f74b797 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -39,6 +39,7 @@
 #include <vector>
 #include <set>
 #include <swundo.hxx>
+#include <ring.hxx>
 #include <svtools/embedhlp.hxx>
 #include <boost/ptr_container/ptr_vector.hpp>
 
@@ -138,9 +139,12 @@ typedef boost::ptr_vector<SwGetINetAttr> SwGetINetAttrs;
 #define CNT_HasGrf(USH) ((USH)&CNT_GRF)
 #define CNT_HasOLE(USH) ((USH)&CNT_OLE)
 
+typedef boost::intrusive::member_hook<Ring, boost::intrusive::list_member_hook<>, &Ring::m_aHook> MemberHookOption;
+typedef boost::intrusive::list<Ring, MemberHookOption> RingList;
 class SW_DLLPUBLIC SwEditShell: public SwCrsrShell
 {
     static SvxSwAutoFmtFlags* pAutoFmtFlags;
+    RingList m_aList;
 
     /// For the private methods DelRange and those of AutoCorrect.
     friend class SwAutoFormat;
diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 8614453..b5a7357 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -154,7 +154,7 @@ extern SwGoInDoc fnGoCntntCellsSkipHidden;
 void _InitPam();
 
 /// PaM is Point and Mark: a selection of the document model.
-class SW_DLLPUBLIC SwPaM : public Ring
+class SW_DLLPUBLIC SwPaM : public Ring 
 {
     SwPosition   m_Bound1;
     SwPosition   m_Bound2;
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index 5d8e7de..25697c9 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -21,6 +21,7 @@
 
 #include <swdllapi.h>
 #include <swtypes.hxx>
+#include <boost/intrusive/list.hpp>
 
 class SW_DLLPUBLIC Ring
 {
@@ -39,6 +40,7 @@ public:
     Ring* GetPrev() const       { return pPrev; }
 
     sal_uInt32 numberOf() const;
+    boost::intrusive::list_member_hook<> m_aHook;
 };
 
 #endif
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 71409b8..cb6b1b7 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -100,6 +100,7 @@ public:
     void testGraphicAnchorDeletion();
     void testTransliterate();
     void testMarkMove();
+    void testInstrusiveList();
 
     CPPUNIT_TEST_SUITE(SwDocTest);
     CPPUNIT_TEST(testTransliterate);
@@ -127,6 +128,7 @@ public:
     CPPUNIT_TEST(testUserPerceivedCharCount);
     CPPUNIT_TEST(testGraphicAnchorDeletion);
     CPPUNIT_TEST(testMarkMove);
+    CPPUNIT_TEST(testInstrusiveList);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1269,6 +1271,10 @@ void SwDocTest::testMarkMove()
         pBM3->GetMarkEnd().nNode.GetIndex());
 }
 
+void SwDocTest::testInstrusiveList()
+{
+}
+
 void SwDocTest::setUp()
 {
     BootstrapFixture::setUp();


More information about the Libreoffice-commits mailing list