sw/qa/core/txtnode/txtnode.cxx | 13 ++-- sw/qa/extras/rtfexport/rtfexport4.cxx | 10 +-- sw/qa/extras/uiwriter/uiwriter2.cxx | 18 +++--- sw/source/core/doc/DocumentLayoutManager.cxx | 13 ++-- sw/source/core/doc/docfly.cxx | 10 +-- sw/source/core/frmedt/feshview.cxx | 2 sw/source/core/layout/atrfrm.cxx | 74 +++++++++++++-------------- sw/source/core/layout/frmtool.cxx | 12 ++-- 8 files changed, 74 insertions(+), 78 deletions(-)
New commits: commit 2be29ee28d06110961775fe05253a949611deed6 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Nov 28 14:51:21 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Nov 29 06:00:30 2022 +0100 use more SwFormatAnchor::GetAnchorContentOffset Change-Id: I44406ddeb765088d86c0484f7097b80f362fd4a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143394 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx index 3712850dccee..55413b4e4711 100644 --- a/sw/qa/core/txtnode/txtnode.cxx +++ b/sw/qa/core/txtnode/txtnode.cxx @@ -176,7 +176,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testFlyAnchorUndo) SwDocShell* pShell = pTextDoc->GetDocShell(); SwDoc* pDoc = pShell->GetDoc(); const SwFrameFormats& rSpz = *pDoc->GetSpzFrameFormats(); - sal_Int32 nExpected = rSpz[0]->GetAnchor().GetContentAnchor()->GetContentIndex(); + sal_Int32 nExpected = rSpz[0]->GetAnchor().GetAnchorContentOffset(); // When deleting that last character and undoing it: SwWrtShell* pWrtShell = pShell->GetWrtShell(); @@ -185,7 +185,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testFlyAnchorUndo) pWrtShell->Undo(); // Then make sure the anchor position after the undo is the same as the original: - sal_Int32 nActual = rSpz[0]->GetAnchor().GetContentAnchor()->GetContentIndex(); + sal_Int32 nActual = rSpz[0]->GetAnchor().GetAnchorContentOffset(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 3 // - Actual : 2 @@ -289,10 +289,11 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testPictureContentControlKeyboard) // When checking if enter should trigger the file picker: const SwFrameFormat* pFlyFormat = pWrtShell->GetFlyFrameFormat(); const SwFormatAnchor& rFormatAnchor = pFlyFormat->GetAnchor(); - const SwPosition* pAnchorPos = rFormatAnchor.GetContentAnchor(); - SwTextNode* pTextNode = pAnchorPos->GetNode().GetTextNode(); - SwTextAttr* pAttr = pTextNode->GetTextAttrAt( - pAnchorPos->GetContentIndex(), RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Parent); + SwNode* pAnchorNode = rFormatAnchor.GetAnchorNode(); + SwTextNode* pTextNode = pAnchorNode->GetTextNode(); + SwTextAttr* pAttr + = pTextNode->GetTextAttrAt(rFormatAnchor.GetAnchorContentOffset(), + RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Parent); auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr); auto& rFormatContentControl = static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr()); diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx index 608d4d094d85..c55c74a4f6b3 100644 --- a/sw/qa/extras/rtfexport/rtfexport4.cxx +++ b/sw/qa/extras/rtfexport/rtfexport4.cxx @@ -255,13 +255,11 @@ DECLARE_RTFEXPORT_TEST(testAnchoredAtSamePosition, "anchor.fodt") sal_Int32 const nIndex(isExported() ? 4 : 3); CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_CHAR, rFlys[0]->GetAnchor().GetAnchorId()); - CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12), - rFlys[0]->GetAnchor().GetContentAnchor()->GetNodeIndex()); - CPPUNIT_ASSERT_EQUAL(nIndex, rFlys[0]->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12), rFlys[0]->GetAnchor().GetAnchorNode()->GetIndex()); + CPPUNIT_ASSERT_EQUAL(nIndex, rFlys[0]->GetAnchor().GetAnchorContentOffset()); CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_CHAR, rFlys[1]->GetAnchor().GetAnchorId()); - CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12), - rFlys[1]->GetAnchor().GetContentAnchor()->GetNodeIndex()); - CPPUNIT_ASSERT_EQUAL(nIndex, rFlys[1]->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(SwNodeOffset(12), rFlys[1]->GetAnchor().GetAnchorNode()->GetIndex()); + CPPUNIT_ASSERT_EQUAL(nIndex, rFlys[1]->GetAnchor().GetAnchorContentOffset()); } DECLARE_RTFEXPORT_TEST(testRedlineInsdel, "redline-insdel.rtf") diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 36d191d43730..0959e88efcee 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1144,7 +1144,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf135976) CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLastPage()->GetSortedObjs()->size()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pFly->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pFly->GetAnchor().GetAnchorContentOffset()); pWrtShell->UnSelectFrame(); pWrtShell->SttEndDoc(/*bStart=*/false); @@ -1157,26 +1157,26 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf135976) // the problem was that the fly was deleted from the layout CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLastPage()->GetSortedObjs()->size()); // check that the anchor was moved outside the redline - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), pFly->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), pFly->GetAnchor().GetAnchorContentOffset()); pWrtShell->Undo(2); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLastPage()->GetSortedObjs()->size()); // check that the anchor was restored - CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pFly->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pFly->GetAnchor().GetAnchorContentOffset()); pWrtShell->Redo(2); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLastPage()->GetSortedObjs()->size()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), pFly->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), pFly->GetAnchor().GetAnchorContentOffset()); pWrtShell->Undo(2); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLastPage()->GetSortedObjs()->size()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pFly->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pFly->GetAnchor().GetAnchorContentOffset()); // now again in the other direction: @@ -1189,25 +1189,25 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf135976) CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); // the problem was that the fly was deleted from the layout CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLastPage()->GetSortedObjs()->size()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), pFly->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), pFly->GetAnchor().GetAnchorContentOffset()); pWrtShell->Undo(2); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLastPage()->GetSortedObjs()->size()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pFly->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pFly->GetAnchor().GetAnchorContentOffset()); pWrtShell->Redo(2); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLastPage()->GetSortedObjs()->size()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), pFly->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), pFly->GetAnchor().GetAnchorContentOffset()); pWrtShell->Undo(2); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetLayout()->GetLastPage()->GetSortedObjs()->size()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pFly->GetAnchor().GetContentAnchor()->GetContentIndex()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pFly->GetAnchor().GetAnchorContentOffset()); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf39721) diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index 79f8ee1f51f8..e0366bdd3a0b 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -289,20 +289,19 @@ void DocumentLayoutManager::DelLayoutFormat( SwFrameFormat *pFormat ) const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); if ((RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()) && rAnchor.GetAnchorNode()) { - const SwPosition* pPos = rAnchor.GetContentAnchor(); - SwTextNode *pTextNd = pPos->GetNode().GetTextNode(); + SwTextNode *pTextNd = rAnchor.GetAnchorNode()->GetTextNode(); // attribute is still in text node, delete it if ( pTextNd ) { SwTextFlyCnt* const pAttr = static_cast<SwTextFlyCnt*>( - pTextNd->GetTextAttrForCharAt( pPos->GetContentIndex(), + pTextNd->GetTextAttrForCharAt( rAnchor.GetAnchorContentOffset(), RES_TXTATR_FLYCNT )); if ( pAttr && (pAttr->GetFlyCnt().GetFrameFormat() == pFormat) ) { // don't delete, set pointer to 0 const_cast<SwFormatFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFormat(); - pTextNd->EraseText( *pPos, 1 ); + pTextNd->EraseText( *rAnchor.GetContentAnchor(), 1 ); } } } @@ -453,10 +452,10 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat( if (bSetTextFlyAtt && (RndStdIds::FLY_AS_CHAR == rNewAnchor.GetAnchorId())) { - const SwPosition* pPos = rNewAnchor.GetContentAnchor(); + SwNode* pAnchorNode = rNewAnchor.GetAnchorNode(); SwFormatFlyCnt aFormat( pDest ); - pPos->GetNode().GetTextNode()->InsertItem( - aFormat, pPos->GetContentIndex(), 0 ); + pAnchorNode->GetTextNode()->InsertItem( + aFormat, rNewAnchor.GetAnchorContentOffset(), 0 ); } if( bMakeFrames ) diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 8a408affd030..7bf5c31681ac 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -307,7 +307,7 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, boo SwNode *pAnchorNode = rOldAnch.GetAnchorNode(); SwTextNode *pTextNode = pAnchorNode->GetTextNode(); 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 ); OSL_ENSURE( pHint && pHint->Which() == RES_TXTATR_FLYCNT, @@ -332,12 +332,12 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, boo // If no position attributes are received, we have to make sure // that no forbidden automatic alignment is left. { - const SwPosition *pPos = aNewAnch.GetContentAnchor(); - SwTextNode *pNd = pPos->GetNode().GetTextNode(); + SwNode *pAnchorNode = aNewAnch.GetAnchorNode(); + SwTextNode *pNd = pAnchorNode->GetTextNode(); OSL_ENSURE( pNd, "Cursor does not point to TextNode." ); SwFormatFlyCnt aFormat( static_cast<SwFlyFrameFormat*>(&rFormat) ); - pNd->InsertItem( aFormat, pPos->GetContentIndex(), 0 ); + pNd->InsertItem( aFormat, aNewAnch.GetAnchorContentOffset(), 0 ); } if( SfxItemState::SET != rSet.GetItemState( RES_VERT_ORIENT, false )) @@ -766,7 +766,7 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, // anchored object the complete <SwPosition> is kept, because the // anchor index position could be moved, if the object again is // anchored as character. - std::optional<const SwPosition> oOldAsCharAnchorPos; + std::optional<SwPosition> oOldAsCharAnchorPos; const RndStdIds eOldAnchorType = pContact->GetAnchorId(); if ( !_bSameOnly && eOldAnchorType == RndStdIds::FLY_AS_CHAR ) { diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index e4b517a0759f..aec1e9693d7f 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -2179,7 +2179,7 @@ bool SwFEShell::ImpEndCreate() SwTextNode *pNd = aAnch.GetAnchorNode()->GetTextNode(); SwFormatFlyCnt aFormat( pFormat ); pNd->InsertItem(aFormat, - aAnch.GetContentAnchor()->GetContentIndex(), 0 ); + aAnch.GetAnchorContentOffset(), 0 ); SwFormatVertOrient aVertical( pFormat->GetVertOrient() ); aVertical.SetVertOrient( text::VertOrientation::LINE_CENTER ); pFormat->SetFormatAttr( aVertical ); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index b3075dc54d58..dac5a59e2ccb 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2564,9 +2564,9 @@ SwFrameFormat::~SwFrameFormat() if( !GetDoc()->IsInDtor()) { const SwFormatAnchor& rAnchor = GetAnchor(); - if (rAnchor.GetContentAnchor() != nullptr) + if (SwNode* pAnchorNode = rAnchor.GetAnchorNode()) { - rAnchor.GetContentAnchor()->GetNode().RemoveAnchoredFly(this); + pAnchorNode->RemoveAnchoredFly(this); } } @@ -2626,7 +2626,7 @@ void SwFrameFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) const SwAttrSetChg* pNewAttrSetChg = nullptr; const SwFormatHeader* pH = nullptr; const SwFormatFooter* pF = nullptr; - const SwPosition* pNewAnchorPosition = nullptr; + SwNode* pNewAnchorNode = nullptr; switch(nNewWhich) { case RES_ATTRSET_CHG: @@ -2651,8 +2651,8 @@ void SwFrameFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) const SwFormatAnchor* pAnchor = pNewAttrSetChg->GetChgSet()->GetItem(RES_ANCHOR, false); if(pAnchor) { - pNewAnchorPosition = pAnchor->GetContentAnchor(); - assert(pNewAnchorPosition == nullptr || // style's set must not contain position! + pNewAnchorNode = pAnchor->GetAnchorNode(); + assert(pNewAnchorNode == nullptr || // style's set must not contain position! pNewAttrSetChg->GetTheChgdSet() == &m_aSet); } break; @@ -2671,11 +2671,11 @@ void SwFrameFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) pF = static_cast<const SwFormatFooter*>(pLegacy->m_pNew); break; case RES_ANCHOR: - pNewAnchorPosition = static_cast<const SwFormatAnchor*>(pLegacy->m_pNew)->GetContentAnchor(); + pNewAnchorNode = static_cast<const SwFormatAnchor*>(pLegacy->m_pNew)->GetAnchorNode(); break; } const sal_uInt16 nOldWhich = pLegacy->m_pOld ? pLegacy->m_pOld->Which() : 0; - const SwPosition* pOldAnchorPosition = nullptr; + SwNode* pOldAnchorNode = nullptr; switch(nOldWhich) { case RES_ATTRSET_CHG: @@ -2685,14 +2685,14 @@ void SwFrameFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) const SwFormatAnchor* pAnchor = pOldAttrSetChg->GetChgSet()->GetItem(RES_ANCHOR, false); if(pAnchor) { - pOldAnchorPosition = pAnchor->GetContentAnchor(); - assert(pOldAnchorPosition == nullptr || // style's set must not contain position! + pOldAnchorNode = pAnchor->GetAnchorNode(); + assert(pOldAnchorNode == nullptr || // style's set must not contain position! pOldAttrSetChg->GetTheChgdSet() == &m_aSet); } break; } case RES_ANCHOR: - pOldAnchorPosition = static_cast<const SwFormatAnchor*>(pLegacy->m_pOld)->GetContentAnchor(); + pOldAnchorNode = static_cast<const SwFormatAnchor*>(pLegacy->m_pOld)->GetAnchorNode(); break; case RES_REMOVE_UNO_OBJECT: SetXObject(uno::Reference<uno::XInterface>(nullptr)); @@ -2711,10 +2711,10 @@ void SwFrameFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) const_cast<SwFormatFooter*>(pF)->RegisterToFormat(*pFormat); } SwFormat::SwClientNotify(rMod, rHint); - if(pOldAnchorPosition != nullptr && (pNewAnchorPosition == nullptr || pOldAnchorPosition->GetNodeIndex() != pNewAnchorPosition->GetNodeIndex())) - pOldAnchorPosition->GetNode().RemoveAnchoredFly(this); - if(pNewAnchorPosition != nullptr && (pOldAnchorPosition == nullptr || pOldAnchorPosition->GetNodeIndex() != pNewAnchorPosition->GetNodeIndex())) - pNewAnchorPosition->GetNode().AddAnchoredFly(this); + if(pOldAnchorNode != nullptr && (pNewAnchorNode == nullptr || pOldAnchorNode->GetIndex() != pNewAnchorNode->GetIndex())) + pOldAnchorNode->RemoveAnchoredFly(this); + if(pNewAnchorNode != nullptr && (pOldAnchorNode == nullptr || pOldAnchorNode->GetIndex() != pNewAnchorNode->GetIndex())) + pNewAnchorNode->AddAnchoredFly(this); } void SwFrameFormat::RegisterToFormat( SwFormat& rFormat ) @@ -2819,11 +2819,10 @@ bool SwFrameFormat::IsLowerOf( const SwFrameFormat& rFormat ) const // let's try it using the node positions const SwFormatAnchor* pAnchor = &rFormat.GetAnchor(); - if ((RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetContentAnchor()) + if ((RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetAnchorNode()) { const SwFrameFormats& rFormats = *GetDoc()->GetSpzFrameFormats(); - const SwNode* pFlyNd = pAnchor->GetContentAnchor()->GetNode(). - FindFlyStartNode(); + const SwNode* pFlyNd = pAnchor->GetAnchorNode()->FindFlyStartNode(); while( pFlyNd ) { // then we walk up using the anchor @@ -2839,13 +2838,12 @@ bool SwFrameFormat::IsLowerOf( const SwFrameFormat& rFormat ) const pAnchor = &pFormat->GetAnchor(); if ((RndStdIds::FLY_AT_PAGE == pAnchor->GetAnchorId()) || - !pAnchor->GetContentAnchor() ) + !pAnchor->GetAnchorNode() ) { return false; } - pFlyNd = pAnchor->GetContentAnchor()->GetNode(). - FindFlyStartNode(); + pFlyNd = pAnchor->GetAnchorNode()->FindFlyStartNode(); break; } } @@ -2970,26 +2968,26 @@ void SwFlyFrameFormat::MakeFrames() case RndStdIds::FLY_AS_CHAR: case RndStdIds::FLY_AT_PARA: case RndStdIds::FLY_AT_CHAR: - if( aAnchorAttr.GetContentAnchor() ) + if( aAnchorAttr.GetAnchorNode() ) { - pModify = aAnchorAttr.GetContentAnchor()->GetNode().GetContentNode(); + pModify = aAnchorAttr.GetAnchorNode()->GetContentNode(); } break; case RndStdIds::FLY_AT_FLY: - if( aAnchorAttr.GetContentAnchor() ) + if( aAnchorAttr.GetAnchorNode() ) { //First search in the content because this is O(1) //This can go wrong for linked frames because in this case it's //possible, that no Frame exists for this content. //In such a situation we also need to search from StartNode to //FrameFormat. - SwNodeIndex aIdx( aAnchorAttr.GetContentAnchor()->GetNode() ); + SwNodeIndex aIdx( *aAnchorAttr.GetAnchorNode() ); SwContentNode *pCNd = GetDoc()->GetNodes().GoNext( &aIdx ); // #i105535# if ( pCNd == nullptr ) { - pCNd = aAnchorAttr.GetContentAnchor()->GetNode().GetContentNode(); + pCNd = aAnchorAttr.GetAnchorNode()->GetContentNode(); } if ( pCNd ) { @@ -3001,7 +2999,7 @@ void SwFlyFrameFormat::MakeFrames() // #i105535# if ( pModify == nullptr ) { - const SwNode & rNd = aAnchorAttr.GetContentAnchor()->GetNode(); + const SwNode & rNd = *aAnchorAttr.GetAnchorNode(); SwFrameFormats& rFormats = *GetDoc()->GetSpzFrameFormats(); for( size_t i = 0; i < rFormats.size(); ++i ) { @@ -3021,9 +3019,9 @@ void SwFlyFrameFormat::MakeFrames() { sal_uInt16 nPgNum = aAnchorAttr.GetPageNum(); SwPageFrame *pPage = static_cast<SwPageFrame*>(GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout()->Lower()); - if( nPgNum == 0 && aAnchorAttr.GetContentAnchor() ) + if( nPgNum == 0 && aAnchorAttr.GetAnchorNode() ) { - SwContentNode *pCNd = aAnchorAttr.GetContentAnchor()->GetNode().GetContentNode(); + SwContentNode *pCNd = aAnchorAttr.GetAnchorNode()->GetContentNode(); SwIterator<SwFrame, SwContentNode, sw::IteratorMode::UnwrapMulti> aIter(*pCNd); for ( SwFrame* pFrame = aIter.First(); pFrame != nullptr; pFrame = aIter.Next() ) { @@ -3345,19 +3343,19 @@ SwHandleAnchorNodeChg::SwHandleAnchorNodeChg( SwFlyFrameFormat& _rFlyFrameFormat const RndStdIds nNewAnchorType( _rNewAnchorFormat.GetAnchorId() ); if ( ((nNewAnchorType == RndStdIds::FLY_AT_PARA) || (nNewAnchorType == RndStdIds::FLY_AT_CHAR)) && - _rNewAnchorFormat.GetContentAnchor() && - _rNewAnchorFormat.GetContentAnchor()->GetNode().GetContentNode() ) + _rNewAnchorFormat.GetAnchorNode() && + _rNewAnchorFormat.GetAnchorNode()->GetContentNode() ) { if ( aOldAnchorFormat.GetAnchorId() == nNewAnchorType && - aOldAnchorFormat.GetContentAnchor() && - aOldAnchorFormat.GetContentAnchor()->GetNode().GetContentNode() && + aOldAnchorFormat.GetAnchorNode() && + aOldAnchorFormat.GetAnchorNode()->GetContentNode() && aOldAnchorFormat.GetContentAnchor()->GetNode() != _rNewAnchorFormat.GetContentAnchor()->GetNode() ) { // determine 'old' number of anchor frames sal_uInt32 nOldNumOfAnchFrame( 0 ); SwIterator<SwFrame, SwContentNode, sw::IteratorMode::UnwrapMulti> aOldIter( - *(aOldAnchorFormat.GetContentAnchor()->GetNode().GetContentNode()) ); + *(aOldAnchorFormat.GetAnchorNode()->GetContentNode()) ); for( SwFrame* pOld = aOldIter.First(); pOld; pOld = aOldIter.Next() ) { ++nOldNumOfAnchFrame; @@ -3365,7 +3363,7 @@ SwHandleAnchorNodeChg::SwHandleAnchorNodeChg( SwFlyFrameFormat& _rFlyFrameFormat // determine 'new' number of anchor frames sal_uInt32 nNewNumOfAnchFrame( 0 ); SwIterator<SwFrame, SwContentNode, sw::IteratorMode::UnwrapMulti> aNewIter( - *(_rNewAnchorFormat.GetContentAnchor()->GetNode().GetContentNode()) ); + *(_rNewAnchorFormat.GetAnchorNode()->GetContentNode()) ); for( SwFrame* pNew = aNewIter.First(); pNew; pNew = aNewIter.Next() ) { ++nNewNumOfAnchFrame; @@ -3391,7 +3389,7 @@ SwHandleAnchorNodeChg::SwHandleAnchorNodeChg( SwFlyFrameFormat& _rFlyFrameFormat } } - if (aOldAnchorFormat.GetContentAnchor() + if (aOldAnchorFormat.GetAnchorNode() && aOldAnchorFormat.GetAnchorId() == RndStdIds::FLY_AT_CHAR) { moCommentAnchor.emplace(*aOldAnchorFormat.GetContentAnchor()); @@ -3681,7 +3679,7 @@ void CheckAnchoredFlyConsistency(SwDoc const& rDoc) for (const auto& rpFly : rFlys) { SwFormatAnchor const& rAnchor((*rpFly).GetAnchor(false)); - assert(&rAnchor.GetContentAnchor()->GetNode() == pNode); + assert(rAnchor.GetAnchorNode() == pNode); } } SwFrameFormats const*const pSpzFrameFormats(rDoc.GetSpzFrameFormats()); @@ -3693,14 +3691,14 @@ void CheckAnchoredFlyConsistency(SwDoc const& rDoc) SwFormatAnchor const& rAnchor((**it).GetAnchor(false)); if (RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId()) { - assert(!rAnchor.GetContentAnchor() + assert(!rAnchor.GetAnchorNode() // for invalid documents that lack text:anchor-page-number // it may have an anchor before MakeFrames() is called || (!SwIterator<SwFrame, SwFrameFormat>(**it).First())); } else { - SwNode & rNode(rAnchor.GetContentAnchor()->GetNode()); + SwNode & rNode(*rAnchor.GetAnchorNode()); std::vector<SwFrameFormat*> const& rFlys(rNode.GetAnchoredFlys()); assert(std::find(rFlys.begin(), rFlys.end(), *it) != rFlys.end()); switch (rAnchor.GetAnchorId()) diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 7f04626a6b03..08097467c237 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1126,7 +1126,7 @@ static bool IsShown(SwNodeOffset const nIndex, { assert(iter->nStart != iter->nEnd); // TODO possible? assert(iter->pNode->GetIndex() == nIndex); - if (rAnch.GetContentAnchor()->GetContentIndex() < iter->nStart) + if (rAnch.GetAnchorContentOffset() < iter->nStart) { return false; } @@ -1144,7 +1144,7 @@ static bool IsShown(SwNodeOffset const nIndex, // the interesting corner cases are on the edge of the extent! // no need to check for > the last extent because those // are never visible. - if (rAnch.GetContentAnchor()->GetContentIndex() <= iter->nEnd) + if (rAnch.GetAnchorContentOffset() <= iter->nEnd) { if (iter->nStart == 0) { @@ -1180,14 +1180,14 @@ static bool IsShown(SwNodeOffset const nIndex, ? iter->pNode->Len() : 0); return !IsDestroyFrameAnchoredAtChar(*rAnch.GetContentAnchor(), start, end); - } + } } } else { assert(rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR); // for AS_CHAR obviously must be < - if (rAnch.GetContentAnchor()->GetContentIndex() < iter->nEnd) + if (rAnch.GetAnchorContentOffset() < iter->nEnd) { return true; } @@ -1337,10 +1337,10 @@ bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor { ret = (pAnchorNode == pMergedPara->pFirstNode && (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA - || rAnchor.GetContentAnchor()->GetContentIndex() == 0)) + || rAnchor.GetAnchorContentOffset() == 0)) || (pAnchorNode == pMergedPara->pLastNode && (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA - || rAnchor.GetContentAnchor()->GetContentIndex() == pMergedPara->pLastNode->Len())); + || rAnchor.GetAnchorContentOffset() == pMergedPara->pLastNode->Len())); } auto iter(iterFirst); SwTextNode const* pNode(pMergedPara->pFirstNode);