summaryrefslogtreecommitdiff
path: root/comphelper/source/misc/namedvaluecollection.cxx
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2007-11-21 15:53:08 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2007-11-21 15:53:08 +0000
commita78417e8b1da7b28d59eeb0ad5b312033b058156 (patch)
tree73c96a0c569c46b1d190cd2d8932d13e645088bf /comphelper/source/misc/namedvaluecollection.cxx
parentd6d49bb48ea7a2ed0ec760c3bb4f9c1dcd8d2fab (diff)
INTEGRATION: CWS dba24c (1.7.40); FILE MERGED
2007/10/09 21:10:50 fs 1.7.40.1: #i82110#: +put / +operator >>=
Diffstat (limited to 'comphelper/source/misc/namedvaluecollection.cxx')
-rw-r--r--comphelper/source/misc/namedvaluecollection.cxx57
1 files changed, 51 insertions, 6 deletions
diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx
index c82688f60f93..c0d924b52a67 100644
--- a/comphelper/source/misc/namedvaluecollection.cxx
+++ b/comphelper/source/misc/namedvaluecollection.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: namedvaluecollection.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: hr $ $Date: 2007-06-27 14:55:20 $
+ * last change: $Author: ihi $ $Date: 2007-11-21 16:53:08 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -41,18 +41,17 @@
#endif
/** === begin UNO includes === **/
-#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_
#include <com/sun/star/beans/NamedValue.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
#include <com/sun/star/lang/IllegalArgumentException.hpp>
-#endif
+#include <com/sun/star/beans/PropertyState.hpp>
/** === end UNO includes === **/
#include <rtl/ustrbuf.hxx>
#include <osl/diagnose.h>
#include <hash_map>
+#include <functional>
+#include <algorithm>
//........................................................................
namespace comphelper
@@ -70,6 +69,7 @@ namespace comphelper
using ::com::sun::star::uno::cpp_queryInterface;
using ::com::sun::star::lang::IllegalArgumentException;
using ::com::sun::star::beans::NamedValue;
+ using ::com::sun::star::beans::PropertyState_DIRECT_VALUE;
/** === end UNO using === **/
//====================================================================
@@ -231,6 +231,14 @@ namespace comphelper
}
//--------------------------------------------------------------------
+ bool NamedValueCollection::impl_put( const ::rtl::OUString& _rValueName, const Any& _rValue )
+ {
+ bool bHas = impl_has( _rValueName );
+ m_pImpl->aValues[ _rValueName ] = _rValue;
+ return bHas;
+ }
+
+ //--------------------------------------------------------------------
bool NamedValueCollection::impl_remove( const ::rtl::OUString& _rValueName )
{
NamedValueRepository::iterator pos = m_pImpl->aValues.find( _rValueName );
@@ -240,6 +248,43 @@ namespace comphelper
return true;
}
+ //--------------------------------------------------------------------
+ namespace
+ {
+ struct Value2PropertyValue : public ::std::unary_function< NamedValueRepository::value_type, PropertyValue >
+ {
+ PropertyValue operator()( const NamedValueRepository::value_type& _rValue )
+ {
+ return PropertyValue(
+ _rValue.first, 0, _rValue.second, PropertyState_DIRECT_VALUE );
+ }
+ };
+
+ struct Value2NamedValue : public ::std::unary_function< NamedValueRepository::value_type, NamedValue >
+ {
+ NamedValue operator()( const NamedValueRepository::value_type& _rValue )
+ {
+ return NamedValue( _rValue.first, _rValue.second );
+ }
+ };
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 NamedValueCollection::operator >>= ( Sequence< PropertyValue >& _out_rValues )
+ {
+ _out_rValues.realloc( m_pImpl->aValues.size() );
+ ::std::transform( m_pImpl->aValues.begin(), m_pImpl->aValues.end(), _out_rValues.getArray(), Value2PropertyValue() );
+ return _out_rValues.getLength();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 NamedValueCollection::operator >>= ( Sequence< NamedValue >& _out_rValues )
+ {
+ _out_rValues.realloc( m_pImpl->aValues.size() );
+ ::std::transform( m_pImpl->aValues.begin(), m_pImpl->aValues.end(), _out_rValues.getArray(), Value2NamedValue() );
+ return _out_rValues.getLength();
+ }
+
//........................................................................
} // namespace comphelper
//........................................................................