add mapKeysToSequence/mapValuesToSequence methods to comphelper

and use them

Change-Id: If4dc9df63db37185228aeaaab2979498d61304ec
Reviewed-on: https://gerrit.libreoffice.org/20055
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Noel Grandin 2015-11-19 13:43:23 +02:00 committed by Noel Grandin
parent 1d5c39192e
commit fe3fd05966
44 changed files with 97 additions and 373 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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 ____

View File

@ -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

View File

@ -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 );

View File

@ -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 );

View File

@ -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 )

View File

@ -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()

View File

@ -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 )

View File

@ -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);
}

View File

@ -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: */

View File

@ -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)

View File

@ -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

View File

@ -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()

View File

@ -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)

View File

@ -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)

View File

@ -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);
}

View File

@ -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(

View File

@ -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 )

View File

@ -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 );
}

View File

@ -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;

View File

@ -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 )

View File

@ -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 )

View File

@ -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(

View File

@ -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;

View File

@ -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 )

View File

@ -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

View File

@ -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
{

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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() )

View File

@ -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() );
}

View File

@ -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 )

View File

@ -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(

View File

@ -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)

View File

@ -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

View File

@ -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
{

View File

@ -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 );
}

View File

@ -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

View File

@ -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 );
}

View File

@ -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 );

View File

@ -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)