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/lngopt.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/lngopt.cxx')
-rw-r--r-- | linguistic/source/lngopt.cxx | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx index f97cb6cf5073..9473a8da2b77 100644 --- a/linguistic/source/lngopt.cxx +++ b/linguistic/source/lngopt.cxx @@ -26,6 +26,7 @@ #include <tools/debug.hxx> #include <unotools/lingucfg.hxx> +#include <comphelper/sequence.hxx> #include <cppuhelper/factory.hxx> #include <cppuhelper/supportsservice.hxx> #include <com/sun/star/container/XNameAccess.hpp> @@ -328,22 +329,16 @@ Sequence< PropertyValue > SAL_CALL { MutexGuard aGuard( GetLinguMutex() ); - sal_Int32 nLen = aPropertyMap.getSize(); - Sequence< PropertyValue > aProps( nLen ); - PropertyValue *pProp = aProps.getArray(); PropertyEntryVector_t aPropEntries = aPropertyMap.getPropertyEntries(); - PropertyEntryVector_t::const_iterator aIt = aPropEntries.begin(); - for (sal_Int32 i = 0; i < nLen; ++i, ++aIt) - { - PropertyValue &rVal = pProp[i]; - Any aAny( aConfig.GetProperty( aIt->nWID ) ); - - rVal.Name = aIt->sName; - rVal.Handle = aIt->nWID; - rVal.Value = aAny; - rVal.State = PropertyState_DIRECT_VALUE ; - } - return aProps; + std::vector<PropertyValue> aProps; + aProps.reserve(aPropertyMap.getSize()); + + std::transform(aPropEntries.begin(), aPropEntries.end(), std::back_inserter(aProps), + [this](PropertyEntryVector_t::const_reference rPropEntry) { + return PropertyValue(rPropEntry.sName, rPropEntry.nWID, + aConfig.GetProperty(rPropEntry.nWID), + css::beans::PropertyState_DIRECT_VALUE); }); + return comphelper::containerToSequence(aProps); } void SAL_CALL @@ -351,11 +346,8 @@ void SAL_CALL { MutexGuard aGuard( GetLinguMutex() ); - sal_Int32 nLen = rProps.getLength(); - const PropertyValue *pVal = rProps.getConstArray(); - for (sal_Int32 i = 0; i < nLen; ++i) + for (const PropertyValue &rVal : rProps) { - const PropertyValue &rVal = pVal[i]; setPropertyValue( rVal.Name, rVal.Value ); } } |