summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-10-11 12:24:33 +0200
committerLászló Németh <nemeth@numbertext.org>2021-10-12 08:57:55 +0200
commitbcc06060bb286bd71a8fd1707eb499c8d2a88b69 (patch)
tree1220c76ece710848946a829c8f10fb2ed2ff4db7 /sw
parentd27187b158d7e3f92180b1f2ab79b048dc5318a5 (diff)
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>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx32
-rw-r--r--sw/source/core/doc/docnum.cxx6
2 files changed, 36 insertions, 2 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 07356f6ea478..dc7d8b8ecf8e 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 026eea9d503d..1e08ec1e1664 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);