sw/qa/extras/uiwriter/uiwriter2.cxx | 51 ++++++++++++++++++++++++++ sw/source/core/doc/DocumentRedlineManager.cxx | 6 ++- 2 files changed, 56 insertions(+), 1 deletion(-)
New commits: commit 0fe7070c9f6c1b4d4e2da05099255fbed10ab50c Author: László Németh <nem...@numbertext.org> AuthorDate: Mon Mar 22 22:17:11 2021 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed Mar 24 15:10:07 2021 +0100 tdf#140757 sw ChangesInMargin: fix crash on Undo of Accept All Change-Id: Ia1e0a58b0843f34c0f5042fdc147c4035e868255 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112946 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 97fea5d32797..bc471a8dda67 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -2265,6 +2265,57 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testJoinParaChangesInMargin) CPPUNIT_ASSERT(!pWrtShell->GetViewOptions()->IsShowChangesInMargin()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf140757) +{ + 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 in the first paragraph, and another character in the second one + dispatchCommand(mxComponent, ".uno:Delete", {}); + pWrtShell->Down(/*bSelect=*/false); + dispatchCommand(mxComponent, ".uno:Delete", {}); + + CPPUNIT_ASSERT_EQUAL(OUString("orem ipsum"), getParagraph(1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("olor sit amet."), getParagraph(2)->getString()); + + // accept all changes + IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess()); + rIDRA.AcceptAllRedline(/*bAccept=*/true); + + CPPUNIT_ASSERT_EQUAL(OUString("orem ipsum"), getParagraph(1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("olor sit amet."), getParagraph(2)->getString()); + + // This crashed + dispatchCommand(mxComponent, ".uno:Undo", {}); + + // Check result of Undo + rIDRA.AcceptAllRedline(/*bAccept=*/false); + CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum"), getParagraph(1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("dolor sit amet."), getParagraph(2)->getString()); + + // switch off "Show changes in margin" mode + dispatchCommand(mxComponent, ".uno:ShowChangesInMargin", {}); + CPPUNIT_ASSERT(!pWrtShell->GetViewOptions()->IsShowChangesInMargin()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf139127) { load(DATA_DIRECTORY, "tdf139127.fodt"); diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 8f8688702a18..1c63619a8e1b 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -154,7 +154,11 @@ void UpdateFramesForAddDeleteRedline(SwDoc & rDoc, SwPaM const& rPam) currentStart.nNode.GetNode().IsTableNode() ? static_cast<SwStartNode*>(currentStart.nNode.GetNode().GetTableNode()) : static_cast<SwStartNode*>(currentStart.nNode.GetNode().GetSectionNode())); - assert(pTableOrSectionNode); // known pathology + if ( !pTableOrSectionNode ) + { + SAL_WARN("sw.core", "UpdateFramesForAddDeleteRedline:: known pathology (or ChangesInRedline mode)"); + return; + } for (sal_uLong j = pTableOrSectionNode->GetIndex(); j <= pTableOrSectionNode->EndOfSectionIndex(); ++j) { pTableOrSectionNode->GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::Hidden); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits