summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-08-20 12:41:51 +0200
committerMichael Stahl <mstahl@redhat.com>2014-08-20 16:40:17 +0200
commitbbd97fe57d9ec184ef6aee36bd57d6d7e53b4719 (patch)
tree78ffc83638da9e5f7ce55f7a973ae76f7871d8b0
parentb8a28f81ecfabbbac7992f120aeedc7b36dfcbf8 (diff)
i#107771: sw: make SwXTextField a client of its format poolitem
In other words, stop registering at SwDoc's "UnoCallBack" Change-Id: Ieb2639497fe5e8d71aa1c47952c007da76fcee84
-rw-r--r--sw/inc/fmtfld.hxx7
-rw-r--r--sw/inc/hintids.hxx1
-rw-r--r--sw/source/core/attr/calbck.cxx1
-rw-r--r--sw/source/core/docnode/nodes.cxx3
-rw-r--r--sw/source/core/inc/unofield.hxx2
-rw-r--r--sw/source/core/txtnode/atrfld.cxx23
-rw-r--r--sw/source/core/txtnode/thints.cxx2
-rw-r--r--sw/source/core/unocore/unofield.cxx16
-rw-r--r--sw/source/uibase/wrtsh/wrtsh2.cxx28
9 files changed, 55 insertions, 28 deletions
diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx
index 7ab3d68b633e..6245f20da7f9 100644
--- a/sw/inc/fmtfld.hxx
+++ b/sw/inc/fmtfld.hxx
@@ -36,7 +36,10 @@ class SwView;
class SwFieldType;
// ATT_FLD
-class SW_DLLPUBLIC SwFmtFld : public SfxPoolItem, public SwClient, public SfxBroadcaster
+class SW_DLLPUBLIC SwFmtFld
+ : public SfxPoolItem
+ , public SwModify
+ , public SfxBroadcaster
{
friend void _InitCore();
SwFmtFld( sal_uInt16 nWhich ); // for default-Attibute
@@ -71,6 +74,8 @@ public:
virtual bool GetInfo( SfxPoolItem& rInfo ) const SAL_OVERRIDE;
+ void InvalidateField();
+
const SwField* GetField() const
{
return mpField;
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 80408ced54ff..3c5db6b159da 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -331,7 +331,6 @@ RES_MSG_BEGIN = RES_FMT_END,
RES_CONTENT_VISIBLE,
RES_FOOTNOTE_DELETED,
RES_GRAPHIC_SWAPIN,
- RES_FIELD_DELETED,
RES_NAME_CHANGED,
RES_TITLE_CHANGED,
RES_DESCRIPTION_CHANGED,
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index f66494352ed5..75d46e5e9307 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -174,7 +174,6 @@ void SwModify::NotifyClients( const SfxPoolItem* pOldValue, const SfxPoolItem* p
break;
case RES_FOOTNOTE_DELETED:
- case RES_FIELD_DELETED:
bLockClientList = false;
break;
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 3dc6ff6b41ae..19e7190deb10 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -290,7 +290,8 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
else
((SwDDEFieldType*)pTyp)->IncRefCnt();
}
- nDelMsg = RES_FIELD_DELETED;
+ static_cast<SwFmtFld&>(pAttr->GetAttr())
+ .InvalidateField();
}
break;
diff --git a/sw/source/core/inc/unofield.hxx b/sw/source/core/inc/unofield.hxx
index 90b659494540..c3e0088df464 100644
--- a/sw/source/core/inc/unofield.hxx
+++ b/sw/source/core/inc/unofield.hxx
@@ -169,7 +169,7 @@ private:
virtual ~SwXTextField();
- SwXTextField(const SwFmtFld& rFmt, SwDoc & rDoc);
+ SwXTextField(SwFmtFld& rFmt, SwDoc & rDoc);
/// descriptor
SwXTextField(sal_uInt16 nServiceId, SwDoc* pDoc=0);
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index 3e06ec99fe8b..7b7dbac0c4b1 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -38,13 +38,13 @@
#include <fieldhint.hxx>
#include <svl/smplhint.hxx>
-TYPEINIT3( SwFmtFld, SfxPoolItem, SwClient,SfxBroadcaster)
+TYPEINIT3(SwFmtFld, SfxPoolItem, SwModify, SfxBroadcaster)
TYPEINIT1(SwFmtFldHint, SfxHint);
// constructor for default item in attribute-pool
SwFmtFld::SwFmtFld( sal_uInt16 nWhich )
: SfxPoolItem( nWhich )
- , SwClient()
+ , SwModify(0)
, SfxBroadcaster()
, mpField( NULL )
, mpTxtFld( NULL )
@@ -53,7 +53,7 @@ SwFmtFld::SwFmtFld( sal_uInt16 nWhich )
SwFmtFld::SwFmtFld( const SwField &rFld )
: SfxPoolItem( RES_TXTATR_FIELD )
- , SwClient( rFld.GetTyp() )
+ , SwModify( rFld.GetTyp() )
, SfxBroadcaster()
, mpField( rFld.CopyField() )
, mpTxtFld( NULL )
@@ -77,7 +77,7 @@ SwFmtFld::SwFmtFld( const SwField &rFld )
// corrected
SwFmtFld::SwFmtFld( const SwFmtFld& rAttr )
: SfxPoolItem( RES_TXTATR_FIELD )
- , SwClient()
+ , SwModify(0)
, SfxBroadcaster()
, mpField( NULL )
, mpTxtFld( NULL )
@@ -183,6 +183,13 @@ SfxPoolItem* SwFmtFld::Clone( SfxItemPool* ) const
return new SwFmtFld( *this );
}
+void SwFmtFld::InvalidateField()
+{
+ SwPtrMsgPoolItem const item(RES_REMOVE_UNO_OBJECT,
+ &static_cast<SwModify&>(*this)); // cast to base class (void*)
+ NotifyClients(&item, &item);
+}
+
void SwFmtFld::SwClientNotify( const SwModify&, const SfxHint& rHint )
{
if( !mpTxtFld )
@@ -208,6 +215,14 @@ void SwFmtFld::SwClientNotify( const SwModify&, const SfxHint& rHint )
void SwFmtFld::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
{
+ if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
+ { // invalidate cached UNO object
+ SetXTextField(css::uno::Reference<css::text::XTextField>(0));
+ // ??? why does this Modify method not already do this?
+ NotifyClients(pOld, pNew);
+ return;
+ }
+
if( !mpTxtFld )
return;
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index d98790aa7ba0..4d84c9110d22 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1178,7 +1178,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr )
}
}
}
- nDelMsg = RES_FIELD_DELETED;
+ static_cast<SwFmtFld&>(pAttr->GetAttr()).InvalidateField();
break;
case RES_TXTATR_TOXMARK:
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 5ae7debea9c2..566381e6ab5f 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1152,9 +1152,9 @@ public:
OUString m_sTypeName;
boost::scoped_ptr<SwFieldProperties_Impl> m_pProps;
- Impl(SwDoc *const pDoc, SwFmtFld const*const pFmt,
+ Impl(SwDoc *const pDoc, SwFmtFld *const pFmt,
sal_uInt16 const nServiceId)
- : SwClient((pFmt) ? pDoc->GetUnoCallBack() : 0)
+ : SwClient(pFmt)
, m_EventListeners(m_Mutex)
, m_pFmtFld(pFmt)
, m_pDoc(pDoc)
@@ -1225,9 +1225,7 @@ SwXTextField::SwXTextField(
}
}
-SwXTextField::SwXTextField(
- const SwFmtFld& rFmt,
- SwDoc & rDoc)
+SwXTextField::SwXTextField(SwFmtFld& rFmt, SwDoc & rDoc)
: m_pImpl(new Impl(&rDoc, &rFmt, USHRT_MAX))
{
}
@@ -1251,7 +1249,7 @@ SwXTextField::CreateXTextField(SwDoc *const pDoc, SwFmtFld const* pFmt,
if (!xField.is())
{
SwXTextField *const pField( (pFmt)
- ? new SwXTextField(*pFmt, *pDoc)
+ ? new SwXTextField(const_cast<SwFmtFld&>(*pFmt), *pDoc)
: new SwXTextField(nServiceId, pDoc));
xField.set(pField);
if (pFmt)
@@ -1995,7 +1993,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
assert(m_pImpl->m_pFmtFld);
m_pImpl->m_pDoc = pDoc;
- m_pImpl->m_pDoc->GetUnoCallBack()->Add(m_pImpl.get());
+ const_cast<SwFmtFld *>(m_pImpl->m_pFmtFld)->Add(m_pImpl.get());
m_pImpl->m_bIsDescriptor = false;
if (m_pImpl->m_FieldTypeClient.GetRegisteredIn())
{
@@ -2649,10 +2647,6 @@ void SwXTextField::Impl::Modify(
((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() )
Invalidate();
break;
- case RES_FIELD_DELETED:
- if ((void*)m_pFmtFld == ((SwPtrMsgPoolItem *)pOld)->pObject)
- Invalidate();
- break;
}
}
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 4ea08d500929..9777940994e7 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -43,6 +43,7 @@
#include <IDocumentUndoRedo.hxx>
#include <viewopt.hxx>
#include <frmfmt.hxx>
+#include <fmtfld.hxx>
#include <swtable.hxx>
#include <mdiexp.hxx>
#include <view.hxx>
@@ -178,10 +179,16 @@ class FieldDeletionModify : public SwModify
void Modify( const SfxPoolItem* pOld, const SfxPoolItem *) SAL_OVERRIDE
{
- // Input fields have been deleted: better to close the dialog
- if (pOld->Which() == RES_FIELD_DELETED)
+ // Input field has been deleted: better to close the dialog
+ if (pOld)
{
- mpInputFieldDlg->EndDialog(RET_CANCEL);
+ switch (pOld->Which())
+ {
+ case RES_REMOVE_UNO_OBJECT:
+ case RES_OBJECTDYING:
+ mpInputFieldDlg->EndDialog(RET_CANCEL);
+ break;
+ }
}
}
private:
@@ -201,14 +208,21 @@ bool SwWrtShell::StartInputFldDlg( SwField* pFld, bool bNextButton,
if(pWindowState && !pWindowState->isEmpty())
pDlg->SetWindowState(*pWindowState);
- // Register for possible input field deletion while dialog is open
FieldDeletionModify aModify(pDlg.get());
- GetDoc()->GetUnoCallBack()->Add(&aModify);
+ SwInputField *const pInputField(dynamic_cast<SwInputField*>(pFld));
+ if (pInputField)
+ {
+ // Register for possible input field deletion while dialog is open
+ pInputField->GetFmtFld()->Add(&aModify);
+ }
bool bRet = RET_CANCEL == pDlg->Execute();
- // Dialog closed, remove modification listener
- GetDoc()->GetUnoCallBack()->Remove(&aModify);
+ if (pInputField)
+ {
+ // Dialog closed, remove modification listener
+ pInputField->GetFmtFld()->Remove(&aModify);
+ }
if(pWindowState)
*pWindowState = pDlg->GetWindowState();