[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 19 08:31:17 UTC 2020


 sw/source/core/docnode/ndsect.cxx |    5 ++++-
 sw/source/core/edit/eddel.cxx     |   12 +++++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

New commits:
commit a12b3da27613bfac7adeb6b847027e82c6649d5b
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Jun 18 18:32:24 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Fri Jun 19 10:30:46 2020 +0200

    tdf#133990 sw_redlinehide: fix Undo with section before table
    
    ... at start of document.
    
    The section node wasn't included in the PaM passed to SwUndoDelete,
    so on Undo it called MakeFrames() starting from the contained table
    node and crashed when reaching the section's end node.
    
    Fixed, then it crashes in Redo, because SwDoc::DelSectionFormat()
    calls SetModified() which calls some event listener which causes
    EndAllAction() to be called, which by itself is scary and then it
    crashes because the nodes array contains a bunch of deleted nodes.
    
    Not sure if that SetModified() serves any purpose, but it's pointless
    in Undo.
    
    (1st crash is regression from 68880a3004623553bf1920ad8a4a4d2be4bca234)
    
    Change-Id: Iafdd073ca9577bf54dd5a8ad2eb8f8f110db93b6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96620
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 57d488660572d62ef0371e50dcdd4ca7a6d98a14)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96633

diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 7ef60935f672..86207616fce5 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -601,7 +601,10 @@ void SwDoc::DelSectionFormat( SwSectionFormat *pFormat, bool bDelNodes )
 
     GetIDocumentUndoRedo().EndUndo(SwUndoId::DELSECTION, nullptr);
 
-    getIDocumentState().SetModified();
+    if (GetIDocumentUndoRedo().DoesUndo())
+    {   // TODO is this ever needed?
+        getIDocumentState().SetModified();
+    }
 }
 
 void SwDoc::UpdateSection( size_t const nPos, SwSectionData & rNewData,
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index b32f72c5fa6d..660f1f79afff 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -99,7 +99,17 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo )
             pNewPam.reset(new SwPaM(*rPam.GetMark(), *rPam.GetPoint()));
             // Selection starts at the first para of the first cell, but we
             // want to delete the table node before the first cell as well.
-            pNewPam->Start()->nNode = pNewPam->Start()->nNode.GetNode().FindTableNode()->GetIndex();
+            while (SwTableNode const* pTableNode =
+                pNewPam->Start()->nNode.GetNode().StartOfSectionNode()->FindTableNode())
+            {
+                pNewPam->Start()->nNode = *pTableNode;
+            }
+            // tdf#133990 ensure section is included in SwUndoDelete
+            while (SwSectionNode const* pSectionNode =
+                pNewPam->Start()->nNode.GetNode().StartOfSectionNode()->FindSectionNode())
+            {
+                pNewPam->Start()->nNode = *pSectionNode;
+            }
             pNewPam->Start()->nContent.Assign(nullptr, 0);
             pPam = pNewPam.get();
         }


More information about the Libreoffice-commits mailing list