summaryrefslogtreecommitdiff
path: root/linguistic/source/spelldsp.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'linguistic/source/spelldsp.cxx')
-rw-r--r--linguistic/source/spelldsp.cxx38
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);
}