sw/source/core/doc/doclay.cxx | 46 ++++++++---------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-)
New commits: commit 09a05c78d5a430ad229c6160261bdff1065be699 Author: Michael Stahl <[email protected]> AuthorDate: Tue Nov 4 14:38:32 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Sat Nov 29 15:18:35 2025 +0100 sw: fix SwDoc::IsInHeaderFooter() with flys If the node is in a fly, this can only print: sw/source/core/doc/doclay.cxx:1619: Found a FlySection but not a Format! This is a regression from commit e07feb9457f2ffb373ae69b73dda290140e4005f which used the wrong node's anchored objects: of course the fly is never anchored to itself, so this will never find anything. It turns out that there is already a function SwNode::GetFlyFormat() that can do most of the work, even using the layout to speed it up, so just use that to get the anchor. Change-Id: I7a22231f929175ed7c5c11724882b03890781cfc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193476 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193531 Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index b6ceedb74674..1e185b2d22dd 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1576,48 +1576,20 @@ bool SwDoc::IsInHeaderFooter( const SwNode& rIdx ) const const SwNode* pFlyNd = pNd->FindFlyStartNode(); while( pFlyNd ) { - // get up by using the Anchor -#if OSL_DEBUG_LEVEL > 0 - std::vector<const SwFrameFormat*> checkFormats; - for(sw::SpzFrameFormat* pFormat: *GetSpzFrameFormats()) - { - const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx(); - if( pIdx && pFlyNd == &pIdx->GetNode() ) - checkFormats.push_back( pFormat ); - } -#endif - std::vector<SwFrameFormat*> const & rFlys(pFlyNd->GetAnchoredFlys()); - bool bFound(false); - for (size_t i = 0; i < rFlys.size(); ++i) + // go up by using the Anchor + SwFormatAnchor const& rAnchor{pNd->GetFlyFormat()->GetAnchor()}; + if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE) { - const SwFrameFormat *const pFormat = rFlys[i]; - const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx(); - if( pIdx && pFlyNd == &pIdx->GetNode() ) - { -#if OSL_DEBUG_LEVEL > 0 - auto checkPos = std::find( - checkFormats.begin(), checkFormats.end(), pFormat ); - assert( checkPos != checkFormats.end()); - checkFormats.erase( checkPos ); -#endif - const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); - if ((RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId()) || - !rAnchor.GetAnchorNode() ) - { - return false; - } - - pNd = rAnchor.GetAnchorNode(); - pFlyNd = pNd->FindFlyStartNode(); - bFound = true; - break; - } + return false; } - if (!bFound) + if (rAnchor.GetAnchorNode() == nullptr) { - OSL_ENSURE(mbInReading, "Found a FlySection but not a Format!"); + assert(mbInReading); return false; } + assert(pNd != rAnchor.GetAnchorNode()); + pNd = rAnchor.GetAnchorNode(); + pFlyNd = pNd->FindFlyStartNode(); } return nullptr != pNd->FindHeaderStartNode() ||
