summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;