summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-03-04 19:18:27 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-03-07 15:10:36 +0100
commitc485690c48c92647b8edeca04be8cafcc8de9628 (patch)
tree6aff038b7056b3ea3d9b3ef0a23211b81e0a64b6
parenttdf#146562 let toc default size and pos on first launch (diff)
downloadcore-c485690c48c92647b8edeca04be8cafcc8de9628.tar.gz
core-c485690c48c92647b8edeca04be8cafcc8de9628.zip
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.stahl@allotropia.de> (cherry picked from commit 6518c45dc0c2fb67500af85b97ed40466fd1d1e0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131025 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx38
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx4
2 files changed, 40 insertions, 2 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 988225938a89..4e9080bdc951 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -1409,6 +1409,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 872e4cee96db..4d576f479e5c 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -653,9 +653,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);