summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-04-30 23:14:02 +0200
committerMichael Stahl <mstahl@redhat.com>2015-05-01 00:53:15 +0200
commitc7fb1d8334d2289906ac2a0a8c32946493d10e00 (patch)
tree618de5cdc12c2f8be6ff96c8ccd78eeb9eb25b50
parentf70ae550ebbfaec629abaacff037d2798aa4b677 (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) Change-Id: Icf5097774aa55ee152a1e20c0c7264330955c615
-rw-r--r--sw/qa/core/macros-test.cxx31
-rw-r--r--sw/source/core/undo/undel.cxx6
2 files changed, 36 insertions, 1 deletions
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 26647c8139e6..c754bb431517 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -79,6 +79,7 @@ public:
void testVba();
#endif
void testBookmarkDeleteAndJoin();
+ void testBookmarkDeleteTdf90816();
#if 0
void testControlShapeGrouping();
#endif
@@ -93,6 +94,7 @@ public:
CPPUNIT_TEST(testVba);
#endif
CPPUNIT_TEST(testBookmarkDeleteAndJoin);
+ CPPUNIT_TEST(testBookmarkDeleteTdf90816);
#if 0
CPPUNIT_TEST(testControlShapeGrouping);
#endif
@@ -222,6 +224,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());
+}
+
#if 0
void SwMacrosTest::testControlShapeGrouping()
{
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index 1bbab983891b..51999e7518a0 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -154,7 +154,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;