sw/source/core/layout/frmtool.cxx |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

New commits:
commit e2f3ba12c238c895dfd61ad09fcd76789ebbfd53
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Sep 5 15:19:13 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Sep 5 17:24:23 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

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<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)
@@ -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<SwSectionFrame*>(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 );

Reply via email to