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

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