From 9a2d15d3358816043016af79588e0eb3bb2fa5ef Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 25 Nov 2022 14:43:21 +0200 Subject: 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 --- sw/source/filter/html/htmlfly.cxx | 4 ++-- sw/source/filter/html/swhtml.cxx | 11 +++++------ sw/source/filter/ww8/docxattributeoutput.cxx | 14 +++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'sw/source/filter') 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 -- cgit v1.2.3