sw/source/core/layout/frmtool.cxx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
New commits: commit 6318d977fc9d8a4b5f9d84a88d3161638ad56177 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Sep 5 15:19:13 2024 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Sep 5 20:31:54 2024 +0200 sw: fix hiding of flys in hidden sections, part 2 Didn't notice that this depends on a global variable "bObjsDirect" so it only works for some documents; move the HideAndShowObjects() call to the end so it works in all cases. (follow-up to commit 8a13277f797c6e2f1b0d9060ad6e5e4d72eb76d0) Change-Id: I26a7cecdb660179f3ac1c3ea1e5d19067806b741 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172915 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins (cherry picked from commit e2f3ba12c238c895dfd61ad09fcd76789ebbfd53) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172901 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index e89274dad0bb..0a7f5ae16456 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1587,6 +1587,8 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc, //the SwActualSection class has a member, which points to an upper(section). //When the "inner" section finishes, the upper will used instead. + std::vector<SwSectionFrame *> newHiddenSections; + // Do not consider the end node. The caller (Section/MakeFrames()) has to // ensure that the end of this range is positioned before EndIndex! for ( ; nEndIndex == SwNodeOffset(0) || nIndex < nEndIndex; ++nIndex) @@ -1907,12 +1909,8 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc, pActualSection.reset(pActualSection->GetUpper()); pLay = pLay->FindSctFrame(); if (pLay->IsHiddenNow()) - { // flys were created visible - for (SwFlowFrame * pSect = SwFlowFrame::CastFlowFrame(pLay); - pSect; pSect = pSect->GetPrecede()) - { // flys were created visible - pSect->GetFrame().HideAndShowObjects(); - } + { + newHiddenSections.push_back(static_cast<SwSectionFrame*>(pLay)); } if ( pActualSection ) { @@ -1947,11 +1945,7 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc, } else if (pOuterSectionFrame->IsHiddenNow()) { - for (SwFlowFrame * pSect = SwFlowFrame::CastFlowFrame(pOuterSectionFrame); - pSect; pSect = pSect->GetPrecede()) - { // flys were created visible - pSect->GetFrame().HideAndShowObjects(); - } + newHiddenSections.push_back(pOuterSectionFrame); } } else @@ -2024,6 +2018,15 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc, bObjsDirect = true; } + // do it after AppendAllObjs() + for (SwSectionFrame * pNew : newHiddenSections) + { + for (SwFlowFrame * pSect = pNew; pSect; pSect = pSect->GetPrecede()) + { // flys were created visible; section may be paginated so iterate + pSect->GetFrame().HideAndShowObjects(); + } + } + if( pPageMaker ) { pPageMaker->CheckFlyCache( pPage );