summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-01-10 16:45:33 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-01-14 10:47:51 +0100
commit58d4b1aae1a599322b27ec388b62d8a6ed158ef9 (patch)
treeb41e5cb6249a2179ce9fc56ed0e0cdda8c3abcc0
parentofz: Use-of-unintialized-value (diff)
downloadcore-58d4b1aae1a599322b27ec388b62d8a6ed158ef9.tar.gz
core-58d4b1aae1a599322b27ec388b62d8a6ed158ef9.zip
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> (cherry picked from commit b14f5424dde966fa3764a7e5c813dc727390354c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128330 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-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 ed777e9e68e2..14f9429d572c 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 5fa56e2eb00f..c4d498f05495 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 bc529bd28708..e5ba5d242667 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 )
@@ -2566,6 +2570,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)