sw/inc/crsrsh.hxx                  |    2 +-
 sw/inc/fldbas.hxx                  |    2 +-
 sw/inc/fmtftn.hxx                  |    3 +--
 sw/inc/fmtmeta.hxx                 |    3 +--
 sw/inc/fmtrfmrk.hxx                |    3 +--
 sw/inc/pagedesc.hxx                |    3 +--
 sw/source/core/attr/calbck.cxx     |   17 ++++++++++++++++-
 sw/source/core/crsr/crsrsh.cxx     |    4 ++--
 sw/source/core/fields/fldbas.cxx   |    2 +-
 sw/source/core/layout/pagedesc.cxx |    5 ++---
 sw/source/core/txtnode/atrftn.cxx  |    2 +-
 sw/source/core/txtnode/atrref.cxx  |    5 ++---
 sw/source/core/txtnode/fmtatr2.cxx |    2 +-
 13 files changed, 31 insertions(+), 22 deletions(-)

New commits:
commit 0d93ed1ea5593d62e835c958ea50c7c9df2d2f33
Author:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
AuthorDate: Mon Nov 2 21:28:18 2020 +0100
Commit:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
CommitDate: Thu Nov 5 07:59:54 2020 +0100

    Ensure no class directly derives from SwModify
    
    - make all classes that used to be SwModify to be
      sw::BroadcastingModify's
    - this makes sure they are all sw::BroadcastMixin too,
      so all clients of SwModify can be migrated over to use
      sw::BroadcastMixin (only) instead
    
    Change-Id: Idd217b98f9c20f01e0788bc65af796050dbb5699
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105207
    Tested-by: Jenkins
    Reviewed-by: Bjoern Michaelsen <bjoern.michael...@libreoffice.org>

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index e4d47805a1bf..7eb1a2d0273b 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -135,7 +135,7 @@ bool GetRanges(std::vector<std::shared_ptr<SwUnoCursor>> & 
rRanges,
 
 class SW_DLLPUBLIC SwCursorShell
     : public SwViewShell
-    , public SwModify
+    , public sw::BroadcastingModify
     , public ::sw::IShellCursorSupplier
 {
     friend class SwCallLink;
diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 82461033fe1b..847e9d2ef356 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -237,7 +237,7 @@ OUString  FormatNumber(sal_uInt32 nNum, SvxNumType nFormat, 
LanguageType nLang =
  For each class there is one instance of the associated type class.
  Base class of all field types is SwFieldType. */
 
-class SW_DLLPUBLIC SwFieldType : public SwModify, public sw::BroadcasterMixin
+class SW_DLLPUBLIC SwFieldType : public sw::BroadcastingModify
 {
     css::uno::WeakReference<css::beans::XPropertySet> m_wXFieldMaster;
 
diff --git a/sw/inc/fmtftn.hxx b/sw/inc/fmtftn.hxx
index 150b3bd7e44e..2ce85ff0728b 100644
--- a/sw/inc/fmtftn.hxx
+++ b/sw/inc/fmtftn.hxx
@@ -39,8 +39,7 @@ class SwRootFrame;
 
 class SW_DLLPUBLIC SwFormatFootnote final
     : public SfxPoolItem
-    , public SwModify
-    , public sw::BroadcasterMixin
+    , public sw::BroadcastingModify
 {
     friend class SwTextFootnote;
     SwTextFootnote* m_pTextAttr;   ///< My TextAttribute.
diff --git a/sw/inc/fmtmeta.hxx b/sw/inc/fmtmeta.hxx
index 3bb8f928f0ee..b495e2655b98 100644
--- a/sw/inc/fmtmeta.hxx
+++ b/sw/inc/fmtmeta.hxx
@@ -126,8 +126,7 @@ namespace sw {
 
 class Meta
     : public ::sfx2::Metadatable
-    , public SwModify
-    , public sw::BroadcasterMixin
+    , public sw::BroadcastingModify
 {
     friend class ::SwFormatMeta; ///< SetFormatMeta, NotifyChangeTextNode
     friend class ::SwXMeta;   ///< GetTextNode, GetTextAttr, Get/SetXMeta
diff --git a/sw/inc/fmtrfmrk.hxx b/sw/inc/fmtrfmrk.hxx
index 971bd8879294..0d037a669db6 100644
--- a/sw/inc/fmtrfmrk.hxx
+++ b/sw/inc/fmtrfmrk.hxx
@@ -35,8 +35,7 @@ class SwTextRefMark;
 
 class SAL_DLLPUBLIC_RTTI SwFormatRefMark final
     : public SfxPoolItem
-    , public SwModify
-    , public sw::BroadcasterMixin
+    , public sw::BroadcastingModify
 {
     friend class SwTextRefMark;
     SwTextRefMark* m_pTextAttr;
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index c5044e19a74e..44bb7ee33b52 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -136,8 +136,7 @@ namespace o3tl {
 }
 
 class SW_DLLPUBLIC SwPageDesc
-    : public SwModify
-    , public sw::BroadcasterMixin
+    : public sw::BroadcastingModify
 {
     friend class SwDoc;
     friend class SwPageDescs;
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 63e5496e821f..b799f21bbb11 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -25,6 +25,9 @@
 #include <tools/debug.hxx>
 #include <sal/log.hxx>
 #include <algorithm>
+#ifdef DBG_UTIL
+#include <sal/backtrace.hxx>
+#endif
 
 namespace sw
 {
@@ -196,8 +199,20 @@ bool SwModify::GetInfo( SfxPoolItem& rInfo ) const
 void SwModify::Add( SwClient* pDepend )
 {
     DBG_TESTSOLARMUTEX();
+#ifdef DBG_UTIL
+    // You should not EVER use SwModify directly in new code:
+    // - Preexisting SwModifys should only ever be used via 
sw::BroadcastingModify.
+    //   This includes sw::BroadcastMixin, which is the long-term target 
(without
+    //   SwModify).
+    // - New classes should use sw::BroadcastMixin alone.
+    if(!dynamic_cast<sw::BroadcastingModify*>(this))
+    {
+        auto pBT = sal::backtrace_get(20);
+        SAL_WARN("sw.core", "Modify that is not broadcasting used!\n" << 
sal::backtrace_to_string(pBT.get()));
+    }
+#endif
 
-    if(pDepend->m_pRegisteredIn == this )
+    if(pDepend->m_pRegisteredIn == this)
         return;
 
 #if OSL_DEBUG_LEVEL > 0
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 80cc4f69da90..2ba78302aa28 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2912,7 +2912,7 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
 */
 SwCursorShell::SwCursorShell( SwCursorShell& rShell, vcl::Window *pInitWin )
     : SwViewShell( rShell, pInitWin )
-    , SwModify()
+    , sw::BroadcastingModify()
     , m_pStackCursor( nullptr )
     , m_pBlockCursor( nullptr )
     , m_pTableCursor( nullptr )
@@ -2949,7 +2949,7 @@ SwCursorShell::SwCursorShell( SwCursorShell& rShell, 
vcl::Window *pInitWin )
 SwCursorShell::SwCursorShell( SwDoc& rDoc, vcl::Window *pInitWin,
                             const SwViewOption *pInitOpt )
     : SwViewShell( rDoc, pInitWin, pInitOpt )
-    , SwModify()
+    , sw::BroadcastingModify()
     , m_pStackCursor( nullptr )
     , m_pBlockCursor( nullptr )
     , m_pTableCursor( nullptr )
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 2a8da69042cb..b1220181df54 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -128,7 +128,7 @@ OUString SwFieldType::GetTypeStr(SwFieldTypesEnum nTypeId)
 
 // each field references a field type that is unique for each document
 SwFieldType::SwFieldType( SwFieldIds nWhichId )
-    : SwModify()
+    : sw::BroadcastingModify()
     , m_nWhich(nWhichId)
 {
 }
diff --git a/sw/source/core/layout/pagedesc.cxx 
b/sw/source/core/layout/pagedesc.cxx
index 5fe089282a84..d642beced472 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -42,7 +42,7 @@
 #include <hints.hxx>
 
 SwPageDesc::SwPageDesc(const OUString& rName, SwFrameFormat *pFormat, SwDoc 
*const pDoc)
-    : SwModify()
+    : sw::BroadcastingModify()
     , m_StyleName( rName )
     , m_Master( pDoc->GetAttrPool(), rName, pFormat )
     , m_Left( pDoc->GetAttrPool(), rName, pFormat )
@@ -62,8 +62,7 @@ SwPageDesc::SwPageDesc(const OUString& rName, SwFrameFormat 
*pFormat, SwDoc *con
 }
 
 SwPageDesc::SwPageDesc( const SwPageDesc &rCpy )
-    : SwModify()
-    , BroadcasterMixin()
+    : sw::BroadcastingModify()
     , m_StyleName( rCpy.GetName() )
     , m_NumType( rCpy.GetNumType() )
     , m_Master( rCpy.GetMaster() )
diff --git a/sw/source/core/txtnode/atrftn.cxx 
b/sw/source/core/txtnode/atrftn.cxx
index ecf9f2d3ff37..7726eac055d1 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -123,7 +123,7 @@ namespace {
 
 SwFormatFootnote::SwFormatFootnote( bool bEndNote )
     : SfxPoolItem( RES_TXTATR_FTN )
-    , SwModify()
+    , sw::BroadcastingModify()
     , m_pTextAttr(nullptr)
     , m_nNumber(0)
     , m_nNumberRLHidden(0)
diff --git a/sw/source/core/txtnode/atrref.cxx 
b/sw/source/core/txtnode/atrref.cxx
index 88292c8a2f7d..62302ae013d9 100644
--- a/sw/source/core/txtnode/atrref.cxx
+++ b/sw/source/core/txtnode/atrref.cxx
@@ -29,7 +29,7 @@ SwFormatRefMark::~SwFormatRefMark( )
 
 SwFormatRefMark::SwFormatRefMark( const OUString& rName )
     : SfxPoolItem(RES_TXTATR_REFMARK)
-    , SwModify()
+    , sw::BroadcastingModify()
     , m_pTextAttr(nullptr)
     , m_aRefName(rName)
 {
@@ -37,8 +37,7 @@ SwFormatRefMark::SwFormatRefMark( const OUString& rName )
 
 SwFormatRefMark::SwFormatRefMark( const SwFormatRefMark& rAttr )
     : SfxPoolItem(RES_TXTATR_REFMARK)
-    , SwModify()
-    , BroadcasterMixin()
+    , sw::BroadcastingModify()
     , m_pTextAttr(nullptr)
     , m_aRefName(rAttr.m_aRefName)
 {
diff --git a/sw/source/core/txtnode/fmtatr2.cxx 
b/sw/source/core/txtnode/fmtatr2.cxx
index cf9d57dd79a9..add813112a29 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -634,7 +634,7 @@ namespace sw {
 
 Meta::Meta(SwFormatMeta * const i_pFormat)
     : ::sfx2::Metadatable()
-    , SwModify()
+    , sw::BroadcastingModify()
     , m_pFormat(i_pFormat)
     , m_pTextNode(nullptr)
 {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to