sw/source/core/unocore/unofield.cxx | 42 ++++++++---------------------------- 1 file changed, 10 insertions(+), 32 deletions(-)
New commits: commit 15bb789b231fb723a679b4565e49b4decbe6d34e Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Tue Feb 25 21:51:19 2020 +0100 Commit: Björn Michaelsen <bjoern.michael...@libreoffice.org> CommitDate: Wed Feb 26 20:56:23 2020 +0100 use GatherFields Change-Id: Ie15add04d66458493476bcbdc9a4f4a1034575e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89487 Tested-by: Jenkins Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index c58b1cd936b1..064d86e78a8b 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -826,27 +826,12 @@ SwXFieldMaster::getPropertyValue(const OUString& rPropertyName) else if(rPropertyName == UNO_NAME_DEPENDENT_TEXT_FIELDS) { //fill all text fields into a sequence - std::vector<SwFormatField*> aFieldArr; - SwIterator<SwFormatField,SwFieldType> aIter( *pType ); - SwFormatField* pField = aIter.First(); - while(pField) - { - if(pField->IsFieldInDoc()) - aFieldArr.push_back(pField); - pField = aIter.Next(); - } - - uno::Sequence<uno::Reference <text::XDependentTextField> > aRetSeq(aFieldArr.size()); - uno::Reference<text::XDependentTextField>* pRetSeq = aRetSeq.getArray(); - for(size_t i = 0; i < aFieldArr.size(); ++i) - { - pField = aFieldArr[i]; - uno::Reference<text::XTextField> const xField = - SwXTextField::CreateXTextField(m_pImpl->m_pDoc, pField); - - pRetSeq[i].set(xField, uno::UNO_QUERY); - } - aRet <<= aRetSeq; + std::vector<SwFormatField*> vpFields; + pType->GatherFields(vpFields); + uno::Sequence<uno::Reference <text::XDependentTextField> > aSeq(vpFields.size()); + std::transform(vpFields.begin(), vpFields.end(), aSeq.begin(), + [this](SwFormatField* pF) { return uno::Reference<text::XDependentTextField>(SwXTextField::CreateXTextField(m_pImpl->m_pDoc, pF), uno::UNO_QUERY); }); + aRet <<= aSeq; } else { commit caaf7f9651325e15ab6da4342a653b0fe6e2af3d Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Tue Feb 25 21:10:15 2020 +0100 Commit: Björn Michaelsen <bjoern.michael...@libreoffice.org> CommitDate: Wed Feb 26 20:56:10 2020 +0100 use GatherFields Change-Id: I5a43d233b55edb13b479c1d1d246a4a6682b79a4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89484 Tested-by: Jenkins Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 6b14d9e8e295..c58b1cd936b1 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -979,17 +979,10 @@ void SAL_CALL SwXFieldMaster::dispose() } // first delete all fields - SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType ); - SwFormatField* pField = aIter.First(); - while(pField) - { - SwTextField *pTextField = pField->GetTextField(); - if(pTextField && pTextField->GetTextNode().GetNodes().IsDocNodes() ) - { - SwTextField::DeleteTextField(*pTextField); - } - pField = aIter.Next(); - } + std::vector<SwFormatField*> vpFields; + pFieldType->GatherFields(vpFields); + for(auto pField : vpFields) + SwTextField::DeleteTextField(*pField->GetTextField()); // then delete FieldType m_pImpl->m_pDoc->getIDocumentFieldsAccess().RemoveFieldType(nTypeIdx); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits