sw/source/core/layout/trvlfrm.cxx | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-)
New commits: commit a11d059702b349f2ca520414b73785b127e8837a Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Sep 12 17:15:06 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Sep 12 18:53:11 2025 +0200 Related: tdf#168355 Optimize the fix Inspired by the code I found in sw::HasPageBreakBefore, the change finds the frame that may provide the page description information once. Change-Id: Ie16b93d97e5a32e2991d68aa9c605fc0a411c1f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190873 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 77aadac373f6..399a6ac9249a 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -1868,15 +1868,19 @@ Point SwFrame::GetRelPos() const return aRet; } +// See also: sw::HasPageBreakBefore and SwFEShell::GetPageOffset static const SwFrame* lcl_FindStartOfVirtualPages(const SwPageFrame *pPage) { const SwPageFrame* pPageFrameIter = pPage; while (pPageFrameIter) { - const SwContentFrame* pContentFrame = pPageFrameIter->FindFirstBodyContent(); - if (pContentFrame) + if (const SwFrame* pFlow = pPageFrameIter->FindFirstBodyContent()) { - const SwFormatPageDesc& rFormatPageDesc = pContentFrame->GetPageDescItem(); + // Since pFlow is obtained from pPageFrameIter->FindFirstBodyContent(), + // it (and every upper table frame) must have valid upper. + while (const SwFrame* pTable = pFlow->GetUpper()->FindTabFrame()) + pFlow = pTable; + const SwFormatPageDesc& rFormatPageDesc = pFlow->GetPageDescItem(); if ( rFormatPageDesc.GetNumOffset() && rFormatPageDesc.GetDefinedIn() ) { @@ -1888,29 +1892,6 @@ static const SwFrame* lcl_FindStartOfVirtualPages(const SwPageFrame *pPage) return aHint.GetFrame(); } } - // might have to search tables too, they may set page number in their text flow properties - const SwLayoutFrame* pParentFrame = pContentFrame->GetUpper(); - while (pParentFrame) - { - if (const SwTabFrame* pTabFrame = pParentFrame->FindTabFrame()) - if (const SwTable* pTable = pTabFrame->GetTable()) - if (const SwTableFormat* pTableFormat = pTable->GetFrameFormat()) - { - const SwFormatPageDesc& rFormatPageDesc2 = pTableFormat->GetPageDesc(); - - if ( rFormatPageDesc2.GetNumOffset() && rFormatPageDesc2.GetDefinedIn() ) - { - const sw::BroadcastingModify* pMod = rFormatPageDesc2.GetDefinedIn(); - sw::VirtPageNumHint aHint(pPage); - pMod->CallSwClientNotify(aHint); - if(aHint.GetPage()) - { - return aHint.GetFrame(); - } - } - } - pParentFrame = pParentFrame->GetUpper(); - } } pPageFrameIter = static_cast<const SwPageFrame*>(pPageFrameIter->GetPrev()); }