[Libreoffice-commits] core.git: accessibility/inc accessibility/source chart2/source comphelper/source connectivity/source dbaccess/source dtrans/source extensions/source forms/source framework/source include/comphelper scripting/source sc/source sfx2/source svx/source sw/source toolkit/source ucb/source vbahelper/source xmloff/source

Noel Grandin noel at peralex.com
Fri Nov 20 00:14:49 PST 2015


 accessibility/inc/accessibility/extended/textwindowaccessibility.hxx |    3 
 accessibility/source/extended/textwindowaccessibility.cxx            |   24 +-----
 chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx    |   10 --
 chart2/source/inc/ContainerHelper.hxx                                |   35 ----------
 chart2/source/model/main/DataSeries.cxx                              |   12 ---
 chart2/source/view/main/PropertyMapper.cxx                           |    5 -
 comphelper/source/container/NamedPropertyValuesContainer.cxx         |    9 --
 comphelper/source/container/embeddedobjectcontainer.cxx              |    8 --
 comphelper/source/container/namecontainer.cxx                        |   11 ---
 comphelper/source/eventattachermgr/eventattachermgr.cxx              |   12 ---
 connectivity/source/commontools/DriversConfig.cxx                    |   11 ---
 dbaccess/source/core/dataaccess/documentevents.cxx                   |   10 --
 dbaccess/source/ui/browser/genericcontroller.cxx                     |    9 --
 dtrans/source/generic/clipboardmanager.cxx                           |   10 --
 extensions/source/propctrlr/eventhandler.cxx                         |    6 -
 extensions/source/propctrlr/genericpropertyhandler.cxx               |    5 -
 forms/source/misc/InterfaceContainer.cxx                             |    9 --
 forms/source/xforms/NameContainer.hxx                                |   14 ----
 forms/source/xforms/convert.cxx                                      |    6 -
 forms/source/xforms/datatyperepository.cxx                           |    9 --
 framework/source/uiconfiguration/graphicnameaccess.cxx               |   10 --
 framework/source/uiconfiguration/imagemanagerimpl.cxx                |    8 --
 framework/source/uiconfiguration/windowstateconfiguration.cxx        |   13 ---
 framework/source/uielement/menubarwrapper.cxx                        |   13 ---
 framework/source/uielement/toolbarmanager.cxx                        |   16 +---
 framework/source/uielement/uicommanddescription.cxx                  |   12 ---
 include/comphelper/sequence.hxx                                      |   25 +++++++
 sc/source/filter/excel/excimp8.cxx                                   |    9 --
 sc/source/ui/vba/vbawindow.cxx                                       |    8 --
 sc/source/ui/vba/vbawindows.cxx                                      |    9 --
 scripting/source/vbaevents/eventhelper.cxx                           |    8 --
 sfx2/source/dialog/filtergrouping.cxx                                |    8 --
 svx/source/form/formcontroller.cxx                                   |    8 --
 svx/source/table/tabledesign.cxx                                     |   11 ---
 svx/source/unodraw/unoprov.cxx                                       |   12 ---
 sw/source/core/access/accpara.cxx                                    |   13 ---
 sw/source/core/unocore/unobkm.cxx                                    |    7 --
 sw/source/core/unocore/unocoll.cxx                                   |    7 --
 toolkit/source/controls/dialogcontrol.cxx                            |    8 --
 ucb/source/ucp/tdoc/tdoc_docmgr.cxx                                  |   13 ---
 vbahelper/source/vbahelper/vbadocumentsbase.cxx                      |    9 --
 xmloff/source/chart/SchXMLExport.cxx                                 |    9 --
 xmloff/source/chart/SchXMLTableContext.cxx                           |    5 -
 xmloff/source/forms/eventexport.cxx                                  |   11 ---
 44 files changed, 97 insertions(+), 373 deletions(-)

New commits:
commit fe3fd05966a668c1cdf53e8221b8614e9a07de65
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Nov 19 13:43:23 2015 +0200

    add mapKeysToSequence/mapValuesToSequence methods to comphelper
    
    and use them
    
    Change-Id: If4dc9df63db37185228aeaaab2979498d61304ec
    Reviewed-on: https://gerrit.libreoffice.org/20055
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/accessibility/inc/accessibility/extended/textwindowaccessibility.hxx b/accessibility/inc/accessibility/extended/textwindowaccessibility.hxx
index ab1e089..01e8e3c 100644
--- a/accessibility/inc/accessibility/extended/textwindowaccessibility.hxx
+++ b/accessibility/inc/accessibility/extended/textwindowaccessibility.hxx
@@ -642,9 +642,6 @@ private:
         const css::uno::Sequence< OUString >& RequestedAttributes,
         tPropValMap& rRunAttrSeq);
 
-    static css::uno::Sequence< css::beans::PropertyValue >
-    convertHashMapToSequence(tPropValMap& rAttrSeq);
-
     css::uno::Reference< css::accessibility::XAccessible > m_xAccessible;
     ::TextEngine & m_rEngine;
     ::TextView & m_rView;
diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx
index b21c771..fbf2cd7 100644
--- a/accessibility/source/extended/textwindowaccessibility.cxx
+++ b/accessibility/source/extended/textwindowaccessibility.cxx
@@ -23,6 +23,7 @@
 #include <unotools/accessiblestatesethelper.hxx>
 #include <vcl/window.hxx>
 #include <toolkit/helper/convert.hxx>
+#include <comphelper/sequence.hxx>
 
 #include <algorithm>
 #include <vector>
@@ -1101,7 +1102,7 @@ Document::retrieveCharacterAttributes(
         aCharAttrSeq[ pValues->Name ] = *pValues;
     }
 
-    css::uno::Sequence< css::beans::PropertyValue > aRes = convertHashMapToSequence( aCharAttrSeq );
+    css::uno::Sequence< css::beans::PropertyValue > aRes = comphelper::mapValuesToSequence( aCharAttrSeq );
 
     // sort the attributes
     sal_Int32 nLength = aRes.getLength();
@@ -1143,24 +1144,7 @@ Document::retrieveDefaultAttributes(
 
     tPropValMap aDefAttrSeq;
     retrieveDefaultAttributesImpl( pParagraph, RequestedAttributes, aDefAttrSeq );
-    return convertHashMapToSequence( aDefAttrSeq );
-}
-
-// static
-css::uno::Sequence< css::beans::PropertyValue >
-Document::convertHashMapToSequence(tPropValMap& rAttrSeq)
-{
-    css::uno::Sequence< css::beans::PropertyValue > aValues( rAttrSeq.size() );
-    css::beans::PropertyValue* pValues = aValues.getArray();
-    ::sal_Int32 i = 0;
-    for ( tPropValMap::const_iterator aIter  = rAttrSeq.begin();
-          aIter != rAttrSeq.end();
-          ++aIter )
-    {
-        pValues[i] = aIter->second;
-        ++i;
-    }
-    return aValues;
+    return comphelper::mapValuesToSequence( aDefAttrSeq );
 }
 
 void Document::retrieveRunAttributesImpl(
@@ -1233,7 +1217,7 @@ Document::retrieveRunAttributes(
 
     tPropValMap aRunAttrSeq;
     retrieveRunAttributesImpl( pParagraph, Index, RequestedAttributes, aRunAttrSeq );
-    return convertHashMapToSequence( aRunAttrSeq );
+    return comphelper::mapValuesToSequence( aRunAttrSeq );
 }
 
 void Document::changeParagraphText(Paragraph * pParagraph,
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index 0061161..035f7e9 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 9f01b47..a50554d 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 1a42a72..11c6174 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 9b588a7..461752c 100644
--- a/chart2/source/view/main/PropertyMapper.cxx
+++ b/chart2/source/view/main/PropertyMapper.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
 #include <com/sun/star/drawing/LineJoint.hpp>
+#include <comphelper/sequence.hxx>
 
 namespace chart
 {
@@ -65,8 +66,8 @@ void PropertyMapper::setMappedProperties(
         for( sal_Int32 nI=0; nI<aNames.getLength(); ++nI )
             aNewMap[ aNames[nI] ] = aValues[nI];
         lcl_overwriteOrAppendValues( aNewMap, *pOverwriteMap );
-        aNames = ContainerHelper::MapKeysToSequence( aNewMap );
-        aValues = ContainerHelper::MapValuesToSequence( aNewMap );
+        aNames = comphelper::mapKeysToSequence( aNewMap );
+        aValues = comphelper::mapValuesToSequence( aNewMap );
     }
 
     PropertyMapper::setMultiProperties( aNames, aValues, xTarget );
diff --git a/comphelper/source/container/NamedPropertyValuesContainer.cxx b/comphelper/source/container/NamedPropertyValuesContainer.cxx
index 69f2b38..90ce4cd 100644
--- a/comphelper/source/container/NamedPropertyValuesContainer.cxx
+++ b/comphelper/source/container/NamedPropertyValuesContainer.cxx
@@ -24,6 +24,7 @@
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/uno/Sequence.h>
 #include <com/sun/star/beans/PropertyValue.hpp>
+#include <comphelper/sequence.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <cppuhelper/supportsservice.hxx>
@@ -151,13 +152,7 @@ css::uno::Any SAL_CALL NamedPropertyValuesContainer::getByName( const OUString&
 css::uno::Sequence< OUString > SAL_CALL NamedPropertyValuesContainer::getElementNames(  )
     throw(css::uno::RuntimeException, std::exception)
 {
-    uno::Sequence< OUString > aNames( maProperties.size() );
-    OUString* pNames = aNames.getArray();
-
-    for( const auto& rProperty : maProperties )
-        *pNames++ = rProperty.first;
-
-    return aNames;
+    return comphelper::mapKeysToSequence(maProperties);
 }
 
 sal_Bool SAL_CALL NamedPropertyValuesContainer::hasByName( const OUString& aName )
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx
index 33814fb..af4bc5c 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -230,13 +230,7 @@ OUString EmbeddedObjectContainer::CreateUniqueObjectName()
 
 uno::Sequence < OUString > EmbeddedObjectContainer::GetObjectNames()
 {
-    uno::Sequence < OUString > aSeq( pImpl->maObjectContainer.size() );
-    OUString* pNames = aSeq.getArray();
-
-    for( const auto& rObj : pImpl->maObjectContainer )
-        *pNames++ = rObj.first;
-
-    return aSeq;
+    return comphelper::mapKeysToSequence(pImpl->maObjectContainer);
 }
 
 bool EmbeddedObjectContainer::HasEmbeddedObjects()
diff --git a/comphelper/source/container/namecontainer.cxx b/comphelper/source/container/namecontainer.cxx
index a7b419b..b04ada1 100644
--- a/comphelper/source/container/namecontainer.cxx
+++ b/comphelper/source/container/namecontainer.cxx
@@ -22,6 +22,7 @@
 #include <map>
 
 #include <comphelper/namecontainer.hxx>
+#include <comphelper/sequence.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <osl/diagnose.h>
 #include <osl/mutex.hxx>
@@ -160,15 +161,7 @@ Sequence< OUString > SAL_CALL NameContainer::getElementNames(  )
 {
     MutexGuard aGuard( maMutex );
 
-    Sequence< OUString > aNames( maProperties.size() );
-    OUString* pNames = aNames.getArray();
-
-    for( const auto& rProperty : maProperties )
-    {
-        *pNames++ = rProperty.first;
-    }
-
-    return aNames;
+    return comphelper::mapKeysToSequence(maProperties);
 }
 
 sal_Bool SAL_CALL NameContainer::hasByName( const OUString& aName )
diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx
index 1210147..d782b74 100644
--- a/comphelper/source/eventattachermgr/eventattachermgr.cxx
+++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx
@@ -21,6 +21,7 @@
 #include <osl/diagnose.h>
 #include <comphelper/eventattachermgr.hxx>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 #include <com/sun/star/beans/theIntrospection.hpp>
 #include <com/sun/star/io/XObjectInputStream.hpp>
 #include <com/sun/star/io/XPersistObject.hpp>
@@ -573,16 +574,7 @@ Sequence< ScriptEventDescriptor > SAL_CALL ImplEventAttacherManager::getScriptEv
 {
     Guard< Mutex > aGuard( aLock );
     ::std::deque<AttacherIndex_Impl>::iterator aIt = implCheckIndex( nIndex );
-
-    Sequence< ScriptEventDescriptor > aSeq( aIt->aEventList.size() );
-    ScriptEventDescriptor * pArray = aSeq.getArray();
-
-    sal_Int32 i = 0;
-    for( const auto& rEvt : aIt->aEventList )
-    {
-        pArray[i++] = rEvt;
-    }
-    return aSeq;
+    return comphelper::containerToSequence<ScriptEventDescriptor>(aIt->aEventList);
 }
 
 
diff --git a/connectivity/source/commontools/DriversConfig.cxx b/connectivity/source/commontools/DriversConfig.cxx
index ef7c03a..f7b5441 100644
--- a/connectivity/source/commontools/DriversConfig.cxx
+++ b/connectivity/source/commontools/DriversConfig.cxx
@@ -19,6 +19,7 @@
 #include <connectivity/DriversConfig.hxx>
 #include <tools/wldcrd.hxx>
 #include <svtools/miscopt.hxx>
+#include <comphelper/sequence.hxx>
 
 using namespace connectivity;
 using namespace utl;
@@ -241,15 +242,7 @@ const ::comphelper::NamedValueCollection& DriversConfig::impl_get(const OUString
 uno::Sequence< OUString > DriversConfig::getURLs() const
 {
     const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB);
-    uno::Sequence< OUString > aRet(rDrivers.size());
-    OUString* pIter = aRet.getArray();
-    TInstalledDrivers::const_iterator aIter = rDrivers.begin();
-    TInstalledDrivers::const_iterator aEnd = rDrivers.end();
-    for(;aIter != aEnd;++aIter,++pIter)
-    {
-        *pIter = aIter->first;
-    }
-    return aRet;
+    return comphelper::mapKeysToSequence(rDrivers);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/core/dataaccess/documentevents.cxx b/dbaccess/source/core/dataaccess/documentevents.cxx
index 5b77496..3d00576 100644
--- a/dbaccess/source/core/dataaccess/documentevents.cxx
+++ b/dbaccess/source/core/dataaccess/documentevents.cxx
@@ -23,6 +23,7 @@
 
 #include <osl/diagnose.h>
 #include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/sequence.hxx>
 
 #include <algorithm>
 #include <functional>
@@ -200,14 +201,7 @@ namespace dbaccess
     {
         ::osl::MutexGuard aGuard( m_pData->rMutex );
 
-        Sequence< OUString > aNames( m_pData->rEventsData.size() );
-        ::std::transform(
-            m_pData->rEventsData.begin(),
-            m_pData->rEventsData.end(),
-            aNames.getArray(),
-            ::o3tl::select1st< DocumentEventsData::value_type >()
-        );
-        return aNames;
+        return comphelper::mapKeysToSequence( m_pData->rEventsData );
     }
 
     sal_Bool SAL_CALL DocumentEvents::hasByName( const OUString& _Name ) throw (RuntimeException, std::exception)
diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx
index 29efea3..1230c17 100644
--- a/dbaccess/source/ui/browser/genericcontroller.cxx
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -1443,14 +1443,7 @@ Sequence< ::sal_Int16 > SAL_CALL OGenericUnoController::getSupportedCommandGroup
         if ( aIter->second.GroupId != CommandGroup::INTERNAL )
             aCmdHashMap.insert( CommandHashMap::value_type( aIter->second.GroupId, 0 ));
 
-    Sequence< sal_Int16 > aCommandGroups( aCmdHashMap.size() );
-    ::std::transform( aCmdHashMap.begin(),
-        aCmdHashMap.end(),
-        aCommandGroups.getArray(),
-        ::o3tl::select1st< CommandHashMap::value_type >()
-    );
-
-    return aCommandGroups;
+    return comphelper::mapKeysToSequence( aCmdHashMap );
 }
 
 namespace
diff --git a/dtrans/source/generic/clipboardmanager.cxx b/dtrans/source/generic/clipboardmanager.cxx
index ad8d9e3..2a5af78 100644
--- a/dtrans/source/generic/clipboardmanager.cxx
+++ b/dtrans/source/generic/clipboardmanager.cxx
@@ -20,6 +20,7 @@
 #include <clipboardmanager.hxx>
 #include <com/sun/star/lang/DisposedException.hpp>
 #include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequence.hxx>
 
 using namespace com::sun::star::container;
 using namespace com::sun::star::datatransfer;
@@ -137,14 +138,7 @@ Sequence< OUString > SAL_CALL ClipboardManager::listClipboardNames()
     if (rBHelper.bInDispose)
         return Sequence< OUString > ();
 
-    Sequence< OUString > aRet(m_aClipboardMap.size());
-    ClipboardMap::iterator iter = m_aClipboardMap.begin();
-    ClipboardMap::iterator imax = m_aClipboardMap.end();
-
-    for (sal_Int32 n = 0; iter != imax; ++iter)
-        aRet[n++] = iter->first;
-
-    return aRet;
+    return comphelper::mapKeysToSequence(m_aClipboardMap);
 }
 
 void SAL_CALL ClipboardManager::dispose()
diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx
index bfdc3d5..eea5124 100644
--- a/extensions/source/propctrlr/eventhandler.cxx
+++ b/extensions/source/propctrlr/eventhandler.cxx
@@ -53,6 +53,7 @@
 
 #include <comphelper/namedvaluecollection.hxx>
 #include <comphelper/evtmethodhelper.hxx>
+#include <comphelper/sequence.hxx>
 #include <comphelper/types.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -773,10 +774,7 @@ namespace pcr
                 PropertyAttribute::BOUND );
         }
 
-        StlSyntaxSequence< Property > aReturn( aOrderedProperties.size() );
-        ::std::transform( aOrderedProperties.begin(), aOrderedProperties.end(), aReturn.begin(),
-                ::o3tl::select2nd< std::map< EventId, Property >::value_type >() );
-        return aReturn;
+        return comphelper::mapValuesToSequence( aOrderedProperties );
     }
 
     Sequence< OUString > SAL_CALL EventHandler::getSupersededProperties( ) throw (RuntimeException, std::exception)
diff --git a/extensions/source/propctrlr/genericpropertyhandler.cxx b/extensions/source/propctrlr/genericpropertyhandler.cxx
index f76b07c..edd4f08 100644
--- a/extensions/source/propctrlr/genericpropertyhandler.cxx
+++ b/extensions/source/propctrlr/genericpropertyhandler.cxx
@@ -528,10 +528,7 @@ namespace pcr
         ::osl::MutexGuard aGuard( m_aMutex );
         impl_ensurePropertyMap();
 
-        Sequence< Property > aReturn( m_aProperties.size() );
-        ::std::transform( m_aProperties.begin(), m_aProperties.end(),
-            aReturn.getArray(), ::o3tl::select2nd< PropertyMap::value_type >() );
-        return aReturn;
+        return comphelper::mapValuesToSequence( m_aProperties );
     }
 
     Sequence< OUString > SAL_CALL GenericPropertyHandler::getSupersededProperties( ) throw (RuntimeException, std::exception)
diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index bc75f4e..63aee56 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -726,14 +726,7 @@ Any SAL_CALL OInterfaceContainer::getByName( const OUString& _rName ) throw(NoSu
 
 css::uno::Sequence<OUString> SAL_CALL OInterfaceContainer::getElementNames() throw(RuntimeException, std::exception)
 {
-    css::uno::Sequence<OUString> aNameList(m_aItems.size());
-    OUString* pStringArray = aNameList.getArray();
-
-    for (OInterfaceMap::const_iterator i = m_aMap.begin(); i != m_aMap.end(); ++i, ++pStringArray)
-    {
-        *pStringArray = (*i).first;
-    }
-    return aNameList;
+    return comphelper::mapKeysToSequence(m_aMap);
 }
 
 
diff --git a/forms/source/xforms/NameContainer.hxx b/forms/source/xforms/NameContainer.hxx
index c4a129f..f8879b0 100644
--- a/forms/source/xforms/NameContainer.hxx
+++ b/forms/source/xforms/NameContainer.hxx
@@ -20,6 +20,7 @@
 #ifndef INCLUDED_FORMS_SOURCE_XFORMS_NAMECONTAINER_HXX
 #define INCLUDED_FORMS_SOURCE_XFORMS_NAMECONTAINER_HXX
 
+#include <comphelper/sequence.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <map>
 
@@ -123,18 +124,7 @@ public:
     virtual css::uno::Sequence<OUString> SAL_CALL getElementNames()
         throw( css::uno::RuntimeException, std::exception ) override
     {
-        css::uno::Sequence<OUString> aSequence( maItems.size() );
-        typename map_t::const_iterator aIter = maItems.begin();
-        OUString* pStrings = aSequence.getArray();
-        while( aIter != maItems.end() )
-        {
-            *pStrings = aIter->first;
-            ++aIter;
-            ++pStrings;
-        }
-        OSL_ENSURE( pStrings == aSequence.getArray() + aSequence.getLength(),
-                    "sequence not of right size; possible buffer overflow" );
-        return aSequence;
+        return comphelper::mapKeysToSequence(maItems);
     }
 
     virtual sal_Bool SAL_CALL hasByName(
diff --git a/forms/source/xforms/convert.cxx b/forms/source/xforms/convert.cxx
index 0e05f2e..da5eb7f 100644
--- a/forms/source/xforms/convert.cxx
+++ b/forms/source/xforms/convert.cxx
@@ -33,6 +33,7 @@
 #include <com/sun/star/util/Date.hpp>
 #include <com/sun/star/util/DateTime.hpp>
 #include <com/sun/star/util/Time.hpp>
+#include <comphelper/sequence.hxx>
 #include <unotools/datetime.hxx>
 
 using xforms::Convert;
@@ -301,10 +302,7 @@ bool Convert::hasType( const css::uno::Type& rType )
 
 css::uno::Sequence<css::uno::Type> Convert::getTypes()
 {
-    css::uno::Sequence<css::uno::Type> aTypes( maMap.size() );
-    transform( maMap.begin(), maMap.end(), aTypes.getArray(),
-            o3tl::select1st<Map_t::value_type>() );
-    return aTypes;
+    return comphelper::mapKeysToSequence( maMap );
 }
 
 OUString Convert::toXSD( const css::uno::Any& rAny )
diff --git a/forms/source/xforms/datatyperepository.cxx b/forms/source/xforms/datatyperepository.cxx
index 0ea1e9c..ea35900 100644
--- a/forms/source/xforms/datatyperepository.cxx
+++ b/forms/source/xforms/datatyperepository.cxx
@@ -178,14 +178,7 @@ namespace xforms
     {
         ::osl::MutexGuard aGuard( m_aMutex );
 
-        Sequence< OUString > aNames( m_aRepository.size() );
-        ::std::transform(
-            m_aRepository.begin(),
-            m_aRepository.end(),
-            aNames.getArray(),
-            ::o3tl::select1st< Repository::value_type >()
-        );
-        return aNames;
+        return comphelper::mapKeysToSequence( m_aRepository );
     }
 
 
diff --git a/framework/source/uiconfiguration/graphicnameaccess.cxx b/framework/source/uiconfiguration/graphicnameaccess.cxx
index 69c083d..2b12988 100644
--- a/framework/source/uiconfiguration/graphicnameaccess.cxx
+++ b/framework/source/uiconfiguration/graphicnameaccess.cxx
@@ -57,15 +57,7 @@ throw(css::uno::RuntimeException, std::exception)
 {
     if ( m_aSeq.getLength() == 0 )
     {
-        uno::Sequence< OUString > aSeq( m_aNameToElementMap.size() );
-        NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.begin();
-        sal_Int32 i( 0);
-        while ( pIter != m_aNameToElementMap.end())
-        {
-            aSeq[i++] = pIter->first;
-            ++pIter;
-        }
-        m_aSeq = aSeq;
+        m_aSeq = comphelper::mapKeysToSequence(m_aNameToElementMap);
     }
 
     return m_aSeq;
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index caea44e..bcddfa3 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -681,13 +681,7 @@ throw (css::uno::RuntimeException)
     for ( i = 0; i < nUserCount; i++ )
         aImageCmdNameMap.insert( ImageNameMap::value_type( rUserImageNames[i], sal_True ));
 
-    Sequence< OUString > aImageNameSeq( aImageCmdNameMap.size() );
-    ImageNameMap::const_iterator pIter;
-    i = 0;
-    for ( pIter = aImageCmdNameMap.begin(); pIter != aImageCmdNameMap.end(); ++pIter )
-        aImageNameSeq[i++] = pIter->first;
-
-    return aImageNameSeq;
+    return comphelper::mapKeysToSequence( aImageCmdNameMap );
 }
 
 bool ImageManagerImpl::hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL )
diff --git a/framework/source/uiconfiguration/windowstateconfiguration.cxx b/framework/source/uiconfiguration/windowstateconfiguration.cxx
index 4082f7e..8dd19b1 100644
--- a/framework/source/uiconfiguration/windowstateconfiguration.cxx
+++ b/framework/source/uiconfiguration/windowstateconfiguration.cxx
@@ -40,6 +40,7 @@
 #include <cppuhelper/compbase.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequence.hxx>
 #include <tools/debug.hxx>
 
 #include <unordered_map>
@@ -1426,17 +1427,7 @@ throw (css::uno::RuntimeException, std::exception)
 {
     osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
 
-    Sequence< OUString > aSeq( m_aModuleToFileHashMap.size() );
-
-    sal_Int32 n = 0;
-    ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.begin();
-    while ( pIter != m_aModuleToFileHashMap.end() )
-    {
-        aSeq[n] = pIter->first;
-        ++pIter;
-    }
-
-    return aSeq;
+    return comphelper::mapKeysToSequence( m_aModuleToFileHashMap );
 }
 
 sal_Bool SAL_CALL WindowStateConfiguration::hasByName( const OUString& aName )
diff --git a/framework/source/uielement/menubarwrapper.cxx b/framework/source/uielement/menubarwrapper.cxx
index b1f63fb..cc5820c 100644
--- a/framework/source/uielement/menubarwrapper.cxx
+++ b/framework/source/uielement/menubarwrapper.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/util/URLTransformer.hpp>
 
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 #include <vcl/svapp.hxx>
 
 using namespace com::sun::star;
@@ -302,17 +303,7 @@ throw (css::uno::RuntimeException, std::exception)
 
     fillPopupControllerCache();
 
-    Sequence< OUString > aSeq( m_aPopupControllerCache.size() );
-
-    sal_Int32 i( 0 );
-    PopupControllerCache::const_iterator pIter = m_aPopupControllerCache.begin();
-    while ( pIter != m_aPopupControllerCache.end() )
-    {
-        aSeq[i++] = pIter->first;
-        ++pIter;
-    }
-
-    return aSeq;
+    return comphelper::mapKeysToSequence( m_aPopupControllerCache );
 }
 
 sal_Bool SAL_CALL MenuBarWrapper::hasByName(
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index ce608f7..49588d7 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -1320,19 +1320,10 @@ void ToolBarManager::RequestImages()
 {
 
     // Request images from image manager
-    Sequence< OUString > aCmdURLSeq( m_aCommandMap.size() );
+    Sequence< OUString > aCmdURLSeq( comphelper::mapKeysToSequence(m_aCommandMap) );
     Sequence< Reference< XGraphic > > aDocGraphicSeq;
     Sequence< Reference< XGraphic > > aModGraphicSeq;
 
-    sal_uInt32 i = 0;
-    CommandToInfoMap::iterator pIter = m_aCommandMap.begin();
-    CommandToInfoMap::iterator pEnd = m_aCommandMap.end();
-    while ( pIter != pEnd )
-    {
-        aCmdURLSeq[i++] = pIter->first;
-        ++pIter;
-    }
-
     bool  bBigImages( SvtMiscOptions().AreCurrentSymbolsLarge() );
     sal_Int16 p = getImageTypeFromBools( SvtMiscOptions().AreCurrentSymbolsLarge() );
 
@@ -1340,8 +1331,9 @@ void ToolBarManager::RequestImages()
         aDocGraphicSeq = m_xDocImageManager->getImages( p, aCmdURLSeq );
     aModGraphicSeq = m_xModuleImageManager->getImages( p, aCmdURLSeq );
 
-    i = 0;
-    pIter = m_aCommandMap.begin();
+    sal_uInt32 i = 0;
+    CommandToInfoMap::iterator pIter = m_aCommandMap.begin();
+    CommandToInfoMap::iterator pEnd = m_aCommandMap.end();
     while ( pIter != pEnd )
     {
         Image aImage;
diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx
index 01e9285..462c69d 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -721,17 +721,7 @@ throw (css::uno::RuntimeException, std::exception)
 {
     osl::MutexGuard g(rBHelper.rMutex);
 
-    Sequence< OUString > aSeq( m_aModuleToCommandFileMap.size() );
-
-    sal_Int32 n = 0;
-    ModuleToCommandFileMap::const_iterator pIter = m_aModuleToCommandFileMap.begin();
-    while ( pIter != m_aModuleToCommandFileMap.end() )
-    {
-        aSeq[n++] = pIter->first;
-        ++pIter;
-    }
-
-    return aSeq;
+    return comphelper::mapKeysToSequence( m_aModuleToCommandFileMap );
 }
 
 sal_Bool SAL_CALL UICommandDescription::hasByName( const OUString& aName )
diff --git a/include/comphelper/sequence.hxx b/include/comphelper/sequence.hxx
index 47bf0c5..17d1b67 100644
--- a/include/comphelper/sequence.hxx
+++ b/include/comphelper/sequence.hxx
@@ -369,6 +369,31 @@ namespace comphelper
         return o_Output;
     }
 
+    /** Copy (keys or values) from a associate container into a Sequence
+
+        @tpl M map container type eg. std::map/std::unordered_map
+
+        @return the generated Sequence
+     */
+    template < typename M >
+    inline css::uno::Sequence< typename M::key_type > mapKeysToSequence( M const& map )
+    {
+        css::uno::Sequence< typename M::key_type > ret( static_cast<sal_Int32>(map.size()) );
+        typename M::key_type* pArray = ret.getArray();
+        for (const auto& i : map)
+            *pArray++ = i.first;
+        return ret;
+    }
+
+    template < typename M >
+    inline css::uno::Sequence< typename M::mapped_type > mapValuesToSequence( M const& map )
+    {
+        css::uno::Sequence< typename M::mapped_type > ret( static_cast<sal_Int32>(map.size()) );
+        typename M::mapped_type* pArray = ret.getArray();
+        for (const auto& i : map)
+            *pArray++ = i.second;
+        return ret;
+    }
 
 }   // namespace comphelper
 
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 8fcfcd3..d14e1f6 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -25,6 +25,7 @@
 
 #include <scitems.hxx>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 #include <unotools/fltrcfg.hxx>
 
 #include <vcl/wmf.hxx>
@@ -137,13 +138,7 @@ public:
     virtual uno::Sequence< OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException, std::exception) override
     {
         ::osl::MutexGuard aGuard( m_aMutex );
-        uno::Sequence< OUString > aResult( IdToOleNameHash.size() );
-        NamedIndexToOleName::iterator it = IdToOleNameHash.begin();
-        NamedIndexToOleName::iterator it_end = IdToOleNameHash.end();
-        OUString* pName = aResult.getArray();
-        for (; it != it_end; ++it, ++pName )
-            *pName = it->first;
-        return aResult;
+        return comphelper::mapKeysToSequence( IdToOleNameHash);
     }
     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (uno::RuntimeException, std::exception) override
     {
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx
index b18184d..ec58bc9 100644
--- a/sc/source/ui/vba/vbawindow.cxx
+++ b/sc/source/ui/vba/vbawindow.cxx
@@ -167,13 +167,7 @@ public:
 
     virtual uno::Sequence< OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException, std::exception) override
     {
-        uno::Sequence< OUString > names( namesToIndices.size() );
-        OUString* pString = names.getArray();
-        NameIndexHash::const_iterator it = namesToIndices.begin();
-        NameIndexHash::const_iterator it_end = namesToIndices.end();
-        for ( ; it != it_end; ++it, ++pString )
-            *pString = it->first;
-        return names;
+        return comphelper::mapKeysToSequence( namesToIndices );
     }
 
     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (uno::RuntimeException, std::exception) override
diff --git a/sc/source/ui/vba/vbawindows.cxx b/sc/source/ui/vba/vbawindows.cxx
index ede740d..1f90d03 100644
--- a/sc/source/ui/vba/vbawindows.cxx
+++ b/sc/source/ui/vba/vbawindows.cxx
@@ -22,6 +22,7 @@
 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <cppuhelper/implbase.hxx>
+#include <comphelper/sequence.hxx>
 
 #include "vbawindow.hxx"
 #include "vbaglobals.hxx"
@@ -178,13 +179,7 @@ public:
 
     virtual uno::Sequence< OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException, std::exception) override
     {
-        uno::Sequence< OUString > names( namesToIndices.size() );
-        OUString* pString = names.getArray();
-        NameIndexHash::const_iterator it = namesToIndices.begin();
-        NameIndexHash::const_iterator it_end = namesToIndices.end();
-        for ( ; it != it_end; ++it, ++pString )
-            *pString = it->first;
-        return names;
+        return comphelper::mapKeysToSequence( namesToIndices );
     }
 
     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (uno::RuntimeException, std::exception) override
diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx
index d201f83..66b4f91 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -520,13 +520,7 @@ ReadOnlyEventsNameContainer::getByName( const OUString& aName ) throw (container
 Sequence< OUString > SAL_CALL
 ReadOnlyEventsNameContainer::getElementNames(  ) throw (RuntimeException, std::exception)
 {
-    Sequence< OUString > names(m_hEvents.size());
-    OUString* pDest = names.getArray();
-    EventSupplierHash::const_iterator it = m_hEvents.begin();
-    EventSupplierHash::const_iterator it_end = m_hEvents.end();
-    for ( sal_Int32 index = 0; it != it_end; ++index, ++pDest, ++it )
-        *pDest = it->first;
-    return names;
+    return comphelper::mapKeysToSequence(m_hEvents);
 }
 
 sal_Bool SAL_CALL
diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx
index c9a3d43..61af422 100644
--- a/sfx2/source/dialog/filtergrouping.cxx
+++ b/sfx2/source/dialog/filtergrouping.cxx
@@ -31,6 +31,7 @@
 #include <unotools/confignode.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/sequence.hxx>
 #include <comphelper/string.hxx>
 #include <tools/diagnose_ex.h>
 
@@ -825,12 +826,7 @@ namespace sfx2
                     // create a representation of the group which is understandable by the XFilterGroupManager
                     if ( _rGroup.size() )
                     {
-                        Sequence< StringPair > aFilters( _rGroup.size() );
-                        ::std::copy(
-                            _rGroup.begin(),
-                            _rGroup.end(),
-                            aFilters.getArray()
-                        );
+                        Sequence< StringPair > aFilters( comphelper::containerToSequence<StringPair>(_rGroup) );
                         if ( _bAddExtension )
                         {
                             StringPair* pFilters = aFilters.getArray();
diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx
index b988371..ce7fa4d 100644
--- a/svx/source/form/formcontroller.cxx
+++ b/svx/source/form/formcontroller.cxx
@@ -4046,13 +4046,7 @@ void SAL_CALL FormController::invalidateAllFeatures(  ) throw (RuntimeException,
 {
     ::osl::ClearableMutexGuard aGuard( m_aMutex );
 
-    Sequence< sal_Int16 > aInterceptedFeatures( m_aFeatureDispatchers.size() );
-    ::std::transform(
-        m_aFeatureDispatchers.begin(),
-        m_aFeatureDispatchers.end(),
-        aInterceptedFeatures.getArray(),
-        ::o3tl::select1st< DispatcherContainer::value_type >()
-    );
+    Sequence< sal_Int16 > aInterceptedFeatures( comphelper::mapKeysToSequence(m_aFeatureDispatchers) );
 
     aGuard.clear();
     if ( aInterceptedFeatures.getLength() )
diff --git a/svx/source/table/tabledesign.cxx b/svx/source/table/tabledesign.cxx
index 966f811..c3cca01 100644
--- a/svx/source/table/tabledesign.cxx
+++ b/svx/source/table/tabledesign.cxx
@@ -36,6 +36,7 @@
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/interfacecontainer.h>
 #include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequence.hxx>
 
 #include "svx/unoprov.hxx"
 #include "svx/sdr/table/tabledesign.hxx"
@@ -301,15 +302,7 @@ Sequence< OUString > SAL_CALL TableDesignStyle::getElementNames() throw(RuntimeE
 {
     SolarMutexGuard aGuard;
 
-    const CellStyleNameMap& rMap = getCellStyleNameMap();
-    Sequence< OUString > aRet( rMap.size() );
-    OUString* pName = aRet.getArray();
-
-    CellStyleNameMap::const_iterator iter = rMap.begin();
-    while( iter != rMap.end() )
-        *pName++ = (*iter++).first;
-
-    return aRet;
+    return comphelper::mapKeysToSequence( getCellStyleNameMap() );
 }
 
 
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index 7c9e150..98472cf 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -31,6 +31,7 @@
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
 #include <comphelper/propertysetinfo.hxx>
+#include <comphelper/sequence.hxx>
 #include <svx/dialmgr.hxx>
 #include "svx/unoapi.hxx"
 #include <editeng/unotext.hxx>
@@ -874,16 +875,7 @@ OUString UHashMap::getNameFromId(sal_uInt32 nId)
 
 uno::Sequence< OUString > UHashMap::getServiceNames()
 {
-    const UHashMapImpl &rMap = GetUHashImpl();
-
-    uno::Sequence< OUString > aSeq( rMap.size() );
-    OUString* pStrings = aSeq.getArray();
-
-    int i = 0;
-    for (UHashMapImpl::const_iterator it = rMap.begin(); it != rMap.end(); ++it)
-        pStrings[i++] = it->first;
-
-    return aSeq;
+    return comphelper::mapKeysToSequence( GetUHashImpl() );
 }
 
 sal_uInt32 UHashMap::getId( const OUString& rCompareString )
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index d18841e..fdcf1ab 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 282502c..dc04928 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -36,6 +36,7 @@
 #include <docsh.hxx>
 #include <xmloff/odffields.hxx>
 #include <comphelper/servicehelper.hxx>
+#include <comphelper/sequence.hxx>
 
 using namespace ::sw::mark;
 using namespace ::com::sun::star;
@@ -532,11 +533,7 @@ uno::Sequence<OUString> SwXFieldmarkParameters::getElementNames()
 {
     SolarMutexGuard aGuard;
     IFieldmark::parameter_map_t* pParameters = getCoreParameters();
-    uno::Sequence<OUString> 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 4cd0973..51f1501 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
diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index e462814..e7ae820 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -102,13 +102,7 @@ public:
     virtual Sequence< OUString > SAL_CALL getElementNames(  ) throw(RuntimeException, std::exception) override
     {
         ::osl::MutexGuard aGuard( m_aMutex );
-        Sequence< OUString > aResult( things.size() );
-        typename NamedThingsHash::iterator it = things.begin();
-        typename NamedThingsHash::iterator it_end = things.end();
-        OUString* pName = aResult.getArray();
-        for (; it != it_end; ++it, ++pName )
-            *pName = it->first;
-        return aResult;
+        return comphelper::mapKeysToSequence( things );
     }
     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(RuntimeException, std::exception) override
     {
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
index 18151f6..17f727b 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
@@ -30,6 +30,7 @@
 
 #include "comphelper/documentinfo.hxx"
 #include "comphelper/namedvaluecollection.hxx"
+#include "comphelper/sequence.hxx"
 
 #include "com/sun/star/awt/XTopWindow.hpp"
 #include "com/sun/star/beans/XPropertySet.hpp"
@@ -550,17 +551,7 @@ uno::Sequence< OUString > OfficeDocumentsManager::queryDocuments()
 {
     osl::MutexGuard aGuard( m_aMtx );
 
-    uno::Sequence< OUString > aRet( m_aDocs.size() );
-    sal_Int32 nPos = 0;
-
-    DocumentList::const_iterator it = m_aDocs.begin();
-    while ( it != m_aDocs.end() )
-    {
-        aRet[ nPos ] = (*it).first;
-        ++it;
-        ++nPos;
-    }
-    return aRet;
+    return comphelper::mapKeysToSequence( m_aDocs );
 }
 
 
diff --git a/vbahelper/source/vbahelper/vbadocumentsbase.cxx b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
index c5a5477..ae8098d 100644
--- a/vbahelper/source/vbahelper/vbadocumentsbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
@@ -21,6 +21,7 @@
 
 #include <unotools/mediadescriptor.hxx>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <com/sun/star/frame/XDesktop.hpp>
 #include <com/sun/star/container/XEnumerationAccess.hpp>
@@ -184,13 +185,7 @@ public:
 
     virtual uno::Sequence< OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException, std::exception) override
     {
-        uno::Sequence< OUString > names( namesToIndices.size() );
-        OUString* pString = names.getArray();
-        NameIndexHash::const_iterator it = namesToIndices.begin();
-        NameIndexHash::const_iterator it_end = namesToIndices.end();
-        for ( ; it != it_end; ++it, ++pString )
-            *pString = it->first;
-        return names;
+        return comphelper::mapKeysToSequence( namesToIndices );
     }
 
     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (uno::RuntimeException, std::exception) override
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 13a13da..729b031 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -34,6 +34,7 @@
 #include <comphelper/processfactory.hxx>
 #include <tools/globname.hxx>
 #include <comphelper/classids.hxx>
+#include <comphelper/sequence.hxx>
 
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmlnmspe.hxx>
@@ -392,10 +393,7 @@ Sequence< Reference< chart2::data::XLabeledDataSequence > > lcl_getAllSeriesSequ
         }
     }
 
-    Sequence< Reference< chart2::data::XLabeledDataSequence > > aRet( aContainer.size());
-    ::std::copy( aContainer.begin(), aContainer.end(), aRet.getArray());
-
-    return aRet;
+    return comphelper::containerToSequence< Reference< chart2::data::XLabeledDataSequence > >( aContainer );
 }
 
 Reference< chart2::data::XLabeledDataSequence >
@@ -444,8 +442,7 @@ Reference< chart2::data::XDataSource > lcl_pressUsedDataIntoRectangularFormat( c
             aLabeledSeqVector.push_back( aSeriesSeqVector[nN] );
     }
 
-    Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( aLabeledSeqVector.size() );
-    ::std::copy( aLabeledSeqVector.begin(), aLabeledSeqVector.end(), aSeq.getArray() );
+    Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( comphelper::containerToSequence(aLabeledSeqVector) );
 
     return lcl_createDataSource( aSeq );
 }
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
index a895c8e..3ac2e35 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -30,6 +30,7 @@
 #include <xmloff/xmlnmspe.hxx>
 #include <xmloff/xmltoken.hxx>
 #include <xmloff/nmspmap.hxx>
+#include <comphelper/sequence.hxx>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
@@ -1020,9 +1021,7 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
                     if( static_cast<sal_Int32>(aRemainingSeries.size()) != aSeriesSeq.getLength() )
                     {
                         //remove the series that have only hidden data
-                        Sequence< Reference< chart2::XDataSeries > > aRemainingSeriesSeq( aRemainingSeries.size());
-                        ::std::copy( aRemainingSeries.begin(), aRemainingSeries.end(), aRemainingSeriesSeq.getArray());
-                        xSeriesContainer->setDataSeries( aRemainingSeriesSeq );
+                        xSeriesContainer->setDataSeries( comphelper::containerToSequence(aRemainingSeries) );
 
                         //remove unused sequences
                         Reference< chart2::data::XDataSource > xDataSource( xChartDoc, uno::UNO_QUERY );
diff --git a/xmloff/source/forms/eventexport.cxx b/xmloff/source/forms/eventexport.cxx
index e26ed66..57b995c 100644
--- a/xmloff/source/forms/eventexport.cxx
+++ b/xmloff/source/forms/eventexport.cxx
@@ -21,6 +21,7 @@
 #include <osl/diagnose.h>
 #include "strings.hxx"
 #include <tools/debug.hxx>
+#include <comphelper/sequence.hxx>
 
 namespace xmloff
 {
@@ -106,15 +107,7 @@ namespace xmloff
 
     Sequence< OUString > SAL_CALL OEventDescriptorMapper::getElementNames(  ) throw(RuntimeException, std::exception)
     {
-        Sequence< OUString > aReturn(m_aMappedEvents.size());
-        OUString* pReturn = aReturn.getArray();
-        for (   MapString2PropertyValueSequence::const_iterator aCollect = m_aMappedEvents.begin();
-                aCollect != m_aMappedEvents.end();
-                ++aCollect, ++pReturn
-            )
-            *pReturn = aCollect->first;
-
-        return aReturn;
+        return comphelper::mapKeysToSequence(m_aMappedEvents);
     }
 
     sal_Bool SAL_CALL OEventDescriptorMapper::hasByName( const OUString& _rName ) throw(RuntimeException, std::exception)


More information about the Libreoffice-commits mailing list