From 116a646a9f36ff07393186d5a001628023c6ded6 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Sat, 1 Apr 2023 23:25:57 +0200 Subject: RES_TBLHEADINGCHG no more ... - replaced LegacyModifyHint by a proper SfxHint - Refactor SwTabFrame for table heading change: * split out Invalidate(SwTabFrameInvFlags) * split out HandleTableHeadlineChange() Change-Id: I374db7a3b16a3062d6ad54c32527ec1056cbc00b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149929 Tested-by: Jenkins Reviewed-by: Michael Stahl --- include/svl/hint.hxx | 1 + sw/inc/hintids.hxx | 1 - sw/inc/hints.hxx | 5 ++ sw/source/core/docnode/ndtbl.cxx | 3 +- sw/source/core/inc/tabfrm.hxx | 2 + sw/source/core/layout/tabfrm.cxx | 119 +++++++++++++++++++++------------------ 6 files changed, 72 insertions(+), 59 deletions(-) diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx index f06f4c6449e9..5967d834ceeb 100644 --- a/include/svl/hint.hxx +++ b/include/svl/hint.hxx @@ -151,6 +151,7 @@ enum class SfxHintId { SwDescriptionChanged, SwDocPosUpdate, SwDocPosUpdateAtIndex, + SwTableHeadingChange, ThisIsAnSdrHint }; diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 5e84921ec832..17c1fe545136 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -433,7 +433,6 @@ constexpr TypedWhichId RES_FMT_CHG(168); constexpr TypedWhichId RES_ATTRSET_CHG(169); constexpr TypedWhichId RES_UPDATE_ATTR(170); constexpr TypedWhichId RES_REFMARKFLD_UPDATE(171); -constexpr TypedWhichId RES_TBLHEADLINECHG(175); constexpr TypedWhichId RES_AUTOFMT_DOCNODE(176); constexpr TypedWhichId RES_HIDDENPARA_PRINT(178); constexpr TypedWhichId RES_VIRTPAGENUM_INFO(180); diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx index 6b993795c058..4cf9e2464c6d 100644 --- a/sw/inc/hints.hxx +++ b/sw/inc/hints.hxx @@ -256,6 +256,11 @@ public: const bool m_isHidden; SectionHidden(const bool isHidden = true) : SfxHint(SfxHintId::SwSectionHidden), m_isHidden(isHidden) {}; }; +class TableHeadingChange final: public SfxHint +{ +public: + TableHeadingChange() : SfxHint(SfxHintId::SwTableHeadingChange) {}; +}; } class SwUpdateAttr final : public SwMsgPoolItem diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 111daec55ef3..d076e616af5c 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2891,8 +2891,7 @@ void SwDoc::SetRowsToRepeat( SwTable &rTable, sal_uInt16 nSet ) } rTable.SetRowsToRepeat(nSet); - const SwMsgPoolItem aChg(RES_TBLHEADLINECHG); - rTable.GetFrameFormat()->CallSwClientNotify(sw::LegacyModifyHint(&aChg, &aChg)); + rTable.GetFrameFormat()->CallSwClientNotify(sw::TableHeadingChange()); getIDocumentState().SetModified(); } diff --git a/sw/source/core/inc/tabfrm.hxx b/sw/source/core/inc/tabfrm.hxx index ca4af59b223c..4fa1c54d27d0 100644 --- a/sw/source/core/inc/tabfrm.hxx +++ b/sw/source/core/inc/tabfrm.hxx @@ -115,6 +115,8 @@ class SW_DLLPUBLIC SwTabFrame final: public SwLayoutFrame, public SwFlowFrame const SfxPoolItem*, SwTabFrameInvFlags &, SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr ); + void Invalidate(SwTabFrameInvFlags); + void HandleTableHeadlineChange(); virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool &rReformat ) override; diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 9bb630f181a0..13c65b977bf5 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -3377,10 +3377,51 @@ SwTwips SwTabFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo ) return nDist; } +void SwTabFrame::Invalidate(SwTabFrameInvFlags eInvFlags) +{ + if(eInvFlags == SwTabFrameInvFlags::NONE) + return; + SwPageFrame* pPage = FindPageFrame(); + InvalidatePage(pPage); + if(eInvFlags & SwTabFrameInvFlags::InvalidatePrt) + InvalidatePrt_(); + if(eInvFlags & SwTabFrameInvFlags::InvalidatePos) + InvalidatePos_(); + SwFrame* pTmp = GetIndNext(); + if(nullptr != pTmp) + { + if(eInvFlags & SwTabFrameInvFlags::InvalidateIndNextPrt) + { + pTmp->InvalidatePrt_(); + if(pTmp->IsContentFrame()) + pTmp->InvalidatePage(pPage); + } + if(eInvFlags & SwTabFrameInvFlags::SetIndNextCompletePaint) + pTmp->SetCompletePaint(); + } + if(eInvFlags & SwTabFrameInvFlags::InvalidatePrevPrt && nullptr != (pTmp = GetPrev())) + { + pTmp->InvalidatePrt_(); + if(pTmp->IsContentFrame()) + pTmp->InvalidatePage(pPage); + } + if(eInvFlags & SwTabFrameInvFlags::InvalidateBrowseWidth) + { + if(pPage && pPage->GetUpper() && !IsFollow()) + static_cast(pPage->GetUpper())->InvalidateBrowseWidth(); + } + if(eInvFlags & SwTabFrameInvFlags::InvalidateNextPos) + InvalidateNextPos(); +} void SwTabFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify) + if(rHint.GetId() == SfxHintId::SwTableHeadingChange) + { + HandleTableHeadlineChange(); + return; + } + else if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast(&rHint); SwTabFrameInvFlags eInvFlags = SwTabFrameInvFlags::NONE; @@ -3407,41 +3448,34 @@ void SwTabFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) } else UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); + Invalidate(eInvFlags); +} - if(eInvFlags == SwTabFrameInvFlags::NONE) +void SwTabFrame::HandleTableHeadlineChange() +{ + if(!IsFollow()) return; + // Delete remaining headlines: + SwRowFrame* pLowerRow = nullptr; + while(nullptr != (pLowerRow = static_cast(Lower())) && pLowerRow->IsRepeatedHeadline()) + { + pLowerRow->Cut(); + SwFrame::DestroyFrame(pLowerRow); + } - SwPageFrame* pPage = FindPageFrame(); - InvalidatePage(pPage); - if(eInvFlags & SwTabFrameInvFlags::InvalidatePrt) - InvalidatePrt_(); - if(eInvFlags & SwTabFrameInvFlags::InvalidatePos) - InvalidatePos_(); - SwFrame* pTmp = GetIndNext(); - if(nullptr != pTmp) + // insert new headlines + const sal_uInt16 nNewRepeat = GetTable()->GetRowsToRepeat(); + auto& rLines = GetTable()->GetTabLines(); + for(sal_uInt16 nIdx = 0; nIdx < nNewRepeat; ++nIdx) { - if(eInvFlags & SwTabFrameInvFlags::InvalidateIndNextPrt) + SwRowFrame* pHeadline = new SwRowFrame(*rLines[nIdx], this); { - pTmp->InvalidatePrt_(); - if(pTmp->IsContentFrame()) - pTmp->InvalidatePage(pPage); + sw::FlyCreationSuppressor aSuppressor; + pHeadline->SetRepeatedHeadline(true); } - if(eInvFlags & SwTabFrameInvFlags::SetIndNextCompletePaint) - pTmp->SetCompletePaint(); - } - if(eInvFlags & SwTabFrameInvFlags::InvalidatePrevPrt && nullptr != (pTmp = GetPrev())) - { - pTmp->InvalidatePrt_(); - if(pTmp->IsContentFrame()) - pTmp->InvalidatePage( pPage ); + pHeadline->Paste(this, pLowerRow); } - if(eInvFlags & SwTabFrameInvFlags::InvalidateBrowseWidth) - { - if(pPage && pPage->GetUpper() && !IsFollow()) - static_cast(pPage->GetUpper())->InvalidateBrowseWidth(); - } - if(eInvFlags & SwTabFrameInvFlags::InvalidateNextPos) - InvalidateNextPos(); + Invalidate(SwTabFrameInvFlags::InvalidatePrt); } void SwTabFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew, @@ -3452,33 +3486,6 @@ void SwTabFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew, const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; switch( nWhich ) { - case RES_TBLHEADLINECHG: - if ( IsFollow() ) - { - // Delete remaining headlines: - SwRowFrame* pLowerRow = nullptr; - while ( nullptr != ( pLowerRow = static_cast(Lower()) ) && pLowerRow->IsRepeatedHeadline() ) - { - pLowerRow->Cut(); - SwFrame::DestroyFrame(pLowerRow); - } - - // insert new headlines - const sal_uInt16 nNewRepeat = GetTable()->GetRowsToRepeat(); - auto& rLines = GetTable()->GetTabLines(); - for ( sal_uInt16 nIdx = 0; nIdx < nNewRepeat; ++nIdx ) - { - SwRowFrame* pHeadline = new SwRowFrame(*rLines[nIdx], this); - { - sw::FlyCreationSuppressor aSuppressor; - pHeadline->SetRepeatedHeadline(true); - } - pHeadline->Paste( this, pLowerRow ); - } - } - rInvFlags |= SwTabFrameInvFlags::InvalidatePrt; - break; - case RES_FRM_SIZE: case RES_HORI_ORIENT: rInvFlags |= SwTabFrameInvFlags::InvalidatePrt | SwTabFrameInvFlags::InvalidateBrowseWidth; -- cgit