tdf#145066 sw change tracking: fix bad deletion at Move Up/Down
In Show Changes mode, moving a list item over
a deleted list item resulted the bad deletion
of the next adjacent paragraph, too.
Note: For manual testing with a non assert build,
put cursor in list item 2, click on Move Down once,
Move Up twice to show the bad deletion.
See also b5ab4836c03e9428aff6a48843f2a054ceff0f85
"tdf#39721 sw change tracking: fix move down".
Change-Id: Ie4dd1089dea4ed7068db94b134cd31881463c9ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123378
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 07356f6..dc7d8b8 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -920,6 +920,38 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf39721)
#endif
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf145066_bad_paragraph_deletion)
{
// check move down with redlining: jumping over a deleted paragraph
// resulted bad deletion of the not deleted adjacent paragraph in Show Changes mode
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf39721.fodt");
//turn on red-lining and show changes
pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete
| RedlineFlags::ShowInsert);
CPPUNIT_ASSERT_MESSAGE("redlining should be on",
pDoc->getIDocumentRedlineAccess().IsRedlineOn());
CPPUNIT_ASSERT_MESSAGE(
"redlines should be visible",
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
// Three paragraphs (list items)
CPPUNIT_ASSERT_EQUAL(3, getParagraphs());
// move down once and move up two times second paragraph with change tracking
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
pWrtShell->Down(/*bSelect=*/false);
dispatchCommand(mxComponent, ".uno:MoveDown", {});
dispatchCommand(mxComponent, ".uno:MoveUp", {});
dispatchCommand(mxComponent, ".uno:MoveUp", {});
// accept all changes
dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {});
// This was 2 (bad deletion of the first paragraph)
CPPUNIT_ASSERT_EQUAL(3, getParagraphs());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf54819)
{
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf54819.fodt");
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 026eea9..1e08ec1 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2188,9 +2188,11 @@ bool SwDoc::MoveParagraphImpl(SwPaM& rPam, tools::Long const nOffset,
{
break;
}
if (pRedline->GetType() == RedlineType::Delete)
if (pRedline->GetType() == RedlineType::Delete &&
// tdf#145066 skip full-paragraph deletion which was jumped over
// in Show Changes mode to avoid of deleting an extra row
*aPam.Start() <= *pRedline->Start())
{
assert(*aPam.Start() <= *pRedline->Start()); // caller's fault
SwRangeRedline* pNewRedline;
{
SwPaM pam(*pRedline, nullptr);