Kaydet (Commit) c7fb1d83 authored tarafından Michael Stahl's avatar Michael Stahl

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 370febbf)

Change-Id: Icf5097774aa55ee152a1e20c0c7264330955c615
üst f70ae550
...@@ -79,6 +79,7 @@ public: ...@@ -79,6 +79,7 @@ public:
void testVba(); void testVba();
#endif #endif
void testBookmarkDeleteAndJoin(); void testBookmarkDeleteAndJoin();
void testBookmarkDeleteTdf90816();
#if 0 #if 0
void testControlShapeGrouping(); void testControlShapeGrouping();
#endif #endif
...@@ -93,6 +94,7 @@ public: ...@@ -93,6 +94,7 @@ public:
CPPUNIT_TEST(testVba); CPPUNIT_TEST(testVba);
#endif #endif
CPPUNIT_TEST(testBookmarkDeleteAndJoin); CPPUNIT_TEST(testBookmarkDeleteAndJoin);
CPPUNIT_TEST(testBookmarkDeleteTdf90816);
#if 0 #if 0
CPPUNIT_TEST(testControlShapeGrouping); CPPUNIT_TEST(testControlShapeGrouping);
#endif #endif
...@@ -222,6 +224,35 @@ void SwMacrosTest::testBookmarkDeleteAndJoin() ...@@ -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 #if 0
void SwMacrosTest::testControlShapeGrouping() void SwMacrosTest::testControlShapeGrouping()
{ {
......
...@@ -154,7 +154,11 @@ SwUndoDelete::SwUndoDelete( ...@@ -154,7 +154,11 @@ SwUndoDelete::SwUndoDelete(
{ {
DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() ); DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() );
::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); ::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; nSetPos = pHistory ? pHistory->Count() : 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment