Blame SOURCES/0042-fdo-71892-sw-fix-crash-when-pasting-table-in-footnot.patch

f0633d
From 640e8abbff03f7f242c0c0b9d73ffd2eda3c4e35 Mon Sep 17 00:00:00 2001
f0633d
From: Michael Stahl <mstahl@redhat.com>
f0633d
Date: Thu, 5 Dec 2013 21:58:11 +0100
f0633d
Subject: [PATCH 042/109] fdo#71892: sw: fix crash when pasting table in
f0633d
 footnote
f0633d
MIME-Version: 1.0
f0633d
Content-Type: text/plain; charset=UTF-8
f0633d
Content-Transfer-Encoding: 8bit
f0633d
f0633d
The code that updates RSIDs assumes that the number of nodes copied is
f0633d
the same as the number of nodes inserted, which is not true when pasting
f0633d
a table into a footnote because Writer can't do that, hence all table
f0633d
nodes are missing.  Count inserted nodes instead.
f0633d
f0633d
(regression from 062eaeffe7cb986255063bb9b0a5f3fb3fc8e34c)
f0633d
f0633d
(cherry picked from commit 4580094d2d9d5b952c4526ee23204f75a5bb2f1b)
f0633d
f0633d
Conflicts:
f0633d
	sw/source/core/frmedt/fecopy.cxx
f0633d
f0633d
(cherry picked from commit 2171fff4c1a57ede8f9693d7c0d95c1171a49a70)
f0633d
f0633d
Change-Id: I77b5b7751d1036a6401f708532537d874969502e
f0633d
Reviewed-on: https://gerrit.libreoffice.org/6951
f0633d
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
f0633d
Tested-by: Caolán McNamara <caolanm@redhat.com>
f0633d
---
f0633d
 sw/source/core/frmedt/fecopy.cxx | 23 ++++++++++-------------
f0633d
 1 file changed, 10 insertions(+), 13 deletions(-)
f0633d
f0633d
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
f0633d
index 3fa4a73..6c503dc 100644
f0633d
--- a/sw/source/core/frmedt/fecopy.cxx
f0633d
+++ b/sw/source/core/frmedt/fecopy.cxx
f0633d
@@ -1039,25 +1039,22 @@ sal_Bool SwFEShell::Paste( SwDoc* pClpDoc, sal_Bool bIncludingPageFrames )
f0633d
                 aIndexBefore--;
f0633d
 
f0633d
                 pClpDoc->CopyRange( aCpyPam, rInsPos, false );
f0633d
+                // Note: aCpyPam is invalid now
f0633d
 
f0633d
-                {
f0633d
-                    ++aIndexBefore;
f0633d
-                    SwPaM aPaM(SwPosition(aIndexBefore),
f0633d
-                               SwPosition(rInsPos.nNode));
f0633d
+                ++aIndexBefore;
f0633d
+                SwPaM aPaM(SwPosition(aIndexBefore),
f0633d
+                           SwPosition(rInsPos.nNode));
f0633d
 
f0633d
-                    aPaM.GetDoc()->MakeUniqueNumRules(aPaM);
f0633d
-                }
f0633d
-            }
f0633d
+                aPaM.GetDoc()->MakeUniqueNumRules(aPaM);
f0633d
 
f0633d
-            // Update the rsid of each pasted text node.
f0633d
-            {
f0633d
-                xub_StrLen nNodesCnt = aCpyPam.End()->nNode.GetIndex() - aCpyPam.Start()->nNode.GetIndex();
f0633d
+                // Update the rsid of each pasted text node.
f0633d
                 SwNodes &rDestNodes = GetDoc()->GetNodes();
f0633d
-                xub_StrLen nDestStart = PCURCRSR->GetPoint()->nNode.GetIndex() - nNodesCnt;
f0633d
+                sal_uLong const nEndIdx = aPaM.End()->nNode.GetIndex();
f0633d
 
f0633d
-                for ( sal_uInt64 nIdx = 0; nIdx <= nNodesCnt; nIdx++ )
f0633d
+                for (sal_uLong nIdx = aPaM.Start()->nNode.GetIndex();
f0633d
+                        nIdx <= nEndIdx; ++nIdx)
f0633d
                 {
f0633d
-                    SwTxtNode *pTxtNode = rDestNodes[ nDestStart + nIdx ]->GetTxtNode();
f0633d
+                    SwTxtNode *const pTxtNode = rDestNodes[nIdx]->GetTxtNode();
f0633d
                     if ( pTxtNode )
f0633d
                     {
f0633d
                         GetDoc()->UpdateParRsid( pTxtNode );
f0633d
-- 
f0633d
1.8.4.2
f0633d