[Libreoffice-commits] core.git: sw/source
Bjoern Michaelsen (via logerrit)
logerrit at kemper.freedesktop.org
Tue Mar 10 07:18:55 UTC 2020
sw/source/core/crsr/annotationmark.cxx | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
New commits:
commit f62079a210ac14b2bc934dcc93bfecf45a53208e
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Sun Mar 8 16:36:07 2020 +0100
Commit: Björn Michaelsen <bjoern.michaelsen at 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.michaelsen at 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;
}
}
More information about the Libreoffice-commits
mailing list