sw/source/core/docnode/ndnum.cxx |    2 ++
 sw/source/core/docnode/nodes.cxx |   18 ++++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

New commits:
commit f7a148cf13cab1505e0ca8229f6cb334662ef20b
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Mon Nov 15 17:29:59 2021 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Thu Nov 18 10:49:57 2021 +0100

    tdf#121546 sw: don't use undo array's m_pOutlineNodes
    
    It's pointless.
    
    Change-Id: I304c123bffc16e6133d2953bc9a4f7a3afad14ef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124999
    Tested-by: Jenkins
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125260
    (cherry picked from commit 74ff78e1e21dc83099d0dfcedba780c176c8fb3f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125143
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>
    Tested-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sw/source/core/docnode/ndnum.cxx b/sw/source/core/docnode/ndnum.cxx
index b3d66affa66e..a7b898ee5f0a 100644
--- a/sw/source/core/docnode/ndnum.cxx
+++ b/sw/source/core/docnode/ndnum.cxx
@@ -38,6 +38,8 @@ bool SwOutlineNodes::Seek_Entry(SwNode* rP, size_type* pnPos) 
const
 
 void SwNodes::UpdateOutlineNode(SwNode & rNd)
 {
+    assert(IsDocNodes()); // no point in m_pOutlineNodes for undo nodes
+
     SwTextNode * pTextNd = rNd.GetTextNode();
 
     if (!(pTextNd && pTextNd->IsOutlineStateChanged()))
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index da593261074b..e7af18a1c16a 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -110,6 +110,16 @@ SwNodes::~SwNodes()
     m_pEndOfContent.reset();
 }
 
+static bool IsInsertOutline(SwNodes const& rNodes, sal_uLong const nIndex)
+{
+    if (!rNodes.IsDocNodes())
+    {
+        return false;
+    }
+    return nIndex < rNodes.GetEndOfRedlines().StartOfSectionNode()->GetIndex()
+        || rNodes.GetEndOfRedlines().GetIndex() < nIndex;
+}
+
 void SwNodes::ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSz,
                         SwNodeIndex& rInsPos, bool bNewFrames )
 {
@@ -125,9 +135,7 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, 
sal_uLong nSz,
 
     // NEVER include nodes from the RedLineArea
     sal_uLong nNd = rInsPos.GetIndex();
-    bool bInsOutlineIdx = (
-            rNds.GetEndOfRedlines().StartOfSectionNode()->GetIndex() >= nNd ||
-            nNd >= rNds.GetEndOfRedlines().GetIndex() );
+    bool const bInsOutlineIdx = IsInsertOutline(rNds, nNd);
 
     if( &rNds == this ) // if in the same node array -> move
     {
@@ -484,9 +492,7 @@ bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes 
& rNodes,
 
                     // NEVER include nodes from the RedLineArea
                     sal_uLong nNd = aIdx.GetIndex();
-                    bool bInsOutlineIdx = ( rNodes.GetEndOfRedlines().
-                            StartOfSectionNode()->GetIndex() >= nNd ||
-                            nNd >= rNodes.GetEndOfRedlines().GetIndex() );
+                    bool const bInsOutlineIdx = IsInsertOutline(rNodes, nNd);
 
                     if( bNewFrames )
                         // delete all frames

Reply via email to