summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-11-25 13:19:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-11-25 18:21:03 +0100
commitdebe76298a7d8f24870d176d33d453a3b0d3f3de (patch)
tree05aa3e4f83c4d47b8cea9a627534b3a557bc0fc8
parent432e5e6e33c3687cdb67ee0a64d57169a82e641d (diff)
use more SwFormatAnchor::GetAnchorNode method
as a step towards switching away from using SwPosition inside SwFormatAnchor (because SwFormatAnchor wants to do weird stuff with the internals of SwPosition) Change-Id: Ie6d4f45c959f87599d1cd0890ca8a693dd147be1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143294 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/core/access/accmap.cxx14
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx38
-rw-r--r--sw/source/core/doc/docfly.cxx9
-rw-r--r--sw/source/core/doc/doclay.cxx42
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx8
-rw-r--r--sw/source/core/undo/rolbck.cxx2
-rw-r--r--sw/source/core/undo/unattr.cxx10
-rw-r--r--sw/source/core/unocore/unoframe.cxx2
-rw-r--r--sw/source/core/unocore/unotext.cxx8
-rw-r--r--sw/source/ui/frmdlg/frmpage.cxx2
-rw-r--r--sw/source/uibase/utlui/content.cxx4
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx2
12 files changed, 67 insertions, 74 deletions
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index fc9f67016051..2ada9c50b8c0 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -1177,7 +1177,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
continue;
}
const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
- const SwPosition *pPos = rAnchor.GetContentAnchor();
+ const SwNode *pAnchorNode = rAnchor.GetAnchorNode();
if(rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
{
@@ -1189,18 +1189,18 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
continue;
}
- if( !pPos )
+ if( !pAnchorNode )
{
++aIter;
continue;
}
- if( pPos->GetNode().GetTextNode() )
+ if( pAnchorNode->GetTextNode() )
{
- int nIndex = pPos->GetContentIndex();
+ int nIndex = rAnchor.GetContentAnchor()->GetContentIndex();
bool bMarked = false;
if( pCursor != nullptr )
{
- const SwTextNode* pNode = pPos->GetNode().GetTextNode();
+ const SwTextNode* pNode = pAnchorNode->GetTextNode();
SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(pNode->getLayoutFrame(pVSh->GetLayout())));
SwNodeOffset nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
SwNodeOffset nLastNode;
@@ -1249,7 +1249,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
uno::Reference<XAccessible> const xAcc((*aIter).second);
if (xAcc.is())
{
- if (IsSelectFrameAnchoredAtPara(*pPos, *pStart, *pEnd))
+ if (IsSelectFrameAnchoredAtPara(*rAnchor.GetContentAnchor(), *pStart, *pEnd))
{
static_cast < ::accessibility::AccessibleShape* >(xAcc.get())->SetState( AccessibleStateType::SELECTED );
}
@@ -1264,7 +1264,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
uno::Reference<XAccessible> const xAcc((*aIter).second);
if (xAcc.is())
{
- if (IsDestroyFrameAnchoredAtChar(*pPos, *pStart, *pEnd))
+ if (IsDestroyFrameAnchoredAtChar(*rAnchor.GetContentAnchor(), *pStart, *pEnd))
{
static_cast<::accessibility::AccessibleShape*>(xAcc.get())->SetState( AccessibleStateType::SELECTED );
}
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 0416482611d0..94f3baf31907 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -107,14 +107,14 @@ namespace
{
SwFrameFormat const*const pFormat = rFrameFormatTable[n];
SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor();
- SwPosition const*const pAPos = pAnchor->GetContentAnchor();
- if (pAPos &&
+ SwNode const*const pAnchorNode = pAnchor->GetAnchorNode();
+ if (pAnchorNode &&
((RndStdIds::FLY_AS_CHAR == pAnchor->GetAnchorId()) ||
(RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId()) ||
(RndStdIds::FLY_AT_FLY == pAnchor->GetAnchorId()) ||
(RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId())) &&
- nSttNd <= pAPos->GetNodeIndex() &&
- pAPos->GetNodeIndex() < nEndNd )
+ nSttNd <= pAnchorNode->GetIndex() &&
+ pAnchorNode->GetIndex() < nEndNd )
{
const SwFormatContent& rContent = pFormat->GetContent();
SwStartNode* pSNd;
@@ -2286,14 +2286,14 @@ bool DocumentContentOperationsManager::DelFullPara( SwPaM& rPam )
{
SwFrameFormat* pFly = (*m_rDoc.GetSpzFrameFormats())[n];
const SwFormatAnchor* pAnchor = &pFly->GetAnchor();
- SwPosition const*const pAPos = pAnchor->GetContentAnchor();
- if (pAPos &&
+ SwNode const*const pAnchorNode = pAnchor->GetAnchorNode();
+ if (pAnchorNode &&
((RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) ||
(RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
// note: here use <= not < like in
// IsDestroyFrameAnchoredAtChar() because of the increment
// of rPam in the bDoesUndo path above!
- aRg.aStart <= pAPos->GetNode() && pAPos->GetNode() <= aRg.aEnd.GetNode() )
+ aRg.aStart <= *pAnchorNode && *pAnchorNode <= aRg.aEnd.GetNode() )
{
m_rDoc.getIDocumentLayoutAccess().DelLayoutFormat( pFly );
--n;
@@ -3188,7 +3188,7 @@ SwDrawFrameFormat* DocumentContentOperationsManager::InsertDrawObj(
}
else if( pAnchor == nullptr
|| ( bIsAtContent
- && pAnchor->GetContentAnchor() == nullptr ) )
+ && pAnchor->GetAnchorNode() == nullptr ) )
{
// apply anchor format
SwFormatAnchor aAnch( pAnchor != nullptr ? *pAnchor : pFormat->GetAnchor() );
@@ -3217,10 +3217,10 @@ SwDrawFrameFormat* DocumentContentOperationsManager::InsertDrawObj(
{
bool bAnchorAtPageAsFallback = true;
const SwFormatAnchor& rDrawObjAnchorFormat = pFormat->GetAnchor();
- if ( rDrawObjAnchorFormat.GetContentAnchor() != nullptr )
+ if ( rDrawObjAnchorFormat.GetAnchorNode() != nullptr )
{
SwTextNode* pAnchorTextNode =
- rDrawObjAnchorFormat.GetContentAnchor()->GetNode().GetTextNode();
+ rDrawObjAnchorFormat.GetAnchorNode()->GetTextNode();
if ( pAnchorTextNode != nullptr )
{
const sal_Int32 nStt = rDrawObjAnchorFormat.GetContentAnchor()->GetContentIndex();
@@ -3798,11 +3798,11 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
{
SwFrameFormat* pFormat = (*m_rDoc.GetSpzFrameFormats())[n];
SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor();
- SwPosition const*const pAPos = pAnchor->GetContentAnchor();
- if ( !pAPos )
+ SwNode const*const pAnchorNode = pAnchor->GetAnchorNode();
+ if ( !pAnchorNode )
continue;
bool bAdd = false;
- SwNodeOffset nSkipAfter = pAPos->GetNodeIndex();
+ SwNodeOffset nSkipAfter = pAnchorNode->GetIndex();
SwNodeOffset nStart = rRg.aStart.GetIndex();
switch ( pAnchor->GetAnchorId() )
{
@@ -3814,7 +3814,7 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
break;
case RndStdIds::FLY_AT_PARA:
{
- bAdd = IsSelectFrameAnchoredAtPara(*pAPos,
+ bAdd = IsSelectFrameAnchoredAtPara(*pAnchor->GetContentAnchor(),
pCopiedPaM ? *pCopiedPaM->Start() : SwPosition(rRg.aStart),
pCopiedPaM ? *pCopiedPaM->End() : SwPosition(rRg.aEnd),
(flags & SwCopyFlags::IsMoveToFly)
@@ -3824,7 +3824,7 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
break;
case RndStdIds::FLY_AT_CHAR:
{
- bAdd = IsDestroyFrameAnchoredAtChar(*pAPos,
+ bAdd = IsDestroyFrameAnchoredAtChar(*pAnchor->GetContentAnchor(),
pCopiedPaM ? *pCopiedPaM->Start() : SwPosition(rRg.aStart),
pCopiedPaM ? *pCopiedPaM->End() : SwPosition(rRg.aEnd),
(flags & SwCopyFlags::IsMoveToFly)
@@ -3839,14 +3839,14 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
{
if (nStart > nSkipAfter)
continue;
- if (pAPos->GetNode() > rRg.aEnd.GetNode())
+ if (*pAnchorNode > rRg.aEnd.GetNode())
continue;
//frames at the last source node are not always copied:
//- if the node is empty and is the last node of the document or a table cell
// or a text frame then they have to be copied
//- if the content index in this node is > 0 then paragraph and frame bound objects are copied
//- to-character bound objects are copied if their index is <= nEndContentIndex
- if (pAPos->GetNode() < rRg.aEnd.GetNode())
+ if (*pAnchorNode < rRg.aEnd.GetNode())
bAdd = true;
if (!bAdd && !m_rDoc.getIDocumentRedlineAccess().IsRedlineMove()) // fdo#40599: not for redline move
{
@@ -3897,7 +3897,7 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
if ( aIdx.GetNode().IsTextNode() )
{
++nAnchorTextNdNumInRange;
- bAnchorTextNdFound = aAnchor.GetContentAnchor()->GetNode() == aIdx.GetNode();
+ bAnchorTextNdFound = *aAnchor.GetAnchorNode() == aIdx.GetNode();
}
++aIdx;
@@ -3952,7 +3952,7 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
newPos.GetNode().IsTextNode() )
{
// only if pCopiedPaM: care about partially selected start node
- sal_Int32 const nContent = pCopiedPaM && pCopiedPaM->Start()->GetNode() == aAnchor.GetContentAnchor()->GetNode()
+ sal_Int32 const nContent = pCopiedPaM && pCopiedPaM->Start()->GetNode() == *aAnchor.GetAnchorNode()
? newPos.GetContentIndex() - pCopiedPaM->Start()->GetContentIndex()
: newPos.GetContentIndex();
newPos.SetContent(nContent);
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index 685394b0fe19..8a408affd030 100644
--- a/sw/source/core/doc/docfly.cxx
+++ b/sw/source/core/doc/docfly.cxx
@@ -226,8 +226,7 @@ static Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFormatAnchor& rAnch,
case RndStdIds::FLY_AT_CHAR: // LAYER_IMPL
if( rAnch.GetAnchorNode() )
{
- const SwPosition *pPos = rAnch.GetContentAnchor();
- const SwContentNode* pNd = pPos->GetNode().GetContentNode();
+ const SwContentNode* pNd = rAnch.GetAnchorNode()->GetContentNode();
std::pair<Point, bool> const tmp(aRet, false);
const SwFrame* pOld = pNd ? pNd->getLayoutFrame(rDoc.getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, &tmp) : nullptr;
if( pOld )
@@ -305,10 +304,10 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, boo
// The TextAttribut needs to be destroyed which, unfortunately, also
// destroys the format. To avoid that, we disconnect the format from
// the attribute.
- const SwPosition *pPos = rOldAnch.GetContentAnchor();
- SwTextNode *pTextNode = pPos->GetNode().GetTextNode();
+ SwNode *pAnchorNode = rOldAnch.GetAnchorNode();
+ SwTextNode *pTextNode = pAnchorNode->GetTextNode();
OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
- const sal_Int32 nIdx = pPos->GetContentIndex();
+ const sal_Int32 nIdx = rOldAnch.GetContentAnchor()->GetContentIndex();
SwTextAttr * const pHint =
pTextNode->GetTextAttrForCharAt( nIdx, RES_TXTATR_FLYCNT );
OSL_ENSURE( pHint && pHint->Which() == RES_TXTATR_FLYCNT,
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index b357bfed522c..457ff80b517b 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -199,9 +199,9 @@ SwFlyFrameFormat* SwDoc::MakeFlySection_( const SwPosition& rAnchPos,
// content anchor set.
if ( !pAnchor ||
( RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId() &&
- !pAnchor->GetContentAnchor() ) ||
+ !pAnchor->GetAnchorNode() ) ||
( RndStdIds::FLY_AT_PAGE == pAnchor->GetAnchorId() &&
- !pAnchor->GetContentAnchor() &&
+ !pAnchor->GetAnchorNode() &&
pAnchor->GetPageNum() == 0 ) )
{
// set it again, needed for Undo
@@ -460,23 +460,22 @@ SwFlyFrameFormat* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rS
* frames at character - o.k. if the PaM starts at least at the same position
* as the frame
*/
-static bool lcl_TstFlyRange( const SwPaM* pPam, const SwPosition* pFlyPos,
- RndStdIds nAnchorId )
+static bool lcl_TstFlyRange( const SwPaM* pPam, const SwFormatAnchor& rFlyFormatAnchor )
{
bool bOk = false;
const SwPaM* pTmp = pPam;
do {
- const SwNodeOffset nFlyIndex = pFlyPos->GetNodeIndex();
+ const SwNodeOffset nFlyIndex = rFlyFormatAnchor.GetAnchorNode()->GetIndex();
auto [pPaMStart, pPaMEnd] = pTmp->StartEnd(); // SwPosition*
const SwNodeOffset nPamStartIndex = pPaMStart->GetNodeIndex();
const SwNodeOffset nPamEndIndex = pPaMEnd->GetNodeIndex();
- if (RndStdIds::FLY_AT_PARA == nAnchorId)
+ if (RndStdIds::FLY_AT_PARA == rFlyFormatAnchor.GetAnchorId())
bOk = (nPamStartIndex < nFlyIndex && nPamEndIndex > nFlyIndex) ||
(((nPamStartIndex == nFlyIndex) && (pPaMStart->GetContentIndex() == 0)) &&
(nPamEndIndex > nFlyIndex));
else
{
- const sal_Int32 nFlyContentIndex = pFlyPos->GetContentIndex();
+ const sal_Int32 nFlyContentIndex = rFlyFormatAnchor.GetContentAnchor()->GetContentIndex();
const sal_Int32 nPamEndContentIndex = pPaMEnd->GetContentIndex();
bOk = (nPamStartIndex < nFlyIndex &&
(( nPamEndIndex > nFlyIndex )||
@@ -509,17 +508,16 @@ SwPosFlyFrames SwDoc::GetAllFlyFormats( const SwPaM* pCmpRange, bool bDrawAlso,
if( bFlyFormat || bDrawFormat )
{
const SwFormatAnchor& rAnchor = pFly->GetAnchor();
- SwPosition const*const pAPos = rAnchor.GetContentAnchor();
- if (pAPos &&
+ SwNode const*const pAnchorNode = rAnchor.GetAnchorNode();
+ if (pAnchorNode &&
((RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId()) ||
(RndStdIds::FLY_AT_FLY == rAnchor.GetAnchorId()) ||
(RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId()) ||
((RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()) && bAsCharAlso)))
{
- if( pCmpRange &&
- !lcl_TstFlyRange( pCmpRange, pAPos, rAnchor.GetAnchorId() ))
+ if( pCmpRange && !lcl_TstFlyRange( pCmpRange, rAnchor ))
continue; // not a valid FlyFrame
- aRetval.insert(SwPosFlyFrame(pAPos->GetNode(), pFly, aRetval.size()));
+ aRetval.insert(SwPosFlyFrame(*pAnchorNode, pFly, aRetval.size()));
}
}
}
@@ -787,10 +785,9 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable,
const SwFormatAnchor& rAnchor = pNewFormat->GetAnchor();
if ( RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId() )
{
- const SwPosition *pPos = rAnchor.GetContentAnchor();
- SwTextNode *pTextNode = pPos->GetNode().GetTextNode();
+ SwTextNode *pTextNode = rAnchor.GetAnchorNode()->GetTextNode();
OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
- const sal_Int32 nIdx = pPos->GetContentIndex();
+ const sal_Int32 nIdx = rAnchor.GetContentAnchor()->GetContentIndex();
SwTextAttr * const pHint =
pTextNode->GetTextAttrForCharAt(nIdx, RES_TXTATR_FLYCNT);
@@ -1106,10 +1103,9 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable
const SwFormatAnchor& rAnchor = pNewFormat->GetAnchor();
if ( RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId() )
{
- const SwPosition *pPos = rAnchor.GetContentAnchor();
- SwTextNode *pTextNode = pPos->GetNode().GetTextNode();
+ SwTextNode *pTextNode = rAnchor.GetAnchorNode()->GetTextNode();
OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
- const sal_Int32 nIdx = pPos->GetContentIndex();
+ const sal_Int32 nIdx = rAnchor.GetContentAnchor()->GetContentIndex();
SwTextAttr * const pHint =
pTextNode->GetTextAttrForCharAt( nIdx, RES_TXTATR_FLYCNT );
@@ -1519,7 +1515,7 @@ void SwDoc::SetAllUniqueFlyNames()
{
const SwFormatAnchor& rAnchor = pFlyFormat->GetAnchor();
if ( (RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId()) &&
- rAnchor.GetContentAnchor() )
+ rAnchor.GetAnchorNode() )
{
bContainsAtPageObjWithContentAnchor = true;
}
@@ -1604,12 +1600,12 @@ bool SwDoc::IsInHeaderFooter( const SwNode& rIdx ) const
#endif
const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
if ((RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId()) ||
- !rAnchor.GetContentAnchor() )
+ !rAnchor.GetAnchorNode() )
{
return false;
}
- pNd = &rAnchor.GetContentAnchor()->GetNode();
+ pNd = rAnchor.GetAnchorNode();
pFlyNd = pNd->FindFlyStartNode();
bFound = true;
break;
@@ -1653,9 +1649,9 @@ SvxFrameDirection SwDoc::GetTextDirection( const SwPosition& rPos,
pItem = nullptr;
const SwFormatAnchor* pAnchor = &pFlyFormat->GetAnchor();
if ((RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId()) &&
- pAnchor->GetContentAnchor())
+ pAnchor->GetAnchorNode())
{
- pFlyFormat = pAnchor->GetContentAnchor()->GetNode().GetFlyFormat();
+ pFlyFormat = pAnchor->GetAnchorNode()->GetFlyFormat();
}
else
pFlyFormat = nullptr;
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index cb15076c492a..d78aacc898d2 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1533,12 +1533,12 @@ void SwTextNode::Update(
{
SwFrameFormat const*const pFormat = rFlys[i];
const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
- const SwPosition* pContentAnchor = rAnchor.GetContentAnchor();
- if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR && pContentAnchor)
+ const SwNode* pAnchorNode = rAnchor.GetAnchorNode();
+ if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR && pAnchorNode)
{
// The fly is at-char anchored and has an anchor position.
- SwContentIndex& rEndIdx = const_cast<SwContentIndex&>(pContentAnchor->nContent);
- if (pContentAnchor->GetNode() == *this && rEndIdx.GetIndex() == rPos.GetIndex())
+ SwContentIndex& rEndIdx = const_cast<SwContentIndex&>(rAnchor.GetContentAnchor()->nContent);
+ if (*pAnchorNode == *this && rEndIdx.GetIndex() == rPos.GetIndex())
{
// The anchor position is exactly our insert position.
rEndIdx.Assign(&aTmpIdxReg, rEndIdx.GetIndex());
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 6413ce4329d8..553a06213852 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -925,7 +925,7 @@ void SwHistorySetAttrSet::SetInDoc( SwDoc* pDoc, bool )
SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( SwFrameFormat& rFormat )
: SwHistoryHint( HSTRY_CHGFLYANCHOR )
, m_rFormat( rFormat )
- , m_nOldNodeIndex( rFormat.GetAnchor().GetContentAnchor()->GetNodeIndex() )
+ , m_nOldNodeIndex( rFormat.GetAnchor().GetAnchorNode()->GetIndex() )
, m_nOldContentIndex( (RndStdIds::FLY_AT_CHAR == rFormat.GetAnchor().GetAnchorId())
? rFormat.GetAnchor().GetContentAnchor()->GetContentIndex()
: COMPLETE_STRING )
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 50d5eb72c68a..6659b35339f5 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -444,10 +444,9 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
// Unfortunately, this not only destroys the Frames but also the format.
// To prevent that, first detach the connection between attribute and
// format.
- const SwPosition *pPos = rOldAnch.GetContentAnchor();
- SwTextNode *pTextNode = static_cast<SwTextNode*>(&pPos->GetNode());
+ SwTextNode *pTextNode = static_cast<SwTextNode*>(rOldAnch.GetAnchorNode());
OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
- const sal_Int32 nIdx = pPos->GetContentIndex();
+ const sal_Int32 nIdx = rOldAnch.GetContentAnchor()->GetContentIndex();
SwTextAttr * const pHint =
pTextNode->GetTextAttrForCharAt( nIdx, RES_TXTATR_FLYCNT );
assert(pHint && "Missing Hint.");
@@ -488,11 +487,10 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
}
if (RndStdIds::FLY_AS_CHAR == aNewAnchor.GetAnchorId()) {
- const SwPosition* pPos = aNewAnchor.GetContentAnchor();
- SwTextNode* pTextNd = pPos->GetNode().GetTextNode();
+ SwTextNode* pTextNd = aNewAnchor.GetAnchorNode()->GetTextNode();
OSL_ENSURE( pTextNd, "no Text Node at position." );
SwFormatFlyCnt aFormat( pFrameFormat );
- pTextNd->InsertItem( aFormat, pPos->GetContentIndex(), 0 );
+ pTextNd->InsertItem( aFormat, aNewAnchor.GetContentAnchor()->GetContentIndex(), 0 );
}
if (RES_DRAWFRMFMT != pFrameFormat->Which())
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index b8aef77bbab8..e7e03326c0a3 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -2699,7 +2699,7 @@ uno::Reference< text::XTextRange > SwXFrame::getAnchor()
// return an anchor for non-page bound frames
// and for page bound frames that have a page no == NULL and a content position
if ((rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PAGE) ||
- (rAnchor.GetContentAnchor() && !rAnchor.GetPageNum()))
+ (rAnchor.GetAnchorNode() && !rAnchor.GetPageNum()))
{
const SwPosition &rPos = *(rAnchor.GetContentAnchor());
if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA)
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index bdaf1d0357e3..2f16de793d35 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1718,8 +1718,8 @@ SwXText::convertToTextFrame(
// added nodes
if (!isGraphicNode(pFrameFormat)
&& ( (RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId()
- && ( oAnchorCheckPam->Start()->GetNode() == rAnchor.GetContentAnchor()->GetNode()
- || oAnchorCheckPam->End()->GetNode() == rAnchor.GetContentAnchor()->GetNode()))
+ && ( oAnchorCheckPam->Start()->GetNode() == *rAnchor.GetAnchorNode()
+ || oAnchorCheckPam->End()->GetNode() == *rAnchor.GetAnchorNode()))
|| (RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId()
&& ( *oAnchorCheckPam->Start() == *rAnchor.GetContentAnchor()
|| *oAnchorCheckPam->End() == *rAnchor.GetContentAnchor()))))
@@ -1794,8 +1794,8 @@ SwXText::convertToTextFrame(
&& rShapeAnchor.GetContentAnchor() && pFrameFormat->GetAnchor().GetContentAnchor()
&& pStartPam->ContainsPosition(*pFrameFormat->GetAnchor().GetContentAnchor()))
{
- const auto& rAnchorNode
- = pFrameFormat->GetAnchor().GetContentAnchor()->GetNode();
+ const SwNode& rAnchorNode
+ = *pFrameFormat->GetAnchor().GetAnchorNode();
if (!(rAnchorNode.FindFooterStartNode() || rAnchorNode.FindHeaderStartNode()))
{
SwFormatAnchor aAnchor(pFrameFormat->GetAnchor());
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 5e86c11d6c90..f1c20e73fa0b 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -971,7 +971,7 @@ void SwFramePage::Reset( const SfxItemSet *rSet )
// i#22341 - determine content position of character
// Note: content position can be NULL
- mpToCharContentPos = rAnchor.GetContentAnchor() ? &rAnchor : nullptr;
+ mpToCharContentPos = rAnchor.GetAnchorNode() ? &rAnchor : nullptr;
// i#18732 - init checkbox value
{
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index f150bda3db77..2bb852f5b617 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -298,9 +298,9 @@ sal_Int32 getYPos(const SwNode& rNode)
if (const auto pFlyFormat = rNode.GetFlyFormat())
{
// Get node index of anchor
- if (auto pSwPosition = pFlyFormat->GetAnchor().GetContentAnchor())
+ if (SwNode* pAnchorNode = pFlyFormat->GetAnchor().GetAnchorNode())
{
- return getYPos(pSwPosition->GetNode());
+ return getYPos(*pAnchorNode);
}
}
}
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 095c6d5a9d95..b2b8ce6d10a9 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -2261,7 +2261,7 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, const SfxRequest& rReq)
if (pFormat)
{
RndStdIds eAnchorId = pFormat->GetAnchor().GetAnchorId();
- if ((eAnchorId == RndStdIds::FLY_AS_CHAR || eAnchorId == RndStdIds::FLY_AT_CHAR) && pFormat->GetAnchor().GetContentAnchor())
+ if ((eAnchorId == RndStdIds::FLY_AS_CHAR || eAnchorId == RndStdIds::FLY_AT_CHAR) && pFormat->GetAnchor().GetAnchorNode())
{
oAnchor.emplace(*pFormat->GetAnchor().GetContentAnchor());
}