summaryrefslogtreecommitdiff
path: root/sw/source/uibase/fldui
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-07-02 17:18:03 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-07-03 21:00:07 +0200
commit671517c462c51b356a35a2d51aa27e90bd3f9531 (patch)
treefb7038e1a186a6f8414ae393ecb782c8231e382b /sw/source/uibase/fldui
parent84ded153cb9c28ddadad773a6fbfe348bdef8fa9 (diff)
Simplify Sequence iterations in sw/source/uibase/
Use range-based loops, STL and comphelper functions Change-Id: Ia67ebfa0aa0abad855975b13e86e699811ef713a Reviewed-on: https://gerrit.libreoffice.org/75003 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'sw/source/uibase/fldui')
-rw-r--r--sw/source/uibase/fldui/fldmgr.cxx29
1 files changed, 9 insertions, 20 deletions
diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx
index 547e71e1283f..c365d661a684 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -704,17 +704,10 @@ sal_uInt16 SwFieldMgr::GetFormatCount(sal_uInt16 nTypeId, bool bHtmlMode) const
if(m_xNumberingInfo.is())
{
Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
- const sal_Int16* pTypes = aTypes.getConstArray();
- for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
- {
- sal_Int16 nCurrent = pTypes[nType];
- //skip all values below or equal to CHARS_LOWER_LETTER_N
- if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
- {
- // #i28073# it's not necessarily a sorted sequence
- ++nCount;
- }
- }
+ // #i28073# it's not necessarily a sorted sequence
+ //skip all values below or equal to CHARS_LOWER_LETTER_N
+ nCount += std::count_if(aTypes.begin(), aTypes.end(),
+ [](sal_Int16 nCurrent) { return nCurrent > NumberingType::CHARS_LOWER_LETTER_N; });
}
return nCount;
}
@@ -748,25 +741,23 @@ OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) cons
if (m_xNumberingInfo.is())
{
Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
- const sal_Int16* pTypes = aTypes.getConstArray();
sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
sal_uInt32 nValidEntry = 0;
- for (sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+ for (const sal_Int16 nCurrent : aTypes)
{
- sal_Int16 nCurrent = pTypes[nType];
if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N &&
(nCurrent != (NumberingType::BITMAP | LINK_TOKEN)))
{
if (nValidEntry == nFormatId - nOffset)
{
- sal_uInt32 n = SvxNumberingTypeTable::FindIndex(pTypes[nType]);
+ sal_uInt32 n = SvxNumberingTypeTable::FindIndex(nCurrent);
if (n != RESARRAY_INDEX_NOTFOUND)
{
aRet = SvxNumberingTypeTable::GetString(n);
}
else
{
- aRet = m_xNumberingInfo->getNumberingIdentifier( pTypes[nType] );
+ aRet = m_xNumberingInfo->getNumberingIdentifier( nCurrent );
}
break;
}
@@ -830,17 +821,15 @@ sal_uInt16 SwFieldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) con
else if (m_xNumberingInfo.is())
{
Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
- const sal_Int16* pTypes = aTypes.getConstArray();
sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
sal_Int32 nValidEntry = 0;
- for (sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+ for (const sal_Int16 nCurrent : aTypes)
{
- sal_Int16 nCurrent = pTypes[nType];
if (nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
{
if (nValidEntry == static_cast<sal_Int32>(nFormatId) - nOffset)
{
- nId = pTypes[nType];
+ nId = nCurrent;
break;
}
++nValidEntry;