Blame SOURCES/0001-tdf-121546-sw-don-t-use-undo-array-s-m_pOutlineNodes.patch

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