summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-09-01 09:35:55 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-01 11:31:33 +0200
commita1ea7bee33ed53ecdc1a68acf554680e5c88804f (patch)
tree211f6faa27609dd64669d78884eace9a1403b3ad
parent24d382a18ec2ade0d9e9b9c6e6c3e86bed6cde14 (diff)
use more SwPosition::Assign
part of hiding the internals of SwPosition Change-Id: Id4d02e2b5c156ff7a93ce5d2d974c4594052bac3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139145 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/core/txtnode/atrflyin.cxx25
1 files changed, 7 insertions, 18 deletions
diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx
index e46487004633..8216c96805c4 100644
--- a/sw/source/core/txtnode/atrflyin.cxx
+++ b/sw/source/core/txtnode/atrflyin.cxx
@@ -110,17 +110,7 @@ void SwTextFlyCnt::CopyFlyFormat( SwDoc& rDoc )
if( !pCNd )
pCNd = rDoc.GetNodes().GoNext( &aIdx );
- SwPosition pos = *aAnchor.GetContentAnchor();
- pos.nNode = aIdx;
- if (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId())
- {
- pos.nContent.Assign( pCNd, 0 );
- }
- else
- {
- pos.nContent.Assign( nullptr, 0 );
- assert(false);
- }
+ SwPosition pos(aIdx.GetNode());
aAnchor.SetAnchor( &pos );
}
@@ -139,26 +129,25 @@ void SwTextFlyCnt::SetAnchor( const SwTextNode *pNode )
SwDoc& rDoc = const_cast<SwDoc&>(pNode->GetDoc());
- SwContentIndex aIdx( pNode, GetStart() );
- SwPosition aPos( *pNode->StartOfSectionNode(), aIdx );
SwFrameFormat* pFormat = GetFlyCnt().GetFrameFormat();
SwFormatAnchor aAnchor( pFormat->GetAnchor() );
SwNode *const pOldNode(aAnchor.GetContentAnchor()
? &aAnchor.GetContentAnchor()->GetNode()
: nullptr);
+ std::optional<SwPosition> oPos;
if (!pOldNode || !pOldNode->GetNodes().IsDocNodes() ||
pOldNode != static_cast<SwNode const *>(pNode))
{
- aPos.nNode = *pNode;
+ oPos.emplace( *pNode, GetStart() );
}
else
{
- aPos.nNode = *pOldNode;
+ oPos.emplace( *pOldNode, pOldNode->GetContentNode(), GetStart() );
}
aAnchor.SetType( RndStdIds::FLY_AS_CHAR ); // default!
- aAnchor.SetAnchor( &aPos );
+ aAnchor.SetAnchor( &*oPos );
// in case of anchor change, delete all FlyFrames
// JP 25.04.95: if the Frames can be moved within SplitNode, they don't
@@ -188,7 +177,7 @@ void SwTextFlyCnt::SetAnchor( const SwTextNode *pNode )
// tdf#91228 must notify the anchor nodes despite LockModify
assert(pOldNode);
pOldNode->RemoveAnchoredFly(pFormat);
- aPos.GetNode().AddAnchoredFly(pFormat);
+ oPos->GetNode().AddAnchoredFly(pFormat);
pFormat->UnlockModify();
}
else
@@ -229,7 +218,7 @@ void SwTextFlyCnt::SetAnchor( const SwTextNode *pNode )
if (bIsInSplitNode)
{
pOldNode->RemoveAnchoredFly(pTextBox);
- aPos.GetNode().AddAnchoredFly(pTextBox);
+ oPos->GetNode().AddAnchoredFly(pTextBox);
pTextBox->UnlockModify();
}
else