diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-02-20 01:10:07 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-20 07:17:38 +0100 |
commit | 6a143985bdc5d12d1f9e8cf8592440282986c099 (patch) | |
tree | 346e09d6ba1146b52a6a484a2883f3e898184648 /editeng/qa | |
parent | d707a5e64ba53ddb7669cca725915527aa788a6b (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng/qa')
-rw-r--r-- | editeng/qa/unit/core-test.cxx | 54 |
1 files changed, 15 insertions, 39 deletions
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 SfxPoolItem*>::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<const SvxWeightItem*>(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<const SvxWeightItem*>(p)->GetWeight() == WEIGHT_BOLD; + }); } bool hasItalic(const editeng::Section& rSecAttr) { - std::vector<const SfxPoolItem*>::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<const SvxPostureItem*>(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<const SvxPostureItem*>(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 SfxPoolItem*>::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<const SvxUnderlineItem*>(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<const SvxUnderlineItem*>(p)->GetLineStyle() == LINESTYLE_SINGLE; + }); } void Test::testUnderlineCopyPaste() |