diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-08-25 14:44:39 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-08-25 17:46:53 +0200 |
commit | e2fe4fde592564d35099ad1e2659ad682dfb77f5 (patch) | |
tree | 1017573cbccc42b9ed2424add6c4fc2940bfbd64 /sw | |
parent | 03e28651142af2ffa7a3749b879f31bde98a2173 (diff) |
(related: tdf#132160) sw: fix lcl_RejectRedline if end is on table node
This happens on Undo:
sw/source/core/undo/undobj.cxx:1394: void SwRedlineSaveData::RedlineToDoc(const SwPaM&): Assertion `result != IDocumentRedlineAccess::AppendResult::IGNORED' failed.
Because the SwRedlineSaveData was created in SwUndoDelete ctor from
this:
(rr) p *pRedl
$18 = (SwRangeRedline) {
<SwPaM> = SwPaM = {
point = SwPosition (node 13457, offset 0),
mark = SwPosition (node 13455, offset 0)
},
(rr) p pRedl->GetPoint()->nNode.GetNode().GetNodes()[13457]
$19 = (SwTableNode *) 0x80bdbe0
DelFullPara() will delete the end node, see "m_rDoc.GetNodes().Delete(
aRg.aStart, nNodeDiff+1 );" or equivalent in SwUndoDelete.
So if the end is on a start node, set it back to the previous node,
because deleting just a start node is a bad idea.
Change-Id: Ib7c35c103ce05ede39e66505fa47fa70bfece018
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101334
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/uiwriter/data2/tdf132160.odt | bin | 0 -> 9501 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentRedlineManager.cxx | 5 |
3 files changed, 23 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data2/tdf132160.odt b/sw/qa/extras/uiwriter/data2/tdf132160.odt Binary files differnew file mode 100644 index 000000000000..8a8ae7b8b1cb --- /dev/null +++ b/sw/qa/extras/uiwriter/data2/tdf132160.odt diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index f93aba8f4e2a..8fb14a87c945 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1722,6 +1722,24 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf122942) CPPUNIT_ASSERT(rOutRect2.Top() > rOutRect1.Top() && rOutRect2.Top() < rOutRect1.Bottom()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf132160) +{ + load(DATA_DIRECTORY, "tdf132160.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + // this would crash due to delete redline starting with ToX + dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); + + // this would crash due to insert redline ending on table node + dispatchCommand(mxComponent, ".uno:Undo", {}); + + dispatchCommand(mxComponent, ".uno:Redo", {}); + + dispatchCommand(mxComponent, ".uno:Undo", {}); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf52391) { load(DATA_DIRECTORY, "tdf52391.fodt"); diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 8b9eaf0179c6..bbf4e816616e 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -660,6 +660,11 @@ namespace { aPam.GetBound().nContent.Assign( nullptr, 0 ); aPam.GetBound( false ).nContent.Assign( nullptr, 0 ); + if (aPam.End()->nNode.GetNode().IsStartNode()) + { // end node will be deleted too! see nNodeDiff+1 + --aPam.End()->nNode; + } + assert(!aPam.End()->nNode.GetNode().IsStartNode()); rDoc.getIDocumentContentOperations().DelFullPara( aPam ); } else |