summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-12-05 21:58:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-12-06 03:07:31 -0600
commit640e8abbff03f7f242c0c0b9d73ffd2eda3c4e35 (patch)
treeb30f818686f3f7c09951e3a2405e9d041b28d416
parentcb4225144f1fff44f9bb972fe06f51524da11b8b (diff)
fdo#71892: sw: fix crash when pasting table in footnote
The code that updates RSIDs assumes that the number of nodes copied is the same as the number of nodes inserted, which is not true when pasting a table into a footnote because Writer can't do that, hence all table nodes are missing. Count inserted nodes instead. (regression from 062eaeffe7cb986255063bb9b0a5f3fb3fc8e34c) (cherry picked from commit 4580094d2d9d5b952c4526ee23204f75a5bb2f1b) Conflicts: sw/source/core/frmedt/fecopy.cxx (cherry picked from commit 2171fff4c1a57ede8f9693d7c0d95c1171a49a70) Change-Id: I77b5b7751d1036a6401f708532537d874969502e Reviewed-on: https://gerrit.libreoffice.org/6951 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/core/frmedt/fecopy.cxx23
1 files changed, 10 insertions, 13 deletions
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 3fa4a73870ee..6c503dc8c533 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -1039,25 +1039,22 @@ sal_Bool SwFEShell::Paste( SwDoc* pClpDoc, sal_Bool bIncludingPageFrames )
aIndexBefore--;
pClpDoc->CopyRange( aCpyPam, rInsPos, false );
+ // Note: aCpyPam is invalid now
- {
- ++aIndexBefore;
- SwPaM aPaM(SwPosition(aIndexBefore),
- SwPosition(rInsPos.nNode));
+ ++aIndexBefore;
+ SwPaM aPaM(SwPosition(aIndexBefore),
+ SwPosition(rInsPos.nNode));
- aPaM.GetDoc()->MakeUniqueNumRules(aPaM);
- }
- }
+ aPaM.GetDoc()->MakeUniqueNumRules(aPaM);
- // Update the rsid of each pasted text node.
- {
- xub_StrLen nNodesCnt = aCpyPam.End()->nNode.GetIndex() - aCpyPam.Start()->nNode.GetIndex();
+ // Update the rsid of each pasted text node.
SwNodes &rDestNodes = GetDoc()->GetNodes();
- xub_StrLen nDestStart = PCURCRSR->GetPoint()->nNode.GetIndex() - nNodesCnt;
+ sal_uLong const nEndIdx = aPaM.End()->nNode.GetIndex();
- for ( sal_uInt64 nIdx = 0; nIdx <= nNodesCnt; nIdx++ )
+ for (sal_uLong nIdx = aPaM.Start()->nNode.GetIndex();
+ nIdx <= nEndIdx; ++nIdx)
{
- SwTxtNode *pTxtNode = rDestNodes[ nDestStart + nIdx ]->GetTxtNode();
+ SwTxtNode *const pTxtNode = rDestNodes[nIdx]->GetTxtNode();
if ( pTxtNode )
{
GetDoc()->UpdateParRsid( pTxtNode );