sw/source/core/inc/pagefrm.hxx | 3 +++ sw/source/core/layout/pagechg.cxx | 17 +++++++++++++++++ sw/source/core/layout/tabfrm.cxx | 25 +++++-------------------- sw/source/core/text/txtfrm.cxx | 25 +++++-------------------- 4 files changed, 30 insertions(+), 40 deletions(-)
New commits: commit 5f2c99839bf041faf5b15aa9d4bb4c73b4b041f0 Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Tue Jul 18 00:29:01 2023 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Jul 18 12:27:08 2023 +0200 deduplicate virtual page info update in SwPageFrame Change-Id: I2753f080f7751189675007ded8ba050245a8758c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154562 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx index cd2f14f5e885..d85ddaecd116 100644 --- a/sw/source/core/inc/pagefrm.hxx +++ b/sw/source/core/inc/pagefrm.hxx @@ -36,6 +36,7 @@ class SwAttrSetChg; namespace vcl { class Font; } class SwSortedObjs; class SwAnchoredObject; +class SwVirtPageNumInfo; enum class SwPageFrameInvFlags : sal_uInt8 { @@ -347,6 +348,8 @@ public: const SwHeaderFrame* GetHeaderFrame() const; const SwFooterFrame* GetFooterFrame() const; + bool UpdateVirtPageNumInfo(SwVirtPageNumInfo& rHint, const SwFrame* pFrame) const; + void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override; }; diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index 6f11380fc030..042a34d46759 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -2598,6 +2598,23 @@ const SwFooterFrame* SwPageFrame::GetFooterFrame() const return nullptr; } +bool SwPageFrame::UpdateVirtPageNumInfo(SwVirtPageNumInfo& rHint, const SwFrame* pFrame) const +{ + if(this == rHint.GetOrigPage() && !pFrame->GetPrev()) + { + // Should be the one (can temporarily be different, should we be concerned about this possibility?) + rHint.SetInfo(this, pFrame); + return false; + } + if(GetPhyPageNum() < rHint.GetOrigPage()->GetPhyPageNum() && + (!rHint.GetPage() || GetPhyPageNum() > rHint.GetPage()->GetPhyPageNum())) + { + // This could be the one. + rHint.SetInfo(this, pFrame); + } + return true; +} + void SwPageFrame::dumpAsXml(xmlTextWriterPtr writer) const { (void)xmlTextWriterStartElement(writer, reinterpret_cast<const xmlChar*>("page")); diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 174ff7227628..a7e767a00e3a 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -3590,28 +3590,13 @@ void SwTabFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew, } } -bool SwTabFrame::GetInfo( SfxPoolItem &rHint ) const +bool SwTabFrame::GetInfo(SfxPoolItem& rHint) const { - if ( RES_VIRTPAGENUM_INFO == rHint.Which() && IsInDocBody() && !IsFollow() ) + if(RES_VIRTPAGENUM_INFO == rHint.Which() && IsInDocBody() && !IsFollow()) { - SwVirtPageNumInfo &rInfo = static_cast<SwVirtPageNumInfo&>(rHint); - const SwPageFrame *pPage = FindPageFrame(); - if ( pPage ) - { - if ( pPage == rInfo.GetOrigPage() && !GetPrev() ) - { - // Should be the one (can temporarily be different, should we be - // concerned about this possibility?) - rInfo.SetInfo( pPage, this ); - return false; - } - if ( pPage->GetPhyPageNum() < rInfo.GetOrigPage()->GetPhyPageNum() && - (!rInfo.GetPage() || pPage->GetPhyPageNum() > rInfo.GetPage()->GetPhyPageNum())) - { - //This could be the one. - rInfo.SetInfo( pPage, this ); - } - } + SwVirtPageNumInfo& rInfo = static_cast<SwVirtPageNumInfo&>(rHint); + if(const SwPageFrame* pPage = FindPageFrame()) + return pPage->UpdateVirtPageNumInfo(rInfo, this); } return true; } diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 7f1c17691ccf..4bc70a7ae233 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -2746,28 +2746,13 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) CalcFootnoteFlag(); } -bool SwTextFrame::GetInfo( SfxPoolItem &rHint ) const +bool SwTextFrame::GetInfo(SfxPoolItem& rHint) const { - if ( RES_VIRTPAGENUM_INFO == rHint.Which() && IsInDocBody() && ! IsFollow() ) + if(RES_VIRTPAGENUM_INFO == rHint.Which() && IsInDocBody() && !IsFollow()) { - SwVirtPageNumInfo &rInfo = static_cast<SwVirtPageNumInfo&>(rHint); - const SwPageFrame *pPage = FindPageFrame(); - if ( pPage ) - { - if ( pPage == rInfo.GetOrigPage() && !GetPrev() ) - { - // this should be the one - // (could only differ temporarily; is that disturbing?) - rInfo.SetInfo( pPage, this ); - return false; - } - if ( pPage->GetPhyPageNum() < rInfo.GetOrigPage()->GetPhyPageNum() && - (!rInfo.GetPage() || pPage->GetPhyPageNum() > rInfo.GetPage()->GetPhyPageNum())) - { - // this could be the one - rInfo.SetInfo( pPage, this ); - } - } + SwVirtPageNumInfo& rInfo = static_cast<SwVirtPageNumInfo&>(rHint); + if(const SwPageFrame* pPage = FindPageFrame()) + return pPage->UpdateVirtPageNumInfo(rInfo, this); } return true; }