dba34a: +assign(Any) / +getNames
This commit is contained in:
parent
19049cbcca
commit
a4789a0d38
2 changed files with 46 additions and 15 deletions
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
//........................................................................
|
||||
namespace comphelper
|
||||
|
@ -91,6 +92,11 @@ namespace comphelper
|
|||
|
||||
~NamedValueCollection();
|
||||
|
||||
inline void assign( const ::com::sun::star::uno::Any& i_rWrappedElements )
|
||||
{
|
||||
impl_assign( i_rWrappedElements );
|
||||
}
|
||||
|
||||
inline void assign( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArguments )
|
||||
{
|
||||
impl_assign( _rArguments );
|
||||
|
@ -117,6 +123,11 @@ namespace comphelper
|
|||
/// determines whether the collection is empty
|
||||
bool empty() const;
|
||||
|
||||
/** returns the names of all elements in the collection
|
||||
*/
|
||||
::std::vector< ::rtl::OUString >
|
||||
getNames() const;
|
||||
|
||||
/** merges the content of another collection into |this|
|
||||
@param _rAdditionalValues
|
||||
the collection whose values are to be merged
|
||||
|
@ -312,6 +323,7 @@ namespace comphelper
|
|||
}
|
||||
|
||||
private:
|
||||
void impl_assign( const ::com::sun::star::uno::Any& i_rWrappedElements );
|
||||
void impl_assign( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArguments );
|
||||
void impl_assign( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArguments );
|
||||
void impl_assign( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rArguments );
|
||||
|
|
|
@ -99,21 +99,7 @@ namespace comphelper
|
|||
NamedValueCollection::NamedValueCollection( const Any& _rElements )
|
||||
:m_pImpl( new NamedValueCollection_Impl )
|
||||
{
|
||||
Sequence< NamedValue > aNamedValues;
|
||||
Sequence< PropertyValue > aPropertyValues;
|
||||
NamedValue aNamedValue;
|
||||
PropertyValue aPropertyValue;
|
||||
|
||||
if ( _rElements >>= aNamedValues )
|
||||
impl_assign( aNamedValues );
|
||||
else if ( _rElements >>= aPropertyValues )
|
||||
impl_assign( aPropertyValues );
|
||||
else if ( _rElements >>= aNamedValue )
|
||||
impl_assign( Sequence< NamedValue >( &aNamedValue, 1 ) );
|
||||
else if ( _rElements >>= aPropertyValue )
|
||||
impl_assign( Sequence< PropertyValue >( &aPropertyValue, 1 ) );
|
||||
else
|
||||
OSL_ENSURE( !_rElements.hasValue(), "NamedValueCollection::NamedValueCollection(Any): unsupported type!" );
|
||||
impl_assign( _rElements );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -169,6 +155,39 @@ namespace comphelper
|
|||
return m_pImpl->aValues.empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
::std::vector< ::rtl::OUString > NamedValueCollection::getNames() const
|
||||
{
|
||||
::std::vector< ::rtl::OUString > aNames( m_pImpl->aValues.size() );
|
||||
::std::transform(
|
||||
m_pImpl->aValues.begin(),
|
||||
m_pImpl->aValues.end(),
|
||||
aNames.begin(),
|
||||
::std::select1st< NamedValueRepository::value_type >()
|
||||
);
|
||||
return aNames;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void NamedValueCollection::impl_assign( const Any& i_rWrappedElements )
|
||||
{
|
||||
Sequence< NamedValue > aNamedValues;
|
||||
Sequence< PropertyValue > aPropertyValues;
|
||||
NamedValue aNamedValue;
|
||||
PropertyValue aPropertyValue;
|
||||
|
||||
if ( i_rWrappedElements >>= aNamedValues )
|
||||
impl_assign( aNamedValues );
|
||||
else if ( i_rWrappedElements >>= aPropertyValues )
|
||||
impl_assign( aPropertyValues );
|
||||
else if ( i_rWrappedElements >>= aNamedValue )
|
||||
impl_assign( Sequence< NamedValue >( &aNamedValue, 1 ) );
|
||||
else if ( i_rWrappedElements >>= aPropertyValue )
|
||||
impl_assign( Sequence< PropertyValue >( &aPropertyValue, 1 ) );
|
||||
else
|
||||
OSL_ENSURE( !i_rWrappedElements.hasValue(), "NamedValueCollection::impl_assign(Any): unsupported type!" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void NamedValueCollection::impl_assign( const Sequence< Any >& _rArguments )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue