sw/qa/extras/uiwriter/uiwriter2.cxx | 38 ++++++++++++++++++++++++++++++++++++ sw/source/core/txtnode/ndtxt.cxx | 4 +-- 2 files changed, 40 insertions(+), 2 deletions(-)
New commits: commit c85863a3b4c632cdf6b6a7448fcf49ffb6bb5f11 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Mar 4 19:18:27 2022 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Mar 7 15:10:51 2022 +0100 tdf#140077 sw_redlinehide: fix crash on SplitNode() The problem is that CutImpl() was called with nLen=0 and so returned without sending any hint to SwTextFrame. Then the MergedPara gets recreated, but the problem is that the SwParaPortion is never invalidated so it still contains the portions of the previous merged paragraph, and painting it will crash. But it turns out that there isn't a hint that would actually work here; instead, generalise a condition in SwTextNode::SplitContentNode() to simply throw away the portions. (regression from commit eb92dc08f2abf5ed088da0d736266f213adf00de) Change-Id: I06091ca695ea9180b32e61ddb88ce64fbf20443e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131039 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 6518c45dc0c2fb67500af85b97ed40466fd1d1e0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131026 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 700f0cbc9884..699264592bba 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1413,6 +1413,44 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571_keep_numbering_with_Reject) CPPUNIT_ASSERT_MESSAGE("Bad numbering", sNumName.isEmpty()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf140077) +{ + SwDoc* const pDoc = createSwDoc(); + + SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + // hide + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + + pWrtShell->Insert("a"); + pWrtShell->SplitNode(); + pWrtShell->Insert("b"); + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); + // enable + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + CPPUNIT_ASSERT_MESSAGE( + "redlines should be visible", + IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines()); + + pWrtShell->Delete(); + pWrtShell->SttEndDoc(/*bStart=*/false); + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + + // crashed in layout + pWrtShell->SplitNode(); + + pWrtShell->Undo(); + pWrtShell->Redo(); + pWrtShell->Undo(); + pWrtShell->Redo(); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf109376_redline) { SwDoc* pDoc = createSwDoc(); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 4be2408ce1e8..415c54b745e5 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -651,9 +651,9 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, // Update the extents with new node; also inits merge flag, // so the MakeFramesForAdjacentContentNode below respects it pFrame->RegisterToNode(*pNode); - if (pFrame->GetText().isEmpty()) + if (nSplitPos == 0) { - // turns out it's empty - in this case, it was not + // in this case, it was not // invalidated because Cut didn't sent it any hints, // so we have to invalidate it here! pFrame->Prepare(PrepareHint::Clear, nullptr, false);