76e0e0
From bced744fea67d50242701ed55271d40e803ac14e Mon Sep 17 00:00:00 2001
76e0e0
From: Michael Stahl <michael.stahl@allotropia.de>
76e0e0
Date: Mon, 15 Nov 2021 17:29:59 +0100
76e0e0
Subject: [PATCH] tdf#121546 sw: don't use undo array's m_pOutlineNodes
76e0e0
76e0e0
It's pointless.
76e0e0
76e0e0
Change-Id: I304c123bffc16e6133d2953bc9a4f7a3afad14ef
76e0e0
---
76e0e0
 sw/source/core/docnode/ndnum.cxx |  2 ++
76e0e0
 sw/source/core/docnode/nodes.cxx | 18 ++++++++++++------
76e0e0
 2 files changed, 14 insertions(+), 6 deletions(-)
76e0e0
76e0e0
diff --git a/sw/source/core/docnode/ndnum.cxx b/sw/source/core/docnode/ndnum.cxx
76e0e0
index b3d66affa66e..a7b898ee5f0a 100644
76e0e0
--- a/sw/source/core/docnode/ndnum.cxx
76e0e0
+++ b/sw/source/core/docnode/ndnum.cxx
76e0e0
@@ -38,6 +38,8 @@ bool SwOutlineNodes::Seek_Entry(SwNode* rP, size_type* pnPos) const
76e0e0
 
76e0e0
 void SwNodes::UpdateOutlineNode(SwNode & rNd)
76e0e0
 {
76e0e0
+    assert(IsDocNodes()); // no point in m_pOutlineNodes for undo nodes
76e0e0
+
76e0e0
     SwTextNode * pTextNd = rNd.GetTextNode();
76e0e0
 
76e0e0
     if (!(pTextNd && pTextNd->IsOutlineStateChanged()))
76e0e0
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
76e0e0
index a7a2078b2091..ab3eb62ac9f2 100644
76e0e0
--- a/sw/source/core/docnode/nodes.cxx
76e0e0
+++ b/sw/source/core/docnode/nodes.cxx
76e0e0
@@ -109,6 +109,16 @@ SwNodes::~SwNodes()
76e0e0
     m_pEndOfContent.reset();
76e0e0
 }
76e0e0
 
76e0e0
+static bool IsInsertOutline(SwNodes const& rNodes, sal_uLong const nIndex)
76e0e0
+{
76e0e0
+    if (!rNodes.IsDocNodes())
76e0e0
+    {
76e0e0
+        return false;
76e0e0
+    }
76e0e0
+    return nIndex < rNodes.GetEndOfRedlines().StartOfSectionNode()->GetIndex()
76e0e0
+        || rNodes.GetEndOfRedlines().GetIndex() < nIndex;
76e0e0
+}
76e0e0
+
76e0e0
 void SwNodes::ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSz,
76e0e0
                         SwNodeIndex& rInsPos, bool bNewFrames )
76e0e0
 {
76e0e0
@@ -124,9 +134,7 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSz,
76e0e0
 
76e0e0
     // NEVER include nodes from the RedLineArea
76e0e0
     sal_uLong nNd = rInsPos.GetIndex();
76e0e0
-    bool bInsOutlineIdx = (
76e0e0
-            rNds.GetEndOfRedlines().StartOfSectionNode()->GetIndex() >= nNd ||
76e0e0
-            nNd >= rNds.GetEndOfRedlines().GetIndex() );
76e0e0
+    bool const bInsOutlineIdx = IsInsertOutline(rNds, nNd);
76e0e0
 
76e0e0
     if( &rNds == this ) // if in the same node array -> move
76e0e0
     {
76e0e0
@@ -478,9 +486,7 @@ bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
76e0e0
 
76e0e0
                     // NEVER include nodes from the RedLineArea
76e0e0
                     sal_uLong nNd = aIdx.GetIndex();
76e0e0
-                    bool bInsOutlineIdx = ( rNodes.GetEndOfRedlines().
76e0e0
-                            StartOfSectionNode()->GetIndex() >= nNd ||
76e0e0
-                            nNd >= rNodes.GetEndOfRedlines().GetIndex() );
76e0e0
+                    bool const bInsOutlineIdx = IsInsertOutline(rNodes, nNd);
76e0e0
 
76e0e0
                     if( bNewFrames )
76e0e0
                         // delete all frames
76e0e0
-- 
76e0e0
2.33.1
76e0e0