[Libreoffice-commits] core.git: sw/inc sw/source
Bjoern Michaelsen
bjoern.michaelsen at libreoffice.org
Thu Jan 25 19:49:32 UTC 2018
sw/inc/calbck.hxx | 1 +
sw/inc/swevent.hxx | 2 +-
sw/inc/tox.hxx | 1 -
sw/source/core/access/accframebase.cxx | 9 +++------
sw/source/core/access/accnotextframe.cxx | 5 +----
sw/source/core/access/accpara.cxx | 3 +--
sw/source/core/access/acctable.cxx | 7 ++-----
sw/source/core/attr/calbck.cxx | 8 +++++++-
sw/source/core/attr/format.cxx | 5 ++---
sw/source/core/crsr/crsrsh.cxx | 3 +--
sw/source/core/doc/acmplwrd.cxx | 6 +++---
sw/source/core/doc/docfly.cxx | 2 +-
sw/source/core/doc/docftn.cxx | 16 ++++++++--------
sw/source/core/inc/UndoCore.hxx | 1 -
sw/source/core/txtnode/fmtatr2.cxx | 4 ++--
sw/source/core/undo/rolbck.cxx | 2 +-
sw/source/core/undo/undobj1.cxx | 5 -----
sw/source/core/unocore/unobkm.cxx | 2 +-
sw/source/core/unocore/unochart.cxx | 2 +-
sw/source/core/unocore/unodraw.cxx | 3 +--
sw/source/core/unocore/unofield.cxx | 2 +-
sw/source/core/unocore/unoflatpara.cxx | 3 +--
sw/source/core/unocore/unoframe.cxx | 3 +--
sw/source/core/unocore/unoftn.cxx | 5 +----
sw/source/core/unocore/unoidx.cxx | 8 ++------
sw/source/core/unocore/unoobj2.cxx | 14 ++++++--------
sw/source/core/unocore/unoport.cxx | 6 +-----
sw/source/core/unocore/unorefmk.cxx | 7 ++-----
sw/source/core/unocore/unostyle.cxx | 3 +--
sw/source/core/unocore/unotbl.cxx | 8 +++-----
sw/source/core/unocore/unotextmarkup.cxx | 5 +----
sw/source/filter/html/htmltab.cxx | 10 +++-------
sw/source/filter/html/swhtml.cxx | 2 +-
sw/source/uibase/wrtsh/wrtsh2.cxx | 7 ++-----
34 files changed, 63 insertions(+), 107 deletions(-)
New commits:
commit 360f2d1b46174fcb33323dcac978bfe8796bad19
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
Date: Wed Jan 24 00:56:50 2018 +0100
introduce SwClient::EndListeningAll()
- this is to reduce the use of GetRegisterdIn(), which should be an
implementation detail
- remove SwTOXMark::DeRegister() which did the same for a part of the
class tree
- remove SwUndoSetFlyFormat::DeRegisterFromFormat(), same
- remove doubletracking FrameDeleteWatch::m_bDeleted, just check
GetRegisteredIn()
Change-Id: Id9364076759446ee5ff1898683c3ca700c1014c9
Reviewed-on: https://gerrit.libreoffice.org/48548
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 38d2e94b4261..06b6266bd32d 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -132,6 +132,7 @@ public:
const SwModify* GetRegisteredIn() const { return m_pRegisteredIn; }
SwModify* GetRegisteredIn() { return m_pRegisteredIn; }
+ void EndListeningAll();
// get information about attribute
diff --git a/sw/inc/swevent.hxx b/sw/inc/swevent.hxx
index b108d8de9168..9b6b4b3b84f1 100644
--- a/sw/inc/swevent.hxx
+++ b/sw/inc/swevent.hxx
@@ -111,7 +111,7 @@ struct SwCallMouseEvent
// note: pFormat is not necessarily the same as
// GetRegisteredIn() here; see ~SwFormat()
assert(PTR.pFormat);
- GetRegisteredInNonConst()->Remove(this);
+ EndListeningAll();
}
eType = EVENT_OBJECT_NONE; PTR.pFormat = nullptr; PTR.IMAP.pIMapObj = nullptr;
}
diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx
index b32b3c8f96ba..2ca0604d3926 100644
--- a/sw/inc/tox.hxx
+++ b/sw/inc/tox.hxx
@@ -142,7 +142,6 @@ public:
{ return m_wXDocumentIndexMark; }
SAL_DLLPRIVATE void SetXTOXMark(css::uno::Reference<css::text::XDocumentIndexMark> const& xMark)
{ m_wXDocumentIndexMark = xMark; }
- void DeRegister() { GetRegisteredInNonConst()->Remove( this ); }
void RegisterToTOXType( SwTOXType& rMark );
static void InsertTOXMarks( SwTOXMarks& aMarks, const SwTOXType& rType );
};
diff --git a/sw/source/core/access/accframebase.cxx b/sw/source/core/access/accframebase.cxx
index 221304bc3857..88ae7c5aa087 100644
--- a/sw/source/core/access/accframebase.cxx
+++ b/sw/source/core/access/accframebase.cxx
@@ -244,14 +244,14 @@ void SwAccessibleFrameBase::Modify( const SfxPoolItem* pOld, const SfxPoolItem *
case RES_OBJECTDYING:
// mba: it seems that this class intentionally does not call code in base class SwClient
if( pOld && ( GetRegisteredIn() == static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) ) )
- GetRegisteredInNonConst()->Remove( this );
+ EndListeningAll();
break;
case RES_FMT_CHG:
if( pOld &&
static_cast< const SwFormatChg * >(pNew)->pChangedFormat == GetRegisteredIn() &&
static_cast< const SwFormatChg * >(pOld)->pChangedFormat->IsFormatInDTOR() )
- GetRegisteredInNonConst()->Remove( this );
+ EndListeningAll();
break;
default:
@@ -263,10 +263,7 @@ void SwAccessibleFrameBase::Modify( const SfxPoolItem* pOld, const SfxPoolItem *
void SwAccessibleFrameBase::Dispose(bool bRecursive, bool bCanSkipInvisible)
{
SolarMutexGuard aGuard;
-
- if( GetRegisteredIn() )
- GetRegisteredInNonConst()->Remove( this );
-
+ EndListeningAll();
SwAccessibleContext::Dispose(bRecursive, bCanSkipInvisible);
}
diff --git a/sw/source/core/access/accnotextframe.cxx b/sw/source/core/access/accnotextframe.cxx
index 82094da0afbf..4e8c9207a85a 100644
--- a/sw/source/core/access/accnotextframe.cxx
+++ b/sw/source/core/access/accnotextframe.cxx
@@ -163,10 +163,7 @@ void SwAccessibleNoTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem
void SwAccessibleNoTextFrame::Dispose(bool bRecursive, bool bCanSkipInvisible)
{
SolarMutexGuard aGuard;
-
- if( m_aDepend.GetRegisteredIn() )
- m_aDepend.GetRegisteredIn()->Remove( &m_aDepend );
-
+ m_aDepend.EndListeningAll();
SwAccessibleFrameBase::Dispose(bRecursive, bCanSkipInvisible);
}
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 1a3a0ef43147..6f206aff32cb 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -560,8 +560,7 @@ SwAccessibleParagraph::~SwAccessibleParagraph()
delete m_pPortionData;
delete m_pHyperTextData;
delete mpParaChangeTrackInfo; // #i108125#
- if(GetRegisteredIn())
- GetRegisteredIn()->Remove(this);
+ EndListeningAll();
}
bool SwAccessibleParagraph::HasCursor()
diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx
index 8fe7bf63ed3a..e683adfd50e1 100644
--- a/sw/source/core/access/acctable.cxx
+++ b/sw/source/core/access/acctable.cxx
@@ -738,7 +738,7 @@ void SwAccessibleTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew
case RES_OBJECTDYING:
// mba: it seems that this class intentionally does not call code in base class SwClient
if( pOld && ( GetRegisteredIn() == static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) ) )
- GetRegisteredInNonConst()->Remove( this );
+ EndListeningAll();
break;
default:
@@ -1276,10 +1276,7 @@ void SwAccessibleTable::InvalidatePosOrSize( const SwRect& rOldBox )
void SwAccessibleTable::Dispose(bool bRecursive, bool bCanSkipInvisible)
{
SolarMutexGuard aGuard;
-
- if( GetRegisteredIn() )
- GetRegisteredInNonConst()->Remove( this );
-
+ EndListeningAll();
SwAccessibleContext::Dispose(bRecursive, bCanSkipInvisible);
}
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index ef588936d12b..400792527a00 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -56,7 +56,7 @@ void SwClient::CheckRegistration( const SfxPoolItem* pOld )
return;
}
// destroy connection
- m_pRegisteredIn->Remove(this);
+ EndListeningAll();
}
}
@@ -68,6 +68,12 @@ void SwClient::SwClientNotify(const SwModify&, const SfxHint& rHint)
}
};
+void SwClient::EndListeningAll()
+{
+ if(m_pRegisteredIn)
+ m_pRegisteredIn->Remove(this);
+}
+
void SwClient::Modify(SfxPoolItem const*const pOldValue, SfxPoolItem const*const /*pNewValue*/)
{
CheckRegistration( pOldValue );
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index d590ea4a5693..f526a300cbef 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -127,8 +127,7 @@ SwFormat &SwFormat::operator=(const SwFormat& rFormat)
if( GetRegisteredIn() != rFormat.GetRegisteredIn() )
{
- if( GetRegisteredIn() )
- GetRegisteredInNonConst()->Remove(this);
+ EndListeningAll();
if( rFormat.GetRegisteredIn() )
{
const_cast<SwFormat&>(rFormat).GetRegisteredInNonConst()->Add(this);
@@ -267,7 +266,7 @@ void SwFormat::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValu
else
{
// otherwise de-register at least from dying one
- GetRegisteredIn()->Remove( this );
+ EndListeningAll();
m_aSet.SetParent( nullptr );
}
}
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 0360962657f4..055891bd99c9 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2741,8 +2741,7 @@ SwCursorShell::~SwCursorShell()
// #i54025# - do not give a HTML parser that might potentially hang as
// a client at the cursor shell the chance to hang itself on a TextNode
- if( GetRegisteredIn() )
- GetRegisteredInNonConst()->Remove( this );
+ EndListeningAll();
}
SwShellCursor* SwCursorShell::getShellCursor( bool bBlock )
diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx
index 32afddc0769a..90a2ac2d148c 100644
--- a/sw/source/core/doc/acmplwrd.cxx
+++ b/sw/source/core/doc/acmplwrd.cxx
@@ -135,8 +135,8 @@ SwAutoCompleteClient& SwAutoCompleteClient::operator=(const SwAutoCompleteClient
pDoc = rClient.pDoc;
if(rClient.GetRegisteredIn())
const_cast<SwModify*>(rClient.GetRegisteredIn())->Add(this);
- else if(GetRegisteredIn())
- GetRegisteredInNonConst()->Remove(this);
+ else
+ EndListeningAll();
return *this;
}
@@ -147,7 +147,7 @@ void SwAutoCompleteClient::Modify( const SfxPoolItem* pOld, const SfxPoolItem *)
case RES_REMOVE_UNO_OBJECT:
case RES_OBJECTDYING:
if( static_cast<void*>(GetRegisteredIn()) == static_cast<const SwPtrMsgPoolItem *>(pOld)->pObject )
- GetRegisteredIn()->Remove(this);
+ EndListeningAll();
pAutoCompleteWord->DocumentDying(*pDoc);
break;
}
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index cc4a6552e18f..6adcb47b894b 100644
--- a/sw/source/core/doc/docfly.cxx
+++ b/sw/source/core/doc/docfly.cxx
@@ -701,7 +701,7 @@ bool SwDoc::SetFrameFormatToFly( SwFrameFormat& rFormat, SwFrameFormat& rNewForm
rFormat.MakeFrames();
if( pUndo )
- pUndo->DeRegisterFromFormat( rFormat );
+ pUndo->EndListeningAll();
getIDocumentState().SetModified();
diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx
index 3e333adcdecc..66b2587c5855 100644
--- a/sw/source/core/doc/docftn.cxx
+++ b/sw/source/core/doc/docftn.cxx
@@ -41,24 +41,24 @@ SwEndNoteInfo& SwEndNoteInfo::operator=(const SwEndNoteInfo& rInfo)
{
if( rInfo.GetFootnoteTextColl() )
rInfo.GetFootnoteTextColl()->Add(this);
- else if ( GetRegisteredIn())
- GetRegisteredInNonConst()->Remove(this);
+ else
+ EndListeningAll();
if ( rInfo.aPageDescDep.GetRegisteredIn() )
const_cast<SwModify*>(rInfo.aPageDescDep.GetRegisteredIn())->Add( &aPageDescDep );
- else if ( aPageDescDep.GetRegisteredIn() )
- aPageDescDep.GetRegisteredIn()->Remove( &aPageDescDep );
+ else
+ aPageDescDep.EndListeningAll();
if ( rInfo.aCharFormatDep.GetRegisteredIn() )
const_cast<SwModify*>(rInfo.aCharFormatDep.GetRegisteredIn())->Add( &aCharFormatDep );
- else if ( aCharFormatDep.GetRegisteredIn() )
- aCharFormatDep.GetRegisteredIn()->Remove( &aCharFormatDep );
+ else
+ aCharFormatDep.EndListeningAll();
if ( rInfo.aAnchorCharFormatDep.GetRegisteredIn() )
const_cast<SwModify*>(rInfo.aAnchorCharFormatDep.GetRegisteredIn())->Add(
&aAnchorCharFormatDep );
- else if( aAnchorCharFormatDep.GetRegisteredIn() )
- aAnchorCharFormatDep.GetRegisteredIn()->Remove( &aAnchorCharFormatDep );
+ else
+ aAnchorCharFormatDep.EndListeningAll();
aFormat = rInfo.aFormat;
nFootnoteOffset = rInfo.nFootnoteOffset;
diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx
index 3d8f0c8df38f..560a92d8dba4 100644
--- a/sw/source/core/inc/UndoCore.hxx
+++ b/sw/source/core/inc/UndoCore.hxx
@@ -209,7 +209,6 @@ public:
virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
virtual SwRewriter GetRewriter() const override;
- void DeRegisterFromFormat( SwFormat& );
};
class SwUndoOutlineLeftRight : public SwUndo, private SwUndRng
diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx
index c1d25970f7d1..9217779ee7b0 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -642,9 +642,9 @@ void Meta::NotifyChangeTextNode(SwTextNode *const pTextNode)
{
m_pTextNode->Add(this);
}
- else if (!m_pTextNode && GetRegisteredIn())
+ else if (!m_pTextNode)
{
- GetRegisteredInNonConst()->Remove(this);
+ EndListeningAll();
}
if (!pTextNode) // text node gone? invalidate UNO object!
{
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 79eb17e30dc8..6b9c025c4d83 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -345,7 +345,7 @@ SwHistorySetTOXMark::SwHistorySetTOXMark( SwTextTOXMark* pTextHt, sal_uLong nNod
, m_nStart( pTextHt->GetStart() )
, m_nEnd( *pTextHt->GetAnyEnd() )
{
- m_TOXMark.DeRegister();
+ m_TOXMark.EndListeningAll();
}
void SwHistorySetTOXMark::SetInDoc( SwDoc* pDoc, bool )
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 0fde62e3091d..b36cb96f11e4 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -479,11 +479,6 @@ SwUndoSetFlyFormat::~SwUndoSetFlyFormat()
{
}
-void SwUndoSetFlyFormat::DeRegisterFromFormat( SwFormat& rFormat )
-{
- rFormat.Remove(this);
-}
-
void SwUndoSetFlyFormat::GetAnchor( SwFormatAnchor& rAnchor,
sal_uLong nNode, sal_Int32 nContent )
{
diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx
index d3212fbbe245..d9729a32552a 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -106,7 +106,7 @@ void SwXBookmark::Impl::registerInMark(SwXBookmark & rThis,
else if (m_pRegisteredBookmark)
{
m_sMarkName = m_pRegisteredBookmark->GetName();
- m_pRegisteredBookmark->Remove(this);
+ EndListeningAll();
}
m_pRegisteredBookmark = pBkmk;
// need a permanent Reference to initialize m_wThis
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 6bfbe15c641b..71f2f1980c16 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -2324,7 +2324,7 @@ void SAL_CALL SwChartDataSequence::dispose( )
SwModify* pLclRegisteredIn = GetRegisteredInNonConst();
if (pLclRegisteredIn && pLclRegisteredIn->HasWriterListeners())
{
- pLclRegisteredIn->Remove(this);
+ EndListeningAll();
m_pTableCursor.reset(nullptr);
}
}
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index d207d0cf2106..ba98ccffdece 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -997,8 +997,7 @@ SwXShape::~SwXShape()
xShapeAgg->setDelegator(xRef);
}
delete pImpl;
- if(GetRegisteredIn())
- GetRegisteredIn()->Remove(this);
+ EndListeningAll();
}
uno::Any SwXShape::queryInterface( const uno::Type& aType )
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index de09842ea8e8..5e45a339d1a6 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -2570,7 +2570,7 @@ void SwXTextField::Impl::Invalidate()
{
if (GetRegisteredIn())
{
- GetRegisteredInNonConst()->Remove(this);
+ EndListeningAll();
m_pFormatField = nullptr;
m_pDoc = nullptr;
uno::Reference<uno::XInterface> const xThis(m_wThis);
diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx
index d907f74cf314..425e894e60ac 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -346,8 +346,7 @@ SwXFlatParagraphIterator::SwXFlatParagraphIterator( SwDoc& rDoc, sal_Int32 nType
SwXFlatParagraphIterator::~SwXFlatParagraphIterator()
{
SolarMutexGuard aGuard;
- if(GetRegisteredIn())
- GetRegisteredIn()->Remove(this);
+ EndListeningAll();
}
void SwXFlatParagraphIterator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 4eea5204a6c8..735e6756a353 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1264,8 +1264,7 @@ SwXFrame::~SwXFrame()
SolarMutexGuard aGuard;
delete m_pCopySource;
delete pProps;
- if(GetRegisteredIn())
- GetRegisteredIn()->Remove(this);
+ EndListeningAll();
}
template<class Interface, class NameLookupIsHard>
diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx
index 7b251e910d34..3b5424f15d43 100644
--- a/sw/source/core/unocore/unoftn.cxx
+++ b/sw/source/core/unocore/unoftn.cxx
@@ -94,10 +94,7 @@ protected:
void SwXFootnote::Impl::Invalidate()
{
- if (GetRegisteredIn())
- {
- GetRegisteredIn()->Remove(this);
- }
+ EndListeningAll();
m_pFormatFootnote = nullptr;
m_rThis.SetDoc(nullptr);
uno::Reference<uno::XInterface> const xThis(m_wThis);
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index b484f9fb4882..4d26cd73953b 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -1593,12 +1593,8 @@ void SwXDocumentIndexMark::Impl::Invalidate()
{
if (GetRegisteredIn())
{
- GetRegisteredIn()->Remove(this);
- if (m_TypeDepend.GetRegisteredIn())
- {
- m_TypeDepend.GetRegisteredIn()->Remove(
- &m_TypeDepend);
- }
+ EndListeningAll();
+ m_TypeDepend.EndListeningAll();
}
if (!m_bInReplaceMark) // #i109983# only dispose on delete, not on replace!
{
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index e175fcf84d62..02a921443eea 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -316,14 +316,14 @@ void ClientModify(SwClient* pClient, const SfxPoolItem *pOld, const SfxPoolItem
case RES_REMOVE_UNO_OBJECT:
case RES_OBJECTDYING:
if( static_cast<void*>(pClient->GetRegisteredIn()) == static_cast<const SwPtrMsgPoolItem *>(pOld)->pObject )
- pClient->GetRegisteredIn()->Remove(pClient);
+ pClient->EndListeningAll();
break;
case RES_FMT_CHG:
// Is the move to the new one finished and will the old one be deleted?
if( static_cast<const SwFormatChg*>(pNew)->pChangedFormat == pClient->GetRegisteredIn() &&
static_cast<const SwFormatChg*>(pOld)->pChangedFormat->IsFormatInDTOR() )
- pClient->GetRegisteredIn()->Remove(pClient);
+ pClient->EndListeningAll();
break;
}
}
@@ -733,17 +733,15 @@ void SwXTextRange::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew
{
ClientModify(&m_ObjectDepend, pOld, pNew);
// if the depend was removed then the range must be removed too
- if (!m_ObjectDepend.GetRegisteredIn() && GetRegisteredIn())
+ if (!m_ObjectDepend.GetRegisteredIn())
{
- GetRegisteredIn()->Remove(this);
+ EndListeningAll();
}
// or if the range has been removed but the depend is still
// connected then the depend must be removed
- else if (bAlreadyRegistered && !GetRegisteredIn() &&
- m_ObjectDepend.GetRegisteredIn())
+ else if (bAlreadyRegistered && !GetRegisteredIn())
{
- m_ObjectDepend.GetRegisteredIn()
- ->Remove(& m_ObjectDepend);
+ m_ObjectDepend.EndListeningAll();
}
}
if (!GetRegisteredIn())
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index 8907e236f079..17daea420340 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -127,11 +127,7 @@ SwXTextPortion::~SwXTextPortion()
{
SolarMutexGuard aGuard;
m_pUnoCursor.reset(nullptr);
- if(m_FrameDepend.GetRegisteredIn())
- {
- auto pFrameDepend(const_cast<SwDepend*>(&m_FrameDepend));
- pFrameDepend->GetRegisteredIn()->Remove(pFrameDepend);
- }
+ const_cast<SwDepend*>(&m_FrameDepend)->EndListeningAll();
}
uno::Reference< text::XText > SwXTextPortion::getText()
diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx
index 49dfa4a0c56c..8560ef0ee8e9 100644
--- a/sw/source/core/unocore/unorefmk.cxx
+++ b/sw/source/core/unocore/unorefmk.cxx
@@ -98,10 +98,7 @@ protected:
void SwXReferenceMark::Impl::Invalidate()
{
- if (IsValid())
- {
- GetRegisteredIn()->Remove(this);
- }
+ EndListeningAll();
m_pDoc = nullptr;
m_pMarkFormat = nullptr;
uno::Reference<uno::XInterface> const xThis(m_wThis);
@@ -117,7 +114,7 @@ void SwXReferenceMark::Impl::Modify( const SfxPoolItem* pOld, const SfxPoolItem
{
ClientModify(this, pOld, pNew);
- if (!GetRegisteredIn()) // removed => dispose
+ if (!IsValid()) // removed => dispose
{
Invalidate();
}
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 604be8e774c6..795883a47ac2 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1310,8 +1310,7 @@ SwXStyle::~SwXStyle()
if(m_pBasePool)
EndListening(*m_pBasePool);
m_pPropertiesImpl.reset();
- if(GetRegisteredIn())
- GetRegisteredIn()->Remove( this );
+ SwClient::EndListeningAll();
}
void SwXStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 67a96acbe0f9..9ee71e613a54 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -774,8 +774,7 @@ SwXCell::SwXCell(SwFrameFormat* pTableFormat, const SwStartNode& rStartNode) :
SwXCell::~SwXCell()
{
SolarMutexGuard aGuard;
- if(GetRegisteredIn())
- GetRegisteredIn()->Remove(this);
+ EndListeningAll();
}
namespace
@@ -1276,8 +1275,7 @@ SwXTextTableRow::SwXTextTableRow(SwFrameFormat* pFormat, SwTableLine* pLn) :
SwXTextTableRow::~SwXTextTableRow()
{
SolarMutexGuard aGuard;
- if(GetRegisteredIn())
- GetRegisteredIn()->Remove(this);
+ EndListeningAll();
}
uno::Reference< beans::XPropertySetInfo > SwXTextTableRow::getPropertySetInfo()
@@ -3100,7 +3098,7 @@ void SwXTextTable::Impl::Modify(
{
if(pOld && pOld->Which() == RES_REMOVE_UNO_OBJECT &&
static_cast<void*>(GetRegisteredIn()) == static_cast<const SwPtrMsgPoolItem *>(pOld)->pObject )
- GetRegisteredIn()->Remove(this);
+ EndListeningAll();
else
ClientModify(this, pOld, pNew);
uno::Reference<uno::XInterface> const xThis(m_wThis);
diff --git a/sw/source/core/unocore/unotextmarkup.cxx b/sw/source/core/unocore/unotextmarkup.cxx
index 9fcf616ee5cb..ce39a1f0529d 100644
--- a/sw/source/core/unocore/unotextmarkup.cxx
+++ b/sw/source/core/unocore/unotextmarkup.cxx
@@ -476,10 +476,7 @@ void SAL_CALL SwXTextMarkup::commitMultiTextMarkup(
void SwXTextMarkup::Impl::Modify( const SfxPoolItem* /*pOld*/, const SfxPoolItem* /*pNew*/ )
{
DBG_TESTSOLARMUTEX();
-
- if ( GetRegisteredIn() )
- GetRegisteredInNonConst()->Remove( this );
-
+ EndListeningAll();
m_pTextNode = nullptr;
}
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index e09f2ab91387..178121062d1a 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -4814,11 +4814,9 @@ namespace
class FrameDeleteWatch : public SwClient
{
SwFrameFormat* m_pObjectFormat;
- bool m_bDeleted;
public:
FrameDeleteWatch(SwFrameFormat* pObjectFormat)
: m_pObjectFormat(pObjectFormat)
- , m_bDeleted(false)
{
if (m_pObjectFormat)
m_pObjectFormat->Add(this);
@@ -4832,21 +4830,19 @@ namespace
{
if (pDrawFrameFormatHint->m_eId == sw::DrawFrameFormatHintId::DYING)
{
- m_pObjectFormat->Remove(this);
- m_bDeleted = true;
+ EndListeningAll();
}
}
}
bool WasDeleted() const
{
- return m_bDeleted;
+ return !GetRegisteredIn();
}
virtual ~FrameDeleteWatch() override
{
- if (!m_bDeleted && m_pObjectFormat)
- m_pObjectFormat->Remove(this);
+ EndListeningAll();
}
};
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 3cb67e703bef..c24502019fe1 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -923,7 +923,7 @@ void SwHTMLParser::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
if (pOld && static_cast<const SwPtrMsgPoolItem *>(pOld)->pObject == GetRegisteredIn())
{
// then we kill ourself
- GetRegisteredInNonConst()->Remove( this );
+ EndListeningAll();
ReleaseRef(); // otherwise we're done!
}
break;
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index f85206f4c656..00d8a7a0f783 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -226,11 +226,8 @@ class FieldDeletionModify : public SwModify
virtual ~FieldDeletionModify() override
{
- if (mpFormatField)
- {
- // Dialog closed, remove modification listener
- mpFormatField->Remove(this);
- }
+ // Dialog closed, remove modification listener
+ EndListeningAll();
}
void Modify( const SfxPoolItem* pOld, const SfxPoolItem *) override
More information about the Libreoffice-commits
mailing list