diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 4bd31c4fb3dc..6ea91ee1c727 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 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) @@ -1908,12 +1910,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(pLay)); } if ( pActualSection ) { @@ -1948,11 +1946,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 @@ -2025,6 +2019,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 );