diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2020-03-21 22:22:43 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@libreoffice.org> | 2020-03-22 22:58:48 +0100 |
commit | d3a93e772a8a0ffb63874aa32add5a302845089f (patch) | |
tree | 8a7a2ecc8208ffb23eaa0a4e00e331bae97cf5d7 | |
parent | 13aed54fda6d84e1a0f6c080a7b2d83f793725c5 (diff) |
FieldDeletionModify: no more Modify
Change-Id: Iec2c7d6178358a4145c10f1c22ab526f03670806
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90862
Tested-by: Jenkins
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@libreoffice.org>
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh2.cxx | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx index f36a668dc83a..951989e4f108 100644 --- a/sw/source/uibase/wrtsh/wrtsh2.cxx +++ b/sw/source/uibase/wrtsh/wrtsh2.cxx @@ -21,6 +21,7 @@ #include <svl/macitem.hxx> #include <sfx2/frame.hxx> #include <svl/eitem.hxx> +#include <svl/listener.hxx> #include <svl/stritem.hxx> #include <sfx2/docfile.hxx> #include <sfx2/dispatch.hxx> @@ -209,10 +210,10 @@ namespace { // Otherwise, the for loop in SwWrtShell::UpdateInputFields will crash when doing: // 'pTmp->GetField( i )->GetTyp()->UpdateFields();' // on a deleted field. -class FieldDeletionModify : public SwModify +class FieldDeletionListener : public SvtListener { public: - FieldDeletionModify(AbstractFieldInputDlg* pInputFieldDlg, SwField* pField) + FieldDeletionListener(AbstractFieldInputDlg* pInputFieldDlg, SwField* pField) : mpInputFieldDlg(pInputFieldDlg) , mpFormatField(nullptr) { @@ -230,28 +231,22 @@ class FieldDeletionModify : public SwModify // Register for possible field deletion while dialog is open if (mpFormatField) - mpFormatField->Add(this); + StartListening(mpFormatField->GetNotifier()); } - virtual ~FieldDeletionModify() override + virtual ~FieldDeletionListener() override { // Dialog closed, remove modification listener EndListeningAll(); } - void Modify( const SfxPoolItem* pOld, const SfxPoolItem *) override + virtual void Notify(const SfxHint& rHint) override { // Input field has been deleted: better to close the dialog - if (pOld) + if(rHint.GetId() == SfxHintId::Dying) { - switch (pOld->Which()) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - mpFormatField = nullptr; - mpInputFieldDlg->EndDialog(RET_CANCEL); - break; - } + mpFormatField = nullptr; + mpInputFieldDlg->EndDialog(RET_CANCEL); } } private: @@ -272,7 +267,7 @@ bool SwWrtShell::StartInputFieldDlg(SwField* pField, bool bPrevButton, bool bNex bool bRet; { - FieldDeletionModify aModify(pDlg.get(), pField); + FieldDeletionListener aModify(pDlg.get(), pField); bRet = RET_CANCEL == pDlg->Execute(); } |