summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2023-04-01 23:25:57 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2023-04-04 11:27:22 +0200
commit116a646a9f36ff07393186d5a001628023c6ded6 (patch)
tree211f8cf096b19045238209179c28a239fe9afabd
parentbd5efa2899a3db51c2b6d525d7e518a7a3fbf912 (diff)
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 <michael.stahl@allotropia.de>
-rw-r--r--include/svl/hint.hxx1
-rw-r--r--sw/inc/hintids.hxx1
-rw-r--r--sw/inc/hints.hxx5
-rw-r--r--sw/source/core/docnode/ndtbl.cxx3
-rw-r--r--sw/source/core/inc/tabfrm.hxx2
-rw-r--r--sw/source/core/layout/tabfrm.cxx119
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<SwFormatChg> RES_FMT_CHG(168);
constexpr TypedWhichId<SwAttrSetChg> RES_ATTRSET_CHG(169);
constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(170);
constexpr TypedWhichId<SwPtrMsgPoolItem> RES_REFMARKFLD_UPDATE(171);
-constexpr TypedWhichId<SwMsgPoolItem> RES_TBLHEADLINECHG(175);
constexpr TypedWhichId<SwAutoFormatGetDocNode> RES_AUTOFMT_DOCNODE(176);
constexpr TypedWhichId<SwMsgPoolItem> RES_HIDDENPARA_PRINT(178);
constexpr TypedWhichId<SwVirtPageNumInfo> 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<SwRootFrame*>(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<const sw::LegacyModifyHint*>(&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<SwRowFrame*>(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<SwRootFrame*>(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<SwRowFrame*>(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;