summaryrefslogtreecommitdiff
path: root/sw/source/core/fields/reffld.cxx
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/source/core/fields/reffld.cxx
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/source/core/fields/reffld.cxx')
-rw-r--r--sw/source/core/fields/reffld.cxx53
1 files changed, 31 insertions, 22 deletions
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 {