summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-05-20 16:01:57 +0200
committerCaolán McNamara <caolanm@redhat.com>2022-05-24 12:44:50 +0200
commitca41437a880a3c40d22557ed3a29203b06eec993 (patch)
tree042d35c3751e9a28e296256bdd7f83901113c528
parent30c171ab3dc07a0a8423775619631f6ad514f916 (diff)
sw: avoid ~SwIndexReg() assert in SwFEShell::PastePages()
Change-Id: I5337dc8568255a778d29b676a39c99f72c42486b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134693 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit 1b8c42f8b007d690a85676f260b28b44639fc79a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134777 Tested-by: Thorsten Behrens <thorsten.behrens@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/core/frmedt/fecopy.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index b7a12a828b90..a907e0e838a0 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -1133,7 +1133,7 @@ void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1
return;
}
MovePage( GetThisFrame, GetFirstSub );
- SwPaM aCpyPam( *GetCursor()->GetPoint() );
+ ::std::optional<SwPaM> oSourcePam( *GetCursor()->GetPoint() );
OUString sStartingPageDesc = GetPageDesc( GetCurPageDesc()).GetName();
SwPageDesc* pDesc = rToFill.FindPageDescByName( sStartingPageDesc, true );
if( pDesc )
@@ -1145,7 +1145,7 @@ void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1
return;
}
//if the page starts with a table a paragraph has to be inserted before
- SwNode* pTableNode = aCpyPam.GetNode().FindTableNode();
+ SwNode *const pTableNode = oSourcePam->GetNode().FindTableNode();
if(pTableNode)
{
//insert a paragraph
@@ -1155,22 +1155,23 @@ void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1
if(GetDoc()->getIDocumentContentOperations().AppendTextNode( aBefore ))
{
SwPaM aTmp(aBefore);
- aCpyPam = aTmp;
+ *oSourcePam = aTmp;
}
EndUndo(SwUndoId::INSERT);
}
MovePage( GetThisFrame, GetLastSub );
- aCpyPam.SetMark();
- *aCpyPam.GetMark() = *GetCursor()->GetPoint();
+ oSourcePam->SetMark();
+ *oSourcePam->GetMark() = *GetCursor()->GetPoint();
CurrShell aCurr( this );
StartAllAction();
GetDoc()->getIDocumentFieldsAccess().LockExpFields();
- SetSelection(aCpyPam);
+ SetSelection(*oSourcePam);
// copy the text of the selection
SwEditShell::Copy(rToFill);
+ oSourcePam.reset(); // delete it because Undo will remove its node!
if(pTableNode)
{