sw/source/core/layout/sortedobjs.cxx |   12 ++++++------
 sw/source/core/text/txtfrm.cxx       |    4 ++--
 sw/source/core/txtnode/thints.cxx    |    6 +++---
 sw/source/core/undo/rolbck.cxx       |    2 +-
 sw/source/core/undo/unattr.cxx       |    6 +++---
 sw/source/core/undo/undobj1.cxx      |   32 ++++++++++++++++----------------
 sw/source/core/undo/undraw.cxx       |    4 ++--
 7 files changed, 33 insertions(+), 33 deletions(-)

New commits:
commit ff41bc546edb4f28ac0852fc8a95fe5dbde40a10
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Nov 28 13:58:43 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Nov 28 21:01:51 2022 +0100

    use more GetAnchorContentOffset
    
    Change-Id: Iacc88f4057d2ece698d76a9ebaaf7de276ab0450
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143382
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/layout/sortedobjs.cxx 
b/sw/source/core/layout/sortedobjs.cxx
index f94ad4467396..da388bd3cbc9 100644
--- a/sw/source/core/layout/sortedobjs.cxx
+++ b/sw/source/core/layout/sortedobjs.cxx
@@ -122,12 +122,12 @@ struct ObjAnchorOrder
 
         // Both objects aren't anchor to page or to fly
         // Thus, compare content anchor nodes, if existing.
-        const SwPosition* pContentAnchorListed = 
pAnchorListed->GetContentAnchor();
-        const SwPosition* pContentAnchorNew = pAnchorNew->GetContentAnchor();
+        const SwNode* pContentAnchorListed = pAnchorListed->GetAnchorNode();
+        const SwNode* pContentAnchorNew = pAnchorNew->GetAnchorNode();
         if ( pContentAnchorListed && pContentAnchorNew &&
-             pContentAnchorListed->GetNode() != pContentAnchorNew->GetNode() )
+             *pContentAnchorListed != *pContentAnchorNew )
         {
-            return pContentAnchorListed->GetNode() < 
pContentAnchorNew->GetNode();
+            return *pContentAnchorListed < *pContentAnchorNew;
         }
 
         // objects anchored at the same content.
@@ -137,9 +137,9 @@ struct ObjAnchorOrder
         if (pContentAnchorListed && pContentAnchorNew)
         {
             sal_Int32 nListedIndex = pAnchorListed->GetAnchorId() != 
RndStdIds::FLY_AT_PARA ?
-                pContentAnchorListed->GetContentIndex() : 0;
+                pAnchorListed->GetAnchorContentOffset() : 0;
             sal_Int32 nNewIndex = pAnchorNew->GetAnchorId() != 
RndStdIds::FLY_AT_PARA ?
-                pContentAnchorNew->GetContentIndex() : 0;
+                pAnchorNew->GetAnchorContentOffset() : 0;
             if (nListedIndex != nNewIndex)
             {
                 return nListedIndex < nNewIndex;
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 8db5779293d3..86cfe6555431 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -1501,7 +1501,7 @@ bool sw_HideObj( const SwTextFrame& _rFrame,
         {
             SwTextNode const& 
rNode(*rFormatAnchor.GetAnchorNode()->GetTextNode());
             assert(FrameContainsNode(_rFrame, rNode.GetIndex()));
-            sal_Int32 const 
nObjAnchorPos(rFormatAnchor.GetContentAnchor()->GetContentIndex());
+            sal_Int32 const 
nObjAnchorPos(rFormatAnchor.GetAnchorContentOffset());
             const sal_Unicode cAnchorChar = nObjAnchorPos < rNode.Len()
                 ? rNode.GetText()[nObjAnchorPos]
                 : 0;
@@ -1597,7 +1597,7 @@ void SwTextFrame::HideAndShowObjects()
                     const SwFormatAnchor& rAnchorFormat = 
pContact->GetAnchorFormat();
                     SwScriptInfo::GetBoundsOfHiddenRange(
                         *rAnchorFormat.GetAnchorNode()->GetTextNode(),
-                        rAnchorFormat.GetContentAnchor()->GetContentIndex(), 
nHiddenStart, nHiddenEnd);
+                        rAnchorFormat.GetAnchorContentOffset(), nHiddenStart, 
nHiddenEnd);
                     // Under certain conditions
                     if ( nHiddenStart != COMPLETE_STRING && bShouldBeHidden &&
                         sw_HideObj(*this, eAnchorType, rAnchorFormat, i))
diff --git a/sw/source/core/txtnode/thints.cxx 
b/sw/source/core/txtnode/thints.cxx
index 08bf8e87c6b3..59a931a406de 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1388,9 +1388,9 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, 
const SetAttrMode nMode )
 
                     if (pAnchor &&
                         (RndStdIds::FLY_AS_CHAR == pAnchor->GetAnchorId()) &&
-                        pAnchor->GetContentAnchor() &&
-                        pAnchor->GetContentAnchor()->GetNode() == *this &&
-                        pAnchor->GetContentAnchor()->GetContentIndex() == 
aIdx.GetIndex() )
+                        pAnchor->GetAnchorNode() &&
+                        *pAnchor->GetAnchorNode() == *this &&
+                        pAnchor->GetAnchorContentOffset() == aIdx.GetIndex() )
                     {
                         
const_cast<SwPosition*>(pAnchor->GetContentAnchor())->AdjustContent(-1);
                     }
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 553a06213852..7501f204824e 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -927,7 +927,7 @@ SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( 
SwFrameFormat& rFormat )
     , m_rFormat( rFormat )
     , m_nOldNodeIndex( rFormat.GetAnchor().GetAnchorNode()->GetIndex() )
     , m_nOldContentIndex( (RndStdIds::FLY_AT_CHAR == 
rFormat.GetAnchor().GetAnchorId())
-            ?   rFormat.GetAnchor().GetContentAnchor()->GetContentIndex()
+            ?   rFormat.GetAnchor().GetAnchorContentOffset()
             :   COMPLETE_STRING )
 {
 }
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 6659b35339f5..19929658e342 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -368,7 +368,7 @@ void SwUndoFormatAttr::SaveFlyAnchor( const SwFormat * 
pFormat, bool bSvDrwPt )
     switch( rAnchor.GetAnchorId() ) {
     case RndStdIds::FLY_AS_CHAR:
     case RndStdIds::FLY_AT_CHAR:
-        nContent = rAnchor.GetContentAnchor()->GetContentIndex();
+        nContent = rAnchor.GetAnchorContentOffset();
         [[fallthrough]];
     case RndStdIds::FLY_AT_PARA:
     case RndStdIds::FLY_AT_FLY:
@@ -446,7 +446,7 @@ bool 
SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
         // format.
         SwTextNode *pTextNode = 
static_cast<SwTextNode*>(rOldAnch.GetAnchorNode());
         OSL_ENSURE( pTextNode->HasHints(), "Missing FlyInCnt-Hint." );
-        const sal_Int32 nIdx = rOldAnch.GetContentAnchor()->GetContentIndex();
+        const sal_Int32 nIdx = rOldAnch.GetAnchorContentOffset();
         SwTextAttr * const pHint =
             pTextNode->GetTextAttrForCharAt( nIdx, RES_TXTATR_FLYCNT );
         assert(pHint && "Missing Hint.");
@@ -490,7 +490,7 @@ bool 
SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
         SwTextNode* pTextNd = aNewAnchor.GetAnchorNode()->GetTextNode();
         OSL_ENSURE( pTextNd, "no Text Node at position." );
         SwFormatFlyCnt aFormat( pFrameFormat );
-        pTextNd->InsertItem( aFormat, 
aNewAnchor.GetContentAnchor()->GetContentIndex(), 0 );
+        pTextNd->InsertItem( aFormat, aNewAnchor.GetAnchorContentOffset(), 0 );
     }
 
     if (RES_DRAWFRMFMT != pFrameFormat->Which())
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 2b3e638f8b01..232af5876c5d 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -191,8 +191,8 @@ void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & 
rContext, bool bShowSelFrame)
     case RndStdIds::FLY_AT_CHAR:
         {
             const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
-            m_nNodePagePos = rAnchor.GetContentAnchor()->GetNodeIndex();
-            m_nContentPos = rAnchor.GetContentAnchor()->GetContentIndex();
+            m_nNodePagePos = rAnchor.GetAnchorNode()->GetIndex();
+            m_nContentPos = rAnchor.GetAnchorContentOffset();
         }
         break;
     case RndStdIds::FLY_AT_PARA:
@@ -236,14 +236,14 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc )
         
m_pFrameFormat->CallSwClientNotify(sw::DrawFrameFormatHint(sw::DrawFrameFormatHintId::PREP_DELETE_FLY));
 
     const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor();
-    const SwPosition* pPos = rAnchor.GetContentAnchor();
+    SwNode* pAnchorNode = rAnchor.GetAnchorNode();
     // The positions in Nodes array got shifted.
     m_nRndId = rAnchor.GetAnchorId();
     if (RndStdIds::FLY_AS_CHAR == m_nRndId)
     {
-        m_nNodePagePos = pPos->GetNodeIndex();
-        m_nContentPos = pPos->GetContentIndex();
-        SwTextNode *const pTextNd = pPos->GetNode().GetTextNode();
+        m_nNodePagePos = pAnchorNode->GetIndex();
+        m_nContentPos = rAnchor.GetAnchorContentOffset();
+        SwTextNode *const pTextNd = pAnchorNode->GetTextNode();
         OSL_ENSURE( pTextNd, "No Textnode found" );
         SwTextFlyCnt* const pAttr = static_cast<SwTextFlyCnt*>(
             pTextNd->GetTextAttrForCharAt( m_nContentPos, RES_TXTATR_FLYCNT ) 
);
@@ -252,17 +252,17 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc )
         {
             // Pointer to 0, do not delete
             const_cast<SwFormatFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFormat();
-            pTextNd->EraseText( *pPos, 1 );
+            pTextNd->EraseText( *rAnchor.GetContentAnchor(), 1 );
         }
     }
     else if (RndStdIds::FLY_AT_CHAR == m_nRndId)
     {
-        m_nNodePagePos = pPos->GetNodeIndex();
-        m_nContentPos = pPos->GetContentIndex();
+        m_nNodePagePos = pAnchorNode->GetIndex();
+        m_nContentPos = rAnchor.GetAnchorContentOffset();
     }
     else if ((RndStdIds::FLY_AT_PARA == m_nRndId) || (RndStdIds::FLY_AT_FLY == 
m_nRndId))
     {
-        m_nNodePagePos = pPos->GetNodeIndex();
+        m_nNodePagePos = pAnchorNode->GetIndex();
     }
     else
     {
@@ -587,10 +587,10 @@ void SwUndoSetFlyFormat::UndoImpl(::sw::UndoRedoContext & 
rContext)
             // deleted. 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 = 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.GetAnchorContentOffset();
             SwTextAttr * pHint = pTextNode->GetTextAttrForCharAt(
                     nIdx, RES_TXTATR_FLYCNT );
             assert(pHint && "Missing Hint.");
@@ -664,11 +664,11 @@ void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, 
const SfxPoolItem* pItem )
             {
             case RndStdIds::FLY_AS_CHAR:
             case RndStdIds::FLY_AT_CHAR:
-                m_nOldContent = pAnchor->GetContentAnchor()->GetContentIndex();
+                m_nOldContent = pAnchor->GetAnchorContentOffset();
                 [[fallthrough]];
             case RndStdIds::FLY_AT_PARA:
             case RndStdIds::FLY_AT_FLY:
-                m_nOldNode = pAnchor->GetContentAnchor()->GetNodeIndex();
+                m_nOldNode = pAnchor->GetAnchorNode()->GetIndex();
                 break;
 
             default:
@@ -681,7 +681,7 @@ void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, const 
SfxPoolItem* pItem )
             {
             case RndStdIds::FLY_AS_CHAR:
             case RndStdIds::FLY_AT_CHAR:
-                m_nNewContent = pAnchor->GetContentAnchor()->GetContentIndex();
+                m_nNewContent = pAnchor->GetAnchorContentOffset();
                 [[fallthrough]];
             case RndStdIds::FLY_AT_PARA:
             case RndStdIds::FLY_AT_FLY:
diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx
index d162cb94cea9..cfdae61e84ab 100644
--- a/sw/source/core/undo/undraw.cxx
+++ b/sw/source/core/undo/undraw.cxx
@@ -110,7 +110,7 @@ static void lcl_SaveAnchor( SwFrameFormat* pFormat, 
SwNodeOffset& rNodePos )
 
     if (RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId())
     {
-        nContentPos = rAnchor.GetContentAnchor()->GetContentIndex();
+        nContentPos = rAnchor.GetAnchorContentOffset();
 
         // destroy TextAttribute
         SwTextNode *pTextNd = pFormat->GetDoc()->GetNodes()[ rNodePos 
]->GetTextNode();
@@ -128,7 +128,7 @@ static void lcl_SaveAnchor( SwFrameFormat* pFormat, 
SwNodeOffset& rNodePos )
     }
     else if (RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId())
     {
-        nContentPos = rAnchor.GetContentAnchor()->GetContentIndex();
+        nContentPos = rAnchor.GetAnchorContentOffset();
     }
 
     pFormat->SetFormatAttr( SwFormatAnchor( rAnchor.GetAnchorId(), nContentPos 
) );

Reply via email to