From 8f4324d0f407868a5dcc71c8ffcafaf9809f3b8f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 12 Mar 2014 17:28:10 +0100 Subject: fdo#75110 SwEditShell::DeleteSel fix start of selection when bSelAll == true MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit f9b62506b22c3eb885ffd5a4ec8025c33df7b2d4) Conflicts: sw/qa/extras/uiwriter/uiwriter.cxx Change-Id: I3e8ce585b29619061b18ab1ab8f0cf6c7d421074 Reviewed-on: https://gerrit.libreoffice.org/8559 Reviewed-by: Björn Michaelsen Tested-by: Björn Michaelsen (cherry picked from commit fea99d32aec1c24b7cbc7a4063b21a471072509b) Reviewed-on: https://gerrit.libreoffice.org/8571 Tested-by: Michael Stahl Reviewed-by: Michael Stahl Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/qa/extras/uiwriter/data/fdo75110.odt | Bin 0 -> 13169 bytes sw/qa/extras/uiwriter/uiwriter.cxx | 15 +++++++++++++++ sw/source/core/edit/eddel.cxx | 9 +++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/uiwriter/data/fdo75110.odt diff --git a/sw/qa/extras/uiwriter/data/fdo75110.odt b/sw/qa/extras/uiwriter/data/fdo75110.odt new file mode 100644 index 000000000000..f4c2f2bb699b Binary files /dev/null and b/sw/qa/extras/uiwriter/data/fdo75110.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 12c76b8a6af7..a86d2ca786f2 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -23,11 +23,13 @@ public: //EDITING: undo search&replace corrupt text when searching backward void testReplaceBackward(); void testFdo69893(); + void testFdo75110(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); CPPUNIT_TEST(testReplaceBackward); CPPUNIT_TEST(testFdo69893); + CPPUNIT_TEST(testFdo75110); CPPUNIT_TEST_SUITE_END(); private: @@ -78,6 +80,19 @@ void SwUiWriterTest::testReplaceForward() CPPUNIT_ASSERT_EQUAL(ORIGINAL_REPLACE_CONTENT, pTxtNode->GetTxt()); } +void SwUiWriterTest::testFdo75110() +{ + SwDoc* pDoc = createDoc("fdo75110.odt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + pWrtShell->SelAll(); + // The problem was that SwEditShell::DeleteSel() what this Delete() invokes took the wrong selection... + pWrtShell->Delete(); + sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); + // ... so this Undo() call resulted in a crash. + rUndoManager.Undo(); +} + void SwUiWriterTest::testReplaceBackward() { SwDoc* pDoc = createDoc(); diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index e94ea3bc43af..6a4fc8715668 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -89,9 +89,14 @@ void SwEditShell::DeleteSel( SwPaM& rPam, sal_Bool* pUndo ) } else { + SwPaM aPam(rPam); + if (bSelectAll) + // 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(); // delete everything - GetDoc()->DeleteAndJoin( rPam ); - SaveTblBoxCntnt( rPam.GetPoint() ); + GetDoc()->DeleteAndJoin( aPam ); + SaveTblBoxCntnt( aPam.GetPoint() ); } // Selection is not needed anymore -- cgit v1.2.3