summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2020-11-16 00:21:46 +0100
committerBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2020-11-16 19:04:28 +0100
commita27966454efc25591fe198548d38e5eafe443a68 (patch)
tree5908e03e52704e23674093928ffa7f7ecfab827f /sw
parentd129e1785e541f217d4f6547faec87b9fa772019 (diff)
Replace needless SwClientNotifyCalls with CallSwClientNotify
Change-Id: I967d458be7cd7c68ff410357da0cb0163dcb454e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105908 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/reffld.hxx3
-rw-r--r--sw/source/core/doc/DocumentFieldsManager.cxx23
-rw-r--r--sw/source/core/fields/reffld.cxx53
3 files changed, 42 insertions, 37 deletions
diff --git a/sw/inc/reffld.hxx b/sw/inc/reffld.hxx
index 6d9ee86f7950..c76fe074c854 100644
--- a/sw/inc/reffld.hxx
+++ b/sw/inc/reffld.hxx
@@ -67,7 +67,7 @@ class SAL_DLLPUBLIC_RTTI SwGetRefFieldType final : public SwFieldType
SwDoc& m_rDoc;
/// Overlay in order to update all ref-fields.
- virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
+ virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
public:
SwGetRefFieldType(SwDoc& rDoc );
virtual std::unique_ptr<SwFieldType> Copy() const override;
@@ -80,6 +80,7 @@ public:
sal_uInt16 nSubType, sal_uInt16 nSeqNo,
sal_Int32* pStt, sal_Int32* pEnd = nullptr,
SwRootFrame const* pLayout = nullptr);
+ void UpdateGetReferences();
};
class SW_DLLPUBLIC SwGetRefField final : public SwField
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index bafe9c29fb00..cbae4727e10d 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -179,11 +179,6 @@ namespace
#endif
}
}
- void lcl_SwClientNotify(sw::BroadcastingModify& rModify, const SfxPoolItem* pNew)
- {
- const sw::LegacyModifyHint aHint(nullptr, pNew);
- rModify.SwClientNotifyCall(rModify, aHint);
- }
}
namespace sw
@@ -409,7 +404,7 @@ void DocumentFieldsManager::UpdateFields( bool bCloseDB )
case SwFieldIds::Dde:
{
SwMsgPoolItem aUpdateDDE( RES_UPDATEDDETBL );
- lcl_SwClientNotify(*pFieldType, &aUpdateDDE );
+ pFieldType->CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aUpdateDDE));
break;
}
case SwFieldIds::GetExp:
@@ -419,7 +414,7 @@ void DocumentFieldsManager::UpdateFields( bool bCloseDB )
// Expression fields are treated separately
break;
default:
- lcl_SwClientNotify(*pFieldType, nullptr );
+ pFieldType->CallSwClientNotify(sw::LegacyModifyHint(nullptr, nullptr));
}
}
@@ -567,7 +562,7 @@ bool DocumentFieldsManager::UpdateField(SwTextField * pDstTextField, SwField & r
if (bUpdateFields)
UpdateTableFields( &aTableUpdate );
else
- lcl_SwClientNotify(*pNewField->GetTyp(), &aTableUpdate);
+ pNewField->GetTyp()->CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aTableUpdate));
if (! bUpdateFields)
bTableSelBreak = true;
@@ -577,7 +572,7 @@ bool DocumentFieldsManager::UpdateField(SwTextField * pDstTextField, SwField & r
case SwFieldIds::Macro:
if( bUpdateFields && pDstTextField->GetpTextNode() )
- lcl_SwClientNotify(*pDstTextField->GetpTextNode(), pDstFormatField);
+ pDstTextField->GetpTextNode()->TriggerNodeUpdate(sw::LegacyModifyHint(nullptr, pDstFormatField));
break;
case SwFieldIds::DatabaseName:
@@ -620,9 +615,9 @@ bool DocumentFieldsManager::UpdateField(SwTextField * pDstTextField, SwField & r
/// Update reference and table fields
void DocumentFieldsManager::UpdateRefFields()
{
- for( auto const & pFieldType : *mpFieldTypes )
- if( SwFieldIds::GetRef == pFieldType->Which() )
- lcl_SwClientNotify(*pFieldType, nullptr );
+ for(auto const& pFieldType: *mpFieldTypes)
+ if(SwFieldIds::GetRef == pFieldType->Which())
+ static_cast<SwGetRefFieldType*>(pFieldType.get())->UpdateGetReferences();
}
void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt )
@@ -1355,10 +1350,10 @@ void DocumentFieldsManager::UpdatePageFields( SfxPoolItem* pMsgHint )
case SwFieldIds::Chapter:
case SwFieldIds::GetExp:
case SwFieldIds::RefPageGet:
- lcl_SwClientNotify(*pFieldType, pMsgHint);
+ pFieldType->CallSwClientNotify(sw::LegacyModifyHint(nullptr, pMsgHint));
break;
case SwFieldIds::DocStat:
- lcl_SwClientNotify(*pFieldType, nullptr);
+ pFieldType->CallSwClientNotify(sw::LegacyModifyHint(nullptr, nullptr));
break;
default: break;
}
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 7d9e73feb7de..b7e75f405d6b 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -1070,33 +1070,42 @@ std::unique_ptr<SwFieldType> SwGetRefFieldType::Copy() const
return std::make_unique<SwGetRefFieldType>( m_rDoc );
}
-void SwGetRefFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
+void SwGetRefFieldType::UpdateGetReferences()
{
- // update to all GetReference fields
- if( !pNew && !pOld )
+ std::vector<SwFormatField*> vFields;
+ GatherFields(vFields, false);
+ for(auto pFormatField: vFields)
{
- std::vector<SwFormatField*> vFields;
- GatherFields(vFields, false);
- for(auto pFormatField: vFields)
+ // update only the GetRef fields
+ //JP 3.4.2001: Task 71231 - we need the correct language
+ SwGetRefField* pGRef = static_cast<SwGetRefField*>(pFormatField->GetField());
+ const SwTextField* pTField;
+ if(!pGRef->GetLanguage() &&
+ nullptr != (pTField = pFormatField->GetTextField()) &&
+ pTField->GetpTextNode())
{
- // update only the GetRef fields
- //JP 3.4.2001: Task 71231 - we need the correct language
- SwGetRefField* pGRef = static_cast<SwGetRefField*>(pFormatField->GetField());
- const SwTextField* pTField;
- if( !pGRef->GetLanguage() &&
- nullptr != ( pTField = pFormatField->GetTextField()) &&
- pTField->GetpTextNode() )
- {
- pGRef->SetLanguage( pTField->GetpTextNode()->GetLang(
- pTField->GetStart() ) );
- }
-
- // #i81002#
- pGRef->UpdateField( pFormatField->GetTextField() );
+ pGRef->SetLanguage(pTField->GetpTextNode()->GetLang(pTField->GetStart()));
}
+
+ // #i81002#
+ pGRef->UpdateField(pFormatField->GetTextField());
}
- // forward to text fields, they "expand" the text
- NotifyClients( pOld, pNew );
+ NotifyClients(nullptr, nullptr);
+}
+
+void SwGetRefFieldType::SwClientNotify(const SwModify&, const SfxHint& rHint)
+{
+ auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint);
+ if(!pLegacy)
+ return;
+ if(!pLegacy->m_pNew && !pLegacy->m_pOld)
+ // update to all GetReference fields
+ // hopefully, this codepath is soon dead code, and
+ // UpdateGetReferences gets only called directly
+ UpdateGetReferences();
+ else
+ // forward to text fields, they "expand" the text
+ NotifyClients(pLegacy->m_pOld, pLegacy->m_pNew);
}
namespace sw {