From 6a143985bdc5d12d1f9e8cf8592440282986c099 Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Wed, 20 Feb 2019 01:10:07 +0300 Subject: Simplify containers iterations in desktop, dtrans, editeng, extensions Use range-based loop or replace with STL functions Change-Id: Ic5389d123d0a6a32a8bb46b081165e94a7c55292 Reviewed-on: https://gerrit.libreoffice.org/68036 Tested-by: Jenkins Reviewed-by: Noel Grandin --- editeng/qa/unit/core-test.cxx | 54 ++++++++++++------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) (limited to 'editeng/qa') diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index 1b8c079b58ba..020a5a32d7aa 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -884,36 +884,20 @@ void Test::testHyperlinkSearch() bool hasBold(const editeng::Section& rSecAttr) { - std::vector::const_iterator it = rSecAttr.maAttributes.begin(), itEnd = rSecAttr.maAttributes.end(); - for (; it != itEnd; ++it) - { - const SfxPoolItem* p = *it; - if (p->Which() != EE_CHAR_WEIGHT) - continue; - - if (static_cast(p)->GetWeight() != WEIGHT_BOLD) - continue; - - return true; - } - return false; + return std::any_of(rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(), + [](const SfxPoolItem* p) { + return p->Which() == EE_CHAR_WEIGHT + && static_cast(p)->GetWeight() == WEIGHT_BOLD; + }); } bool hasItalic(const editeng::Section& rSecAttr) { - std::vector::const_iterator it = rSecAttr.maAttributes.begin(), itEnd = rSecAttr.maAttributes.end(); - for (; it != itEnd; ++it) - { - const SfxPoolItem* p = *it; - if (p->Which() != EE_CHAR_ITALIC) - continue; - - if (static_cast(p)->GetPosture() != ITALIC_NORMAL) - continue; - - return true; - } - return false; + return std::any_of(rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(), + [](const SfxPoolItem* p) { + return p->Which() == EE_CHAR_ITALIC + && static_cast(p)->GetPosture() == ITALIC_NORMAL; + }); } void Test::testBoldItalicCopyPaste() @@ -1104,19 +1088,11 @@ void Test::testBoldItalicCopyPaste() // Auxiliary function to test Underline text Copy/Paste using Legacy Format bool hasUnderline(const editeng::Section& rSecAttr) { - std::vector::const_iterator it = rSecAttr.maAttributes.begin(), itEnd = rSecAttr.maAttributes.end(); - for (; it != itEnd; ++it) - { - const SfxPoolItem* p = *it; - if (p->Which() != EE_CHAR_UNDERLINE) - continue; - - if (static_cast(p)->GetLineStyle() != LINESTYLE_SINGLE) - continue; - - return true; - } - return false; + return std::any_of(rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(), + [](const SfxPoolItem* p) { + return p->Which() == EE_CHAR_UNDERLINE + && static_cast(p)->GetLineStyle() == LINESTYLE_SINGLE; + }); } void Test::testUnderlineCopyPaste() -- cgit