Blame SOURCES/0001-if-we-change-the-keys-we-have-to-resort-based-on-the.patch

ebc4bd
From dcc2e18191652bdffb7b4a2e4ee536c24635a4fb Mon Sep 17 00:00:00 2001
ebc4bd
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
ebc4bd
Date: Mon, 19 Jan 2015 12:09:17 +0000
ebc4bd
Subject: [PATCH] if we change the keys we have to resort based on the new keys
ebc4bd
ebc4bd
Change-Id: Ied95c2d1490554d9ba5402c936a9720c8a325771
ebc4bd
---
ebc4bd
 sw/source/core/doc/docredln.cxx | 26 ++++++++++++++++++++++----
ebc4bd
 1 file changed, 22 insertions(+), 4 deletions(-)
ebc4bd
ebc4bd
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
ebc4bd
index cb1520a..8d3d704 100644
ebc4bd
--- a/sw/source/core/doc/docredln.cxx
ebc4bd
+++ b/sw/source/core/doc/docredln.cxx
ebc4bd
@@ -3820,6 +3820,8 @@ void SwRangeRedline::MoveFromSection()
ebc4bd
         SwDoc* pDoc = GetDoc();
ebc4bd
         const SwRedlineTbl& rTbl = pDoc->GetRedlineTbl();
ebc4bd
         std::vector<SwPosition*> aBeforeArr, aBehindArr;
ebc4bd
+        typedef std::map<sal_uInt16, SwRangeRedline*> IndexAndRange;
ebc4bd
+        IndexAndRange aIndexAndRangeMap;
ebc4bd
         sal_uInt16 nMyPos = rTbl.GetPos( this );
ebc4bd
         OSL_ENSURE( this, "this is not in the array?" );
ebc4bd
         bool bBreak = false;
ebc4bd
@@ -3830,12 +3832,16 @@ void SwRangeRedline::MoveFromSection()
ebc4bd
             bBreak = true;
ebc4bd
             if( rTbl[ n ]->GetBound(true) == *GetPoint() )
ebc4bd
             {
ebc4bd
-                aBehindArr.push_back( &rTbl[ n ]->GetBound(true) );
ebc4bd
+                SwRangeRedline* pRedl = rTbl[n];
ebc4bd
+                aBehindArr.push_back(&pRedl->GetBound(true));
ebc4bd
+                aIndexAndRangeMap.insert(std::make_pair(n, pRedl));
ebc4bd
                 bBreak = false;
ebc4bd
             }
ebc4bd
             if( rTbl[ n ]->GetBound(false) == *GetPoint() )
ebc4bd
             {
ebc4bd
-                aBehindArr.push_back( &rTbl[ n ]->GetBound(false) );
ebc4bd
+                SwRangeRedline* pRedl = rTbl[n];
ebc4bd
+                aBehindArr.push_back(&pRedl->GetBound(false));
ebc4bd
+                aIndexAndRangeMap.insert(std::make_pair(n, pRedl));
ebc4bd
                 bBreak = false;
ebc4bd
             }
ebc4bd
         }
ebc4bd
@@ -3845,12 +3851,16 @@ void SwRangeRedline::MoveFromSection()
ebc4bd
             bBreak = true;
ebc4bd
             if( rTbl[ n ]->GetBound(true) == *GetPoint() )
ebc4bd
             {
ebc4bd
-                aBeforeArr.push_back( &rTbl[ n ]->GetBound(true) );
ebc4bd
+                SwRangeRedline* pRedl = rTbl[n];
ebc4bd
+                aBeforeArr.push_back(&pRedl->GetBound(true));
ebc4bd
+                aIndexAndRangeMap.insert(std::make_pair(n, pRedl));
ebc4bd
                 bBreak = false;
ebc4bd
             }
ebc4bd
             if( rTbl[ n ]->GetBound(false) == *GetPoint() )
ebc4bd
             {
ebc4bd
-                aBeforeArr.push_back( &rTbl[ n ]->GetBound(false) );
ebc4bd
+                SwRangeRedline* pRedl = rTbl[n];
ebc4bd
+                aBeforeArr.push_back(&pRedl->GetBound(false));
ebc4bd
+                aIndexAndRangeMap.insert(std::make_pair(n, pRedl));
ebc4bd
                 bBreak = false;
ebc4bd
             }
ebc4bd
         }
ebc4bd
@@ -3904,6 +3914,7 @@ void SwRangeRedline::MoveFromSection()
ebc4bd
             if( pColl && pCNd )
ebc4bd
                 pCNd->ChgFmtColl( pColl );
ebc4bd
         }
ebc4bd
+
ebc4bd
         // #i95771#
ebc4bd
         // Under certain conditions the previous <SwDoc::Move(..)> has already
ebc4bd
         // removed the change tracking section of this <SwRangeRedline> instance from
ebc4bd
@@ -3924,6 +3935,13 @@ void SwRangeRedline::MoveFromSection()
ebc4bd
             *aBeforeArr[ n ] = *Start();
ebc4bd
         for( n = 0; n < aBehindArr.size(); ++n )
ebc4bd
             *aBehindArr[ n ] = *End();
ebc4bd
+        SwRedlineTbl& rResortTbl = const_cast<SwRedlineTbl&>(rTbl);
ebc4bd
+        for (auto& a : aIndexAndRangeMap)
ebc4bd
+        {
ebc4bd
+            // re-insert
ebc4bd
+            rResortTbl.Remove(a.first);
ebc4bd
+            rResortTbl.Insert(a.second);
ebc4bd
+        }
ebc4bd
     }
ebc4bd
     else
ebc4bd
         InvalidateRange();
ebc4bd
-- 
ebc4bd
1.9.3
ebc4bd