sw/qa/core/macros-test.cxx | 31 +++++++++++++++++++++++++++++++ sw/source/core/undo/undel.cxx | 6 +++++- 2 files changed, 36 insertions(+), 1 deletion(-)
New commits: commit d70174ef1bc5894fe3cd46d4bda1dfd5f6422d39 Author: Michael Stahl <mst...@redhat.com> Date: Thu Apr 30 23:14:02 2015 +0200 tdf#90816: sw: fix bookmark loss in SwUndoDelete _DelBookmarks() will actually delete marks that exactly match both start and end position of the range, so restrict the call to only the fully-deleted nodes that will be moved to the Undo-array. (regression from 370febbf19a5f362394d1c9e69b12dcb218f6501) (cherry picked from commit c7fb1d8334d2289906ac2a0a8c32946493d10e00) Conflicts: sw/qa/core/macros-test.cxx Change-Id: Icf5097774aa55ee152a1e20c0c7264330955c615 Reviewed-on: https://gerrit.libreoffice.org/15581 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index 3101de7..1f33c91 100644 --- a/sw/qa/core/macros-test.cxx +++ b/sw/qa/core/macros-test.cxx @@ -69,6 +69,7 @@ public: void testVba(); #endif void testBookmarkDeleteAndJoin(); + void testBookmarkDeleteTdf90816(); void testFdo55289(); void testFdo68983(); CPPUNIT_TEST_SUITE(SwMacrosTest); @@ -79,6 +80,7 @@ public: CPPUNIT_TEST(testVba); #endif CPPUNIT_TEST(testBookmarkDeleteAndJoin); + CPPUNIT_TEST(testBookmarkDeleteTdf90816); CPPUNIT_TEST(testFdo55289); CPPUNIT_TEST(testFdo68983); @@ -204,6 +206,35 @@ void SwMacrosTest::testBookmarkDeleteAndJoin() } } +void SwMacrosTest::testBookmarkDeleteTdf90816() +{ + SwDoc *const pDoc = new SwDoc; + pDoc->GetIDocumentUndoRedo().DoUndo(true); // bug is in SwUndoDelete + SwNodeIndex aIdx(pDoc->GetNodes().GetEndOfContent(), -1); + SwPaM aPaM(aIdx); + + IDocumentContentOperations & rIDCO(pDoc->getIDocumentContentOperations()); + rIDCO.AppendTxtNode(*aPaM.GetPoint()); + rIDCO.InsertString(aPaM, OUString("ABC")); + aPaM.Move(fnMoveBackward, fnGoCntnt); + aPaM.SetMark(); + aPaM.Move(fnMoveBackward, fnGoCntnt); + IDocumentMarkAccess & rIDMA = *pDoc->getIDocumentMarkAccess(); + sw::mark::IMark *pMark = + rIDMA.makeMark(aPaM, "test", IDocumentMarkAccess::MarkType::BOOKMARK); + CPPUNIT_ASSERT(pMark); + + // delete the same selection as the bookmark + rIDCO.DeleteAndJoin(aPaM, false); + + // bookmark still there? + auto iter = rIDMA.getAllMarksBegin(); + CPPUNIT_ASSERT_MESSAGE("the bookmark was deleted", + iter != rIDMA.getAllMarksEnd()); + CPPUNIT_ASSERT(*aPaM.Start() == (*iter)->GetMarkPos()); + CPPUNIT_ASSERT(*aPaM.End() == (*iter)->GetOtherMarkPos()); +} + void SwMacrosTest::testFdo55289() { SwDoc *const pDoc = new SwDoc; diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 253ef99..0c5c1f1 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -156,7 +156,11 @@ SwUndoDelete::SwUndoDelete( { DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() ); ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); - _DelBookmarks(pStt->nNode, pEnd->nNode, nullptr, &pStt->nContent, &pEnd->nContent); + if (nEndNode - nSttNode > 1) // check for fully selected nodes + { + SwNodeIndex const start(pStt->nNode, +1); + _DelBookmarks(start, pEnd->nNode); + } } nSetPos = pHistory ? pHistory->Count() : 0;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits