sw/source/core/doc/doclay.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
New commits: commit a46ccc36d430607f667c0672f72e9aa117a74990 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Oct 9 12:15:39 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Oct 9 13:48:28 2022 +0200 avoid accessing nContent field of SwPosition part of the process of hiding the internals of SwPosition Change-Id: I04917cb80887e82b873f5e778fd9f54f0615b38d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141139 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index e1ade4a118ec..e83e6173b4d1 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -360,7 +360,7 @@ SwFlyFrameFormat* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rS // Attention: Do not create an index on the stack, or we // cannot delete ContentNode in the end! - SwPosition aPos( aIndex ); + std::optional<SwPosition> oPos( std::in_place, aIndex ); if( pSelBoxes && !pSelBoxes->empty() ) { @@ -389,11 +389,11 @@ SwFlyFrameFormat* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rS GetNodes().MakeTextNode( aRg.aStart.GetNode(), GetDfltTextFormatColl() ); - getIDocumentContentOperations().MoveNodeRange( aRg, aPos.GetNode(), SwMoveFlags::DEFAULT ); + getIDocumentContentOperations().MoveNodeRange( aRg, oPos->GetNode(), SwMoveFlags::DEFAULT ); } else { - rTable.MakeCopy(*this, aPos, *pSelBoxes); + rTable.MakeCopy(*this, *oPos, *pSelBoxes); // Don't delete a part of a table with row span!! // You could delete the content instead -> ToDo //rTable.DeleteSel( this, *pSelBoxes, 0, 0, true, true ); @@ -403,7 +403,7 @@ SwFlyFrameFormat* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rS aIndex = rContent.GetContentIdx()->GetNode().EndOfSectionIndex() - 1; OSL_ENSURE( aIndex.GetNode().GetTextNode(), "a TextNode should be here" ); - aPos.nContent.Assign( nullptr, 0 ); // Deregister index! + oPos.reset(); // Deregister index! GetNodes().Delete( aIndex ); // This is a hack: whilst FlyFrames/Headers/Footers are not undoable we delete all Undo objects @@ -427,7 +427,7 @@ SwFlyFrameFormat* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rS *rTmp.GetPoint() != *rTmp.GetMark() ) { // aPos is the newly created fly section, so definitely outside rPam, it's pointless to check that again. - getIDocumentContentOperations().CopyRange(*const_cast<SwPaM*>(&rTmp), aPos, SwCopyFlags::IsMoveToFly); + getIDocumentContentOperations().CopyRange(*const_cast<SwPaM*>(&rTmp), *oPos, SwCopyFlags::IsMoveToFly); } } getIDocumentRedlineAccess().SetRedlineMove(bOldRedlineMove);