Blob Blame History Raw
From f752aa8de421ab6ee296370b4c287354fc2ba06c Mon Sep 17 00:00:00 2001
From: Michael Stahl <mstahl@redhat.com>
Date: Thu, 2 Apr 2015 22:32:59 +0200
Subject: [PATCH 1/4] tdf#87400: sw: fix ~SwIndexReg assertion in AutoCorrect
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

SwAutoFormat::DoUnderline() calls DeleteSel() with a SwPaM that is not
corrected, except if it's passed along directly to SwDoc methods.

(regression from f9b62506b22c3eb885ffd5a4ec8025c33df7b2d4)

(cherry picked from commit 41e4998cdeb54a6fc316f349de61296be820fe47)
Reviewed-on: https://gerrit.libreoffice.org/15127
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit d8d946210a39400e4fc0b83f186e6234ad364836)

Conflicts:
	sw/source/core/edit/eddel.cxx

Change-Id: I741e0391e7f8e09a64bcfe99ca4d650f1016aaa7
---
 sw/source/core/edit/eddel.cxx | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index 47614f2c..fad1eaf 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -89,14 +89,20 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo )
     }
     else
     {
-        SwPaM aPam(rPam);
+        std::unique_ptr<SwPaM> pNewPam;
+        SwPaM * pPam = &rPam;
         if (bSelectAll)
+        {
+            assert(dynamic_cast<SwShellCrsr*>(&rPam)); // must be corrected pam
+            pNewPam.reset(new SwPaM(rPam));
             // Selection starts at the first para of the first cell, but we
             // want to delete the table node before the first cell as well.
-            aPam.Start()->nNode = aPam.Start()->nNode.GetNode().FindTableNode()->GetIndex();
+            pNewPam->Start()->nNode = pNewPam->Start()->nNode.GetNode().FindTableNode()->GetIndex();
+            pPam = pNewPam.get();
+        }
         // delete everything
-        GetDoc()->DeleteAndJoin( aPam );
-        SaveTblBoxCntnt( aPam.GetPoint() );
+        GetDoc()->DeleteAndJoin( *pPam );
+        SaveTblBoxCntnt( pPam->GetPoint() );
     }
 
     // Selection is not needed anymore
-- 
2.1.0