Remove SwModify::SetInDocDTOR ...

... its only used once in SwTOXType and has no place in SwModify, which
is the base of ~everything in Writer still.

Change-Id: I07007f08723f8db2dd09bb7c07cb0ebfc2a6506a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110594
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 32b0d35..0cd8efb 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -201,7 +201,6 @@ public:

    void LockModify()                   { m_bModifyLocked = true;  }
    void UnlockModify()                 { m_bModifyLocked = false; }
    void SetInDocDTOR();
    bool IsModifyLocked() const     { return m_bModifyLocked;  }

    void CheckCaching( const sal_uInt16 nWhich );
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index 25fed4c..e83d422 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -166,6 +166,10 @@ public:
    const SwTableBox& m_rTableBox;
    MoveTableBoxHint(const SwFrameFormat& rNewFormat, const SwTableBox& rTableBox): m_rNewFormat(rNewFormat), m_rTableBox(rTableBox) {};
};

class DocumentDyingHint final : public SfxHint
{
};
}

class SwUpdateAttr final : public SwMsgPoolItem
diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx
index c7bcaac..f1b4960 100644
--- a/sw/inc/tox.hxx
+++ b/sw/inc/tox.hxx
@@ -19,20 +19,20 @@
#ifndef INCLUDED_SW_INC_TOX_HXX
#define INCLUDED_SW_INC_TOX_HXX

#include <vector>

#include <cppuhelper/weakref.hxx>
#include <sal/log.hxx>

#include <i18nlangtag/lang.h>
#include <svl/poolitem.hxx>
#include <svl/listener.hxx>

#include <editeng/svxenum.hxx>
#include <i18nlangtag/lang.h>
#include <o3tl/typed_flags_set.hxx>
#include <sal/log.hxx>
#include <svl/listener.hxx>
#include <svl/poolitem.hxx>

#include "calbck.hxx"
#include "hints.hxx"
#include "swtypes.hxx"
#include "toxe.hxx"
#include "calbck.hxx"
#include <o3tl/typed_flags_set.hxx>

#include <vector>

namespace com::sun::star {
    namespace text { class XDocumentIndexMark; }
@@ -467,6 +467,13 @@ public:
    SwTOXBase( const SwTOXBase& rCopy, SwDoc* pDoc = nullptr );
    virtual ~SwTOXBase() override;

    virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override
    {
        if(dynamic_cast<const sw::DocumentDyingHint*>(&rHint))
            GetRegisteredIn()->Remove(this);
        else
            SwClient::SwClientNotify(rMod, rHint);
    }
    // a kind of CopyCtor - check if the TOXBase is at TOXType of the doc.
    // If not, so create it and copy all other used things.
    void                CopyTOXBase( SwDoc*, const SwTOXBase& );
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 0efc4ad..ae840ed 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -138,17 +138,6 @@ void SwClient::EndListeningAll()
        m_pRegisteredIn->Remove(this);
}

void SwModify::SetInDocDTOR()
{
    // If the document gets destroyed anyway, just tell clients to
    // forget me so that they don't try to get removed from my list
    // later when they also get destroyed
    SwIterator<SwClient,SwModify> aIter(*this);
    for(SwClient* pClient = aIter.First(); pClient; pClient = aIter.Next())
        pClient->m_pRegisteredIn = nullptr;
    m_pWriterListeners = nullptr;
}

SwModify::~SwModify()
{
    DBG_TESTSOLARMUTEX();
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 575980c..9c789de 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -466,16 +466,9 @@ SwDoc::~SwDoc()
        delete pTmp;
    }

    // Old - deletion without a Flag is expensive, because we send a Modify
    // aTOXTypes.DeleteAndDestroy( 0, aTOXTypes.Count() );
    {
        for( auto n = mpTOXTypes->size(); n; )
        {
            (*mpTOXTypes)[ --n ]->SetInDocDTOR();
            (*mpTOXTypes)[ n ].reset();
        }
        mpTOXTypes->clear();
    }
    for(auto& pType : *mpTOXTypes)
        pType->CallSwClientNotify(sw::DocumentDyingHint());
    mpTOXTypes->clear();
    mpDefTOXBases.reset();

    // Any of the FrameFormats can still have indices registered.