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 --- .../chartapiwrapper/ChartDocumentWrapper.cxx | 10 +------ chart2/source/inc/ContainerHelper.hxx | 35 ---------------------- chart2/source/model/main/DataSeries.cxx | 12 +------- chart2/source/view/main/PropertyMapper.cxx | 5 ++-- 4 files changed, 5 insertions(+), 57 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index 00611617d01b..035f7e9372ff 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -1453,15 +1453,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstanceW uno::Sequence< OUString > SAL_CALL ChartDocumentWrapper::getAvailableServiceNames() throw (uno::RuntimeException, std::exception) { - tServiceNameMap & rMap = lcl_getStaticServiceNameMap(); - uno::Sequence< OUString > aResult( rMap.size()); - - ::std::transform( rMap.begin(), rMap.end(), - aResult.getArray(), - ::o3tl::select1st< tServiceNameMap::value_type >() ); - - return aResult; - + return comphelper::mapKeysToSequence( lcl_getStaticServiceNameMap() ); } // ____ XAggregation ____ diff --git a/chart2/source/inc/ContainerHelper.hxx b/chart2/source/inc/ContainerHelper.hxx index 9f01b47ab01b..a50554d8a0b0 100644 --- a/chart2/source/inc/ContainerHelper.hxx +++ b/chart2/source/inc/ContainerHelper.hxx @@ -70,41 +70,6 @@ template< typename T > return SequenceToSTLSequenceContainer< ::std::vector< T > >( rSeq ); } -/** converts the keys of a Pair Associative Container into a UNO sequence - - example: - - ::std::multimap< sal_Int32, OUString > aMyMultiMap; - uno::Sequence< sal_Int32 > aMyKeys( ContainerHelper::MapKeysToSequence( aMyMultiMap )); - // note: aMyKeys may contain duplicate keys here - */ -template< class Map > -::com::sun::star::uno::Sequence< typename Map::key_type > MapKeysToSequence( - const Map & rCont ) -{ - ::com::sun::star::uno::Sequence< typename Map::key_type > aResult( rCont.size()); - ::std::transform( rCont.begin(), rCont.end(), aResult.getArray(), - ::o3tl::select1st< typename Map::value_type >() ); - return aResult; -} - -/** converts the values of a Pair Associative Container into a UNO sequence - - example: - - ::std::map< sal_Int32, OUString > aMyMultiMap; - uno::Sequence< OUString > aMyValues( ContainerHelper::MapValuesToSequence( aMyMultiMap )); - */ -template< class Map > -::com::sun::star::uno::Sequence< typename Map::mapped_type > MapValuesToSequence( - const Map & rCont ) -{ - ::com::sun::star::uno::Sequence< typename Map::mapped_type > aResult( rCont.size()); - ::std::transform( rCont.begin(), rCont.end(), aResult.getArray(), - ::o3tl::select2nd< typename Map::value_type >() ); - return aResult; -} - } // namespace ContainerHelper } // namespace chart diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx index 1a42a726646e..11c617481f02 100644 --- a/chart2/source/model/main/DataSeries.cxx +++ b/chart2/source/model/main/DataSeries.cxx @@ -275,18 +275,8 @@ void SAL_CALL DataSeries::getFastPropertyValue if( nHandle == DataSeriesProperties::PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) { // TODO: only add those property sets that are really modified - uno::Sequence< sal_Int32 > aSeq( m_aAttributedDataPoints.size()); - sal_Int32 * pIndexArray = aSeq.getArray(); - sal_Int32 i = 0; - for( tDataPointAttributeContainer::const_iterator aIt( m_aAttributedDataPoints.begin()); - aIt != m_aAttributedDataPoints.end(); ++aIt ) - { - pIndexArray[ i ] = (*aIt).first; - ++i; - } - - rValue <<= aSeq; + rValue <<= comphelper::mapKeysToSequence(m_aAttributedDataPoints); } else OPropertySet::getFastPropertyValue( rValue, nHandle ); diff --git a/chart2/source/view/main/PropertyMapper.cxx b/chart2/source/view/main/PropertyMapper.cxx index 9b588a706340..461752cfd84c 100644 --- a/chart2/source/view/main/PropertyMapper.cxx +++ b/chart2/source/view/main/PropertyMapper.cxx @@ -27,6 +27,7 @@ #include #include #include +#include namespace chart { @@ -65,8 +66,8 @@ void PropertyMapper::setMappedProperties( for( sal_Int32 nI=0; nI