sw/source/core/layout/sectfrm.cxx |   69 ++++++++++++++++++++------------------
 1 file changed, 38 insertions(+), 31 deletions(-)

New commits:
commit c647937e6066fb911b8ddc5a77b2621d5cb874e4
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Sep 5 18:19:44 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Sep 6 09:53:51 2024 +0200

    sw: fix problem with 0-height tables after unhiding section
    
    Mysteriously this works the first time the section is made visible, but
    then hide it again and unhide it and a table has height 0 because only
    the table itself is invalidated and none of the text frames inside it.
    
    SwTabFrame::MakeAll() does Prepare(PrepareHint::FramePositionChanged) on
    all contained text frames, but that may actually do nothing in common
    cases.
    
    So just recursively invalidate everything in the section, that should
    fix things.
    
    (regression from commit ff7f1b59e22092d8548459e75fe912db852f056f)
    
    Change-Id: I26e72193947685fde52fb8da78e95592a3866c12
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172920
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins

diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index ceab3099a257..92d1e1bde1b5 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -2680,6 +2680,24 @@ void SwSectionFrame::CalcEndAtEndFlag()
     }
 }
 
+static void InvalidateFramesInSection(SwFrame * pFrame)
+{
+    while (pFrame)
+    {
+        pFrame->InvalidateAll();
+        pFrame->InvalidateObjs(false);
+        if (pFrame->IsLayoutFrame())
+        {
+            InvalidateFramesInSection(pFrame->GetLower());
+        }
+        else if (pFrame->IsTextFrame())
+        {
+            pFrame->Prepare(PrepareHint::Clear, nullptr, false);
+        }
+        pFrame = pFrame->GetNext();
+    }
+}
+
 void SwSectionFrame::Notify(SfxHint const& rHint)
 {
     SwSectionFormat *const pFormat(GetSection()->GetFormat());
@@ -2742,35 +2760,8 @@ void SwSectionFrame::SwClientNotify(const SwModify& 
rMod, const SfxHint& rHint)
             SwRectFnSet(this).SetHeight(area, HUGE_POSITIVE);
         }
 
-        SwColumnFrame * pColumn{Lower()->IsColumnFrame()
-                ? static_cast<SwColumnFrame*>(Lower()) : nullptr};
-        auto IterateLower = [&pColumn](SwFrame *const pLowerFrame) -> SwFrame*
-        {
-            if (pLowerFrame->GetNext())
-            {
-                return pLowerFrame->GetNext();
-            }
-            if (pColumn)
-            {
-                pColumn = static_cast<SwColumnFrame*>(pColumn->GetNext());
-                if (pColumn)
-                {
-                    return 
static_cast<SwLayoutFrame*>(pColumn->Lower())->Lower();
-                }
-            }
-            return nullptr;
-        };
-        for (SwFrame* pLowerFrame = pColumn
-                    ? static_cast<SwLayoutFrame*>(pColumn->Lower())->Lower()
-                    : Lower();
-             pLowerFrame;
-             pLowerFrame = IterateLower(pLowerFrame))
-        {
-            pLowerFrame->Prepare(PrepareHint::Clear, nullptr, false);
-            pLowerFrame->InvalidateAll();
-            pLowerFrame->InvalidateObjs(false);
-            pLowerFrame->HideAndShowObjects();
-        }
+        InvalidateFramesInSection(Lower());
+        Lower()->HideAndShowObjects(); // recursive
         // Check if any page-breaks have been unhidden, create the new pages.
         // Call IsHiddenNow() because a parent section could still hide.
         if (!IsFollow() && IsInDocBody() && !IsInTab() && !IsHiddenNow())
@@ -2799,8 +2790,24 @@ void SwSectionFrame::SwClientNotify(const SwModify& 
rMod, const SfxHint& rHint)
                 pFirstOnPage = pFirstOnPage->GetUpper();
             }
             assert(pFirstOnPage->IsContentFrame() || 
pFirstOnPage->IsTabFrame());
-            pColumn = Lower()->IsColumnFrame()
-                ? static_cast<SwColumnFrame*>(Lower()) : nullptr;
+            SwColumnFrame * pColumn{Lower()->IsColumnFrame()
+                    ? static_cast<SwColumnFrame*>(Lower()) : nullptr};
+            auto IterateLower = [&pColumn](SwFrame *const pLowerFrame) -> 
SwFrame*
+            {
+                if (pLowerFrame->GetNext())
+                {
+                    return pLowerFrame->GetNext();
+                }
+                if (pColumn)
+                {
+                    pColumn = static_cast<SwColumnFrame*>(pColumn->GetNext());
+                    if (pColumn)
+                    {
+                        return 
static_cast<SwLayoutFrame*>(pColumn->Lower())->Lower();
+                    }
+                }
+                return nullptr;
+            };
             for (SwFrame* pLowerFrame = pColumn
                         ? 
static_cast<SwLayoutFrame*>(pColumn->Lower())->Lower()
                         : Lower();

Reply via email to