diff options
author | jsala <javier.salamanca.munoz@gmail.com> | 2022-06-25 13:35:01 +0200 |
---|---|---|
committer | Hossein <hossein@libreoffice.org> | 2022-11-06 01:22:27 +0100 |
commit | 04a58d7eae2b26559efd48ff7cdd23cec1c2187c (patch) | |
tree | a43067d9b24d5c86a8fa2f299f8f7c807ff96ebb /unotools | |
parent | 804f21e42bdc9328ab0f17b983411657e1f6215d (diff) |
tdf#147021 Use std::size() instead of SAL_N_ELEMENTS() macro
Also change some range based for.
Change-Id: I32c5cbe0033c40cde3f1fc86ec8af90e558f2652
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141666
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/config/compatibility.cxx | 2 | ||||
-rw-r--r-- | unotools/source/config/fontcfg.cxx | 5 | ||||
-rw-r--r-- | unotools/source/config/lingucfg.cxx | 10 | ||||
-rw-r--r-- | unotools/source/config/searchopt.cxx | 6 | ||||
-rw-r--r-- | unotools/source/misc/fontcvt.cxx | 19 |
5 files changed, 13 insertions, 29 deletions
diff --git a/unotools/source/config/compatibility.cxx b/unotools/source/config/compatibility.cxx index a5ac6ea895b4..4f0e1d2ac20c 100644 --- a/unotools/source/config/compatibility.cxx +++ b/unotools/source/config/compatibility.cxx @@ -96,7 +96,7 @@ OUString SvtCompatibilityEntry::getName( const Index rIdx ) }; /* Size of sPropertyName array not equal size of the SvtCompatibilityEntry::Index enum class */ - assert( SAL_N_ELEMENTS(sPropertyName) == static_cast<int>( SvtCompatibilityEntry::getElementCount() ) ); + assert( std::size(sPropertyName) == SvtCompatibilityEntry::getElementCount() ); return OUString::createFromAscii( sPropertyName[ static_cast<int>(rIdx) ] ); } diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index 0a8ab40b3116..beeba82030d0 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -32,7 +32,6 @@ #include <unotools/syslocale.hxx> #include <rtl/ustrbuf.hxx> #include <osl/diagnose.h> -#include <sal/macros.h> #include <sal/log.hxx> #include <string.h> @@ -886,7 +885,7 @@ FontWeight FontSubstConfiguration::getSubstWeight( const css::uno::Reference< XN { if( !pLine->isEmpty() ) { - for( weight=SAL_N_ELEMENTS(pWeightNames)-1; weight >= 0; weight-- ) + for( weight=std::size(pWeightNames)-1; weight >= 0; weight-- ) if( pLine->equalsIgnoreAsciiCaseAscii( pWeightNames[weight].pName ) ) break; } @@ -913,7 +912,7 @@ FontWidth FontSubstConfiguration::getSubstWidth( const css::uno::Reference< XNam { if( !pLine->isEmpty() ) { - for( width=SAL_N_ELEMENTS(pWidthNames)-1; width >= 0; width-- ) + for( width=std::size(pWidthNames)-1; width >= 0; width-- ) if( pLine->equalsIgnoreAsciiCaseAscii( pWidthNames[width].pName ) ) break; } diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx index efee41e6bbb2..03969c3d1ffe 100644 --- a/unotools/source/config/lingucfg.cxx +++ b/unotools/source/config/lingucfg.cxx @@ -33,7 +33,6 @@ #include <unotools/configitem.hxx> #include <unotools/lingucfg.hxx> #include <unotools/linguprops.hxx> -#include <sal/macros.h> #include <comphelper/getexpandeduri.hxx> #include <comphelper/processfactory.hxx> #include <o3tl/string_view.hxx> @@ -271,15 +270,12 @@ NamesToHdl const aNamesToHdl[] = uno::Sequence< OUString > SvtLinguConfigItem::GetPropertyNames() { uno::Sequence< OUString > aNames; - - sal_Int32 nMax = SAL_N_ELEMENTS(aNamesToHdl); - - aNames.realloc( nMax ); + aNames.realloc(std::size(aNamesToHdl)); OUString *pNames = aNames.getArray(); sal_Int32 nIdx = 0; - for (sal_Int32 i = 0; i < nMax; ++i) + for (auto const & nameToHdl: aNamesToHdl) { - const char *pFullPropName = aNamesToHdl[i].pFullPropName; + const char *pFullPropName = nameToHdl.pFullPropName; if (pFullPropName) pNames[ nIdx++ ] = OUString::createFromAscii( pFullPropName ); } diff --git a/unotools/source/config/searchopt.cxx b/unotools/source/config/searchopt.cxx index 23a2ae93358f..4237fd7281dd 100644 --- a/unotools/source/config/searchopt.cxx +++ b/unotools/source/config/searchopt.cxx @@ -24,7 +24,6 @@ #include <unotools/configitem.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Any.h> -#include <sal/macros.h> #include <osl/diagnose.h> #include <i18nutil/transliteration.hxx> @@ -153,10 +152,9 @@ Sequence< OUString > SvtSearchOptions_Impl::GetPropertyNames() "IsUseWildcard" // 29 }; - const int nCount = SAL_N_ELEMENTS( aPropNames ); - Sequence< OUString > aNames( nCount ); + Sequence< OUString > aNames(std::size(aPropNames)); OUString* pNames = aNames.getArray(); - for (sal_Int32 i = 0; i < nCount; ++i) + for (std::size_t i = 0; i < std::size(aPropNames); ++i) pNames[i] = OUString::createFromAscii( aPropNames[i] ); return aNames; diff --git a/unotools/source/misc/fontcvt.cxx b/unotools/source/misc/fontcvt.cxx index 02796e7d3ca2..2c415dae969f 100644 --- a/unotools/source/misc/fontcvt.cxx +++ b/unotools/source/misc/fontcvt.cxx @@ -23,7 +23,6 @@ #include <sal/log.hxx> #include <unotools/fontcvt.hxx> #include <unotools/fontdefs.hxx> -#include <sal/macros.h> #include <cstddef> #include <map> @@ -1163,11 +1162,8 @@ StarSymbolToMSMultiFontImpl::StarSymbolToMSMultiFontImpl() //Reverse map from a given starsymbol char to exact matches in ms symbol //fonts. - int nEntries = SAL_N_ELEMENTS(aConservativeTable); - int i; - for (i = 0; i < nEntries; ++i) + for (auto const & r: aConservativeTable) { - const ConvertTable& r = aConservativeTable[i]; SymbolEntry aEntry; aEntry.eFont = r.meFont; for (aEntry.cIndex = 0xFF; aEntry.cIndex >= 0x20; --aEntry.cIndex) @@ -1190,12 +1186,9 @@ StarSymbolToMSMultiFontImpl::StarSymbolToMSMultiFontImpl() sizeof(aTNRExtraTab)) }; - //Allow extra conversions that are not perfect, but "good enough" - nEntries = SAL_N_ELEMENTS(aAggressiveTable); - - for (i = 0; i < nEntries; ++i) + //Allow extra conversions that are not perfect, but "good enough" + for (auto const & r: aAggressiveTable) { - const ExtendedConvertTable& r = aAggressiveTable[i]; SymbolEntry aEntry; aEntry.eFont = r.meFont; for (int j = r.mnSize / sizeof(r.mpTable[0]) - 1; j >=0; --j) @@ -1353,9 +1346,8 @@ const ConvertChar* ConvertChar::GetRecodeData( std::u16string_view rOrgFontName, if( aMapName == "starsymbol" || aMapName == "opensymbol" ) { - for( std::size_t i = 0; i < SAL_N_ELEMENTS(aStarSymbolRecodeTable); ++i) + for (auto const & r: aStarSymbolRecodeTable) { - const RecodeTable& r = aStarSymbolRecodeTable[i]; if( aOrgName.equalsAscii( r.pOrgName ) ) { pCvt = &r.aCvt; @@ -1368,9 +1360,8 @@ const ConvertChar* ConvertChar::GetRecodeData( std::u16string_view rOrgFontName, //adobe-symbol to unicode conversion in rtl instead else if( aMapName == "applesymbol" ) { - for( std::size_t i = 0; i < SAL_N_ELEMENTS(aAppleSymbolRecodeTable); ++i) + for (auto const & r: aAppleSymbolRecodeTable) { - const RecodeTable& r = aAppleSymbolRecodeTable[i]; if( aOrgName.equalsAscii( r.pOrgName ) ) { pCvt = &r.aCvt; |