Kaydet (Commit) 1fb1016e authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

Pipe legacy Modify calls through SwClientModify

Change-Id: Ic55abdee0486021d8361271fabec9fcaa06c3502
üst ea7f16bf
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <ring.hxx> #include <ring.hxx>
#include <hintids.hxx> #include <hintids.hxx>
#include <hints.hxx> #include <hints.hxx>
#include <typeinfo>
class SwModify; class SwModify;
...@@ -65,6 +66,12 @@ class SwClient; ...@@ -65,6 +66,12 @@ class SwClient;
class SwClientIter; class SwClientIter;
namespace sw namespace sw
{ {
struct LegacyModifyHint SAL_FINAL: SfxHint
{
LegacyModifyHint(const SfxPoolItem* pOld, const SfxPoolItem* pNew) : m_pOld(pOld), m_pNew(pNew) {};
const SfxPoolItem* m_pOld;
const SfxPoolItem* m_pNew;
};
/// refactoring out the some of the more sane SwClient functionality /// refactoring out the some of the more sane SwClient functionality
class SW_DLLPUBLIC WriterListener : ::boost::noncopyable class SW_DLLPUBLIC WriterListener : ::boost::noncopyable
{ {
...@@ -79,11 +86,7 @@ namespace sw ...@@ -79,11 +86,7 @@ namespace sw
: m_pLeft(nullptr), m_pRight(nullptr) : m_pLeft(nullptr), m_pRight(nullptr)
{} {}
virtual ~WriterListener() {}; virtual ~WriterListener() {};
// callbacks received from SwModify (friend class - so these methods can be private) virtual void SwClientNotify( const SwModify&, const SfxHint& rHint) =0;
// should be called only from SwModify the client is registered in
// mba: IMHO these methods should be pure virtual
virtual void Modify(const SfxPoolItem*, const SfxPoolItem*) {};
virtual void SwClientNotify( const SwModify&, const SfxHint&) {};
public: public:
bool IsLast() const { return !m_pLeft && !m_pRight; } bool IsLast() const { return !m_pLeft && !m_pRight; }
}; };
...@@ -108,8 +111,20 @@ public: ...@@ -108,8 +111,20 @@ public:
SwClient() : pRegisteredIn(nullptr) {} SwClient() : pRegisteredIn(nullptr) {}
virtual ~SwClient() SAL_OVERRIDE; virtual ~SwClient() SAL_OVERRIDE;
// callbacks received from SwModify (friend class - so these methods can be private)
// should be called only from SwModify the client is registered in
// mba: IMHO this method should be pure virtual
// DO NOT USE IN NEW CODE! use SwClientNotify instead.
virtual void Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue ) SAL_OVERRIDE virtual void Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue ) SAL_OVERRIDE
{ CheckRegistration( pOldValue, pNewValue ); } { CheckRegistration( pOldValue, pNewValue ); }
// when overriding this, you MUST call SwClient::SwClientModify() in the override!
virtual void SwClientNotify( const SwModify&, const SfxHint& rHint)
{
// assuming the compiler to realize that a dynamic_cast to a final class is just a pointer compare ...
auto pLegacyHint(dynamic_cast<const sw::LegacyModifyHint*>(&rHint));
if(pLegacyHint)
Modify(pLegacyHint->m_pOld, pLegacyHint->m_pNew);
};
// in case an SwModify object is destroyed that itself is registered in another SwModify, // in case an SwModify object is destroyed that itself is registered in another SwModify,
// its SwClient objects can decide to get registered to the latter instead by calling this method // its SwClient objects can decide to get registered to the latter instead by calling this method
...@@ -144,6 +159,7 @@ class SW_DLLPUBLIC SwModify: public SwClient ...@@ -144,6 +159,7 @@ class SW_DLLPUBLIC SwModify: public SwClient
bool bInSwFntCache : 1; bool bInSwFntCache : 1;
// mba: IMHO this method should be pure virtual // mba: IMHO this method should be pure virtual
// DO NOT USE IN NEW CODE! use CallSwClientNotify instead.
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE
{ NotifyClients( pOld, pNew ); }; { NotifyClients( pOld, pNew ); };
...@@ -151,23 +167,25 @@ public: ...@@ -151,23 +167,25 @@ public:
SwModify() SwModify()
: SwClient(nullptr), pRoot(nullptr), bModifyLocked(false), bLockClientList(false), bInDocDTOR(false), bInCache(false), bInSwFntCache(false) : SwClient(nullptr), pRoot(nullptr), bModifyLocked(false), bLockClientList(false), bInDocDTOR(false), bInCache(false), bInSwFntCache(false)
{} {}
explicit SwModify( SwModify* pToRegisterIn )
: SwClient(pToRegisterIn), pRoot(nullptr), bModifyLocked(false), bLockClientList(false), bInDocDTOR(false), bInCache(false), bInSwFntCache(false)
{}
// broadcasting: send notifications to all clients // broadcasting: send notifications to all clients
// DO NOT USE IN NEW CODE! use CallSwClientNotify instead.
void NotifyClients( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue ); void NotifyClients( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue );
// DO NOT USE IN NEW CODE! use CallSwClientNotify instead.
void ModifyBroadcast( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
{ CallSwClientNotify( sw::LegacyModifyHint{ pOldValue, pNewValue } ); };
// the same, but without setting bModifyLocked or checking for any of the flags // the same, but without setting bModifyLocked or checking for any of the flags
// mba: it would be interesting to know why this is necessary // mba: it would be interesting to know why this is necessary
// also allows to limit callback to certain type (HACK) // also allows to limit callback to certain type (HACK)
inline void ModifyBroadcast( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, TypeId nType = TYPE(SwClient) ); // DO NOT USE IN NEW CODE! use CallSwClientNotify instead.
inline void ModifyBroadcast( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, TypeId nType );
// a more universal broadcasting mechanism // a more universal broadcasting mechanism
inline void CallSwClientNotify( const SfxHint& rHint ) const; inline void CallSwClientNotify( const SfxHint& rHint ) const;
// single argument ctors shall be explicit.
explicit SwModify( SwModify* pToRegisterIn )
: SwClient(pToRegisterIn), pRoot(nullptr), bModifyLocked(false), bLockClientList(false), bInDocDTOR(false), bInCache(false), bInSwFntCache(false)
{}
virtual ~SwModify(); virtual ~SwModify();
void Add(SwClient *pDepend); void Add(SwClient *pDepend);
......
...@@ -86,8 +86,9 @@ void SwDDETable::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) ...@@ -86,8 +86,9 @@ void SwDDETable::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
SwTable::Modify( pOld, pNew ); SwTable::Modify( pOld, pNew );
} }
void SwDDETable::SwClientNotify( const SwModify&, const SfxHint& rHint ) void SwDDETable::SwClientNotify( const SwModify& rModify, const SfxHint& rHint )
{ {
SwClient::SwClientNotify(rModify, rHint);
const SwFieldHint* pHint = dynamic_cast<const SwFieldHint*>( &rHint ); const SwFieldHint* pHint = dynamic_cast<const SwFieldHint*>( &rHint );
if ( pHint ) if ( pHint )
// replace DDETable by real table // replace DDETable by real table
......
...@@ -628,8 +628,9 @@ SfxPoolItem* SwFmtPageDesc::Clone( SfxItemPool* ) const ...@@ -628,8 +628,9 @@ SfxPoolItem* SwFmtPageDesc::Clone( SfxItemPool* ) const
return new SwFmtPageDesc( *this ); return new SwFmtPageDesc( *this );
} }
void SwFmtPageDesc::SwClientNotify( const SwModify&, const SfxHint& rHint ) void SwFmtPageDesc::SwClientNotify( const SwModify& rModify, const SfxHint& rHint )
{ {
SwClient::SwClientNotify(rModify, rHint);
const SwPageDescHint* pHint = dynamic_cast<const SwPageDescHint*>(&rHint); const SwPageDescHint* pHint = dynamic_cast<const SwPageDescHint*>(&rHint);
if ( pHint ) if ( pHint )
{ {
......
...@@ -2283,6 +2283,7 @@ void SwSectionFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew ) ...@@ -2283,6 +2283,7 @@ void SwSectionFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
void SwSectionFrm::SwClientNotify( const SwModify& rMod, const SfxHint& rHint ) void SwSectionFrm::SwClientNotify( const SwModify& rMod, const SfxHint& rHint )
{ {
SwClient::SwClientNotify(rMod, rHint);
// #i117863# // #i117863#
const SwSectionFrmMoveAndDeleteHint* pHint = const SwSectionFrmMoveAndDeleteHint* pHint =
dynamic_cast<const SwSectionFrmMoveAndDeleteHint*>(&rHint); dynamic_cast<const SwSectionFrmMoveAndDeleteHint*>(&rHint);
......
...@@ -204,8 +204,9 @@ void SwFmtFld::InvalidateField() ...@@ -204,8 +204,9 @@ void SwFmtFld::InvalidateField()
NotifyClients(&item, &item); NotifyClients(&item, &item);
} }
void SwFmtFld::SwClientNotify( const SwModify&, const SfxHint& rHint ) void SwFmtFld::SwClientNotify( const SwModify& rModify, const SfxHint& rHint )
{ {
SwClient::SwClientNotify(rModify, rHint);
if( !mpTxtFld ) if( !mpTxtFld )
return; return;
......
...@@ -5069,6 +5069,7 @@ bool SwTxtNode::IsInContent() const ...@@ -5069,6 +5069,7 @@ bool SwTxtNode::IsInContent() const
void SwTxtNode::SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) void SwTxtNode::SwClientNotify( const SwModify& rModify, const SfxHint& rHint )
{ {
SwClient::SwClientNotify(rModify, rHint);
const SwAttrHint* pHint = dynamic_cast<const SwAttrHint*>(&rHint); const SwAttrHint* pHint = dynamic_cast<const SwAttrHint*>(&rHint);
if ( pHint && pHint->GetId() == RES_CONDTXTFMTCOLL && &rModify == GetRegisteredIn() ) if ( pHint && pHint->GetId() == RES_CONDTXTFMTCOLL && &rModify == GetRegisteredIn() )
ChkCondColl(); ChkCondColl();
......
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