summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-01-10 16:45:33 +0100
committerThorsten Behrens <thorsten.behrens@allotropia.de>2022-01-12 02:38:23 +0100
commitb14f5424dde966fa3764a7e5c813dc727390354c (patch)
tree7b9780e859649bf0295d9695989225c03b294bca
parent20c819bf3bfd9d203f860f1fd078903d0b3945a7 (diff)
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.stahl@allotropia.de> (cherry picked from commit cb188ce336e434c2b7002b3d8a41a681e73ae51a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128243 Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r--sw/inc/section.hxx3
-rw-r--r--sw/source/core/docnode/section.cxx8
-rw-r--r--sw/source/core/inc/sectfrm.hxx4
-rw-r--r--sw/source/core/layout/sectfrm.cxx11
4 files changed, 26 insertions, 0 deletions
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index b311f864cd26..feb06761a68c 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 2e1a4cab6270..d9c12c68f4e8 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())
{
@@ -401,6 +404,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;
auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
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)