diff options
author | Hans-Joachim Lankenau <hjs@openoffice.org> | 2010-12-17 13:36:59 +0100 |
---|---|---|
committer | Hans-Joachim Lankenau <hjs@openoffice.org> | 2010-12-17 13:36:59 +0100 |
commit | 238883621ee13e53f535fb56c4dc8510e39a7f3b (patch) | |
tree | 3fea36e0243440f0e5c96364a0fe36269966c8fd /comphelper | |
parent | 845ab68981c2aacf81af53adbf9d2d4d2e9d5527 (diff) | |
parent | 9103c81b03961788743d6248099f6a7f35f735d9 (diff) |
CWS-TOOLING: integrate CWS mib19
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/inc/comphelper/mediadescriptor.hxx | 26 | ||||
-rw-r--r-- | comphelper/source/misc/mediadescriptor.cxx | 36 |
2 files changed, 33 insertions, 29 deletions
diff --git a/comphelper/inc/comphelper/mediadescriptor.hxx b/comphelper/inc/comphelper/mediadescriptor.hxx index 01fa8059b284..e92a6c4650f6 100644 --- a/comphelper/inc/comphelper/mediadescriptor.hxx +++ b/comphelper/inc/comphelper/mediadescriptor.hxx @@ -128,10 +128,6 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap //------------------------------------------- // interface public: - /** Value type of the 'ComponentData' property. - */ - typedef ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > ComponentDataSequence; - //--------------------------------------- /** @short these ctors do nothing - excepting that they forward the given parameters to the base class ctors. @@ -205,8 +201,9 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap /** Returns a value from the sequence contained in the property 'ComponentData' of this media descriptor. - @descr The property 'ComponentData' should be empty or should - contain a value of type ComponentDataSequence (see above). + @descr The property 'ComponentData' should be empty, or should + contain a value of type sequence<com.sun.star.beans.NamedValue> + or sequence<com.sun.star.beans.PropertyValue>. @return The value with the specified name, if existing in the sequence of the 'ComponentData' property, otherwise an empty @@ -219,10 +216,11 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap /** Inserts a value into the sequence contained in the property 'ComponentData' of the media descriptor. - @descr The property 'ComponentData' should be empty or should - contain a value of type ComponentDataSequence (see above). The - passed value will be inserted into the sequence, or, if already - existing, will be overwritten. + @descr The property 'ComponentData' should be empty, or should + contain a value of type sequence<com.sun.star.beans.NamedValue> + or sequence<com.sun.star.beans.PropertyValue>. The passed value + will be inserted into the sequence, or, if already existing, + will be overwritten. @param rName The name of the value to be inserted into the sequence of the 'ComponentData' property. @@ -238,10 +236,10 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap /** Removes a value from the sequence contained in the property 'ComponentData' of the media descriptor. - @descr The property 'ComponentData' should be empty or should - contain a value of type ComponentDataSequence (see above). The - value with the passed name will be removed from the sequence, - if existing. + @descr The property 'ComponentData' should be empty, or should + contain a value of type sequence<com.sun.star.beans.NamedValue> + or sequence<com.sun.star.beans.PropertyValue>. The value with + the passed name will be removed from the sequence, if existing. @param rName The name of the value to be removed from the sequence of the 'ComponentData' property. diff --git a/comphelper/source/misc/mediadescriptor.cxx b/comphelper/source/misc/mediadescriptor.cxx index 143f8ba4dfa2..e0b3e797264a 100644 --- a/comphelper/source/misc/mediadescriptor.cxx +++ b/comphelper/source/misc/mediadescriptor.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_comphelper.hxx" #include <comphelper/mediadescriptor.hxx> +#include <comphelper/namedvaluecollection.hxx> #include <comphelper/stillreadwriteinteraction.hxx> #include <com/sun/star/ucb/XContent.hpp> @@ -483,27 +484,30 @@ sal_Bool MediaDescriptor::isStreamReadOnly() const css::uno::Any MediaDescriptor::getComponentDataEntry( const ::rtl::OUString& rName ) const { - SequenceAsHashMap aCompDataMap( getUnpackedValueOrDefault( PROP_COMPONENTDATA(), ComponentDataSequence() ) ); - SequenceAsHashMap::iterator aIt = aCompDataMap.find( rName ); - return (aIt == aCompDataMap.end()) ? css::uno::Any() : aIt->second; + css::uno::Any aEntry; + SequenceAsHashMap::const_iterator aPropertyIter = find( PROP_COMPONENTDATA() ); + if( aPropertyIter != end() ) + return NamedValueCollection( aPropertyIter->second ).get( rName ); + return css::uno::Any(); } void MediaDescriptor::setComponentDataEntry( const ::rtl::OUString& rName, const css::uno::Any& rValue ) { if( rValue.hasValue() ) { - // get or craete the 'ComponentData' property entry + // get or create the 'ComponentData' property entry css::uno::Any& rCompDataAny = operator[]( PROP_COMPONENTDATA() ); - // check type, insert the value - OSL_ENSURE( !rCompDataAny.hasValue() || rCompDataAny.has< ComponentDataSequence >(), - "MediaDescriptor::setComponentDataEntry - incompatible 'ComponentData' property in media descriptor" ); - if( !rCompDataAny.hasValue() || rCompDataAny.has< ComponentDataSequence >() ) + // insert the value (retain sequence type, create NamedValue elements by default) + bool bHasNamedValues = !rCompDataAny.hasValue() || rCompDataAny.has< css::uno::Sequence< css::beans::NamedValue > >(); + bool bHasPropValues = rCompDataAny.has< css::uno::Sequence< css::beans::PropertyValue > >(); + OSL_ENSURE( bHasNamedValues || bHasPropValues, "MediaDescriptor::setComponentDataEntry - incompatible 'ComponentData' property in media descriptor" ); + if( bHasNamedValues || bHasPropValues ) { // insert or overwrite the passed value SequenceAsHashMap aCompDataMap( rCompDataAny ); aCompDataMap[ rName ] = rValue; - // write back the sequence (sal_False = use NamedValue instead of PropertyValue) - rCompDataAny = aCompDataMap.getAsConstAny( sal_False ); + // write back the sequence (restore sequence with correct element type) + rCompDataAny = aCompDataMap.getAsConstAny( bHasPropValues ); } } else @@ -518,18 +522,20 @@ void MediaDescriptor::clearComponentDataEntry( const ::rtl::OUString& rName ) SequenceAsHashMap::iterator aPropertyIter = find( PROP_COMPONENTDATA() ); if( aPropertyIter != end() ) { - OSL_ENSURE( aPropertyIter->second.has< ComponentDataSequence >(), - "MediaDescriptor::clearComponentDataEntry - incompatible 'ComponentData' property in media descriptor" ); - if( aPropertyIter->second.has< ComponentDataSequence >() ) + css::uno::Any& rCompDataAny = aPropertyIter->second; + bool bHasNamedValues = rCompDataAny.has< css::uno::Sequence< css::beans::NamedValue > >(); + bool bHasPropValues = rCompDataAny.has< css::uno::Sequence< css::beans::PropertyValue > >(); + OSL_ENSURE( bHasNamedValues || bHasPropValues, "MediaDescriptor::clearComponentDataEntry - incompatible 'ComponentData' property in media descriptor" ); + if( bHasNamedValues || bHasPropValues ) { // remove the value with the passed name - SequenceAsHashMap aCompDataMap( aPropertyIter->second ); + SequenceAsHashMap aCompDataMap( rCompDataAny ); aCompDataMap.erase( rName ); // write back the sequence, or remove it completely if it is empty if( aCompDataMap.empty() ) erase( aPropertyIter ); else - aPropertyIter->second = aCompDataMap.getAsConstAny( sal_False ); + rCompDataAny = aCompDataMap.getAsConstAny( bHasPropValues ); } } } |