summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-12-16 12:23:22 +0100
committerLászló Németh <nemeth@numbertext.org>2020-12-17 20:36:56 +0100
commit172373c4a2c4a66b8abbe26dbe07fd621c971ed0 (patch)
tree384b8901e1c5caaf19206953b2d42c61036b718e /sw/qa
parenta66a6f4cc8efbca282d39e8dd48709ec82bbc26b (diff)
sw ChangesInMargin: fix crash at Undo of deletion of paragraph break
Deletion of the paragraph break by pressing Delete results an empty hidden redline, too, which caused a problem during Undo (if there were other tracked redlines, too). Change-Id: I64968688688be72d4e501631244b4c57ab634585 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107830 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index c3d4d71d6b5c..496b9b8602bc 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -2084,6 +2084,47 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137771)
CPPUNIT_ASSERT(!pWrtShell->GetViewOptions()->IsShowChangesInMargin());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testJoinParaChangesInMargin)
+{
+ load(DATA_DIRECTORY, "tdf54819.fodt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ // switch on "Show changes in margin" mode
+ dispatchCommand(mxComponent, ".uno:ShowChangesInMargin", {});
+
+ SwWrtShell* const pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell->GetViewOptions()->IsShowChangesInMargin());
+
+ // turn on red-lining and show changes
+ SwDoc* pDoc = pWrtShell->GetDoc();
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowInsert
+ | RedlineFlags::ShowDelete);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // delete a character and the paragraph break at the end of the paragraph
+ dispatchCommand(mxComponent, ".uno:GotoEndOfPara", {});
+ pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
+ dispatchCommand(mxComponent, ".uno:Delete", {});
+ dispatchCommand(mxComponent, ".uno:Delete", {});
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsudolor sit amet."), getParagraph(1)->getString());
+
+ // Undo
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ // this would crash due to bad redline range
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum"), getParagraph(1)->getString());
+
+ // switch off "Show changes in margin" mode
+ dispatchCommand(mxComponent, ".uno:ShowChangesInMargin", {});
+ CPPUNIT_ASSERT(!pWrtShell->GetViewOptions()->IsShowChangesInMargin());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf138479)
{
SwDoc* const pDoc = createDoc();