sw/qa/extras/uiwriter/data/tdf132160.odt      |binary
 sw/qa/extras/uiwriter/uiwriter.cxx            |   18 ++++++++++++++++++
 sw/source/core/doc/DocumentRedlineManager.cxx |    5 +++++
 3 files changed, 23 insertions(+)

New commits:
commit d0ebd31df55d6bec2a0a7f84978712e49b90b993
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Tue Aug 25 14:44:39 2020 +0200
Commit:     Thorsten Behrens <thorsten.behr...@cib.de>
CommitDate: Wed Aug 26 14:25:57 2020 +0200

    (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.st...@cib.de>
    (cherry picked from commit e2fe4fde592564d35099ad1e2659ad682dfb77f5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101352
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>

diff --git a/sw/qa/extras/uiwriter/data/tdf132160.odt 
b/sw/qa/extras/uiwriter/data/tdf132160.odt
new file mode 100644
index 000000000000..8a8ae7b8b1cb
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf132160.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index c14306e233c9..be8a972a181a 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -4231,6 +4231,24 @@ void SwUiWriterTest::testDde()
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest, 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
+    lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
+
+    // this would crash due to insert redline ending on table node
+    lcl_dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    lcl_dispatchCommand(mxComponent, ".uno:Redo", {});
+
+    lcl_dispatchCommand(mxComponent, ".uno:Undo", {});
+}
+
 //IdleTask class to add a low priority Idle task
 class IdleTask
 {
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index 8e026a876dc9..ff9b05743d10 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -658,6 +658,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
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to