diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-04-30 23:14:02 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-05-01 16:54:13 +0000 |
commit | d70174ef1bc5894fe3cd46d4bda1dfd5f6422d39 (patch) | |
tree | fae579127b40d9a6a22ccf1b65761d854fb86246 | |
parent | 5c49c7cab35be0863408444d4fe06711cfdb7650 (diff) |
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 <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/qa/core/macros-test.cxx | 31 | ||||
-rw-r--r-- | sw/source/core/undo/undel.cxx | 6 |
2 files changed, 36 insertions, 1 deletions
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index 3101de7ed048..1f33c9156003 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 253ef993dca6..0c5c1f174ead 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; |