diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-11-25 14:43:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-11-26 07:13:38 +0100 |
commit | 9a2d15d3358816043016af79588e0eb3bb2fa5ef (patch) | |
tree | 35c751597726097d767cbd6f5d8bf4a663148155 /sw | |
parent | cb7153403a55a0e565584aedd8a4dc8da149b08c (diff) |
use more SwFormatAnchor::GetAnchorNode method
as a step towards switching away from using SwPosition inside
SwFormatAnchor (because SwFormatAnchor wants to do weird stuff with the
internals of SwPosition)
Change-Id: I1cdbe2fc6623d8fe2bb0c1bc629b570ca4d0cb0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143298
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/layout/frmtool.cxx | 44 | ||||
-rw-r--r-- | sw/source/filter/html/htmlfly.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/html/swhtml.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 17 |
5 files changed, 45 insertions, 45 deletions
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 93f02c5bf756..7f04626a6b03 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -960,12 +960,12 @@ void SwContentNotify::ImplDestroy() SwFrameFormat *pFormat = (*pTable)[i]; const SwFormatAnchor &rAnch = pFormat->GetAnchor(); if ( RndStdIds::FLY_AT_PAGE != rAnch.GetAnchorId() || - rAnch.GetContentAnchor() == nullptr ) + rAnch.GetAnchorNode() == nullptr ) { continue; } - if (FrameContainsNode(*pCnt, rAnch.GetContentAnchor()->GetNodeIndex())) + if (FrameContainsNode(*pCnt, rAnch.GetAnchorNode()->GetIndex())) { OSL_FAIL( "<SwContentNotify::~SwContentNotify()> - to page anchored object with content position." ); if ( !pPage ) @@ -1102,8 +1102,8 @@ static bool IsShown(SwNodeOffset const nIndex, SwTextNode const*const pFirstNode, SwTextNode const*const pLastNode) { assert(!pIter || *pIter == *pEnd || (*pIter)->pNode->GetIndex() == nIndex); - SwPosition const& rAnchor(*rAnch.GetContentAnchor()); - if (rAnchor.GetNodeIndex() != nIndex) + SwNode* pAnchorNode = rAnch.GetAnchorNode(); + if (pAnchorNode->GetIndex() != nIndex) { return false; } @@ -1111,7 +1111,7 @@ static bool IsShown(SwNodeOffset const nIndex, { return pIter == nullptr // not merged || pIter != pEnd // at least one char visible in node - || !IsSelectFrameAnchoredAtPara(rAnchor, + || !IsSelectFrameAnchoredAtPara(*rAnch.GetContentAnchor(), SwPosition(*pFirstNode, 0), SwPosition(*pLastNode, pLastNode->Len())); } @@ -1126,7 +1126,7 @@ static bool IsShown(SwNodeOffset const nIndex, { assert(iter->nStart != iter->nEnd); // TODO possible? assert(iter->pNode->GetIndex() == nIndex); - if (rAnchor.GetContentIndex() < iter->nStart) + if (rAnch.GetContentAnchor()->GetContentIndex() < 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 (rAnchor.GetContentIndex() <= iter->nEnd) + if (rAnch.GetContentAnchor()->GetContentIndex() <= iter->nEnd) { if (iter->nStart == 0) { @@ -1162,7 +1162,7 @@ static bool IsShown(SwNodeOffset const nIndex, : pFirstNode->Len() // previous node; simplification but should get right result : (iter-1)->nEnd); // previous extent SwPosition const end(*iter->pNode, iter->nStart); - return !IsDestroyFrameAnchoredAtChar(rAnchor, start, end); + return !IsDestroyFrameAnchoredAtChar(*rAnch.GetContentAnchor(), start, end); } } else if (iter == *pEnd - 1) // special case: after last extent @@ -1179,7 +1179,7 @@ static bool IsShown(SwNodeOffset const nIndex, iter->pNode == pLastNode ? iter->pNode->Len() : 0); - return !IsDestroyFrameAnchoredAtChar(rAnchor, start, end); + return !IsDestroyFrameAnchoredAtChar(*rAnch.GetContentAnchor(), start, end); } } } @@ -1187,7 +1187,7 @@ static bool IsShown(SwNodeOffset const nIndex, { assert(rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR); // for AS_CHAR obviously must be < - if (rAnchor.GetContentIndex() < iter->nEnd) + if (rAnch.GetContentAnchor()->GetContentIndex() < iter->nEnd) { return true; } @@ -1213,7 +1213,7 @@ void RemoveHiddenObjsOfNode(SwTextNode const& rNode, if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR || rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR) { - assert(rAnchor.GetContentAnchor()->GetNodeIndex() == rNode.GetIndex()); + assert(rAnchor.GetAnchorNode()->GetIndex() == rNode.GetIndex()); if (!IsShown(rNode.GetIndex(), rAnchor, pIter, pEnd, pFirstNode, pLastNode)) { pFrameFormat->DelFrames(); @@ -1234,7 +1234,7 @@ void AppendObjsOfNode(SwFrameFormats const*const pTable, SwNodeOffset const nInd { SwFrameFormat *pFormat = (*pTable)[i]; const SwFormatAnchor &rAnch = pFormat->GetAnchor(); - if ( rAnch.GetContentAnchor() && + if ( rAnch.GetAnchorNode() && IsShown(nIndex, rAnch, pIter, pEnd, pFirstNode, pLastNode)) { checkFormats.push_back( pFormat ); @@ -1250,7 +1250,7 @@ void AppendObjsOfNode(SwFrameFormats const*const pTable, SwNodeOffset const nInd { SwFrameFormat *const pFormat = rFlys[it]; const SwFormatAnchor &rAnch = pFormat->GetAnchor(); - if ( rAnch.GetContentAnchor() && + if ( rAnch.GetAnchorNode() && IsShown(nIndex, rAnch, pIter, pEnd, pFirstNode, pLastNode)) { #if OSL_DEBUG_LEVEL > 0 @@ -1329,18 +1329,18 @@ bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor if (auto const pMergedPara = rFrame.GetMergedPara()) { ret = false; - auto const pAnchor(rAnchor.GetContentAnchor()); + SwNode* pAnchorNode(rAnchor.GetAnchorNode()); auto iterFirst(pMergedPara->extents.cbegin()); if (iterFirst == pMergedPara->extents.end() && (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA || rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR)) { - ret = (&pAnchor->GetNode() == pMergedPara->pFirstNode + ret = (pAnchorNode == pMergedPara->pFirstNode && (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA - || pAnchor->GetContentIndex() == 0)) - || (&pAnchor->GetNode() == pMergedPara->pLastNode + || rAnchor.GetContentAnchor()->GetContentIndex() == 0)) + || (pAnchorNode == pMergedPara->pLastNode && (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA - || pAnchor->GetContentIndex() == pMergedPara->pLastNode->Len())); + || rAnchor.GetContentAnchor()->GetContentIndex() == pMergedPara->pLastNode->Len())); } auto iter(iterFirst); SwTextNode const* pNode(pMergedPara->pFirstNode); @@ -1350,7 +1350,7 @@ bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor || iter->pNode != pNode) { assert(pNode->GetRedlineMergeFlag() != SwNode::Merge::Hidden); - if (pNode == &pAnchor->GetNode()) + if (pNode == pAnchorNode) { ret = IsShown(pNode->GetIndex(), rAnchor, &iterFirst, &iter, pMergedPara->pFirstNode, pMergedPara->pLastNode); @@ -1361,7 +1361,7 @@ bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor break; } pNode = iter->pNode; - if (pAnchor->GetNodeIndex() < pNode->GetIndex()) + if (pAnchorNode->GetIndex() < pNode->GetIndex()) { break; } @@ -1385,9 +1385,9 @@ void AppendAllObjs(const SwFrameFormats* pTable, const SwFrame* pSib) // frames nor objects which are anchored to character bounds. if ((rAnch.GetAnchorId() != RndStdIds::FLY_AT_PAGE) && (rAnch.GetAnchorId() != RndStdIds::FLY_AS_CHAR)) { - const SwPosition* pContentAnchor = rAnch.GetContentAnchor(); + const SwNode* pAnchorNode = rAnch.GetAnchorNode(); // formats in header/footer have no dependencies - if(pContentAnchor && pFormat->GetDoc()->IsInHeaderFooter(pContentAnchor->GetNode())) + if(pAnchorNode && pFormat->GetDoc()->IsInHeaderFooter(*pAnchorNode)) pFormat->MakeFrames(); else vFormatsToConnect.push_back(pFormat); diff --git a/sw/source/filter/html/htmlfly.cxx b/sw/source/filter/html/htmlfly.cxx index 2c50a4de78bc..f76f1d536888 100644 --- a/sw/source/filter/html/htmlfly.cxx +++ b/sw/source/filter/html/htmlfly.cxx @@ -47,8 +47,8 @@ SwHTMLPosFlyFrame::SwHTMLPosFlyFrame( const SwPosFlyFrame& rPosFly, // Output of auto-bound frames will be a character farther back, // because then the position aligns with Netscape. - OSL_ENSURE( rAnchor.GetContentAnchor(), "No anchor position?" ); - if( !rAnchor.GetContentAnchor() ) + OSL_ENSURE( rAnchor.GetAnchorNode(), "No anchor position?" ); + if( !rAnchor.GetAnchorNode() ) return; m_nContentIndex = rAnchor.GetContentAnchor()->GetContentIndex(); diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index f9f0e7f59bd7..6f9c71494461 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -3012,8 +3012,7 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable, const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor(); OSL_ENSURE( RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId(), "Only At-Para flys need special handling" ); - const SwPosition *pFlyPos = rAnchor.GetContentAnchor(); - SwNodeOffset nFlyParaIdx = pFlyPos->GetNodeIndex(); + SwNodeOffset nFlyParaIdx = rAnchor.GetAnchorNode()->GetIndex(); bool bMoveFly; if( bChkEnd ) { @@ -3031,7 +3030,7 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable, if( bMoveFly ) { pFrameFormat->DelFrames(); - *aAttrPam.GetPoint() = *pFlyPos; + *aAttrPam.GetPoint() = *rAnchor.GetContentAnchor(); aAttrPam.GetPoint()->SetContent( m_aMoveFlyCnts[n] ); SwFormatAnchor aAnchor( rAnchor ); aAnchor.SetType( RndStdIds::FLY_AT_CHAR ); @@ -4561,11 +4560,11 @@ bool SwHTMLParser::HasCurrentParaFlys( bool bNoSurroundOnly, // - every paragraph-bound frame counts, or // - (only frames without wrapping count and) the frame doesn't have // a wrapping - 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->GetNode() == rNode ) + *pAnchorNode == rNode ) { if( !(bNoSurroundOnly || bSurroundOnly) ) { diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index e245b22caf4a..6a01be448df8 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -372,12 +372,12 @@ static void checkAndWriteFloatingTables(DocxAttributeOutput& rDocxAttributeOutpu { const SwFrameFormat* pFrameFormat = (*rExport.m_rDoc.GetSpzFrameFormats())[ --nCnt ]; const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor(); - const SwPosition* pPosition = rAnchor.GetContentAnchor(); + const SwNode* pAnchorNode = rAnchor.GetAnchorNode(); - if (!pPosition || ! rExport.m_pCurPam->GetPointNode().GetTextNode()) + if (!pAnchorNode || ! rExport.m_pCurPam->GetPointNode().GetTextNode()) continue; - if (pPosition->GetNode() != *rExport.m_pCurPam->GetPointNode().GetTextNode()) + if (*pAnchorNode != *rExport.m_pCurPam->GetPointNode().GetTextNode()) continue; const SwNodeIndex* pStartNode = pFrameFormat->GetContent().GetContentIdx(); @@ -412,7 +412,7 @@ static void checkAndWriteFloatingTables(DocxAttributeOutput& rDocxAttributeOutpu continue; // write table to docx - ww8::Frame aFrame(*pFrameFormat,*pPosition); + ww8::Frame aFrame(*pFrameFormat, *rAnchor.GetContentAnchor()); rDocxAttributeOutput.WriteFloatingTable(&aFrame); } } @@ -6697,11 +6697,11 @@ void DocxAttributeOutput::WriteFlyFrame(const ww8::Frame& rFrame) //If we have a formula with inline anchor... if(SotExchange::IsMath(xObj->getClassID()) && rFrame.IsInline()) { - SwPosition const* const aAPos = rFrameFormat.GetAnchor().GetContentAnchor(); - if(aAPos) + SwNode const* const pAnchorNode = rFrameFormat.GetAnchor().GetAnchorNode(); + if(pAnchorNode) { //Get the text node what the formula anchored to - const SwTextNode* pTextNode = aAPos->GetNode().GetTextNode(); + const SwTextNode* pTextNode = pAnchorNode->GetTextNode(); if(pTextNode && pTextNode->Len() == 1) { //Get the paragraph alignment diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 5aa8bb75fe51..0ffec86f5ed0 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -1553,14 +1553,15 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt) // See if the fly frame's anchor is in a content control. If so, // try to interact with it. const SwFormatAnchor& rFormatAnchor = pFlyFormat->GetAnchor(); - const SwPosition* pAnchorPos = rFormatAnchor.GetContentAnchor(); - if (pAnchorPos) + SwNode* pAnchorNode = rFormatAnchor.GetAnchorNode(); + if (pAnchorNode) { - SwTextNode* pTextNode = pAnchorPos->GetNode().GetTextNode(); + SwTextNode* pTextNode = pAnchorNode->GetTextNode(); if (pTextNode) { + sal_Int32 nContentIdx = rFormatAnchor.GetContentAnchor()->GetContentIndex(); SwTextAttr* pAttr = pTextNode->GetTextAttrAt( - pAnchorPos->GetContentIndex(), RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Parent); + nContentIdx, RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Parent); if (pAttr) { SwTextContentControl* pTextContentControl @@ -4813,14 +4814,14 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) // See if the fly frame's anchor is in a content control. If so, // interact with it. const SwFormatAnchor& rFormatAnchor = pFlyFormat->GetAnchor(); - const SwPosition* pAnchorPos = rFormatAnchor.GetContentAnchor(); - if (pAnchorPos) + SwNode* pAnchorNode = rFormatAnchor.GetAnchorNode(); + if (pAnchorNode) { - SwTextNode* pTextNode = pAnchorPos->GetNode().GetTextNode(); + SwTextNode* pTextNode = pAnchorNode->GetTextNode(); if (pTextNode) { SwTextAttr* pAttr = pTextNode->GetTextAttrAt( - pAnchorPos->GetContentIndex(), RES_TXTATR_CONTENTCONTROL, + rFormatAnchor.GetContentAnchor()->GetContentIndex(), RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Parent); if (pAttr) { |