From fe3fd05966a668c1cdf53e8221b8614e9a07de65 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 19 Nov 2015 13:43:23 +0200 Subject: add mapKeysToSequence/mapValuesToSequence methods to comphelper and use them Change-Id: If4dc9df63db37185228aeaaab2979498d61304ec Reviewed-on: https://gerrit.libreoffice.org/20055 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/access/accpara.cxx | 13 +------------ sw/source/core/unocore/unobkm.cxx | 7 ++----- sw/source/core/unocore/unocoll.cxx | 7 +------ 3 files changed, 4 insertions(+), 23 deletions(-) (limited to 'sw') diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index d18841e924eb..fdcf1ab6821f 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -2074,18 +2074,7 @@ uno::Sequence< PropertyValue > SwAccessibleParagraph::getRunAttributes( tAccParaPropValMap aRunAttrSeq; _getRunAttributesImpl( nIndex, aRequestedAttributes, aRunAttrSeq ); - uno::Sequence< PropertyValue > aValues( aRunAttrSeq.size() ); - PropertyValue* pValues = aValues.getArray(); - sal_Int32 i = 0; - for ( tAccParaPropValMap::const_iterator aIter = aRunAttrSeq.begin(); - aIter != aRunAttrSeq.end(); - ++aIter ) - { - pValues[i] = aIter->second; - ++i; - } - - return aValues; + return comphelper::mapValuesToSequence( aRunAttrSeq ); } void SwAccessibleParagraph::_getSupplementalAttributesImpl( diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 282502ca221c..dc049286e6d7 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -36,6 +36,7 @@ #include #include #include +#include using namespace ::sw::mark; using namespace ::com::sun::star; @@ -532,11 +533,7 @@ uno::Sequence SwXFieldmarkParameters::getElementNames() { SolarMutexGuard aGuard; IFieldmark::parameter_map_t* pParameters = getCoreParameters(); - uno::Sequence vResult(pParameters->size()); - OUString* pOutEntry = vResult.getArray(); - for(IFieldmark::parameter_map_t::iterator pEntry = pParameters->begin(); pEntry!=pParameters->end(); ++pEntry, ++pOutEntry) - *pOutEntry = pEntry->first; - return vResult; + return comphelper::mapKeysToSequence(*pParameters); } sal_Bool SwXFieldmarkParameters::hasByName(const OUString& aName) diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 4cd09735e93f..51f1501a2900 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -194,12 +194,7 @@ public: } virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (css::uno::RuntimeException, std::exception) override { - uno::Sequence< OUString > aElements( mTemplateToProject.size() ); - StringHashMap::iterator it_end = mTemplateToProject.end(); - sal_Int32 index = 0; - for ( StringHashMap::iterator it = mTemplateToProject.begin(); it != it_end; ++it, ++index ) - aElements[ index ] = it->first; - return aElements; + return comphelper::mapKeysToSequence( mTemplateToProject ); } virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw ( css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, std::exception ) override -- cgit