sw/inc/crsrsh.hxx                                       |    2 
 sw/inc/pam.hxx                                          |   10 
 sw/inc/ring.hxx                                         |  173 ++++++++--------
 sw/inc/viewsh.hxx                                       |    8 
 sw/qa/core/uwriter.cxx                                  |   14 +
 sw/source/core/crsr/crsrsh.cxx                          |   12 -
 sw/source/core/crsr/crstrvl.cxx                         |    2 
 sw/source/core/crsr/findattr.cxx                        |    2 
 sw/source/core/crsr/findtxt.cxx                         |    4 
 sw/source/core/crsr/swcrsr.cxx                          |    8 
 sw/source/core/crsr/viscrs.cxx                          |   18 -
 sw/source/core/doc/DocumentContentOperationsManager.cxx |    2 
 sw/source/core/doc/doccomp.cxx                          |    4 
 sw/source/core/doc/docruby.cxx                          |    8 
 sw/source/core/doc/extinput.cxx                         |    2 
 sw/source/core/docnode/ndtbl1.cxx                       |    2 
 sw/source/core/edit/acorrect.cxx                        |    4 
 sw/source/core/edit/autofmt.cxx                         |    4 
 sw/source/core/edit/eddel.cxx                           |    2 
 sw/source/core/edit/edfld.cxx                           |    2 
 sw/source/core/edit/editsh.cxx                          |    4 
 sw/source/core/edit/ednumber.cxx                        |   12 -
 sw/source/core/frmedt/fefly1.cxx                        |    2 
 sw/source/core/layout/layact.cxx                        |    2 
 sw/source/core/unocore/unoobj2.cxx                      |    4 
 sw/source/uibase/uiview/formatclipboard.cxx             |    2 
 sw/source/uibase/uiview/viewling.cxx                    |    2 
 27 files changed, 176 insertions(+), 135 deletions(-)

New commits:
commit c17ca4c2088a7092733b67a509b5c0afb799c293
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Fri Dec 5 14:19:51 2014 +0100

    move use of IsMultiSelection()
    
    Change-Id: Ie99906ef2a97617857f5243353e51d8ab4bd6218

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index e9ea189..d57520c 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -890,7 +890,7 @@ inline bool SwCrsrShell::IsMultiSelection() const
 
 inline bool SwCrsrShell::IsSelOnePara() const
 {
-    return m_pCurCrsr == m_pCurCrsr->GetNext() &&
+    return !m_pCurCrsr->IsMultiSelection() &&
            m_pCurCrsr->GetPoint()->nNode == m_pCurCrsr->GetMark()->nNode;
 }
 
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 5dd77ab..45cfd13 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -146,7 +146,7 @@ bool SwCrsrShell::DestroyCrsr()
     OSL_ENSURE( !IsTableMode(), "in table Selection" );
 
     // Is there a next one? Don't do anything if not.
-    if(m_pCurCrsr->GetNext() == m_pCurCrsr)
+    if(!m_pCurCrsr->IsMultiSelection())
         return false;
 
     SwCallLink aLk( *this ); // watch Crsr-Moves
@@ -993,7 +993,7 @@ bool SwCrsrShell::ChgCurrPam(
 void SwCrsrShell::KillPams()
 {
     // Does any exist for deletion?
-    if( !m_pTblCrsr && !m_pBlockCrsr && m_pCurCrsr->GetNext() == m_pCurCrsr )
+    if( !m_pTblCrsr && !m_pBlockCrsr && !m_pCurCrsr->IsMultiSelection() )
         return;
 
     while( m_pCurCrsr->GetNext() != m_pCurCrsr )
@@ -1196,8 +1196,7 @@ sal_uInt16 SwCrsrShell::GetPageCnt()
 /// go to the next SSelection
 bool SwCrsrShell::GoNextCrsr()
 {
-    // is there a ring of cursors?
-    if( m_pCurCrsr->GetNext() == m_pCurCrsr )
+    if( !m_pCurCrsr->IsMultiSelection() )
         return false;
 
     SET_CURR_SHELL( this );
@@ -1216,8 +1215,7 @@ bool SwCrsrShell::GoNextCrsr()
 /// go to the previous SSelection
 bool SwCrsrShell::GoPrevCrsr()
 {
-    // is there a ring of cursors?
-    if( m_pCurCrsr->GetNext() == m_pCurCrsr )
+    if( !m_pCurCrsr->IsMultiSelection() )
         return false;
 
     SET_CURR_SHELL( this );
@@ -3040,7 +3038,7 @@ bool SwCrsrShell::IsSelFullPara() const
     bool bRet = false;
 
     if( m_pCurCrsr->GetPoint()->nNode.GetIndex() ==
-        m_pCurCrsr->GetMark()->nNode.GetIndex() && m_pCurCrsr == 
m_pCurCrsr->GetNext() )
+        m_pCurCrsr->GetMark()->nNode.GetIndex() && 
!m_pCurCrsr->IsMultiSelection() )
     {
         sal_Int32 nStt = m_pCurCrsr->GetPoint()->nContent.GetIndex();
         sal_Int32 nEnd = m_pCurCrsr->GetMark()->nContent.GetIndex();
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index 347ae36..d0f0005 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -2210,7 +2210,7 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr )
             if( !pNd->IsCntntNode() )
                 pNd = rNds.GoNextSection( &aIdx, true, false );
 
-            SwPaM *const pNew = (pAktCrsr->GetNext() == pAktCrsr && 
!pAktCrsr->HasMark())
+            SwPaM *const pNew = (!pAktCrsr->IsMultiSelection() && 
!pAktCrsr->HasMark())
                 ? pAktCrsr
                 : pAktCrsr->Create( pAktCrsr );
             pNew->GetPoint()->nNode = *pNd;
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 5559215..30d2fbc 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -355,7 +355,7 @@ namespace
 
                 do {
                     pDestDoc->getIDocumentContentOperations().DeleteAndJoin( 
*static_cast<SwPaM*>(pDelPam->GetNext()) );
-                    if( pDelPam->GetNext() == pDelPam )
+                    if( !pDelPam->IsMultiSelection() )
                         break;
                     delete pDelPam->GetNext();
                 } while( true );
diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx
index f7109fa..c3bfa25 100644
--- a/sw/source/core/doc/extinput.cxx
+++ b/sw/source/core/doc/extinput.cxx
@@ -291,7 +291,7 @@ SwExtTextInput* SwDoc::GetExtTextInput( const SwNode& rNd,
 
 SwExtTextInput* SwDoc::GetExtTextInput() const
 {
-    OSL_ENSURE( !mpExtInputRing || mpExtInputRing == mpExtInputRing->GetNext(),
+    OSL_ENSURE( !mpExtInputRing || !mpExtInputRing->IsMultiSelection(),
             "more than one InputEngine available" );
     return static_cast<SwExtTextInput*>(mpExtInputRing);
 }
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 905858e..e3d7ebf 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -2560,7 +2560,7 @@ void SwEditShell::AutoFmtBySplitNode()
 {
     SET_CURR_SHELL( this );
     SwPaM* pCrsr = GetCrsr();
-    if( pCrsr->GetNext() == pCrsr && pCrsr->Move( fnMoveBackward, fnGoNode ) )
+    if( !pCrsr->IsMultiSelection() && pCrsr->Move( fnMoveBackward, fnGoNode ) )
     {
         StartAllAction();
         StartUndo( UNDO_AUTOFORMAT );
diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx
index 0dbcb92..5ab5ea0 100644
--- a/sw/source/core/edit/edfld.cxx
+++ b/sw/source/core/edit/edfld.cxx
@@ -264,7 +264,7 @@ void SwEditShell::UpdateFlds( SwField &rFld )
         SwTxtFld *pTxtFld;
         SwFmtFld *pFmtFld;
 
-        if ( pCrsr->GetNext() == pCrsr && !pCrsr->HasMark())
+        if ( !pCrsr->IsMultiSelection() && !pCrsr->HasMark())
         {
             pTxtFld = GetTxtFldAtPos( pCrsr->Start(), true );
 
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index a646d20..3d8afe0 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -634,7 +634,7 @@ bool SwEditShell::InsertURL( const SwFmtINetFmt& rFmt, 
const OUString& rStr, boo
             if( bDelTxt )
                 Delete();
         }
-        else if( pCrsr->GetNext() != pCrsr && rFmt.GetValue() == rStr )
+        else if( pCrsr->IsMultiSelection() && rFmt.GetValue() == rStr )
             bInsTxt = false;
 
         if( bInsTxt )
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index a5ab5c0..812d485 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -599,7 +599,7 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& 
rSet, bool bAnchValid,
         else
             bMoveCntnt = false;
     }
-    else if( !pCrsr->HasMark() && pCrsr->GetNext() == pCrsr )
+    else if( !pCrsr->HasMark() && !pCrsr->IsMultiSelection() )
         bMoveCntnt = false;
 
     const SwPosition& rPos = *pCrsr->Start();
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index d830ed7..7597881 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -1917,7 +1917,7 @@ bool SwLayIdle::_DoIdleJob( const SwCntntFrm *pCnt, 
IdleJobType eJob )
             if( pSh->ISA(SwCrsrShell) && 
!static_cast<SwCrsrShell*>(pSh)->IsTableMode() )
             {
                 SwPaM *pCrsr = static_cast<SwCrsrShell*>(pSh)->GetCrsr();
-                if( !pCrsr->HasMark() && pCrsr == pCrsr->GetNext() )
+                if( !pCrsr->HasMark() && !pCrsr->IsMultiSelection() )
                 {
                     pCntntNode = pCrsr->GetCntntNode();
                     nTxtPos =  pCrsr->GetPoint()->nContent.GetIndex();
diff --git a/sw/source/core/unocore/unoobj2.cxx 
b/sw/source/core/unocore/unoobj2.cxx
index 476a8cd..d018b19 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -1077,7 +1077,7 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill,
                 : ((pPortion) ? pPortion->GetCursor() : 0);
             if (pUnoCrsr && pDoc == rToFill.GetDoc())
             {
-                OSL_ENSURE(pUnoCrsr->GetNext() == pUnoCrsr,
+                OSL_ENSURE(!pUnoCrsr->IsMultiSelection(),
                         "what to do about rings?");
                 bRet = true;
                 *rToFill.GetPoint() = *pUnoCrsr->GetPoint();
commit 41104b6ea86aacd5bc5dc68b1b6daac8f31e4982
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Fri Dec 5 05:58:45 2014 +0100

    use unique() for checks for multiselection
    
    Change-Id: I595dea68b67d1a40df7955bee7e6a935b4efdc1c

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 4e34cc4..26d847f 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -312,6 +312,8 @@ public:
         { return GetPrevInRing(); }
     const SwPaM* GetPrev() const
         { return GetPrevInRing(); }
+    bool IsMultiSelection() const
+        { return !unique(); }
 };
 
 std::ostream &operator <<(std::ostream& s, const SwPaM& pam);
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index c1c8943..a37abda 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -840,7 +840,7 @@ SwField* SwCrsrShell::GetFieldAtCrsr(
 SwField* SwCrsrShell::GetCurFld( const bool bIncludeInputFldAtStart ) const
 {
     SwPaM* pCrsr = GetCrsr();
-    if ( pCrsr->GetNext() != pCrsr )
+    if ( pCrsr->IsMultiSelection() )
     {
         // multi selection not handled.
         return NULL;
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index 4a2a634..7cc0973 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -326,7 +326,7 @@ bool SwEditShell::DelFullPara()
     {
         SwPaM* pCrsr = GetCrsr();
         // no multi selection
-        if( pCrsr->GetNext() == pCrsr && !HasReadonlySel() )
+        if( !pCrsr->IsMultiSelection() && !HasReadonlySel() )
         {
             SET_CURR_SHELL( this );
             StartAllAction();
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 617a4e3..a646d20 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -621,7 +621,7 @@ bool SwEditShell::InsertURL( const SwFmtINetFmt& rFmt, 
const OUString& rStr, boo
         {
             // Selection existent, multi selection?
             bool bDelTxt = true;
-            if( pCrsr->GetNext() == pCrsr )
+            if( !pCrsr->IsMultiSelection() )
             {
                 // einfach Selection -> Text ueberpruefen
                 const OUString sTxt(comphelper::string::stripEnd(GetSelTxt(), 
' '));
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 92f2428..fc86a60 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -276,7 +276,7 @@ void SwEditShell::DelNumRules()
     StartAllAction();
 
     SwPaM* pCrsr = GetCrsr();
-    if( pCrsr->GetNext() != pCrsr ) // multi-selection?
+    if( pCrsr->IsMultiSelection() )
     {
         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
         SwPamRanges aRangeArr( *pCrsr );
@@ -307,7 +307,7 @@ bool SwEditShell::NumUpDown( bool bDown )
 
     bool bRet = true;
     SwPaM* pCrsr = GetCrsr();
-    if( pCrsr->GetNext() == pCrsr )         // no multiple selection ?
+    if( !pCrsr->IsMultiSelection() )
         bRet = GetDoc()->NumUpDown( *pCrsr, bDown );
     else
     {
@@ -528,7 +528,7 @@ bool SwEditShell::OutlineUpDown( short nOffset )
 
     bool bRet = true;
     SwPaM* pCrsr = GetCrsr();
-    if( pCrsr->GetNext() == pCrsr ) // no multi selection?
+    if( !pCrsr->IsMultiSelection() )
         bRet = GetDoc()->OutlineUpDown( *pCrsr, nOffset );
     else
     {
@@ -789,7 +789,7 @@ void SwEditShell::SetNumRuleStart( bool bFlag, SwPaM* pPaM )
 {
     StartAllAction();
     SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
-    if( pCrsr->GetNext() != pCrsr )         // multiple selection ?
+    if( pCrsr->IsMultiSelection() )         // multiple selection ?
     {
         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
         SwPamRanges aRangeArr( *pCrsr );
@@ -816,7 +816,7 @@ void SwEditShell::SetNodeNumStart( sal_uInt16 nStt, SwPaM* 
pPaM )
     StartAllAction();
 
     SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
-    if( pCrsr->GetNext() != pCrsr )         // multiple selection ?
+    if( pCrsr->IsMultiSelection() )         // multiple selection ?
     {
         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
         SwPamRanges aRangeArr( *pCrsr );
diff --git a/sw/source/uibase/uiview/formatclipboard.cxx 
b/sw/source/uibase/uiview/formatclipboard.cxx
index ffaa515..229fb83 100644
--- a/sw/source/uibase/uiview/formatclipboard.cxx
+++ b/sw/source/uibase/uiview/formatclipboard.cxx
@@ -294,7 +294,7 @@ void SwFormatClipboard::Copy( SwWrtShell& rWrtShell, 
SfxItemPool& rPool, bool bP
         bool bHasSelection = pCrsr->HasMark();
         bool bForwardSelection = false;
 
-        if(!bHasSelection && pCrsr->GetPrev() != pCrsr && pCrsr->GetPrev() != 
0)
+        if(!bHasSelection && pCrsr->IsMultiSelection())
         {
             // if cursor has multiple selections
 
diff --git a/sw/source/uibase/uiview/viewling.cxx 
b/sw/source/uibase/uiview/viewling.cxx
index 1abec86..17cb15b 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -487,7 +487,7 @@ bool SwView::IsValidSelectionForThesaurus() const
     // must not be a multi-selection, and if it is a selection it needs
     // to be within a single paragraph
 
-    const bool bMultiSel = m_pWrtShell->GetCrsr() != 
m_pWrtShell->GetCrsr()->GetNext();
+    const bool bMultiSel = m_pWrtShell->GetCrsr()->IsMultiSelection();
     const bool bSelection = 
static_cast<SwCrsrShell*>(m_pWrtShell)->HasSelection();
     return !bMultiSel && (!bSelection || m_pWrtShell->IsSelOnePara() );
 }
commit cb11bca59019682c0d7eae837e2022bfe02ddc9d
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Fri Dec 5 05:33:22 2014 +0100

    add unique() function
    
    Change-Id: I9866a2725bc74e3afd90eb5c32587beb7f4f6e2a

diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index bd5c634..913d62a 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -85,6 +85,9 @@ namespace sw
             /** @return the previous item in the ring container */
             const_value_type* GetPrevInRing() const
                 { return pPrev; }
+            /** @return true if and only if this item is alone in its ring */
+            bool unique() const
+                { return algo::unique(static_cast< const_value_type* >(this)); 
}
 
         private:
             /** internal implementation class -- not for external use */
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index e69229a..e1de020 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1282,6 +1282,8 @@ namespace
             { return GetNextInRing(); }
         TestRing* GetPrev()
             { return GetPrevInRing(); }
+        bool lonely() const
+            { return unique(); }
 #if 0
         void debug()
         {
@@ -1301,11 +1303,17 @@ void SwDocTest::testIntrusiveRing()
     vRings.push_back(&aRing4);
     vRings.push_back(&aRing5);
     CPPUNIT_ASSERT_EQUAL(aRing1.GetRingContainer().size(), 
static_cast<size_t>(1));
+    CPPUNIT_ASSERT(aRing1.lonely());
+    CPPUNIT_ASSERT(aRing2.lonely());
+    CPPUNIT_ASSERT(aRing3.lonely());
     aRing2.MoveTo(&aRing1);
     aRing3.MoveTo(&aRing1);
     CPPUNIT_ASSERT_EQUAL(aRing1.GetRingContainer().size(), 
static_cast<size_t>(3));
     CPPUNIT_ASSERT_EQUAL(aRing2.GetRingContainer().size(), 
static_cast<size_t>(3));
     CPPUNIT_ASSERT_EQUAL(aRing3.GetRingContainer().size(), 
static_cast<size_t>(3));
+    CPPUNIT_ASSERT(!aRing1.lonely());
+    CPPUNIT_ASSERT(!aRing2.lonely());
+    CPPUNIT_ASSERT(!aRing3.lonely());
     aRing5.MoveTo(&aRing4);
     CPPUNIT_ASSERT_EQUAL(aRing4.GetRingContainer().size(), 
static_cast<size_t>(2));
     aRing4.GetRingContainer().merge(aRing1.GetRingContainer());
commit bf449c26d0af39f3411dd527f847157eb6642733
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Fri Dec 5 05:14:32 2014 +0100

    update test
    
    Change-Id: Icccf85795d2f46cb5b50150ff553cad647247862

diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 078bf2e..e69229a 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1278,6 +1278,10 @@ namespace
     struct TestRing : public sw::Ring<TestRing>
     {
         TestRing() : sw::Ring<TestRing>() {};
+        TestRing* GetNext()
+            { return GetNextInRing(); }
+        TestRing* GetPrev()
+            { return GetPrevInRing(); }
 #if 0
         void debug()
         {
@@ -1304,7 +1308,7 @@ void SwDocTest::testIntrusiveRing()
     CPPUNIT_ASSERT_EQUAL(aRing3.GetRingContainer().size(), 
static_cast<size_t>(3));
     aRing5.MoveTo(&aRing4);
     CPPUNIT_ASSERT_EQUAL(aRing4.GetRingContainer().size(), 
static_cast<size_t>(2));
-    aRing4.MoveRingTo(&aRing1);
+    aRing4.GetRingContainer().merge(aRing1.GetRingContainer());
     BOOST_FOREACH(TestRing* pRing, vRings)
     {
         CPPUNIT_ASSERT_EQUAL(pRing->GetRingContainer().size(), 
static_cast<size_t>(5));
commit 04adb4de787086c59813dce65dae8d7b94e900ca
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Fri Dec 5 05:14:07 2014 +0100

    move Ring<>::MoveRingTo to RingContainer<>::merge
    
    Change-Id: I864c9768ffd84c8cdee986cafd205ef2943c73e5

diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index f83ce3e..bd5c634 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -41,7 +41,7 @@ namespace sw
         public:
             typedef typename std::add_const<value_type>::type const_value_type;
             typedef RingContainer<value_type> ring_container;
-            typedef RingContainer< const_value_type > const_ring_container;
+            typedef RingContainer<const_value_type> const_ring_container;
             virtual ~Ring()
                 { algo::unlink(static_cast< value_type* >(this)); };
             /**
@@ -53,18 +53,6 @@ namespace sw
              * @param pDestRing the container to add this item to
              */
             void MoveTo( value_type* pDestRing );
-            /**
-             * Merges two ring containers. All item from both ring containers 
will
-             * be in the same ring container in the end.
-             * Note: value_typehe items of this ring container will be 
inserted just before
-             * item pDestRing
-             * @param pDestRing the container to merge this container with
-             */
-            void MoveRingTo( value_type* pDestRing )
-            {
-                std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
-                std::swap(*(&pPrev), *(&pDestRing->pPrev));
-            }
             /** @return a stl-like container with begin()/end() for iteration 
*/
             ring_container GetRingContainer();
             /** @return a stl-like container with begin()/end() for const 
iteration */
@@ -110,6 +98,8 @@ namespace sw
                 static node_ptr get_previous(const_node_ptr n) { return 
const_cast<node_ptr>(static_cast<const_node_ptr>(n))->GetPrevInRing(); };
                 static void set_previous(node_ptr n, node_ptr previous) { 
n->pPrev = previous; };
             };
+            friend ring_container;
+            friend const_ring_container;
             friend typename ring_container::iterator;
             friend typename ring_container::const_iterator;
             friend typename const_ring_container::iterator;
@@ -175,6 +165,18 @@ namespace sw
             /** @return the number of elements in the container */
             size_t size() const
                 { return std::distance(begin(), end()); }
+            /**
+             * Merges two ring containers. All item from both ring containers 
will
+             * be in the same ring container in the end.
+             * Note: value_typehe items of this ring container will be 
inserted just before
+             * item pDestRing
+             * @param pDestRing the container to merge this container with
+             */
+            void merge( RingContainer< value_type > aDestRing )
+            {
+                std::swap(*(&m_pStart->pPrev->pNext), 
*(&aDestRing.m_pStart->pPrev->pNext));
+                std::swap(*(&m_pStart->pPrev), *(&aDestRing.m_pStart->pPrev));
+            }
     };
 
     template <typename value_type>
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index ff341f8..abf042c 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -1148,7 +1148,7 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, 
const SwPaM* pRegion,
         if( bRegExp )
         {
             pPrevRing = const_cast< SwPaM* >(pRegion)->GetPrev();
-            const_cast< SwPaM* >(pRegion)->MoveRingTo( &rCursor );
+            const_cast< SwPaM* >(pRegion)->GetRingContainer().merge( 
rCursor.GetRingContainer() );
         }
 
         boost::scoped_ptr<OUString> pRepl( (bRegExp) ?
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 40af2a8..ea5c6ad 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -579,7 +579,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove,
         if( bRegExp )
         {
             pPrev = const_cast<SwPaM*>(pRegion)->GetPrev();
-            const_cast<SwPaM*>(pRegion)->MoveRingTo( &rCursor );
+            const_cast<SwPaM*>(pRegion)->GetRingContainer().merge( 
rCursor.GetRingContainer() );
         }
 
         boost::scoped_ptr<OUString> pRepl( (bRegExp)
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index e726efc..347ae36 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -953,7 +953,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas,
         *GetPoint() = *pFndRing->GetPoint();
         SetMark();
         *GetMark() = *pFndRing->GetMark();
-        pFndRing->MoveRingTo( this );
+        pFndRing->GetRingContainer().merge( GetRingContainer() );
         delete pFndRing;
     }
     else if( FND_IN_OTHER & eFndRngs )
@@ -1011,7 +1011,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas,
             *GetPoint() = *pFndRing->GetPoint();
             SetMark();
             *GetMark() = *pFndRing->GetMark();
-            pFndRing->MoveRingTo( this );
+            pFndRing->GetRingContainer().merge( GetRingContainer() );
         }
         delete pFndRing;
     }
@@ -1051,7 +1051,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas,
         *GetPoint() = *pFndRing->GetPoint();
         SetMark();
         *GetMark() = *pFndRing->GetMark();
-        pFndRing->MoveRingTo( this );
+        pFndRing->GetRingContainer().merge( GetRingContainer() );
         delete pFndRing;
     }
     else
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 440510e..216a033 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -59,8 +59,8 @@ _PaMIntoCrsrShellRing::_PaMIntoCrsrShellRing( SwCrsrShell& 
rCSh,
     pPrevDelPam = rDelPam.GetPrev();
     pPrevCrsr = rCrsr.GetPrev();
 
-    rDelPam.MoveRingTo( pShCrsr );
-    rCrsr.MoveRingTo( pShCrsr );
+    rDelPam.GetRingContainer().merge( pShCrsr->GetRingContainer() );
+    rCrsr.GetRingContainer().merge( pShCrsr->GetRingContainer() );
 }
 
 _PaMIntoCrsrShellRing::~_PaMIntoCrsrShellRing()
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 4326f71..905858e 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1089,7 +1089,7 @@ void SwAutoFormat::DeleteSel( SwPaM& rDelPam )
         SwPaM aTmp( *m_pCurTxtNd, 0, pShCrsr );
 
         SwPaM* pPrev = rDelPam.GetPrev();
-        rDelPam.MoveRingTo( pShCrsr );
+        rDelPam.GetRingContainer().merge( pShCrsr->GetRingContainer() );
 
         m_pEditShell->DeleteSel( rDelPam );
 
commit dd21dac3ea6f0d78061d602c99c7d952a29661ad
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Fri Dec 5 04:29:45 2014 +0100

    Rename GetNext/GetPrev to GetPrevInRing/GetNextInRing ...
    
    ... and make them protected. We already have way too many GetNexts in
    Writer. For now heal this by providing wrappers in the derived classes.
    This should allow to remove these classes from exposing these one at a
    time.
    
    Change-Id: Iabe3a56e22a4e640e6887aa98decf4e021e627bc

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 9e696d8..4e34cc4 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -304,6 +304,14 @@ public:
 
     OUString GetTxt() const;
     void InvalidatePaM();
+    SwPaM* GetNext()
+        { return GetNextInRing(); }
+    const SwPaM* GetNext() const
+        { return GetNextInRing(); }
+    SwPaM* GetPrev()
+        { return GetPrevInRing(); }
+    const SwPaM* GetPrev() const
+        { return GetPrevInRing(); }
 };
 
 std::ostream &operator <<(std::ostream& s, const SwPaM& pam);
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index 3589cef..f83ce3e 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -65,18 +65,6 @@ namespace sw
                 std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
                 std::swap(*(&pPrev), *(&pDestRing->pPrev));
             }
-            /** @return the next item in the ring container */
-            value_type* GetNext()
-                { return pNext; }
-            /** @return the previous item in the ring container */
-            value_type* GetPrev()
-                { return pPrev; }
-            /** @return the next item in the ring container */
-            const_value_type* GetNext() const
-                { return pNext; }
-            /** @return the previous item in the ring container */
-            const_value_type* GetPrev() const
-                { return pPrev; }
             /** @return a stl-like container with begin()/end() for iteration 
*/
             ring_container GetRingContainer();
             /** @return a stl-like container with begin()/end() for const 
iteration */
@@ -97,6 +85,18 @@ namespace sw
              * @param pRing ring container to add the created item to
              */
             Ring( value_type* pRing );
+            /** @return the next item in the ring container */
+            value_type* GetNextInRing()
+                { return pNext; }
+            /** @return the previous item in the ring container */
+            value_type* GetPrevInRing()
+                { return pPrev; }
+            /** @return the next item in the ring container */
+            const_value_type* GetNextInRing() const
+                { return pNext; }
+            /** @return the previous item in the ring container */
+            const_value_type* GetPrevInRing() const
+                { return pPrev; }
 
         private:
             /** internal implementation class -- not for external use */
@@ -105,9 +105,9 @@ namespace sw
                 typedef value_type node;
                 typedef value_type* node_ptr;
                 typedef const value_type* const_node_ptr;
-                static node_ptr get_next(const_node_ptr n) { return 
const_cast<node_ptr>(static_cast<const_node_ptr>(n))->GetNext(); };
+                static node_ptr get_next(const_node_ptr n) { return 
const_cast<node_ptr>(static_cast<const_node_ptr>(n))->GetNextInRing(); };
                 static void set_next(node_ptr n, node_ptr next) { n->pNext = 
next; };
-                static node_ptr get_previous(const_node_ptr n) { return 
const_cast<node_ptr>(static_cast<const_node_ptr>(n))->GetPrev(); };
+                static node_ptr get_previous(const_node_ptr n) { return 
const_cast<node_ptr>(static_cast<const_node_ptr>(n))->GetPrevInRing(); };
                 static void set_previous(node_ptr n, node_ptr previous) { 
n->pPrev = previous; };
             };
             friend typename ring_container::iterator;
@@ -202,7 +202,7 @@ namespace sw
         private:
             friend class boost::iterator_core_access;
             void increment()
-                { m_pCurrent = m_pCurrent ? m_pCurrent->GetNext() : 
m_pStart->GetNext(); }
+                { m_pCurrent = m_pCurrent ? m_pCurrent->GetNextInRing() : 
m_pStart->GetNext(); }
             bool equal(RingIterator const& other) const
             {
                 // we never want to compare iterators from
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 6896e9e..1c5eddb 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -572,6 +572,14 @@ public:
     bool IsShowHeaderFooterSeparator( FrameControlType eControl ) { return 
(eControl == Header)? mbShowHeaderSeparator: mbShowFooterSeparator; }
     virtual void SetShowHeaderFooterSeparator( FrameControlType eControl, bool 
bShow ) { if ( eControl == Header ) mbShowHeaderSeparator = bShow; else 
mbShowFooterSeparator = bShow; }
     bool IsSelectAll() { return mbSelectAll; }
+    SwViewShell* GetNext()
+        { return GetNextInRing(); }
+    const SwViewShell* GetNext() const
+        { return GetNextInRing(); }
+    SwViewShell* GetPrev()
+        { return GetPrevInRing(); }
+    const SwViewShell* GetPrev() const
+        { return GetPrevInRing(); }
 };
 
 // manages global ShellPointer
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 588051e..077d460 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1837,9 +1837,9 @@ public:
                         const SwRangeRedline& rSrcRedl, _SaveMergeRedlines* 
pRing );
     sal_uInt16 InsertRedline();
     _SaveMergeRedlines* GetNext()
-        { return GetNext(); }
+        { return GetNextInRing(); }
     _SaveMergeRedlines* GetPrev()
-        { return GetPrev(); }
+        { return GetPrevInRing(); }
 };
 
 _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
commit ee9344b68fcca2d1db8eba99d39874edc4aec822
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Fri Dec 5 04:07:44 2014 +0100

    more const correctness
    
    Change-Id: I786269210a7906c0d6b74e2cdb32100c8ae07666

diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index b2c341e..3589cef 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -66,10 +66,16 @@ namespace sw
                 std::swap(*(&pPrev), *(&pDestRing->pPrev));
             }
             /** @return the next item in the ring container */
-            value_type* GetNext() const
+            value_type* GetNext()
                 { return pNext; }
             /** @return the previous item in the ring container */
-            value_type* GetPrev() const
+            value_type* GetPrev()
+                { return pPrev; }
+            /** @return the next item in the ring container */
+            const_value_type* GetNext() const
+                { return pNext; }
+            /** @return the previous item in the ring container */
+            const_value_type* GetPrev() const
                 { return pPrev; }
             /** @return a stl-like container with begin()/end() for iteration 
*/
             ring_container GetRingContainer();
@@ -99,9 +105,9 @@ namespace sw
                 typedef value_type node;
                 typedef value_type* node_ptr;
                 typedef const value_type* const_node_ptr;
-                static node_ptr get_next(const_node_ptr n) { return 
n->GetNext(); };
+                static node_ptr get_next(const_node_ptr n) { return 
const_cast<node_ptr>(static_cast<const_node_ptr>(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 node_ptr get_previous(const_node_ptr n) { return 
const_cast<node_ptr>(static_cast<const_node_ptr>(n))->GetPrev(); };
                 static void set_previous(node_ptr n, node_ptr previous) { 
n->pPrev = previous; };
             };
             friend typename ring_container::iterator;
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 66143b3..40af2a8 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -578,7 +578,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove,
         SwPaM* pPrev(nullptr);
         if( bRegExp )
         {
-            pPrev = pRegion->GetPrev();
+            pPrev = const_cast<SwPaM*>(pRegion)->GetPrev();
             const_cast<SwPaM*>(pRegion)->MoveRingTo( &rCursor );
         }
 
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 937fcf0..3bc4b7c 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -545,24 +545,14 @@ void SwShellCrsr::Show()
 // area is invalid.
 void SwShellCrsr::Invalidate( const SwRect& rRect )
 {
-    SwShellCrsr * pTmp = this;
-
-    do
+    for(SwPaM& rPaM : GetRingContainer())
     {
-        pTmp->SwSelPaintRects::Invalidate( rRect );
-
+        SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rPaM);
         // skip any non SwShellCrsr objects in the ring
         // see also: SwAutoFormat::DeleteSel()
-        Ring* pTmpRing = pTmp;
-        pTmp = 0;
-        do
-        {
-            pTmpRing = pTmpRing->GetNext();
-            pTmp = dynamic_cast<SwShellCrsr*>(pTmpRing);
-        }
-        while ( !pTmp );
+        if(pShCrsr)
+            pShCrsr->SwSelPaintRects::Invalidate(rRect);
     }
-    while( this != pTmp );
 }
 
 void SwShellCrsr::Hide()
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 8b8a223..588051e 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1836,6 +1836,10 @@ public:
     _SaveMergeRedlines( const SwNode& rDstNd,
                         const SwRangeRedline& rSrcRedl, _SaveMergeRedlines* 
pRing );
     sal_uInt16 InsertRedline();
+    _SaveMergeRedlines* GetNext()
+        { return GetNext(); }
+    _SaveMergeRedlines* GetPrev()
+        { return GetPrev(); }
 };
 
 _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd,
diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx
index 8e07ca2..e2e6764 100644
--- a/sw/source/core/doc/docruby.cxx
+++ b/sw/source/core/doc/docruby.cxx
@@ -48,7 +48,7 @@ using namespace ::com::sun::star::i18n;
 sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList,
                             sal_uInt16 nMode )
 {
-    const SwPaM *_pStartCrsr = static_cast<SwPaM*>(rPam.GetNext()),
+    const SwPaM *_pStartCrsr = rPam.GetNext(),
                 *__pStartCrsr = _pStartCrsr;
     bool bCheckEmpty = &rPam != _pStartCrsr;
     do {
@@ -86,7 +86,7 @@ sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, 
SwRubyList& rList,
             } while( 30 > rList.size() && *aPam.GetPoint() < *pEnd );
         }
     } while( 30 > rList.size() &&
-        (_pStartCrsr = static_cast<SwPaM *>(_pStartCrsr->GetNext())) != 
__pStartCrsr );
+        (_pStartCrsr = _pStartCrsr->GetNext()) != __pStartCrsr );
 
     return rList.size();
 }
@@ -100,7 +100,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const 
SwRubyList& rList,
 
     sal_uInt16 nListEntry = 0;
 
-    const SwPaM *_pStartCrsr = static_cast<SwPaM*>(rPam.GetNext()),
+    const SwPaM *_pStartCrsr = rPam.GetNext(),
                 *__pStartCrsr = _pStartCrsr;
     bool bCheckEmpty = &rPam != _pStartCrsr;
     do {
@@ -173,7 +173,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const 
SwRubyList& rList,
             } while( nListEntry < rList.size() && *aPam.GetPoint() < *pEnd );
         }
     } while( 30 > rList.size() &&
-        (_pStartCrsr = static_cast<SwPaM *>(_pStartCrsr->GetNext())) != 
__pStartCrsr );
+        (_pStartCrsr = _pStartCrsr->GetNext()) != __pStartCrsr );
 
     GetIDocumentUndoRedo().EndUndo( UNDO_SETRUBYATTR, NULL );
 
diff --git a/sw/source/core/docnode/ndtbl1.cxx 
b/sw/source/core/docnode/ndtbl1.cxx
index 4e9b038..a731e4d 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -139,7 +139,7 @@ static bool lcl_GetBoxSel( const SwCursor& rCursor, 
SwSelBoxes& rBoxes,
                 rBoxes.insert( pBox );
             }
         } while( bAllCrsr &&
-                pSttPam != ( pCurPam = 
static_cast<SwPaM*>(pCurPam->GetNext())) );
+                pSttPam != ( pCurPam = pCurPam->GetNext()) );
     }
     return !rBoxes.empty();
 }
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index e118362..92f2428 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -30,7 +30,7 @@
 
 SwPamRanges::SwPamRanges( const SwPaM& rRing )
 {
-    for(const SwPaM& rTmp : rRing.GetRingContainer())
+    for(SwPaM& rTmp : const_cast<SwPaM*>(&rRing)->GetRingContainer())
         Insert( rTmp.GetMark()->nNode, rTmp.GetPoint()->nNode );
 }
 
diff --git a/sw/source/core/unocore/unoobj2.cxx 
b/sw/source/core/unocore/unoobj2.cxx
index ec47aff..476a8cd 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -140,7 +140,7 @@ void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget)
 
     if (rSource.GetNext() != &rSource)
     {
-        SwPaM *pPam = rSource.GetNext();
+        SwPaM *pPam = const_cast<SwPaM*>(rSource.GetNext());
         do
         {
             // create new PaM
commit d150ace12b6d8fbb30664d1de1001622720bd53b
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Fri Dec 5 03:54:55 2014 +0100

    stick to code conventions for new code
    
    Change-Id: I596733f76a16c01f85d1cae5f130e6ef59fe137a

diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index c1a5179..b2c341e 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -29,22 +29,21 @@
 
 namespace sw
 {
-    template <class T> class RingContainer;
-    template <class T> class RingIterator;
+    template <typename value_type> class RingContainer;
+    template <typename value_type> class RingIterator;
     /**
      * An intrusive container class double linking the contained nodes
      * @example sw/qa/core/uwriter.cxx
      */
-    template <class T>
+    template <typename value_type>
     class Ring
     {
         public:
-            typedef T value_type;
-            typedef typename std::add_const<T>::type const_value_type;
-            typedef RingContainer<T> ring_container;
+            typedef typename std::add_const<value_type>::type const_value_type;
+            typedef RingContainer<value_type> ring_container;
             typedef RingContainer< const_value_type > const_ring_container;
             virtual ~Ring()
-                { algo::unlink(static_cast< T* >(this)); };
+                { algo::unlink(static_cast< value_type* >(this)); };
             /**
              * Removes this item from its current ring container and adds it to
              * another ring container. If the item was not alone in the 
original
@@ -53,24 +52,24 @@ namespace sw
              * Note: the newly created item will be inserted just before item 
pDestRing.
              * @param pDestRing the container to add this item to
              */
-            void MoveTo( T* pDestRing );
+            void MoveTo( value_type* pDestRing );
             /**
              * Merges two ring containers. All item from both ring containers 
will
              * be in the same ring container in the end.
-             * Note: The items of this ring container will be inserted just 
before
+             * Note: value_typehe items of this ring container will be 
inserted just before
              * item pDestRing
              * @param pDestRing the container to merge this container with
              */
-            void MoveRingTo( T* pDestRing )
+            void MoveRingTo( value_type* pDestRing )
             {
                 std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
                 std::swap(*(&pPrev), *(&pDestRing->pPrev));
             }
             /** @return the next item in the ring container */
-            T* GetNext() const
+            value_type* GetNext() const
                 { return pNext; }
             /** @return the previous item in the ring container */
-            T* GetPrev() const
+            value_type* GetPrev() const
                 { return pPrev; }
             /** @return a stl-like container with begin()/end() for iteration 
*/
             ring_container GetRingContainer();
@@ -84,22 +83,22 @@ namespace sw
              * are alone in one.
              */
             Ring()
-                : pPrev(static_cast< T* >(this))
-                { algo::init_header(static_cast< T* >(this)); }
+                : pPrev(static_cast< value_type* >(this))
+                { algo::init_header(static_cast< value_type* >(this)); }
             /**
              * Creates a new item and add it to an existing ring container.
              * Note: the newly created item will be inserted just before item 
pRing.
              * @param pRing ring container to add the created item to
              */
-            Ring( T* pRing );
+            Ring( value_type* pRing );
 
         private:
             /** internal implementation class -- not for external use */
             struct Ring_node_traits
             {
-                typedef T node;
-                typedef T* node_ptr;
-                typedef const T* const_node_ptr;
+                typedef value_type node;
+                typedef value_type* node_ptr;
+                typedef const value_type* 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(); };
@@ -111,25 +110,25 @@ namespace sw
             friend typename const_ring_container::const_iterator;
             friend class boost::iterator_core_access;
             typedef 
boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
-            T* pNext;
-            T* pPrev;
+            value_type* pNext;
+            value_type* pPrev;
     };
 
-    template <class T>
-    inline Ring<T>::Ring( T* pObj )
-        : pPrev(static_cast< T* >(this))
+    template <typename value_type>
+    inline Ring<value_type>::Ring( value_type* pObj )
+        : pPrev(static_cast< value_type* >(this))
     {
-        T* pThis = static_cast< T* >(this);
+        value_type* pThis = static_cast< value_type* >(this);
         if( !pObj )
             algo::init_header(pThis);
         else
             algo::link_before(pObj, pThis);
     }
 
-    template <class T>
-    inline void Ring<T>::MoveTo(T* pDestRing)
+    template <typename value_type>
+    inline void Ring<value_type>::MoveTo(value_type* pDestRing)
     {
-        T* pThis = static_cast< T* >(this);
+        value_type* pThis = static_cast< value_type* >(this);
         // insert into "new"
         if( pDestRing )
         {
@@ -143,19 +142,19 @@ namespace sw
     }
 
     /**
-     * helper class that provides STL-style container iteration to the ring
+     * helper class that provides Svalue_typeL-style container iteration to 
the ring
      */
-    template <class T>
+    template <typename value_type>
     class RingContainer SAL_FINAL
     {
         private:
             /** the item in the ring where iteration starts */
-            T* m_pStart;
+            value_type* m_pStart;
 
         public:
-            RingContainer( T* pRing ) : m_pStart(pRing) {};
-            typedef RingIterator<T> iterator;
-            typedef RingIterator<const T> const_iterator;
+            RingContainer( value_type* pRing ) : m_pStart(pRing) {};
+            typedef RingIterator<value_type> iterator;
+            typedef RingIterator<const value_type> const_iterator;
             /**
              * iterator access
              * @code
@@ -172,22 +171,23 @@ namespace sw
                 { return std::distance(begin(), end()); }
     };
 
-    template <class T>
+    template <typename value_type>
     class RingIterator SAL_FINAL : public boost::iterator_facade<
-          RingIterator<T>
-        , T
+          RingIterator<value_type>
+        , value_type
         , boost::forward_traversal_tag
         >
     {
-            typedef typename std::remove_const<T>::type Tnonconst;
+        private:
+            typedef typename std::remove_const<value_type>::type 
nonconst_value_type;
         public:
             RingIterator()
                 : m_pCurrent(nullptr)
                 , m_pStart(nullptr)
             {}
-            explicit RingIterator(T* pRing, bool bStart = true)
+            explicit RingIterator(value_type* pRing, bool bStart = true)
                 : m_pCurrent(nullptr)
-                , m_pStart(const_cast<Tnonconst*>(pRing))
+                , m_pStart(const_cast<nonconst_value_type*>(pRing))
             {
                 if(!bStart)
                     m_pCurrent = m_pStart;
@@ -204,42 +204,42 @@ namespace sw
                 assert(m_pStart == other.m_pStart);
                 return m_pCurrent == other.m_pCurrent;
             }
-            T& dereference() const
+            value_type& dereference() const
                 { return m_pCurrent ? *m_pCurrent : * m_pStart; }
             /**
-             * This is:
+             * value_typehis is:
              * - pointing to the current item in the iteration in general
              * - nullptr if on the first item (begin())
              * - m_pStart when beyond the last item (end())
              */
-            Tnonconst* m_pCurrent;
+            nonconst_value_type* m_pCurrent;
             /** the first item of the iteration */
-            Tnonconst* m_pStart;
+            nonconst_value_type* m_pStart;
     };
 
-    template <class T>
-    inline typename Ring<T>::ring_container Ring<T>::GetRingContainer()
-        { return Ring<T>::ring_container(static_cast< T* >(this)); };
+    template <typename value_type>
+    inline typename Ring<value_type>::ring_container 
Ring<value_type>::GetRingContainer()
+        { return Ring<value_type>::ring_container(static_cast< value_type* 
>(this)); };
 
-    template <class T>
-    inline typename Ring<T>::const_ring_container Ring<T>::GetRingContainer() 
const
-        { return Ring<T>::const_ring_container(static_cast< const T* >(this)); 
};
+    template <typename value_type>
+    inline typename Ring<value_type>::const_ring_container 
Ring<value_type>::GetRingContainer() const
+        { return Ring<value_type>::const_ring_container(static_cast< const 
value_type* >(this)); };
 
-    template <class T>
-    inline typename RingContainer<T>::iterator RingContainer<T>::begin()
-        { return RingContainer<T>::iterator(m_pStart); };
+    template <typename value_type>
+    inline typename RingContainer<value_type>::iterator 
RingContainer<value_type>::begin()
+        { return RingContainer<value_type>::iterator(m_pStart); };
 
-    template <class T>
-    inline typename RingContainer<T>::iterator RingContainer<T>::end()
-        { return RingContainer<T>::iterator(m_pStart, false); };
+    template <typename value_type>
+    inline typename RingContainer<value_type>::iterator 
RingContainer<value_type>::end()
+        { return RingContainer<value_type>::iterator(m_pStart, false); };
 
-    template <class T>
-    inline typename RingContainer<T>::const_iterator RingContainer<T>::begin() 
const
-        { return RingContainer<T>::const_iterator(m_pStart); };
+    template <typename value_type>
+    inline typename RingContainer<value_type>::const_iterator 
RingContainer<value_type>::begin() const
+        { return RingContainer<value_type>::const_iterator(m_pStart); };
 
-    template <class T>
-    inline typename RingContainer<T>::const_iterator RingContainer<T>::end() 
const
-        { return RingContainer<T>::const_iterator(m_pStart, false); };
+    template <typename value_type>
+    inline typename RingContainer<value_type>::const_iterator 
RingContainer<value_type>::end() const
+        { return RingContainer<value_type>::const_iterator(m_pStart, false); };
 }
 #endif
 
commit d011686765eb13740e8fd821b579836d0c117e02
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Fri Dec 5 03:38:51 2014 +0100

    work towards better constness
    
    Change-Id: Ideef73ecd6620f1d1dd283d830e41f567699a5fc

diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index 5d5494e..c1a5179 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -23,12 +23,14 @@
 #include <swtypes.hxx>
 #include <utility>
 #include <iterator>
+#include <type_traits>
 #include <boost/iterator/iterator_facade.hpp>
 #include <boost/intrusive/circular_list_algorithms.hpp>
 
 namespace sw
 {
     template <class T> class RingContainer;
+    template <class T> class RingIterator;
     /**
      * An intrusive container class double linking the contained nodes
      * @example sw/qa/core/uwriter.cxx
@@ -37,8 +39,10 @@ namespace sw
     class Ring
     {
         public:
+            typedef T value_type;
+            typedef typename std::add_const<T>::type const_value_type;
             typedef RingContainer<T> ring_container;
-            typedef RingContainer<const T> const_ring_container;
+            typedef RingContainer< const_value_type > const_ring_container;
             virtual ~Ring()
                 { algo::unlink(static_cast< T* >(this)); };
             /**
@@ -101,7 +105,11 @@ namespace sw
                 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 struct Ring_node_traits;
+            friend typename ring_container::iterator;
+            friend typename ring_container::const_iterator;
+            friend typename const_ring_container::iterator;
+            friend typename const_ring_container::const_iterator;
+            friend class boost::iterator_core_access;
             typedef 
boost::intrusive::circular_list_algorithms<Ring_node_traits> algo;
             T* pNext;
             T* pPrev;
@@ -134,7 +142,6 @@ namespace sw
             algo::unlink(pThis);
     }
 
-    template <class T> class RingIterator;
     /**
      * helper class that provides STL-style container iteration to the ring
      */
@@ -172,6 +179,7 @@ namespace sw
         , boost::forward_traversal_tag
         >
     {
+            typedef typename std::remove_const<T>::type Tnonconst;
         public:
             RingIterator()
                 : m_pCurrent(nullptr)
@@ -179,7 +187,7 @@ namespace sw
             {}
             explicit RingIterator(T* pRing, bool bStart = true)
                 : m_pCurrent(nullptr)
-                , m_pStart(pRing)
+                , m_pStart(const_cast<Tnonconst*>(pRing))
             {
                 if(!bStart)
                     m_pCurrent = m_pStart;
@@ -204,9 +212,9 @@ namespace sw
              * - nullptr if on the first item (begin())
              * - m_pStart when beyond the last item (end())
              */
-            T* m_pCurrent;
+            Tnonconst* m_pCurrent;
             /** the first item of the iteration */
-            T* m_pStart;
+            Tnonconst* m_pStart;
     };
 
     template <class T>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to