sw/inc/fldbas.hxx | 1 + sw/inc/fmtfld.hxx | 4 ++++ sw/source/core/fields/fldbas.cxx | 5 +++++ sw/source/core/txtnode/atrfld.cxx | 7 +++++++ sw/source/core/unocore/unofield.cxx | 20 +++++--------------- 5 files changed, 22 insertions(+), 15 deletions(-)
New commits: commit 619e757283037e2ba91cfe2038fa3778e5249dfd Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Mon Feb 24 00:11:16 2020 +0100 Commit: Björn Michaelsen <bjoern.michael...@libreoffice.org> CommitDate: Tue Feb 25 08:08:05 2020 +0100 add GatherField member function Change-Id: Ifa2ea333ccccec240cc10374fd6539a8b3f6df46 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89316 Tested-by: Jenkins Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 92a94fb8a096..1cd3b0f85c68 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -279,6 +279,7 @@ public: bool HasHiddenInformationNotes(); void GatherNodeIndex(std::vector<sal_uLong>& rvNodeIndex); void GatherRefFields(std::vector<SwGetRefField*>& rvRFields, const sal_uInt16 nTyp); + void GatherFields(std::vector<SwFormatField*>& rvFormatFields) const; }; inline void SwFieldType::UpdateFields() const diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx index 3ddce1977d96..13145771096a 100644 --- a/sw/inc/fmtfld.hxx +++ b/sw/inc/fmtfld.hxx @@ -67,6 +67,10 @@ namespace sw { const sal_uInt16 m_nType; GatherRefFieldsHint(std::vector<SwGetRefField*>& rvRFields, const sal_uInt16 nType) : m_rvRFields(rvRFields), m_nType(nType) {}; }; + struct GatherFieldsHint final : SfxHint { + std::vector<SwFormatField*>& m_rvFields; + GatherFieldsHint(std::vector<SwFormatField*>& rvFields) : m_rvFields(rvFields) {}; + }; } diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 921c69752935..5a96dfe29663 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -190,6 +190,11 @@ void SwFieldType::GatherRefFields(std::vector<SwGetRefField*>& rvRFields, const CallSwClientNotify(sw::GatherRefFieldsHint(rvRFields, nTyp)); } +void SwFieldType::GatherFields(std::vector<SwFormatField*>& rvFields) const +{ + CallSwClientNotify(sw::GatherFieldsHint(rvFields)); +} + void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const { xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldTypes")); diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 99eb71787ec0..30b8f6aec960 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -273,6 +273,13 @@ void SwFormatField::SwClientNotify( const SwModify& rModify, const SfxHint& rHin SwTextNode* pNd = GetTextField()->GetpTextNode(); if(pNd && pNd->GetNodes().IsDocNodes()) pGatherRefFieldsHint->m_rvRFields.push_back(static_cast<SwGetRefField*>(GetField())); + } else if (const auto pGatherFieldsHint = dynamic_cast<const sw::GatherFieldsHint*>( &rHint )) + { + if(!GetTextField()) + return; + SwTextNode* pNd = GetTextField()->GetpTextNode(); + if(pNd && pNd->GetNodes().IsDocNodes()) + pGatherFieldsHint->m_rvFields.push_back(this); } } diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 0067dff27216..6b14d9e8e295 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -3010,21 +3010,11 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc & rDoc) const size_t nCount = pFieldTypes->size(); for(size_t nType = 0; nType < nCount; ++nType) { - const SwFieldType *pCurType = (*pFieldTypes)[nType].get(); - SwIterator<SwFormatField,SwFieldType> aIter( *pCurType ); - const SwFormatField* pCurFieldFormat = aIter.First(); - while (pCurFieldFormat) - { - const SwTextField *pTextField = pCurFieldFormat->GetTextField(); - // skip fields that are currently not in the document - // e.g. fields in undo or redo array - bool bSkip = !pTextField || - !pTextField->GetpTextNode()->GetNodes().IsDocNodes(); - if (!bSkip) - m_pImpl->m_Items.push_back( SwXTextField::CreateXTextField( - m_pImpl->m_pDoc, pCurFieldFormat)); - pCurFieldFormat = aIter.Next(); - } + const SwFieldType* pCurType = (*pFieldTypes)[nType].get(); + std::vector<SwFormatField*> vFormatFields; + pCurType->GatherFields(vFormatFields); + std::for_each(vFormatFields.begin(), vFormatFields.end(), + [this](SwFormatField* pF) { m_pImpl->m_Items.push_back(SwXTextField::CreateXTextField(m_pImpl->m_pDoc, pF)); }); } // now handle meta-fields, which are not SwFields const std::vector< uno::Reference<text::XTextField> > MetaFields( _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits