Kaydet (Commit) 36847ce4 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen Kaydeden (comit) Björn Michaelsen

make SwDepend an implementation detail of sw::WriterMultiListener

- ... and rename it to ListenerEntry

Change-Id: Ie0f77f1d381da469899420f864995e1697e4c639
Reviewed-on: https://gerrit.libreoffice.org/53909Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>
üst 642cc000
......@@ -251,18 +251,19 @@ private:
namespace sw
{
class ListenerEntry;
class SW_DLLPUBLIC WriterMultiListener final
{
#ifdef WNT
typedef std::shared_ptr<SwDepend> pointer_t;
typedef std::shared_ptr<ListenerEntry> pointer_t;
#else
typedef std::unique_ptr<SwDepend> pointer_t;
typedef std::unique_ptr<ListenerEntry> pointer_t;
#endif
SwClient& m_rToTell;
std::vector<pointer_t> m_vDepends;
public:
WriterMultiListener(SwClient& rToTell)
: m_rToTell(rToTell) {}
WriterMultiListener(SwClient& rToTell);
~WriterMultiListener();
void StartListening(SwModify* pDepend);
void EndListening(SwModify* pDepend);
bool IsListeningTo(const SwModify* const pDepend);
......
......@@ -25,6 +25,43 @@
#include <tools/debug.hxx>
#include <algorithm>
namespace sw
{
class ListenerEntry final : public SwClient
{
SwClient *m_pToTell;
public:
ListenerEntry(SwClient* pTellHim, SwModify * pDepend) : SwClient(pDepend), m_pToTell(pTellHim) {}
ListenerEntry(ListenerEntry&) = delete;
/** get Client information */
virtual bool GetInfo( SfxPoolItem& rInfo) const override
{ return m_pToTell == nullptr || m_pToTell->GetInfo( rInfo ); }
private:
virtual void Modify( const SfxPoolItem* pOldValue, const SfxPoolItem *pNewValue ) override
{
SwClientNotify(*GetRegisteredIn(), sw::LegacyModifyHint(pOldValue, pNewValue));
}
virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) override
{
if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
{
if( pLegacyHint->m_pNew && pLegacyHint->m_pNew->Which() == RES_OBJECTDYING )
{
auto pModifyChanged = CheckRegistration(pLegacyHint->m_pOld);
if(pModifyChanged)
m_pToTell->SwClientNotify(rModify, *pModifyChanged);
}
else if( m_pToTell )
m_pToTell->ModifyNotification(pLegacyHint->m_pOld, pLegacyHint->m_pNew);
}
else if(m_pToTell)
m_pToTell->SwClientNotifyCall(rModify, rHint);
}
};
}
sw::LegacyModifyHint::~LegacyModifyHint() {}
sw::ModifyChangedHint::~ModifyChangedHint() {}
......@@ -296,10 +333,17 @@ void SwModify::CheckCaching( const sal_uInt16 nWhich )
}
}
sw::WriterMultiListener::WriterMultiListener(SwClient& rToTell)
: m_rToTell(rToTell)
{}
sw::WriterMultiListener::~WriterMultiListener()
{}
void sw::WriterMultiListener::StartListening(SwModify* pDepend)
{
EndListening(nullptr);
m_vDepends.emplace_back(pointer_t( new SwDepend(&m_rToTell, pDepend)));
m_vDepends.emplace_back(pointer_t(new ListenerEntry(&m_rToTell, pDepend)));
}
......
......@@ -1582,7 +1582,7 @@ struct SwXParaFrameEnumerationImpl final : public SwXParaFrameEnumeration
}
else
{
// removing orphaned SwDepends
// removing orphaned Clients
const auto iter = std::remove_if(m_vFrames.begin(), m_vFrames.end(),
[] (std::shared_ptr<sw::FrameClient>& rEntry) -> bool { return !rEntry->GetRegisteredIn(); });
m_vFrames.erase(iter, m_vFrames.end());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment