Blob Blame History Raw
From 37469a1e3eb5b3295f5b496e27fc6f0445699339 Mon Sep 17 00:00:00 2001
From: Michael Stahl <mstahl@redhat.com>
Date: Wed, 22 Apr 2015 14:28:38 +0200
Subject: [PATCH] rhbz#1198848: sw: delete *all* table redlines to fix DOCX
 import crash

SwExtraRedlineTbl::DeleteAllTableRedlines() increments its position even
when deleting the current element from the vector.

(cherry picked from commit 28764d7ed5df874c2bfbc6025a97968e08cf2315)

Conflicts:
	sw/source/core/doc/docredln.cxx

Change-Id: Ie827a7b66fa9690bbabaf53204e9ec77247239f2
---
 sw/source/core/doc/docredln.cxx | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index cb1520a..f7cdc7f 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1529,7 +1529,7 @@ bool SwExtraRedlineTbl::DeleteAllTableRedlines( SwDoc* pDoc, const SwTable& rTab
         */
     }
 
-    for(sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < GetSize(); ++nCurRedlinePos )
+    for (sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < GetSize(); )
     {
         SwExtraRedline* pExtraRedline = GetRedline(nCurRedlinePos);
         const SwTableCellRedline* pTableCellRedline = dynamic_cast<const SwTableCellRedline*>(pExtraRedline);
@@ -1544,11 +1544,12 @@ bool SwExtraRedlineTbl::DeleteAllTableRedlines( SwDoc* pDoc, const SwTable& rTab
                 sal_uInt16 nRedlineType = aRedlineData.GetType();
 
                 // Check if this redline object type should be deleted
-                if( USHRT_MAX != nRedlineTypeToDelete && nRedlineTypeToDelete != nRedlineType )
-                    continue;
-
-                DeleteAndDestroy( nCurRedlinePos );
-                bChg = true;
+                if (USHRT_MAX == nRedlineTypeToDelete || nRedlineTypeToDelete == nRedlineType)
+                {
+                    DeleteAndDestroy( nCurRedlinePos );
+                    bChg = true;
+                    continue; // don't increment position after delete
+                }
             }
         }
         else
@@ -1566,14 +1567,17 @@ bool SwExtraRedlineTbl::DeleteAllTableRedlines( SwDoc* pDoc, const SwTable& rTab
                     sal_uInt16 nRedlineType = aRedlineData.GetType();
 
                     // Check if this redline object type should be deleted
-                    if( USHRT_MAX != nRedlineTypeToDelete && nRedlineTypeToDelete != nRedlineType )
-                        continue;
+                    if (USHRT_MAX == nRedlineTypeToDelete || nRedlineTypeToDelete == nRedlineType)
 
-                    DeleteAndDestroy( nCurRedlinePos );
-                    bChg = true;
+                    {
+                        DeleteAndDestroy( nCurRedlinePos );
+                        bChg = true;
+                        continue; // don't increment position after delete
+                    }
                 }
             }
         }
+        ++nCurRedlinePos;
     }
 
     if( bChg )
-- 
2.1.0