summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-14 17:41:46 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-16 20:37:23 +0100
commit1fb1016eca1d8e9f43baad18bf7228913aa29715 (patch)
tree36e28fad1dbdd61fce674c199f7b00eef9c91864
parentea7f16bf0b5e195d65e51c624b0fb37980bf2b95 (diff)
Pipe legacy Modify calls through SwClientModify
Change-Id: Ic55abdee0486021d8361271fabec9fcaa06c3502
-rw-r--r--sw/inc/calbck.hxx42
-rw-r--r--sw/source/core/fields/ddetbl.cxx3
-rw-r--r--sw/source/core/layout/atrfrm.cxx3
-rw-r--r--sw/source/core/layout/sectfrm.cxx1
-rw-r--r--sw/source/core/txtnode/atrfld.cxx3
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx1
6 files changed, 38 insertions, 15 deletions
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 89f9f758d46d..6e1a1cc16f4a 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -26,6 +26,7 @@
#include <ring.hxx>
#include <hintids.hxx>
#include <hints.hxx>
+#include <typeinfo>
class SwModify;
@@ -65,6 +66,12 @@ class SwClient;
class SwClientIter;
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
class SW_DLLPUBLIC WriterListener : ::boost::noncopyable
{
@@ -79,11 +86,7 @@ namespace sw
: m_pLeft(nullptr), m_pRight(nullptr)
{}
virtual ~WriterListener() {};
- // 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 these methods should be pure virtual
- virtual void Modify(const SfxPoolItem*, const SfxPoolItem*) {};
- virtual void SwClientNotify( const SwModify&, const SfxHint&) {};
+ virtual void SwClientNotify( const SwModify&, const SfxHint& rHint) =0;
public:
bool IsLast() const { return !m_pLeft && !m_pRight; }
};
@@ -108,8 +111,20 @@ public:
SwClient() : pRegisteredIn(nullptr) {}
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
{ 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,
// 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
bool bInSwFntCache : 1;
// 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
{ NotifyClients( pOld, pNew ); };
@@ -151,23 +167,25 @@ public:
SwModify()
: 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
+ // DO NOT USE IN NEW CODE! use CallSwClientNotify instead.
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
// mba: it would be interesting to know why this is necessary
// 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
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();
void Add(SwClient *pDepend);
diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx
index be1212d8de01..277438e0686a 100644
--- a/sw/source/core/fields/ddetbl.cxx
+++ b/sw/source/core/fields/ddetbl.cxx
@@ -86,8 +86,9 @@ void SwDDETable::Modify( const SfxPoolItem* pOld, const SfxPoolItem* 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 );
if ( pHint )
// replace DDETable by real table
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index d93118f3a162..c1d3ae6087bf 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -628,8 +628,9 @@ SfxPoolItem* SwFmtPageDesc::Clone( SfxItemPool* ) const
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);
if ( pHint )
{
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index f0a6c85c42c9..e719b882b670 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -2283,6 +2283,7 @@ void SwSectionFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
void SwSectionFrm::SwClientNotify( const SwModify& rMod, const SfxHint& rHint )
{
+ SwClient::SwClientNotify(rMod, rHint);
// #i117863#
const SwSectionFrmMoveAndDeleteHint* pHint =
dynamic_cast<const SwSectionFrmMoveAndDeleteHint*>(&rHint);
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index bf45bba005c4..34aee5e32c23 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -204,8 +204,9 @@ void SwFmtFld::InvalidateField()
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 )
return;
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 55bdf180032d..308004b3d0ed 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -5069,6 +5069,7 @@ bool SwTxtNode::IsInContent() const
void SwTxtNode::SwClientNotify( const SwModify& rModify, const SfxHint& rHint )
{
+ SwClient::SwClientNotify(rModify, rHint);
const SwAttrHint* pHint = dynamic_cast<const SwAttrHint*>(&rHint);
if ( pHint && pHint->GetId() == RES_CONDTXTFMTCOLL && &rModify == GetRegisteredIn() )
ChkCondColl();