diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-08-29 00:51:02 +0300 |
---|---|---|
committer | Arkadiy Illarionov <qarkai@gmail.com> | 2019-08-30 14:15:57 +0200 |
commit | 760a377f7148e623e9e16d24e66f54a401ecb946 (patch) | |
tree | c9ea106618e4b9f6bb2c20d8817603c7556a9ef6 /linguistic/source/spelldsp.cxx | |
parent | cc4edc0f29c034722f10ab289eb0d8d563a8632c (diff) |
Simplify Sequence iterations in lingucomponent..lotuswordpro
Use range-based loops, STL and comphelper functions.
Change-Id: I975a9c09265976d5ce4a1d7ac2023cbb75bb7f28
Reviewed-on: https://gerrit.libreoffice.org/78242
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'linguistic/source/spelldsp.cxx')
-rw-r--r-- | linguistic/source/spelldsp.cxx | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx index ecb8ec723610..6bbc664794ef 100644 --- a/linguistic/source/spelldsp.cxx +++ b/linguistic/source/spelldsp.cxx @@ -115,11 +115,8 @@ void ProposalList::Append( const std::vector< OUString > &rNew ) void ProposalList::Append( const Sequence< OUString > &rNew ) { - sal_Int32 nLen = rNew.getLength(); - const OUString *pNew = rNew.getConstArray(); - for (sal_Int32 i = 0; i < nLen; ++i) + for (const OUString& rText : rNew) { - const OUString &rText = pNew[i]; if (!HasEntry( rText )) Append( rText ); } @@ -159,22 +156,11 @@ static bool SvcListHasLanguage( const LangSvcEntries_Spell &rEntry, LanguageType nLanguage ) { - bool bHasLanguage = false; - Locale aTmpLocale; - - const Reference< XSpellChecker > *pRef = rEntry.aSvcRefs .getConstArray(); - sal_Int32 nLen = rEntry.aSvcRefs.getLength(); - for (sal_Int32 k = 0; k < nLen && !bHasLanguage; ++k) - { - if (pRef[k].is()) - { - if (aTmpLocale.Language.isEmpty()) - aTmpLocale = LanguageTag::convertToLocale( nLanguage ); - bHasLanguage = pRef[k]->hasLocale( aTmpLocale ); - } - } + Locale aTmpLocale = LanguageTag::convertToLocale( nLanguage ); - return bHasLanguage; + return std::any_of(rEntry.aSvcRefs.begin(), rEntry.aSvcRefs.end(), + [&aTmpLocale](const Reference<XSpellChecker>& rRef) { + return rRef.is() && rRef->hasLocale( aTmpLocale ); }); } SpellCheckerDispatcher::SpellCheckerDispatcher( LngSvcMgr &rLngSvcMgr ) : @@ -192,13 +178,13 @@ Sequence< Locale > SAL_CALL SpellCheckerDispatcher::getLocales() { MutexGuard aGuard( GetLinguMutex() ); - Sequence< Locale > aLocales( static_cast< sal_Int32 >(m_aSvcMap.size()) ); - Locale *pLocales = aLocales.getArray(); - for (auto const& elem : m_aSvcMap) - { - *pLocales++ = LanguageTag::convertToLocale(elem.first); - } - return aLocales; + std::vector<Locale> aLocales; + aLocales.reserve(m_aSvcMap.size()); + + std::transform(m_aSvcMap.begin(), m_aSvcMap.end(), std::back_inserter(aLocales), + [](SpellSvcByLangMap_t::const_reference elem) { return LanguageTag::convertToLocale(elem.first); }); + + return comphelper::containerToSequence(aLocales); } |