sw/source/core/layout/sectfrm.cxx | 69 ++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 31 deletions(-)
New commits: commit bb6ad4cd2815e071b8ae177a482dd3054e18ba3a Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Sep 5 18:19:44 2024 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Sep 6 14:11:29 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 (cherry picked from commit c647937e6066fb911b8ddc5a77b2621d5cb874e4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172904 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index 953d55073676..a7dbf0e02be5 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -2671,6 +2671,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()); @@ -2732,35 +2750,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()) @@ -2789,8 +2780,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();