i18npool/qa/cppunit/test_breakiterator.cxx | 44 ++++++++++++++--------------- svx/source/dialog/strarray.cxx | 10 +++--- 2 files changed, 27 insertions(+), 27 deletions(-)
New commits: commit eb5c14f305f9c6355bd49bd65ab9175831453cb3 Author: ektagoel12 <[email protected]> AuthorDate: Mon Jan 23 11:49:42 2023 +0530 Commit: Hossein <[email protected]> CommitDate: Tue Jan 31 13:30:53 2023 +0000 tdf#147021 Use std::size() instead of SAL_N_ELEMENTS() macro Also change some range based for Change-Id: I2e17feaba7a6b219aa0c9126c5046cf3bdf855d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145988 Tested-by: Jenkins Reviewed-by: Hossein <[email protected]> diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx index cdcbff9be535..6673fb4b8df5 100644 --- a/i18npool/qa/cppunit/test_breakiterator.cxx +++ b/i18npool/qa/cppunit/test_breakiterator.cxx @@ -274,9 +274,9 @@ void TestBreakIterator::testWordBoundaries() for (int mode = i18n::WordType::ANY_WORD; mode <= i18n::WordType::WORD_COUNT; ++mode) { //make sure that in all cases isBeginWord and isEndWord matches getWordBoundary - for (size_t i = 0; i < SAL_N_ELEMENTS(aBreakTests); ++i) + for (auto const& i: aBreakTests) { - OUString aTest = "Word" + OUStringChar(aBreakTests[i]) + "Word"; + OUString aTest = "Word" + OUStringChar(i) + "Word"; aBounds = m_xBreak->getWordBoundary(aTest, 0, aLocale, mode, true); switch (mode) { @@ -307,9 +307,9 @@ void TestBreakIterator::testWordBoundaries() for (int mode = i18n::WordType::ANY_WORD; mode <= i18n::WordType::WORD_COUNT; ++mode) { //make sure that in all cases isBeginWord and isEndWord matches getWordBoundary - for (size_t i = 0; i < SAL_N_ELEMENTS(aJoinTests); ++i) + for (auto const& p: aJoinTests) { - OUString aTest = "Word" + OUStringChar(aJoinTests[i]) + "Word"; + OUString aTest = "Word" + OUStringChar(p) + "Word"; aBounds = m_xBreak->getWordBoundary(aTest, 0, aLocale, mode, true); switch (mode) { @@ -347,21 +347,21 @@ void TestBreakIterator::testWordBoundaries() }; const sal_Int32 aDoublePositions[] = {0, 2, 4, 6, 8, 10, 12, 14}; - for (size_t j = 0; j < SAL_N_ELEMENTS(aTests); ++j) + for (auto const& r: aTests) { - OUString aTest = aBase.replace('x', aTests[j]); + OUString aTest = aBase.replace('x', r); sal_Int32 nPos = -1; size_t i = 0; do { - CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aDoublePositions)); + CPPUNIT_ASSERT(i < std::size(aDoublePositions)); nPos = m_xBreak->nextWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; CPPUNIT_ASSERT_EQUAL(aDoublePositions[i], nPos); ++i; } while (nPos < aTest.getLength()); nPos = aTest.getLength(); - i = SAL_N_ELEMENTS(aDoublePositions)-1; + i = std::size(aDoublePositions)-1; do { nPos = m_xBreak->previousWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; @@ -379,14 +379,14 @@ void TestBreakIterator::testWordBoundaries() size_t i = 0; do { - CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aSinglePositions)); + CPPUNIT_ASSERT(i < std::size(aSinglePositions)); nPos = m_xBreak->nextWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; CPPUNIT_ASSERT_EQUAL(aSinglePositions[i], nPos); ++i; } while (nPos < aTest.getLength()); nPos = aTest.getLength(); - i = SAL_N_ELEMENTS(aSinglePositions)-1; + i = std::size(aSinglePositions)-1; do { nPos = m_xBreak->previousWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; @@ -404,14 +404,14 @@ void TestBreakIterator::testWordBoundaries() size_t i = 0; do { - CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aSingleQuotePositions)); + CPPUNIT_ASSERT(i < std::size(aSingleQuotePositions)); nPos = m_xBreak->nextWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; CPPUNIT_ASSERT_EQUAL(aSingleQuotePositions[i], nPos); ++i; } while (nPos < aTest.getLength()); nPos = aTest.getLength(); - i = SAL_N_ELEMENTS(aSingleQuotePositions)-1; + i = std::size(aSingleQuotePositions)-1; do { nPos = m_xBreak->previousWord(aTest, nPos, aLocale, i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos; @@ -434,14 +434,14 @@ void TestBreakIterator::testWordBoundaries() size_t i = 0; do { - CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aExpected)); + CPPUNIT_ASSERT(i < std::size(aExpected)); nPos = m_xBreak->getWordBoundary(aTest, nPos, aLocale, i18n::WordType::DICTIONARY_WORD, true).endPos; CPPUNIT_ASSERT_EQUAL(aExpected[i], nPos); ++i; } while (nPos++ < aTest.getLength()); - CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(aExpected), i); + CPPUNIT_ASSERT_EQUAL(std::size(aExpected), i); } //See https://bz.apache.org/ooo/show_bug.cgi?id=85411 @@ -474,14 +474,14 @@ void TestBreakIterator::testWordBoundaries() size_t i = 0; do { - CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aExpected)); + CPPUNIT_ASSERT(i < std::size(aExpected)); nPos = m_xBreak->getWordBoundary(aTest, nPos, aLocale, i18n::WordType::DICTIONARY_WORD, true).endPos; CPPUNIT_ASSERT_EQUAL(aExpected[i], nPos); ++i; } while (nPos++ < aTest.getLength()); - CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(aExpected), i); + CPPUNIT_ASSERT_EQUAL(std::size(aExpected), i); } //https://bz.apache.org/ooo/show_bug.cgi?id=21290 @@ -513,14 +513,14 @@ void TestBreakIterator::testWordBoundaries() size_t i = 0; do { - CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aExpected)); + CPPUNIT_ASSERT(i < std::size(aExpected)); nPos = m_xBreak->getWordBoundary(aTest, nPos, aLocale, i18n::WordType::DICTIONARY_WORD, true).endPos; CPPUNIT_ASSERT_EQUAL(aExpected[i], nPos); ++i; } while (nPos++ < aTest.getLength()); - CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(aExpected), i); + CPPUNIT_ASSERT_EQUAL(std::size(aExpected), i); } //See https://bz.apache.org/ooo/show_bug.cgi?id=58513 @@ -537,14 +537,14 @@ void TestBreakIterator::testWordBoundaries() size_t i = 0; do { - CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aExpected)); + CPPUNIT_ASSERT(i < std::size(aExpected)); nPos = m_xBreak->getWordBoundary(aTest, nPos, aLocale, i18n::WordType::WORD_COUNT, true).endPos; CPPUNIT_ASSERT_EQUAL(aExpected[i], nPos); ++i; } while (nPos++ < aTest.getLength()); - CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(aExpected), i); + CPPUNIT_ASSERT_EQUAL(std::size(aExpected), i); } { @@ -554,7 +554,7 @@ void TestBreakIterator::testWordBoundaries() size_t i = 0; do { - CPPUNIT_ASSERT(i < SAL_N_ELEMENTS(aExpected)); + CPPUNIT_ASSERT(i < std::size(aExpected)); aBounds = m_xBreak->getWordBoundary(aTest, nPos, aLocale, i18n::WordType::DICTIONARY_WORD, true); CPPUNIT_ASSERT_EQUAL(aExpected[i], aBounds.startPos); @@ -564,7 +564,7 @@ void TestBreakIterator::testWordBoundaries() nPos = aBounds.endPos; } while (nPos++ < aTest.getLength()); - CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(aExpected), i); + CPPUNIT_ASSERT_EQUAL(std::size(aExpected), i); } } diff --git a/svx/source/dialog/strarray.cxx b/svx/source/dialog/strarray.cxx index 33564245230f..28bf16a4355f 100644 --- a/svx/source/dialog/strarray.cxx +++ b/svx/source/dialog/strarray.cxx @@ -24,7 +24,7 @@ #include <fieldunit.hrc> #include <numberingtype.hrc> -sal_uInt32 SvxFieldUnitTable::Count() { return SAL_N_ELEMENTS(RID_SVXSTR_FIELDUNIT_TABLE); } +sal_uInt32 SvxFieldUnitTable::Count() { return std::size(RID_SVXSTR_FIELDUNIT_TABLE); } OUString SvxFieldUnitTable::GetString(sal_uInt32 nPos) { @@ -47,11 +47,11 @@ OUString SvxAttrNameTable::GetString(sal_uInt32 nPos) return OUString(); } -sal_uInt32 SvxAttrNameTable::Count() { return SAL_N_ELEMENTS(RID_ATTR_NAMES); } +sal_uInt32 SvxAttrNameTable::Count() { return std::size(RID_ATTR_NAMES); } sal_uInt32 SvxAttrNameTable::FindIndex(int nValue) { - for (size_t i = 0; i < SAL_N_ELEMENTS(RID_ATTR_NAMES); ++i) + for (size_t i = 0; i < std::size(RID_ATTR_NAMES); ++i) { if (nValue == RID_ATTR_NAMES[i].second) return i; @@ -66,7 +66,7 @@ OUString SvxNumberingTypeTable::GetString(sal_uInt32 nPos) return OUString(); } -sal_uInt32 SvxNumberingTypeTable::Count() { return SAL_N_ELEMENTS(RID_SVXSTRARY_NUMBERINGTYPE); } +sal_uInt32 SvxNumberingTypeTable::Count() { return std::size(RID_SVXSTRARY_NUMBERINGTYPE); } int SvxNumberingTypeTable::GetValue(sal_uInt32 nPos) { @@ -77,7 +77,7 @@ int SvxNumberingTypeTable::GetValue(sal_uInt32 nPos) sal_uInt32 SvxNumberingTypeTable::FindIndex(int nValue) { - for (size_t i = 0; i < SAL_N_ELEMENTS(RID_SVXSTRARY_NUMBERINGTYPE); ++i) + for (size_t i = 0; i < std::size(RID_SVXSTRARY_NUMBERINGTYPE); ++i) { if (nValue == RID_SVXSTRARY_NUMBERINGTYPE[i].second) return i;
