sw/source/core/crsr/annotationmark.cxx | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
New commits: commit f62079a210ac14b2bc934dcc93bfecf45a53208e Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Sun Mar 8 16:36:07 2020 +0100 Commit: Björn Michaelsen <bjoern.michael...@libreoffice.org> CommitDate: Tue Mar 10 08:18:20 2020 +0100 AnnotationField: SwIterator now more ... Change-Id: I410deb7c23b9a253b4331b12a59abd1d47884d62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90189 Tested-by: Jenkins Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org> diff --git a/sw/source/core/crsr/annotationmark.cxx b/sw/source/core/crsr/annotationmark.cxx index aa5f7fc25922..0fc6d16daedf 100644 --- a/sw/source/core/crsr/annotationmark.cxx +++ b/sw/source/core/crsr/annotationmark.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <algorithm> #include <annotationmark.hxx> #include <doc.hxx> @@ -80,24 +81,16 @@ namespace sw::mark SwDoc* pDoc = GetMarkPos().GetDoc(); assert(pDoc != nullptr); - SwFormatField* pAnnotationFormatField = nullptr; - + const auto sName = GetName(); SwFieldType* pType = pDoc->getIDocumentFieldsAccess().GetFieldType( SwFieldIds::Postit, OUString(), false ); - SwIterator<SwFormatField,SwFieldType> aIter( *pType ); - for( SwFormatField* pFormatField = aIter.First(); pFormatField != nullptr; pFormatField = aIter.Next() ) + std::vector<SwFormatField*> vFields; + pType->GatherFields(vFields); + auto ppFound = std::find_if(vFields.begin(), vFields.end(), [&sName](SwFormatField* pF) { - if ( pFormatField->IsFieldInDoc() ) - { - const SwPostItField* pPostItField = dynamic_cast< const SwPostItField* >(pFormatField->GetField()); - if (pPostItField != nullptr && pPostItField->GetName() == GetName()) - { - pAnnotationFormatField = pFormatField; - break; - } - } - } - - return pAnnotationFormatField; + auto pPF = dynamic_cast<const SwPostItField*>(pF->GetField()); + return pPF && pPF->GetName() == sName; + }); + return ppFound != vFields.end() ? *ppFound : nullptr; } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits