summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--comphelper/inc/comphelper/namedvaluecollection.hxx8
-rw-r--r--comphelper/source/misc/namedvaluecollection.cxx13
-rw-r--r--sfx2/source/notify/eventsupplier.cxx4
3 files changed, 23 insertions, 2 deletions
diff --git a/comphelper/inc/comphelper/namedvaluecollection.hxx b/comphelper/inc/comphelper/namedvaluecollection.hxx
index 6ec12a6aa5c2..bfaa1a017bde 100644
--- a/comphelper/inc/comphelper/namedvaluecollection.hxx
+++ b/comphelper/inc/comphelper/namedvaluecollection.hxx
@@ -118,6 +118,14 @@ namespace comphelper
impl_assign( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >() );
}
+ /** determines whether or not named values can be extracted from the given value
+
+ @return
+ <TRUE/> if and only if the given <code>Any</code> contains a <code>NamedValue</code>, a
+ <code>PropertyValue</code>, or a sequence thereof.
+ */
+ static bool canExtractFrom( ::com::sun::star::uno::Any const & i_value );
+
/// returns the number of elements in the collection
size_t size() const;
diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx
index a9eaccb3223b..85c2883764fd 100644
--- a/comphelper/source/misc/namedvaluecollection.cxx
+++ b/comphelper/source/misc/namedvaluecollection.cxx
@@ -127,6 +127,19 @@ namespace comphelper
}
//--------------------------------------------------------------------
+ bool NamedValueCollection::canExtractFrom( ::com::sun::star::uno::Any const & i_value )
+ {
+ Type const & aValueType = i_value.getValueType();
+ if ( aValueType.equals( ::cppu::UnoType< PropertyValue >::get() )
+ || aValueType.equals( ::cppu::UnoType< NamedValue >::get() )
+ || aValueType.equals( ::cppu::UnoType< Sequence< PropertyValue > >::get() )
+ || aValueType.equals( ::cppu::UnoType< Sequence< NamedValue > >::get() )
+ )
+ return true;
+ return false;
+ }
+
+ //--------------------------------------------------------------------
NamedValueCollection& NamedValueCollection::merge( const NamedValueCollection& _rAdditionalValues, bool _bOverwriteExisting )
{
for ( NamedValueRepository::const_iterator namedValue = _rAdditionalValues.m_pImpl->aValues.begin();
diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx
index ad1ed19e493a..6c7e2796347c 100644
--- a/sfx2/source/notify/eventsupplier.cxx
+++ b/sfx2/source/notify/eventsupplier.cxx
@@ -84,10 +84,10 @@ void SAL_CALL SfxEvents_Impl::replaceByName( const OUSTRING & aName, const ANY &
{
if ( maEventNames[i] == aName )
{
- const ::comphelper::NamedValueCollection aEventDescriptor( rElement );
// check for correct type of the element
- if ( rElement.hasValue() && aEventDescriptor.empty() )
+ if ( !::comphelper::NamedValueCollection::canExtractFrom( rElement ) )
throw ILLEGALARGUMENTEXCEPTION();
+ ::comphelper::NamedValueCollection const aEventDescriptor( rElement );
// create Configuration at first, creation might call this method also and that would overwrite everything
// we might have stored before!