sw/inc/fmtanchr.hxx | 2 + sw/qa/extras/layout/layout.cxx | 30 ++++++++++++------------ sw/qa/extras/layout/layout2.cxx | 6 ++-- sw/qa/extras/tiledrendering/tiledrendering.cxx | 4 +-- sw/qa/extras/uiwriter/uiwriter8.cxx | 10 ++++---- sw/qa/uibase/wrtsh/wrtsh.cxx | 4 +-- sw/source/core/attr/swatrset.cxx | 2 - sw/source/core/crsr/findtxt.cxx | 14 +++++------ sw/source/core/doc/DocumentLayoutManager.cxx | 8 +++--- sw/source/core/doc/dbgoutsw.cxx | 4 +-- sw/source/core/doc/docfly.cxx | 26 ++++++++++---------- sw/source/core/doc/docglbl.cxx | 10 ++++---- sw/source/core/doc/docnew.cxx | 2 - sw/source/core/doc/docsort.cxx | 6 ++-- sw/source/core/doc/tblcpy.cxx | 6 ++-- sw/source/core/doc/textboxhelper.cxx | 22 +++++++---------- sw/source/core/docnode/ndtbl.cxx | 8 +++--- sw/source/core/docnode/node.cxx | 18 ++++++-------- sw/source/core/docnode/swbaslnk.cxx | 10 ++++---- sw/source/core/draw/dcontact.cxx | 8 +++--- sw/source/core/frmedt/fecopy.cxx | 14 +++++------ sw/source/core/frmedt/fefly1.cxx | 6 ++-- sw/source/core/frmedt/feshview.cxx | 2 - sw/source/core/frmedt/tblsel.cxx | 6 ++-- sw/source/core/layout/anchoredobject.cxx | 2 - sw/source/core/layout/atrfrm.cxx | 9 +++++++ sw/source/core/layout/flowfrm.cxx | 2 - sw/source/core/layout/flycnt.cxx | 2 - sw/source/core/layout/flylay.cxx | 2 - sw/source/core/layout/pagechg.cxx | 4 +-- sw/source/core/ole/ndole.cxx | 4 +-- sw/source/core/text/EnhancedPDFExportHelper.cxx | 6 ++-- sw/source/core/text/itratr.cxx | 6 ++-- sw/source/core/text/txtfly.cxx | 2 - sw/source/core/txtnode/atrflyin.cxx | 4 --- sw/source/core/txtnode/ndtxt.cxx | 2 - sw/source/core/txtnode/thints.cxx | 2 - sw/source/core/undo/unattr.cxx | 4 +-- sw/source/core/undo/undel.cxx | 9 +++---- sw/source/core/undo/undobj1.cxx | 10 ++++---- sw/source/core/undo/undraw.cxx | 2 - sw/source/core/undo/untbl.cxx | 8 +++--- sw/source/core/undo/untblk.cxx | 14 +++++------ sw/source/filter/basflt/shellio.cxx | 2 - sw/source/filter/html/css1atr.cxx | 15 +++++------- sw/source/filter/html/htmlflywriter.cxx | 6 ++-- sw/source/filter/html/htmlform.cxx | 4 +-- sw/source/filter/html/htmlforw.cxx | 6 ++-- sw/source/filter/html/htmlgrin.cxx | 6 ++-- sw/source/filter/html/htmltab.cxx | 12 ++++----- sw/source/filter/ww8/writerhelper.cxx | 2 - sw/source/filter/ww8/wrtw8esh.cxx | 6 ++-- sw/source/filter/ww8/wrtw8nds.cxx | 12 ++++----- sw/source/filter/ww8/ww8glsy.cxx | 6 ++-- sw/source/filter/ww8/ww8par2.cxx | 6 ++-- sw/source/filter/xml/XMLRedlineImportHelper.cxx | 4 +-- sw/source/uibase/wrtsh/delete.cxx | 2 - 57 files changed, 206 insertions(+), 205 deletions(-)
New commits: commit dd90710a0acd58ac76bdbe9809382fa266733167 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Nov 24 10:52:52 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Nov 24 11:58:04 2022 +0100 add 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: I1527b6585d1e130b46e1e51b1e40eea043339d8f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143205 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/fmtanchr.hxx b/sw/inc/fmtanchr.hxx index 8dc5ecf59db6..582801d379f0 100644 --- a/sw/inc/fmtanchr.hxx +++ b/sw/inc/fmtanchr.hxx @@ -70,6 +70,8 @@ public: // #i28701# sal_uInt32 GetOrder() const { return m_nOrder;} + SwNode* GetAnchorNode() const; + void SetType( RndStdIds nRndId ) { m_eAnchorId = nRndId; } void SetPageNum( sal_uInt16 nNew ) { m_nPageNumber = nNew; } void SetAnchor( const SwPosition *pPos ); diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index c84b21f4e5bc..2707f940dfbf 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -341,7 +341,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); @@ -465,7 +465,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); @@ -585,7 +585,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInBody) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); @@ -817,7 +817,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); @@ -940,7 +940,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); @@ -1069,7 +1069,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInHeader) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); @@ -1343,7 +1343,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); @@ -1527,7 +1527,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); @@ -1708,7 +1708,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFootnote) if (i == 1) // secondly, try with different anchor type { anchor.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor.GetContentAnchor()); + SwPosition pos(*anchor.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor.SetAnchor(&pos); pDoc->SetAttr(anchor, *const_cast<SwFrameFormat*>(pFly)); @@ -2167,12 +2167,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) if (i == 1) // secondly, try with different anchor type { anchor1.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor1.GetContentAnchor()); + SwPosition pos(*anchor1.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor1.SetAnchor(&pos); pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1)); anchor2.SetType(RndStdIds::FLY_AT_PARA); - pos.nNode = anchor2.GetContentAnchor()->nNode; + pos.nNode = *anchor2.GetAnchorNode(); anchor2.SetAnchor(&pos); pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2)); } @@ -2363,12 +2363,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) if (i == 1) // secondly, try with different anchor type { anchor1.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor1.GetContentAnchor()); + SwPosition pos(*anchor1.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor1.SetAnchor(&pos); pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1)); anchor2.SetType(RndStdIds::FLY_AT_PARA); - pos.nNode = anchor2.GetContentAnchor()->nNode; + pos.nNode = *anchor2.GetAnchorNode(); anchor2.SetAnchor(&pos); pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2)); } @@ -2537,12 +2537,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys) if (i == 1) // secondly, try with different anchor type { anchor1.SetType(RndStdIds::FLY_AT_PARA); - SwPosition pos(*anchor1.GetContentAnchor()); + SwPosition pos(*anchor1.GetAnchorNode()); pos.nContent.Assign(nullptr, 0); anchor1.SetAnchor(&pos); pDoc->SetAttr(anchor1, *const_cast<SwFrameFormat*>(pFly1)); anchor2.SetType(RndStdIds::FLY_AT_PARA); - pos.nNode = anchor2.GetContentAnchor()->nNode; + pos.nNode = *anchor2.GetAnchorNode(); anchor2.SetAnchor(&pos); pDoc->SetAttr(anchor2, *const_cast<SwFrameFormat*>(pFly2)); } diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index b229621928a5..14a03999b091 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -401,7 +401,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testtdf138951) // Check the anchor the same and the textbox is inside the shape const bool bIsAnchTheSame - = *pShFrm->GetAnchor().GetContentAnchor() == *pShFrm->GetAnchor().GetContentAnchor(); + = *pShFrm->GetAnchor().GetAnchorNode() == *pShFrm->GetAnchor().GetAnchorNode(); CPPUNIT_ASSERT_MESSAGE("The anchor is different for the textbox and shape!", bIsAnchTheSame); CPPUNIT_ASSERT_MESSAGE("The textbox has fallen apart!", aShpRect.Contains(aTxtFrmRect)); // Without the fix the anchor differs, and the frame outside of the shape @@ -2322,8 +2322,8 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf121509) bool bFlyInFlyFound = false; for (auto secondformat : *pSecondFormats) { - auto& pNd = secondformat->GetAnchor().GetContentAnchor()->GetNode(); - if (pNd.FindFlyStartNode()) + const SwNode* pNd = secondformat->GetAnchor().GetAnchorNode(); + if (pNd->FindFlyStartNode()) { // So there is a fly inside another -> problem. bFlyInFlyFound = true; diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 84a88ce1e527..664abbfaa238 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -3659,8 +3659,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testPictureContentControl) pWrtShell->EnterSelFrameMode(); const SwFrameFormat* pFlyFormat = pWrtShell->GetFlyFrameFormat(); const SwFormatAnchor& rFormatAnchor = pFlyFormat->GetAnchor(); - const SwPosition* pAnchorPos = rFormatAnchor.GetContentAnchor(); - SwTextNode* pTextNode = pAnchorPos->GetNode().GetTextNode(); + const SwNode* pAnchorNode = rFormatAnchor.GetAnchorNode(); + const SwTextNode* pTextNode = pAnchorNode->GetTextNode(); SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, RES_TXTATR_CONTENTCONTROL); auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr); auto& rFormatContentControl diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index e61c7ab42547..dfc7ac6feddd 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -1002,13 +1002,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf130805) auto pTxBxFrm = SwTextBoxHelper::getOtherTextBoxFormat(getShape(1)); CPPUNIT_ASSERT(pTxBxFrm); - auto pTxAnch = pTxBxFrm->GetAnchor().GetContentAnchor(); - auto pShpAnch = pShape->GetAnchor().GetContentAnchor(); + const SwNode* pTxAnch = pTxBxFrm->GetAnchor().GetAnchorNode(); + const SwNode* pShpAnch = pShape->GetAnchor().GetAnchorNode(); CPPUNIT_ASSERT(pTxAnch); CPPUNIT_ASSERT(pShpAnch); - CPPUNIT_ASSERT_EQUAL_MESSAGE("The textbox got apart!", pTxAnch->GetNodeIndex(), - pShpAnch->GetNodeIndex()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("The textbox got apart!", pTxAnch->GetIndex(), + pShpAnch->GetIndex()); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf107893) @@ -1974,7 +1974,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, AtPageTextBoxCrash) // unless this will lead to crash later, for example on // removing the paragraph where it is anchored to... CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AT_PAGE, pTxBxFrm->GetAnchor().GetAnchorId()); - CPPUNIT_ASSERT(!pTxBxFrm->GetAnchor().GetContentAnchor()); + CPPUNIT_ASSERT(!pTxBxFrm->GetAnchor().GetAnchorNode()); // Remove the paragraph where the textframe should be anchored // before. Now with the patch it must not crash... diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx index d44cb23ce190..d2adde32a179 100644 --- a/sw/qa/uibase/wrtsh/wrtsh.cxx +++ b/sw/qa/uibase/wrtsh/wrtsh.cxx @@ -278,8 +278,8 @@ CPPUNIT_TEST_FIXTURE(Test, testReplacePictureContentControl) pWrtShell->EnterSelFrameMode(); const SwFrameFormat* pFlyFormat = pWrtShell->GetFlyFrameFormat(); const SwFormatAnchor& rFormatAnchor = pFlyFormat->GetAnchor(); - const SwPosition* pAnchorPos = rFormatAnchor.GetContentAnchor(); - SwTextNode* pTextNode = pAnchorPos->GetNode().GetTextNode(); + SwNode* pAnchorNode = rFormatAnchor.GetAnchorNode(); + SwTextNode* pTextNode = pAnchorNode->GetTextNode(); SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, RES_TXTATR_CONTENTCONTROL); auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr); auto& rFormatContentControl diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx index de014a521d2e..e35dfc492406 100644 --- a/sw/source/core/attr/swatrset.cxx +++ b/sw/source/core/attr/swatrset.cxx @@ -353,7 +353,7 @@ void SwAttrSet::CopyToModify( sw::BroadcastingModify& rMod ) const const SwFormatAnchor* pAnchorItem; if( pSrcDoc != pDstDoc && (pAnchorItem = GetItemIfSet( RES_ANCHOR, false )) - && pAnchorItem->GetContentAnchor() != nullptr ) + && pAnchorItem->GetAnchorNode() != nullptr ) { if( !tmpSet ) tmpSet.emplace( *this ); diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index 5a1085961454..dc27f677b6be 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -516,10 +516,10 @@ bool FindTextImpl(SwPaM & rSearchPam, { if (SwFrameFormat* pFrameFormat = FindFrameFormat(pObject)) { - const SwPosition* pPosition = pFrameFormat->GetAnchor().GetContentAnchor(); - if (!pPosition || (pLayout - ? !FrameContainsNode(*pFrame, pPosition->GetNodeIndex()) - : pPosition->GetNodeIndex() != pNode->GetIndex())) + const SwNode* pAnchorNode = pFrameFormat->GetAnchor().GetAnchorNode(); + if (!pAnchorNode || (pLayout + ? !FrameContainsNode(*pFrame, pAnchorNode->GetIndex()) + : pAnchorNode->GetIndex() != pNode->GetIndex())) pObject = nullptr; } } @@ -580,11 +580,11 @@ bool FindTextImpl(SwPaM & rSearchPam, { if (SwFrameFormat* pFrameFormat = FindFrameFormat(pObject)) { - const SwPosition* pPosition = pFrameFormat->GetAnchor().GetContentAnchor(); - if (pPosition) + const SwNode* pAnchorNode = pFrameFormat->GetAnchor().GetAnchorNode(); + if (pAnchorNode) { // Set search position to the shape's anchor point. - rSearchPam.GetPoint()->Assign(pPosition->GetNode()); + rSearchPam.GetPoint()->Assign(*pAnchorNode); rSearchPam.SetMark(); bFound = true; break; diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index 5bd14376a0ec..79f8ee1f51f8 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -259,7 +259,7 @@ void DocumentLayoutManager::DelLayoutFormat( SwFrameFormat *pFormat ) SwFrameFormat* pTmpFormat = (*pTable)[i]; const SwFormatAnchor &rAnch = pTmpFormat->GetAnchor(); if ( rAnch.GetAnchorId() == RndStdIds::FLY_AT_FLY && - rAnch.GetContentAnchor()->GetNodeIndex() == nNodeIdxOfFlyFormat ) + rAnch.GetAnchorNode()->GetIndex() == nNodeIdxOfFlyFormat ) { aToDeleteFrameFormats.push_back( pTmpFormat ); } @@ -287,7 +287,7 @@ void DocumentLayoutManager::DelLayoutFormat( SwFrameFormat *pFormat ) // Delete the character for FlyFrames anchored as char (if necessary) const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); - if ((RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()) && rAnchor.GetContentAnchor()) + if ((RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()) && rAnchor.GetAnchorNode()) { const SwPosition* pPos = rAnchor.GetContentAnchor(); SwTextNode *pTextNd = pPos->GetNode().GetTextNode(); @@ -335,8 +335,8 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat( // 2) anchored in a header/footer // 3) anchored (to paragraph?) bool bMayNotCopy = false; - const auto pCAnchor = rNewAnchor.GetContentAnchor(); - bool bInHeaderFooter = pCAnchor && m_rDoc.IsInHeaderFooter(pCAnchor->GetNode()); + const SwNode* pCAnchor = rNewAnchor.GetAnchorNode(); + bool bInHeaderFooter = pCAnchor && m_rDoc.IsInHeaderFooter(*pCAnchor); if(bDraw) { bool bCheckControlLayer = false; diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index eecb4cd05545..184390720407 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -412,9 +412,9 @@ static OUString lcl_AnchoredFrames(const SwNode & rNode) i != pFrameFormats->end(); ++i) { const SwFormatAnchor & rAnchor = (*i)->GetAnchor(); - const SwPosition * pPos = rAnchor.GetContentAnchor(); + const SwNode * pPos = rAnchor.GetAnchorNode(); - if (pPos && pPos->GetNode() == rNode) + if (pPos && *pPos == rNode) { if (! bFirst) aResult.append(", "); diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index aeb871c817c3..0cf7ccc44a5a 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -214,7 +214,7 @@ static Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFormatAnchor& rAnch, switch( rAnch.GetAnchorId() ) { case RndStdIds::FLY_AS_CHAR: - if( pFlyFormat && rAnch.GetContentAnchor() ) + if( pFlyFormat && rAnch.GetAnchorNode() ) { const SwFrame* pOld = static_cast<const SwFlyFrameFormat*>(pFlyFormat)->GetFrame( &aRet ); if( pOld ) @@ -224,7 +224,7 @@ static Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFormatAnchor& rAnch, case RndStdIds::FLY_AT_PARA: case RndStdIds::FLY_AT_CHAR: // LAYER_IMPL - if( rAnch.GetContentAnchor() ) + if( rAnch.GetAnchorNode() ) { const SwPosition *pPos = rAnch.GetContentAnchor(); const SwContentNode* pNd = pPos->GetNode().GetContentNode(); @@ -236,10 +236,10 @@ static Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFormatAnchor& rAnch, break; case RndStdIds::FLY_AT_FLY: // LAYER_IMPL - if( rAnch.GetContentAnchor() ) + if( rAnch.GetAnchorNode() ) { - const SwFlyFrameFormat* pFormat = static_cast<SwFlyFrameFormat*>(rAnch.GetContentAnchor()-> - GetNode().GetFlyFormat()); + const SwFlyFrameFormat* pFormat = static_cast<SwFlyFrameFormat*>(rAnch.GetAnchorNode()-> + GetFlyFormat()); const SwFrame* pOld = pFormat ? pFormat->GetFrame( &aRet ) : nullptr; if( pOld ) aRet = pOld->getFrameArea().Pos(); @@ -281,7 +281,7 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, SfxItemSet& rSet, boo RndStdIds nNew = aNewAnch.GetAnchorId(); // Is the new anchor valid? - if( !aNewAnch.GetContentAnchor() && (RndStdIds::FLY_AT_FLY == nNew || + if( !aNewAnch.GetAnchorNode() && (RndStdIds::FLY_AT_FLY == nNew || (RndStdIds::FLY_AT_PARA == nNew) || (RndStdIds::FLY_AS_CHAR == nNew) || (RndStdIds::FLY_AT_CHAR == nNew) )) { @@ -1050,9 +1050,9 @@ SwChainRet SwDoc::Chainable( const SwFrameFormat &rSource, const SwFrameFormat & if ( (rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PARA) && (rAnchor.GetAnchorId() != RndStdIds::FLY_AT_CHAR) ) continue; - if ( nullptr == rAnchor.GetContentAnchor() ) + if ( nullptr == rAnchor.GetAnchorNode() ) continue; - SwNodeOffset nTstSttNd = rAnchor.GetContentAnchor()->GetNodeIndex(); + SwNodeOffset nTstSttNd = rAnchor.GetAnchorNode()->GetIndex(); if( nFlySttNd <= nTstSttNd && nTstSttNd < nFlySttNd + SwNodeOffset(2) ) { return SwChainRet::NOT_EMPTY; @@ -1072,14 +1072,14 @@ SwChainRet SwDoc::Chainable( const SwFrameFormat &rSource, const SwFrameFormat & if ( RndStdIds::FLY_AT_PAGE == rSrcAnchor.GetAnchorId() ) { if ( (RndStdIds::FLY_AT_PAGE == rDstAnchor.GetAnchorId()) || - ( rDstAnchor.GetContentAnchor() && - rDstAnchor.GetContentAnchor()->GetNodeIndex() > nEndOfExtras )) + ( rDstAnchor.GetAnchorNode() && + rDstAnchor.GetAnchorNode()->GetIndex() > nEndOfExtras )) bAllowed = true; } - else if( rSrcAnchor.GetContentAnchor() && rDstAnchor.GetContentAnchor() ) + else if( rSrcAnchor.GetAnchorNode() && rDstAnchor.GetAnchorNode() ) { - const SwNode &rSrcNd = rSrcAnchor.GetContentAnchor()->GetNode(), - &rDstNd = rDstAnchor.GetContentAnchor()->GetNode(); + const SwNode &rSrcNd = *rSrcAnchor.GetAnchorNode(), + &rDstNd = *rDstAnchor.GetAnchorNode(); const SwStartNode* pSttNd = nullptr; if( rSrcNd == rDstNd || ( !pSttNd && diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index f5c716ff0301..4cd8b7fa179c 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -372,13 +372,13 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline, { SwFrameFormat* pFly = (*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())) && - aSIdx <= pAPos->GetNode() && - pAPos->GetNode() < aEIdx.GetNode() ) + aSIdx <= *pAnchorNode && + *pAnchorNode < aEIdx.GetNode() ) { getIDocumentLayoutAccess().DelLayoutFormat( pFly ); --n; diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 8dc280e2853e..716c31f0dbae 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -193,7 +193,7 @@ static void lcl_DelFormatIndices( SwFormat const * pFormat ) if ( rFormatContent.GetContentIdx() ) rFormatContent.SetNewContentIdx( nullptr ); SwFormatAnchor &rFormatAnchor = const_cast<SwFormatAnchor&>(pFormat->GetAnchor()); - if ( rFormatAnchor.GetContentAnchor() ) + if ( rFormatAnchor.GetAnchorNode() ) rFormatAnchor.SetAnchor( nullptr ); } diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 3061f1b4ed56..f4693871c3e3 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -289,10 +289,10 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) for ( const auto *pFormat : *GetSpzFrameFormats() ) { SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); - SwPosition const*const pAPos = pAnchor->GetContentAnchor(); + SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); - if (pAPos && (RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) && - pStart->GetNode() <= pAPos->GetNode() && pAPos->GetNode() <= pEnd->GetNode() ) + if (pAnchorNode && (RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) && + pStart->GetNode() <= *pAnchorNode && *pAnchorNode <= pEnd->GetNode() ) return false; } diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 808f0ac3d8bb..0343c9c35b27 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -543,11 +543,11 @@ static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox, for( const auto pFly : *pDoc->GetSpzFrameFormats() ) { SwFormatAnchor const*const 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())) && - aInsIdx <= pAPos->GetNode() && pAPos->GetNode() <= aEndNdIdx.GetNode() ) + aInsIdx <= *pAnchorNode && *pAnchorNode <= aEndNdIdx.GetNode() ) { pDoc->getIDocumentLayoutAccess().DelLayoutFormat( pFly ); } diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 77165b8e34bc..f253502e56a6 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1028,8 +1028,8 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& const bool bInlineAnchored = rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR; const bool bLayoutInCell = rShape.GetFollowTextFlow().GetValue() - && rShape.GetAnchor().GetContentAnchor() - && rShape.GetAnchor().GetContentAnchor()->GetNode().FindTableNode(); + && rShape.GetAnchor().GetAnchorNode() + && rShape.GetAnchor().GetAnchorNode()->FindTableNode(); SfxItemSet aTextBoxSet(pFormat->GetDoc()->GetAttrPool(), aFrameFormatSetRange); SfxItemIter aIter(rSet); @@ -1448,17 +1448,14 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb } // Other special case: shape is inside a table or floating table following the text flow - if (pShape->GetFollowTextFlow().GetValue() && pShape->GetAnchor().GetContentAnchor() - && pShape->GetAnchor().GetContentAnchor()->GetNode().FindTableNode()) + if (pShape->GetFollowTextFlow().GetValue() && pShape->GetAnchor().GetAnchorNode() + && pShape->GetAnchor().GetAnchorNode()->FindTableNode()) { // Table position Point nTableOffset; // Floating table - if (auto pFly = pShape->GetAnchor() - .GetContentAnchor() - ->GetNode() - .FindTableNode() - ->FindFlyStartNode()) + if (auto pFly + = pShape->GetAnchor().GetAnchorNode()->FindTableNode()->FindFlyStartNode()) { if (auto pFlyFormat = pFly->GetFlyFormat()) { @@ -1469,8 +1466,7 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb else // Normal table { - auto pTableNode - = pShape->GetAnchor().GetContentAnchor()->GetNode().FindTableNode(); + auto pTableNode = pShape->GetAnchor().GetAnchorNode()->FindTableNode(); if (auto pTableFormat = pTableNode->GetTable().GetFrameFormat()) { nTableOffset.setX(pTableFormat->GetHoriOrient().GetPos()); @@ -1644,7 +1640,7 @@ bool SwTextBoxHelper::isAnchorSyncNeeded(const SwFrameFormat* pFirst, const SwFr if (rShapeAnchor.GetAnchorId() == rFrameAnchor.GetAnchorId()) { - if (rShapeAnchor.GetContentAnchor() && rFrameAnchor.GetContentAnchor()) + if (rShapeAnchor.GetAnchorNode() && rFrameAnchor.GetAnchorNode()) { if (*rShapeAnchor.GetContentAnchor() != *rFrameAnchor.GetContentAnchor()) return true; @@ -1667,7 +1663,7 @@ bool SwTextBoxHelper::isAnchorSyncNeeded(const SwFrameFormat* pFirst, const SwFr if (rShapeAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR && rFrameAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR) { - if (rShapeAnchor.GetContentAnchor() && rFrameAnchor.GetContentAnchor()) + if (rShapeAnchor.GetAnchorNode() && rFrameAnchor.GetAnchorNode()) { if (*rShapeAnchor.GetContentAnchor() != *rFrameAnchor.GetContentAnchor()) return true; diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 679437f4d880..ba27869937c9 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1670,12 +1670,12 @@ bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, { SwFrameFormat *const pFormat = pFly; const SwFormatAnchor& rAnchor = pFormat->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_CHAR == rAnchor.GetAnchorId())) && - nStt <= pAPos->GetNodeIndex() && - pAPos->GetNodeIndex() < nEnd ) + nStt <= pAnchorNode->GetIndex() && + pAnchorNode->GetIndex() < nEnd ) { pFormat->MakeFrames(); } diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 684849468d12..60cc18131e3b 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -474,11 +474,10 @@ bool SwNode::IsProtect() const if (pFlyFormat->GetProtect().IsContentProtected()) return true; const SwFormatAnchor& rAnchor = pFlyFormat->GetAnchor(); - const SwPosition* pAnchorPos = rAnchor.GetContentAnchor(); - if (!pAnchorPos) + const SwNode* pAnchorNode = rAnchor.GetAnchorNode(); + if (!pAnchorNode) return false; - const SwNode& rAnchorNd = pAnchorPos->GetNode(); - return &rAnchorNd != this && rAnchorNd.IsProtect(); + return pAnchorNode != this && pAnchorNode->IsProtect(); } pSttNd = FindFootnoteStartNode(); @@ -567,9 +566,9 @@ const SwPageDesc* SwNode::FindPageDesc( SwNodeOffset* pPgDescNdIdx ) const { const SwFormatAnchor* pAnchor = &pFormat->GetAnchor(); if ((RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId()) && - pAnchor->GetContentAnchor() ) + pAnchor->GetAnchorNode() ) { - pNd = &pAnchor->GetContentAnchor()->GetNode(); + pNd = pAnchor->GetAnchorNode(); const SwNode* pFlyNd = pNd->FindFlyStartNode(); while( pFlyNd ) { @@ -590,14 +589,13 @@ const SwPageDesc* SwNode::FindPageDesc( SwNodeOffset* pPgDescNdIdx ) const } pAnchor = &pFrameFormat->GetAnchor(); if ((RndStdIds::FLY_AT_PAGE == pAnchor->GetAnchorId()) || - !pAnchor->GetContentAnchor() ) + !pAnchor->GetAnchorNode() ) { pFlyNd = nullptr; break; } - pFlyNd = pAnchor->GetContentAnchor()-> - GetNode().FindFlyStartNode(); + pFlyNd = pAnchor->GetAnchorNode()->FindFlyStartNode(); break; } } @@ -2182,7 +2180,7 @@ bool SwNode::IsInRedlines() const void SwNode::AddAnchoredFly(SwFrameFormat *const pFlyFormat) { assert(pFlyFormat); - assert(&pFlyFormat->GetAnchor(false).GetContentAnchor()->GetNode() == this); + assert(pFlyFormat->GetAnchor(false).GetAnchorNode() == this); // check node type, cf. SwFormatAnchor::SetAnchor() assert(IsTextNode() || IsStartNode() || IsTableNode()); m_aAnchoredFlys.push_back(pFlyFormat); diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index ebb48e9a51a7..287bc8079586 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -192,9 +192,9 @@ static bool SetGrfFlySize( const Size& rGrfSz, SwGrfNode* pGrfNd, const Size& rO // If the graphic is anchored in a table, we need to recalculate // the table rows const SwDoc& rDoc = pGrfNd->GetDoc(); - const SwPosition* pAPos = pFormat->GetAnchor().GetContentAnchor(); + SwNode* pAnchorNode = pFormat->GetAnchor().GetAnchorNode(); SwTableNode *pTableNd; - if (pAPos && nullptr != (pTableNd = pAPos->GetNode().FindTableNode())) + if (pAnchorNode && nullptr != (pTableNd = pAnchorNode->FindTableNode())) { const bool bLastGrf = !pTableNd->GetTable().DecGrfsThatResize(); SwHTMLTableLayout *pLayout = @@ -283,14 +283,14 @@ const SwNode* SwBaseLink::GetAnchor() const if (pFormat) { const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); - SwPosition const*const pAPos = rAnchor.GetContentAnchor(); - if (pAPos && + SwNode const*const pAnchorNode = rAnchor.GetAnchorNode(); + if (pAnchorNode && ((RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()) || (RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId()) || (RndStdIds::FLY_AT_FLY == rAnchor.GetAnchorId()) || (RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId()))) { - return &pAPos->GetNode(); + return pAnchorNode; } return nullptr; } diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index f1375a85eb45..156f73adc58a 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1866,17 +1866,17 @@ void SwDrawContact::ConnectToLayout( const SwFormatAnchor* pAnch ) // at the following frames 'virtual' drawing objects. // Note: method is similar to <SwFlyFrameFormat::MakeFrames(..)> sw::BroadcastingModify *pModify = nullptr; - if( pAnch->GetContentAnchor() ) + if( pAnch->GetAnchorNode() ) { if ( pAnch->GetAnchorId() == RndStdIds::FLY_AT_FLY ) { - SwNodeIndex aIdx( pAnch->GetContentAnchor()->GetNode() ); + SwNodeIndex aIdx( *pAnch->GetAnchorNode() ); SwContentNode* pCNd = pDrawFrameFormat->GetDoc()->GetNodes().GoNext( &aIdx ); if (SwIterator<SwFrame, SwContentNode, sw::IteratorMode::UnwrapMulti>(*pCNd).First()) pModify = pCNd; else { - const SwNode& rIdx = pAnch->GetContentAnchor()->GetNode(); + const SwNode& rIdx = *pAnch->GetAnchorNode(); SwFrameFormats& rFormats = *(pDrawFrameFormat->GetDoc()->GetSpzFrameFormats()); for( auto pFlyFormat : rFormats ) { @@ -1891,7 +1891,7 @@ void SwDrawContact::ConnectToLayout( const SwFormatAnchor* pAnch ) } else { - pModify = pAnch->GetContentAnchor()->GetNode().GetContentNode(); + pModify = pAnch->GetAnchorNode()->GetContentNode(); } } diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index ab7ccfe6c9eb..961c64d12bc9 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -96,11 +96,11 @@ void SwFEShell::Copy( SwDoc& rClpDoc, const OUString* pNewClpText ) for( const auto pFly : *rClpDoc.GetSpzFrameFormats() ) { SwFormatAnchor const*const 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())) && - aSttIdx <= pAPos->GetNode() && pAPos->GetNode() <= aEndNdIdx.GetNode() ) + aSttIdx <= *pAnchorNode && *pAnchorNode <= aEndNdIdx.GetNode() ) { rClpDoc.getIDocumentLayoutAccess().DelLayoutFormat( pFly ); } @@ -676,13 +676,13 @@ namespace { bool IsInTextBox(const SwFrameFormat* pFormat) { const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); - const SwPosition* pPosition = rAnchor.GetContentAnchor(); - if (!pPosition) + const SwNode* pAnchorNode = rAnchor.GetAnchorNode(); + if (!pAnchorNode) { return false; } - const SwStartNode* pFlyNode = pPosition->GetNode().FindFlyStartNode(); + const SwStartNode* pFlyNode = pAnchorNode->FindFlyStartNode(); if (!pFlyNode) { return false; @@ -1050,7 +1050,7 @@ bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable) // shouldn't happen here) SwFormatAnchor const& rAnchor(pFlyFormat->GetAnchor()); if (RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId() - || rClpDoc.GetNodes().GetEndOfExtras().GetIndex() < rAnchor.GetContentAnchor()->GetNodeIndex()) + || rClpDoc.GetNodes().GetEndOfExtras().GetIndex() < rAnchor.GetAnchorNode()->GetIndex()) { inserted.emplace_back( lcl_PasteFlyOrDrawFormat(rPaM, pFlyFormat, *this)); diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 327601678e75..3e1bb21df9f8 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -228,7 +228,7 @@ bool sw_ChkAndSetNewAnchor( #if OSL_DEBUG_LEVEL > 0 OSL_ENSURE( !(nNew == RndStdIds::FLY_AT_PAGE && (RndStdIds::FLY_AT_PARA==nOld || RndStdIds::FLY_AT_CHAR==nOld || RndStdIds::FLY_AS_CHAR==nOld ) && - pDoc->IsInHeaderFooter( rOldAnch.GetContentAnchor()->GetNode() )), + pDoc->IsInHeaderFooter( *rOldAnch.GetAnchorNode() )), "forbidden anchor change in Head/Foot." ); #endif @@ -859,13 +859,13 @@ void SwFEShell::Insert( const OUString& rGrfName, const OUString& rFltName, case RndStdIds::FLY_AT_PARA: case RndStdIds::FLY_AT_CHAR: // LAYER_IMPL case RndStdIds::FLY_AS_CHAR: - if( !pAnchor->GetContentAnchor() ) + if( !pAnchor->GetAnchorNode() ) { pAnchor->SetAnchor( pCursor->GetPoint() ); } break; case RndStdIds::FLY_AT_FLY: - if( !pAnchor->GetContentAnchor() ) + if( !pAnchor->GetAnchorNode() ) { lcl_SetNewFlyPos( pCursor->GetPointNode(), *pAnchor, GetCursorDocPos() ); diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 46e17971f5c7..c4a5d5faac51 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -2176,7 +2176,7 @@ bool SwFEShell::ImpEndCreate() if( bCharBound ) { OSL_ENSURE( aAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR, "wrong AnchorType" ); - SwTextNode *pNd = aAnch.GetContentAnchor()->GetNode().GetTextNode(); + SwTextNode *pNd = aAnch.GetAnchorNode()->GetTextNode(); SwFormatFlyCnt aFormat( pFormat ); pNd->InsertItem(aFormat, aAnch.GetContentAnchor()->GetContentIndex(), 0 ); diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 1733ed8fea73..01022e60a7d9 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -909,11 +909,11 @@ bool IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam ) for( auto pFormat : rFormats ) { const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); - const SwPosition* pAPos = rAnchor.GetContentAnchor(); - if (pAPos && + const SwNode* pAnchorNode = rAnchor.GetAnchorNode(); + if (pAnchorNode && ((RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId()) || (RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId())) && - nSttIdx <= ( nIdx = pAPos->GetNodeIndex() ) && + nSttIdx <= ( nIdx = pAnchorNode->GetIndex() ) && nIdx < nEndIdx ) { bRet = false; diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx index 2c4459dbe704..130a5d8c7553 100644 --- a/sw/source/core/layout/anchoredobject.cxx +++ b/sw/source/core/layout/anchoredobject.cxx @@ -216,7 +216,7 @@ void SwAnchoredObject::CheckCharRectAndTopOfLine( const SwFormatAnchor& rAnch = GetFrameFormat().GetAnchor(); if ( !((rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR) && - rAnch.GetContentAnchor()) ) + rAnch.GetAnchorNode()) ) return; // --> if requested, assure that anchor frame, diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index bb4110ef46d8..9e4105d21753 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -1603,6 +1603,15 @@ void SwFormatAnchor::SetAnchor( const SwPosition *pPos ) } } +SwNode* SwFormatAnchor::GetAnchorNode() const +{ + if (!m_oContentAnchor) + return nullptr; + if (auto pCntNd = m_oContentAnchor->nContent.GetContentNode()) + return const_cast<SwContentNode*>(pCntNd); + return &m_oContentAnchor->nNode.GetNode(); +} + SwFormatAnchor& SwFormatAnchor::operator=(const SwFormatAnchor& rAnchor) { if (this != &rAnchor) diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index c60e4ca6ec86..0e762f371aa4 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -395,7 +395,7 @@ sal_uInt8 SwFlowFrame::BwdMoveNecessary( const SwPageFrame *pPage, const SwRect if ( rFormat.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PARA ) { // The index of the other one can be retrieved using the anchor attribute. - SwNodeOffset nTmpIndex = rFormat.GetAnchor().GetContentAnchor()->GetNodeIndex(); + SwNodeOffset nTmpIndex = rFormat.GetAnchor().GetAnchorNode()->GetIndex(); // Now we're going to check whether the current paragraph before // the anchor of the displacing object sits in the text. If this // is the case, we don't try to evade it. diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 0756eadf5b5a..8ba6655cd7de 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -110,7 +110,7 @@ void SwFlyAtContentFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rH // Search the new anchor using the NodeIdx; the relation between old // and new NodeIdx determines the search direction - const SwNodeIndex aNewIdx(pAnch->GetContentAnchor()->GetNode()); + const SwNodeIndex aNewIdx(*pAnch->GetAnchorNode()); SwNodeIndex aOldIdx(pContent->IsTextFrame() // sw_redlinehide: can pick any node here, the compare with // FrameContainsNode should catch it diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index b174aa8e5a48..193c678a2e18 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -767,7 +767,7 @@ void SwFlyLayFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) } else { - SwNodeIndex aIdx(pAnch->GetContentAnchor()->GetNode()); + SwNodeIndex aIdx(*pAnch->GetAnchorNode()); SwContentFrame* pContent = GetFormat()->GetDoc()->GetNodes().GoNext(&aIdx)-> GetContentNode()->getLayoutFrame(getRootFrame(), nullptr, nullptr); if(pContent) diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index 42720ee194a9..da4c2fb81c5d 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -405,7 +405,7 @@ static void lcl_MakeObjs( const SwFrameFormats &rTable, SwPageFrame *pPage ) const SwFormatAnchor &rAnch = pFormat->GetAnchor(); if ( rAnch.GetPageNum() == pPage->GetPhyPageNum() ) { - if( rAnch.GetContentAnchor() ) + if( rAnch.GetAnchorNode() ) { if (RndStdIds::FLY_AT_PAGE == rAnch.GetAnchorId()) { @@ -1572,7 +1572,7 @@ void SwRootFrame::AssertFlyPages() for ( size_t i = 0; i < pTable->size(); ++i ) { const SwFormatAnchor &rAnch = (*pTable)[i]->GetAnchor(); - if(!rAnch.GetContentAnchor()) + if(!rAnch.GetAnchorNode()) { const sal_uInt16 nPageNum(rAnch.GetPageNum()); diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index 0435a370914c..a5210d22d339 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -479,10 +479,10 @@ bool SwOLENode::IsInGlobalDocSection() const return false; const SwFormatAnchor& rAnchor = pFlyFormat->GetAnchor(); - if( !rAnchor.GetContentAnchor() ) + if( !rAnchor.GetAnchorNode() ) return false; - pAnchorNd = &rAnchor.GetContentAnchor()->GetNode(); + pAnchorNd = rAnchor.GetAnchorNode(); } while( pAnchorNd->GetIndex() < nEndExtraIdx ); const SwSectionNode* pSectNd = pAnchorNd->FindSectionNode(); diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 227197864923..7491ab42d52c 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -1816,10 +1816,10 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() const SwFormatAnchor &rAnch = pFrameFormat->GetAnchor(); if (RndStdIds::FLY_AT_PAGE != rAnch.GetAnchorId()) { - const SwPosition* pPosition = rAnch.GetContentAnchor(); - if ( pPosition && pDoc->IsInHeaderFooter( pPosition->GetNode() ) ) + const SwNode* pAnchorNode = rAnch.GetAnchorNode(); + if ( pAnchorNode && pDoc->IsInHeaderFooter( *pAnchorNode ) ) { - const SwTextNode* pTNd = pPosition->GetNode().GetTextNode(); + const SwTextNode* pTNd = pAnchorNode->GetTextNode(); if ( pTNd ) MakeHeaderFooterLinks(*pPDFExtOutDevData, *pTNd, aLinkRect, nDestId, aURL, bIntern, formatName); } diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index a37536e76121..d78a687a23d1 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -891,9 +891,9 @@ static void lcl_MinMaxNode(SwFrameFormat* pNd, SwMinMaxNodeArgs& rIn) return; } - const SwPosition *pPos = rFormatA.GetContentAnchor(); - OSL_ENSURE(pPos, "Unexpected NULL arguments"); - if (!pPos || rIn.m_nIndex != pPos->GetNodeIndex()) + const SwNode *pAnchorNode = rFormatA.GetAnchorNode(); + OSL_ENSURE(pAnchorNode, "Unexpected NULL arguments"); + if (!pAnchorNode || rIn.m_nIndex != pAnchorNode->GetIndex()) return; tools::Long nMin, nMax; diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index f3bac6eb6bb5..2c7f5aeadb4f 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -806,7 +806,7 @@ bool SwTextFly::GetTop( const SwAnchoredObject* _pAnchoredObj, // Compare indices: // The Index of the other is retrieved from the anchor attr. - SwNodeOffset nTmpIndex = rNewA.GetContentAnchor()->GetNodeIndex(); + SwNodeOffset nTmpIndex = rNewA.GetAnchorNode()->GetIndex(); // Now check whether the current paragraph is before the anchor // of the displaced object in the text, then we don't have to // get out of its way. diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index c1f3225b5d22..28eb7b38e530 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -143,9 +143,7 @@ void SwTextFlyCnt::SetAnchor( const SwTextNode *pNode ) SwFrameFormat* pFormat = GetFlyCnt().GetFrameFormat(); SwFormatAnchor aAnchor( pFormat->GetAnchor() ); - SwNode *const pOldNode(aAnchor.GetContentAnchor() - ? &aAnchor.GetContentAnchor()->GetNode() - : nullptr); + SwNode *const pOldNode(aAnchor.GetAnchorNode()); std::optional<SwPosition> oPos; if (!pOldNode || !pOldNode->GetNodes().IsDocNodes() || diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 89a149744e74..cb15076c492a 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -410,7 +410,7 @@ void MoveMergedFlysAndFootnotes(std::vector<SwTextFrame*> const& rFrames, { SwFrameFormat & rFormat(pObj->GetFrameFormat()); SwFormatAnchor const& rAnchor(rFormat.GetAnchor()); - if (rFirstNode.GetIndex() < rAnchor.GetContentAnchor()->GetNodeIndex()) + if (rFirstNode.GetIndex() < rAnchor.GetAnchorNode()->GetIndex()) { // move it to the new frame of "this" rFormat.CallSwClientNotify(sw::LegacyModifyHint(&rAnchor, &rAnchor)); diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 518f2786c661..08bf8e87c6b3 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1405,7 +1405,7 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode ) // OD 26.06.2003 - allow drawing objects in header/footer. // But don't allow control objects in header/footer if( RES_DRAWFRMFMT == pFormat->Which() && - pDoc->IsInHeaderFooter( pFormat->GetAnchor().GetContentAnchor()->GetNode() ) ) + pDoc->IsInHeaderFooter( *pFormat->GetAnchor().GetAnchorNode() ) ) { bool bCheckControlLayer = false; pFormat->CallSwClientNotify(sw::CheckDrawFrameFormatLayerHint(&bCheckControlLayer)); diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 4813b4e269d0..50d5eb72c68a 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -361,7 +361,7 @@ void SwUndoFormatAttr::SaveFlyAnchor( const SwFormat * pFormat, bool bSvDrwPt ) const SwFormatAnchor& rAnchor = m_oOldSet->Get( RES_ANCHOR, false ); - if( !rAnchor.GetContentAnchor() ) + if( !rAnchor.GetAnchorNode() ) return; sal_Int32 nContent = 0; @@ -372,7 +372,7 @@ void SwUndoFormatAttr::SaveFlyAnchor( const SwFormat * pFormat, bool bSvDrwPt ) [[fallthrough]]; case RndStdIds::FLY_AT_PARA: case RndStdIds::FLY_AT_FLY: - m_nNodeIndex = rAnchor.GetContentAnchor()->GetNodeIndex(); + m_nNodeIndex = rAnchor.GetAnchorNode()->GetIndex(); break; default: return; diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index b3026c1c375f..d09e1ec6d210 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -62,8 +62,8 @@ static void lcl_MakeAutoFrames( const SwFrameFormats& rSpzArr, SwNodeOffset nMov const SwFormatAnchor* pAnchor = &pFormat->GetAnchor(); if (pAnchor->GetAnchorId() == RndStdIds::FLY_AT_CHAR) { - const SwPosition* pAPos = pAnchor->GetContentAnchor(); - if( pAPos && nMovedIndex == pAPos->GetNodeIndex() ) + const SwNode* pAnchorNode = pAnchor->GetAnchorNode(); + if( pAnchorNode && nMovedIndex == pAnchorNode->GetIndex() ) pFormat->MakeFrames(); } } @@ -824,15 +824,14 @@ static void lcl_ReAnchorAtContentFlyFrames( const SwFrameFormats& rSpzArr, const SwFrameFormat* pFormat; const SwFormatAnchor* pAnchor; - const SwPosition* pAPos; for( size_t n = 0; n < rSpzArr.size(); ++n ) { pFormat = rSpzArr[n]; pAnchor = &pFormat->GetAnchor(); if (pAnchor->GetAnchorId() == RndStdIds::FLY_AT_PARA) { - pAPos = pAnchor->GetContentAnchor(); - if( pAPos && nOldIdx == pAPos->GetNodeIndex() ) + SwNode* pAnchorNode = pAnchor->GetAnchorNode(); + if( pAnchorNode && nOldIdx == pAnchorNode->GetIndex() ) { SwFormatAnchor aAnch( *pAnchor ); aAnch.SetAnchor( &rPos ); diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index 8ece221511f8..2b3e638f8b01 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -139,7 +139,7 @@ void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrame) if (RndStdIds::FLY_AS_CHAR == m_nRndId) { // there must be at least the attribute in a TextNode - SwContentNode* pCNd = aAnchor.GetContentAnchor()->GetNode().GetContentNode(); + SwContentNode* pCNd = aAnchor.GetAnchorNode()->GetContentNode(); OSL_ENSURE( pCNd->IsTextNode(), "no Text Node at position." ); SwFormatFlyCnt aFormat( m_pFrameFormat ); pCNd->GetTextNode()->InsertItem(aFormat, m_nContentPos, m_nContentPos, SetAttrMode::NOHINTEXPAND); @@ -199,7 +199,7 @@ void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrame) case RndStdIds::FLY_AT_FLY: { const SwFormatAnchor& rAnchor = m_pFrameFormat->GetAnchor(); - m_nNodePagePos = rAnchor.GetContentAnchor()->GetNodeIndex(); + m_nNodePagePos = rAnchor.GetAnchorNode()->GetIndex(); } break; case RndStdIds::FLY_AT_PAGE: @@ -612,9 +612,9 @@ void SwUndoSetFlyFormat::UndoImpl(::sw::UndoRedoContext & rContext) if (RndStdIds::FLY_AS_CHAR == aNewAnchor.GetAnchorId()) { - const SwPosition* pPos = aNewAnchor.GetContentAnchor(); + SwNode* pAnchorNode = aNewAnchor.GetAnchorNode(); SwFormatFlyCnt aFormat( m_pFrameFormat ); - pPos->GetNode().GetTextNode()->InsertItem( aFormat, + pAnchorNode->GetTextNode()->InsertItem( aFormat, m_nOldContent, 0 ); } @@ -685,7 +685,7 @@ void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem ) [[fallthrough]]; case RndStdIds::FLY_AT_PARA: case RndStdIds::FLY_AT_FLY: - m_nNewNode = pAnchor->GetContentAnchor()->GetNodeIndex(); + m_nNewNode = pAnchor->GetAnchorNode()->GetIndex(); break; default: diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index 6167ae04ca4e..d162cb94cea9 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -105,7 +105,7 @@ static void lcl_SaveAnchor( SwFrameFormat* pFormat, SwNodeOffset& rNodePos ) (RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()))) return; - rNodePos = rAnchor.GetContentAnchor()->GetNodeIndex(); + rNodePos = rAnchor.GetAnchorNode()->GetIndex(); sal_Int32 nContentPos = 0; if (RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()) diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 7844532ddb2c..ce646033df6c 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -432,12 +432,12 @@ SwUndoTableToText::SwUndoTableToText( const SwTable& rTable, sal_Unicode cCh ) { SwFrameFormat* 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_AT_CHAR == pAnchor->GetAnchorId()) || (RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId())) && - nTableStt <= pAPos->GetNodeIndex() && - pAPos->GetNodeIndex() < nTableEnd ) + nTableStt <= pAnchorNode->GetIndex() && + pAnchorNode->GetIndex() < nTableEnd ) { m_pHistory->AddChangeFlyAnchor(*pFormat); } diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 76a335027c15..29b49e17a485 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -46,9 +46,9 @@ GetFlysAnchoredAt(SwDoc & rDoc, SwNodeOffset const nSttNode) { SwFrameFormat *const pFormat = (*rDoc.GetSpzFrameFormats())[n]; SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); - SwPosition const*const pAPos = pAnchor->GetContentAnchor(); - if (pAPos - && nSttNode == pAPos->GetNodeIndex() + SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); + if (pAnchorNode + && nSttNode == pAnchorNode->GetIndex() && ((pAnchor->GetAnchorId() == RndStdIds::FLY_AT_PARA) || (pAnchor->GetAnchorId() == RndStdIds::FLY_AT_CHAR))) { @@ -178,12 +178,12 @@ bool SwUndoInserts::IsCreateUndoForNewFly(SwFormatAnchor const& rAnchor, // check all at-char flys at the start/end nodes: // ExcludeFlyAtStartEnd will exclude them! - SwPosition const*const pAnchorPos = rAnchor.GetContentAnchor(); - return pAnchorPos != nullptr + SwNode const*const pAnchorNode = rAnchor.GetAnchorNode(); + return pAnchorNode != nullptr && ( rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA || rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR) - && ( nStartNode == pAnchorPos->GetNodeIndex() - || nEndNode == pAnchorPos->GetNodeIndex()); + && ( nStartNode == pAnchorNode->GetIndex() + || nEndNode == pAnchorNode->GetIndex()); } void SwUndoInserts::dumpAsXml(xmlTextWriterPtr pWriter) const diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 443e1a25902e..3157943dcceb 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -287,7 +287,7 @@ ErrCode SwReader::Read( const Reader& rOptions ) if (RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId()) { - if( !rAnchor.GetContentAnchor() ) + if( !rAnchor.GetAnchorNode() ) { pFrameFormat->MakeFrames(); } diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index f9ee4adf5005..135494df00ca 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -2136,23 +2136,22 @@ void SwHTMLWriter::OutCSS1_FrameFormatBackground( const SwFrameFormat& rFrameFor // If the frame is not linked to a page, we use the background of the anchor. const SwFormatAnchor& rAnchor = rFrameFormat.GetAnchor(); RndStdIds eAnchorId = rAnchor.GetAnchorId(); - const SwPosition *pAnchorPos = rAnchor.GetContentAnchor(); - if (RndStdIds::FLY_AT_PAGE != eAnchorId && pAnchorPos) + const SwNode *pAnchorNode = rAnchor.GetAnchorNode(); + if (RndStdIds::FLY_AT_PAGE != eAnchorId && pAnchorNode) { - const SwNode& rNode = pAnchorPos->GetNode(); - if( rNode.IsContentNode() ) + if( pAnchorNode->IsContentNode() ) { // If the frame is linked to a content-node, // we take the background of the content-node, if it has one. if( OutCSS1_FrameFormatBrush( *this, - rNode.GetContentNode()->GetSwAttrSet().GetBackground()) ) + pAnchorNode->GetContentNode()->GetSwAttrSet().GetBackground()) ) return; // Otherwise we also could be in a table - const SwTableNode *pTableNd = rNode.FindTableNode(); + const SwTableNode *pTableNd = pAnchorNode->FindTableNode(); if( pTableNd ) { - const SwStartNode *pBoxSttNd = rNode.FindTableBoxStartNode(); + const SwStartNode *pBoxSttNd = pAnchorNode->FindTableBoxStartNode(); const SwTableBox *pBox = pTableNd->GetTable().GetTableBox( pBoxSttNd->GetIndex() ); @@ -2181,7 +2180,7 @@ void SwHTMLWriter::OutCSS1_FrameFormatBackground( const SwFrameFormat& rFrameFor } // If the anchor is again in a Fly-Frame, use the background of the Fly-Frame. - const SwFrameFormat *pFrameFormat = rNode.GetFlyFormat(); + const SwFrameFormat *pFrameFormat = pAnchorNode->GetFlyFormat(); if( pFrameFormat ) { OutCSS1_FrameFormatBackground( *pFrameFormat ); diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index f39721763d56..2cf3c6894ec1 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -297,7 +297,7 @@ void SwHTMLWriter::CollectFlyFrames() { const SwFrameFormat& rFrameFormat = rItem.GetFormat(); const SdrObject *pSdrObj = nullptr; - const SwPosition *pAPos; + const SwNode *pAnchorNode; const SwContentNode *pACNd; SwHTMLFrameType eType = static_cast<SwHTMLFrameType>(GuessFrameType( rFrameFormat, pSdrObj )); @@ -316,8 +316,8 @@ void SwHTMLWriter::CollectFlyFrames() // before the paragraph, if the paragraph has a // spacing. if( text::RelOrientation::FRAME == eHoriRel && - (pAPos = rAnchor.GetContentAnchor()) != nullptr && - (pACNd = pAPos->GetNode().GetContentNode()) != nullptr ) + (pAnchorNode = rAnchor.GetAnchorNode()) != nullptr && + (pACNd = pAnchorNode->GetContentNode()) != nullptr ) { const SvxLRSpaceItem& rLRItem = pACNd->GetAttr(RES_LR_SPACE); diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index eeeb65d2aeff..e264ec609b24 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -515,9 +515,9 @@ void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height ) SwFrameFormat *pFrameFormat = pSwShape->GetFrameFormat(); const SwDoc *pDoc = pFrameFormat->GetDoc(); - const SwPosition* pAPos = pFrameFormat->GetAnchor().GetContentAnchor(); + SwNode* pAnchorNode = pFrameFormat->GetAnchor().GetAnchorNode(); SwTableNode *pTableNd; - if (pAPos && nullptr != (pTableNd = pAPos->GetNode().FindTableNode())) + if (pAnchorNode && nullptr != (pTableNd = pAnchorNode->FindTableNode())) { const bool bLastGrf = !pTableNd->GetTable().DecGrfsThatResize(); SwHTMLTableLayout *pLayout = diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index d7104251e6fe..9bad5a4cbc8f 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -1327,8 +1327,8 @@ void SwHTMLWriter::GetControls() continue; const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor(); - const SwPosition *pPos = rAnchor.GetContentAnchor(); - if ((RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId()) || !pPos) + const SwNode *pAnchorNode = rAnchor.GetAnchorNode(); + if ((RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId()) || !pAnchorNode) continue; const SdrObject *pSdrObj = @@ -1336,7 +1336,7 @@ void SwHTMLWriter::GetControls() if( !pSdrObj ) continue; - AddControl( m_aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj), pPos->GetNodeIndex() ); + AddControl( m_aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj), pAnchorNode->GetIndex() ); } } diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 492319a598bb..840a80962293 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -1461,11 +1461,11 @@ void SwHTMLParser::StripTrailingPara() for( auto pFormat : rFrameFormatTable ) { SwFormatAnchor const*const pAnchor = &pFormat->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())) && - pAPos->GetNodeIndex() == nNodeIdx ) + pAnchorNode->GetIndex() == nNodeIdx ) return; // we can't delete the node } diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index 11e2ecbd5bc5..3f7f03f19d3c 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -2423,8 +2423,8 @@ void HTMLTable::MakeTable( SwTableBox *pBox, sal_uInt16 nAbsAvail, // left or right adjusted table without width mustn't be adjusted in width // as they would only shrink but never grow m_xLayoutInfo->SetMustNotRecalc( true ); - if( m_pContext->GetFrameFormat()->GetAnchor().GetContentAnchor() - ->GetNode().FindTableNode() ) + if( m_pContext->GetFrameFormat()->GetAnchor().GetAnchorNode() + ->FindTableNode() ) { sal_uInt32 nMax = m_xLayoutInfo->GetMax(); if( nMax > USHRT_MAX ) @@ -4917,13 +4917,13 @@ void SwHTMLParser::ClearFootnotesMarksInRange(const SwNodeIndex& rMkNdIdx, const { SwFrameFormat *pFormat = rTable[--i]; const SwFormatAnchor &rAnch = pFormat->GetAnchor(); - SwPosition const*const pAPos = rAnch.GetContentAnchor(); - if (pAPos && + SwNode const*const pAnchorNode = rAnch.GetAnchorNode(); + if (pAnchorNode && ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA) || (rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR)) && - ( rMkNdIdx < pAPos->GetNode() && pAPos->GetNode() <= rPtNdIdx.GetNode() )) + ( rMkNdIdx < *pAnchorNode && *pAnchorNode <= rPtNdIdx.GetNode() )) { - if( rPtNdIdx != pAPos->GetNode() ) + if( rPtNdIdx != *pAnchorNode ) { // If the Fly is deleted, all Flys in its content have to be deleted too. const SwFormatContent &rContent = pFormat->GetContent(); diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 8b14ceb70b79..61be965848e6 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -114,7 +114,7 @@ namespace { const SwFrameFormat &rEntry = rFly.GetFormat(); - if (const SwPosition* pAnchor = rEntry.GetAnchor().GetContentAnchor()) + if (const SwNode* pAnchor = rEntry.GetAnchor().GetAnchorNode()) { // the anchor position will be invalidated by SetRedlineFlags // so set a dummy position and fix it in UpdateFramePositions diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 0bd3f19388ca..66b4aa8fe450 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -2394,11 +2394,11 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri, // break before" attribute bool bConvDueToAnchoredAtColBreakPara( false ); if ( ( (eAnchor == RndStdIds::FLY_AT_PARA) || (eAnchor == RndStdIds::FLY_AT_CHAR) ) && - _rFrameFormat.GetAnchor().GetContentAnchor() && - _rFrameFormat.GetAnchor().GetContentAnchor()->GetNode().IsTextNode() ) + _rFrameFormat.GetAnchor().GetAnchorNode() && + _rFrameFormat.GetAnchor().GetAnchorNode()->IsTextNode() ) { SwTextNode& rAnchorTextNode = - dynamic_cast<SwTextNode&>(_rFrameFormat.GetAnchor().GetContentAnchor()->GetNode()); + dynamic_cast<SwTextNode&>(*_rFrameFormat.GetAnchor().GetAnchorNode()); const SvxFormatBreakItem& rBreak = rAnchorTextNode.GetAttr(RES_BREAK); if (rBreak.GetBreak() == SvxBreak::ColumnBefore) { diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 927ed91bf876..a173a2014c4b 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1671,9 +1671,9 @@ SvxFrameDirection MSWordExportBase::TrueFrameDirection( const SwFrameFormat &rFl 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; @@ -1724,10 +1724,10 @@ std::shared_ptr<SvxBrushItem> WW8Export::TrueFrameBgBrush(const SwFrameFormat &r pRet = nullptr; const SwFormatAnchor* pAnchor = &pFlyFormat->GetAnchor(); if ((RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId()) && - pAnchor->GetContentAnchor()) + pAnchor->GetAnchorNode()) { pFlyFormat = - pAnchor->GetContentAnchor()->GetNode().GetFlyFormat(); + pAnchor->GetAnchorNode()->GetFlyFormat(); } else pFlyFormat = nullptr; @@ -3444,7 +3444,7 @@ void WW8AttributeOutput::OutputFlyFrame_Impl( const ww8::Frame& rFormat, const P if ( !m_rWW8Export.IsInTable() && rFormat.IsInline() ) { //Test to see if this textbox contains only a single graphic/ole - SwTextNode* pParTextNode = rAnch.GetContentAnchor()->GetNode().GetTextNode(); + SwTextNode* pParTextNode = rAnch.GetAnchorNode()->GetTextNode(); if ( pParTextNode && !m_rWW8Export.m_rDoc.GetNodes()[ nStt ]->IsNoTextNode() ) bDone = true; } @@ -3457,7 +3457,7 @@ void WW8AttributeOutput::OutputFlyFrame_Impl( const ww8::Frame& rFormat, const P if ( m_rWW8Export.m_pParentFrame ) { /* Munge flys in fly into absolutely positioned elements for word 6 */ - const SwTextNode* pParTextNode = rAnch.GetContentAnchor()->GetNode().GetTextNode(); + const SwTextNode* pParTextNode = rAnch.GetAnchorNode()->GetTextNode(); const SwRect aPageRect = pParTextNode->FindPageFrameRect(); aOffset = rFrameFormat.FindLayoutRect().Pos(); diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index 2ad84960dcb1..7e5d3ddd70e8 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -66,11 +66,11 @@ bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc, SwNode const &rIdx) RES_DRAWFRMFMT != pFrameFormat->Which() ) continue; const SwFormatAnchor& rAnchor = pFrameFormat->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_CHAR == rAnchor.GetAnchorId())) && - rIdx == pAPos->GetNode() ) + rIdx == *pAnchorNode ) { bRet=true; break; diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 08b7e8017a46..8b842557e8e4 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -2389,9 +2389,9 @@ void WW8TabDesc::CreateSwTable() ? m_pIo->m_xFormatOfJustInsertedApo->GetFormat() : nullptr; if (pFormat) { - const SwPosition* pAPos = - pFormat->GetAnchor().GetContentAnchor(); - if (pAPos && pAPos->GetNode() == pPoint->GetNode()) + const SwNode* pAnchorNode = + pFormat->GetAnchor().GetAnchorNode(); + if (pAnchorNode && *pAnchorNode == pPoint->GetNode()) { bInsNode = true; bSetMinHeight = true; diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 5b7b008129b5..268ddd5cdf25 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -597,7 +597,7 @@ static auto RecursiveContains(SwStartNode const& rRedlineSection, SwNode const& } else if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_FLY) { // anchor is on a start node, avoid skipping it: - pStartNode = rAnchor.GetContentAnchor()->GetNode().GetStartNode(); + pStartNode = rAnchor.GetAnchorNode()->GetStartNode(); assert(pStartNode); // pass the next node to recursive call - it will call // call StartOfSectionNode on it and go back to pStartNode @@ -606,7 +606,7 @@ static auto RecursiveContains(SwStartNode const& rRedlineSection, SwNode const& } else { - return RecursiveContains(rRedlineSection, rAnchor.GetContentAnchor()->GetNode()); + return RecursiveContains(rRedlineSection, *rAnchor.GetAnchorNode()); } } break; diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx index e66797a7086d..ad49d66e58bf 100644 --- a/sw/source/uibase/wrtsh/delete.cxx +++ b/sw/source/uibase/wrtsh/delete.cxx @@ -443,7 +443,7 @@ bool SwWrtShell::DelRight(bool const isReplaceHeuristic) eAnchorId = pFormat->GetAnchor().GetAnchorId(); } if ((eAnchorId == RndStdIds::FLY_AS_CHAR || eAnchorId == RndStdIds::FLY_AT_CHAR) - && pFormat->GetAnchor().GetContentAnchor()) + && pFormat->GetAnchor().GetAnchorNode()) { oAnchor.emplace(*pFormat->GetAnchor().GetContentAnchor()); // set cursor before the anchor point