sw/inc/section.hxx | 3 +++ sw/source/core/docnode/section.cxx | 8 ++++++++ sw/source/core/inc/sectfrm.hxx | 4 ++++ sw/source/core/layout/sectfrm.cxx | 11 +++++++++++ 4 files changed, 26 insertions(+)
New commits: commit cb188ce336e434c2b7002b3d8a41a681e73ae51a Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Mon Jan 10 16:45:33 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Jan 11 10:27:43 2022 +0100 tdf#146605 sw: try to fix SwSectionFormat notifications SwSectionFormat no longer notifies via its SwModify to SwClient listeners, but only via SvtBroadcaster, so SwSection and SwSectionFrame need to be SvtListeners. This can be seen when changing the footnote-at-end setting in the section dialog, if the SwSection doesn't get the event the footnote numbers aren't adapted to a new restart value, if the SwSectionFrame doesn't get the event the footnote container isn't moved. This is of course not pretty but hopefully it will be refactored further in the future. (regression from commit 2e32f4ed5af16a68c97a50806a42ffa2d10f1d7a) Change-Id: I93c616e209a01fc5d4c8eba701a6ddce5d5b432e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128257 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 65591f216ee1..4350048f9700 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -24,6 +24,7 @@ #include <tools/ref.hxx> #include <svl/hint.hxx> +#include <svl/listener.hxx> #include <sfx2/lnkbase.hxx> #include <sfx2/Metadatable.hxx> @@ -137,6 +138,7 @@ public: class SW_DLLPUBLIC SwSection : public SwClient + , public SvtListener // needed for SwClientNotify to be called from SwSectionFormat { // In order to correctly maintain the flag when creating/deleting frames. friend class SwSectionNode; @@ -153,6 +155,7 @@ private: bool const bHidden, bool const bCondition); protected: + virtual void Notify(SfxHint const& rHint) override; virtual void SwClientNotify(const SwModify&, const SfxHint&) override; public: diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 12feba3c3eb6..390600cfa3ba 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -198,6 +198,8 @@ SwSection::SwSection( : SwClient(& rFormat) , m_Data(eType, rName) { + StartListening(rFormat.GetNotifier()); + SwSection *const pParentSect = GetParent(); if( pParentSect ) { @@ -230,6 +232,7 @@ SwSection::~SwSection() else { pFormat->Remove( this ); // remove + SvtListener::EndListeningAll(); if (SectionType::Content != m_Data.GetType()) { @@ -400,6 +403,11 @@ void SwSection::SetEditInReadonly(bool const bFlag) } void SwSection::SwClientNotify(const SwModify&, const SfxHint& rHint) +{ + Notify(rHint); +} + +void SwSection::Notify(SfxHint const& rHint) { if (rHint.GetId() != SfxHintId::SwLegacyModify) return; diff --git a/sw/source/core/inc/sectfrm.hxx b/sw/source/core/inc/sectfrm.hxx index 276819dff7bf..09c742f8da79 100644 --- a/sw/source/core/inc/sectfrm.hxx +++ b/sw/source/core/inc/sectfrm.hxx @@ -22,6 +22,8 @@ #include "layfrm.hxx" #include "flowfrm.hxx" +#include <svl/listener.hxx> + class SwSection; class SwSectionFormat; class SwAttrSetChg; @@ -45,6 +47,7 @@ namespace o3tl { } class SwSectionFrame final: public SwLayoutFrame, public SwFlowFrame + , public SvtListener // TODO? { SwSection* m_pSection; bool m_bFootnoteAtEnd; // footnotes at the end of section @@ -70,6 +73,7 @@ class SwSectionFrame final: public SwLayoutFrame, public SwFlowFrame virtual void MakeAll(vcl::RenderContext* pRenderContext) override; virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool &rReformat ) override; virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override; + virtual void Notify(SfxHint const& rHint) override; virtual void SwClientNotify( const SwModify&, const SfxHint& ) override; public: diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index 7d1cb799be91..9b33ceeadd63 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -74,6 +74,8 @@ SwSectionFrame::SwSectionFrame( SwSection &rSect, SwFrame* pSib ) , m_bOwnFootnoteNum(false) , m_bFootnoteLock(false) { + StartListening(rSect.GetFormat()->GetNotifier()); + mnFrameType = SwFrameType::Section; CalcFootnoteAtEndFlag(); @@ -90,6 +92,8 @@ SwSectionFrame::SwSectionFrame( SwSectionFrame &rSect, bool bMaster ) : m_bOwnFootnoteNum( false ), m_bFootnoteLock( false ) { + StartListening(rSect.GetFormat()->GetNotifier()); + mnFrameType = SwFrameType::Section; PROTOCOL( this, PROT::Section, bMaster ? DbgAction::CreateMaster : DbgAction::CreateFollow, &rSect ) @@ -2567,6 +2571,13 @@ void SwSectionFrame::CalcEndAtEndFlag() } } +void SwSectionFrame::Notify(SfxHint const& rHint) +{ + SwSectionFormat *const pFormat(GetSection()->GetFormat()); + assert(pFormat); + SwClientNotify(*pFormat, rHint); +} + void SwSectionFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { if (rHint.GetId() == SfxHintId::SwLegacyModify)