summaryrefslogtreecommitdiff
path: root/cppu/inc/com/sun/star
diff options
context:
space:
mode:
Diffstat (limited to 'cppu/inc/com/sun/star')
-rw-r--r--cppu/inc/com/sun/star/uno/Any.h383
-rw-r--r--cppu/inc/com/sun/star/uno/Any.hxx589
-rw-r--r--cppu/inc/com/sun/star/uno/Reference.h533
-rw-r--r--cppu/inc/com/sun/star/uno/Reference.hxx431
-rw-r--r--cppu/inc/com/sun/star/uno/Sequence.h288
-rw-r--r--cppu/inc/com/sun/star/uno/Sequence.hxx307
-rw-r--r--cppu/inc/com/sun/star/uno/Type.h458
-rw-r--r--cppu/inc/com/sun/star/uno/Type.hxx327
-rw-r--r--cppu/inc/com/sun/star/uno/genfunc.h69
-rw-r--r--cppu/inc/com/sun/star/uno/genfunc.hxx88
10 files changed, 3473 insertions, 0 deletions
diff --git a/cppu/inc/com/sun/star/uno/Any.h b/cppu/inc/com/sun/star/uno/Any.h
new file mode 100644
index 000000000000..c9e8aed205e1
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Any.h
@@ -0,0 +1,383 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_ANY_H_
+#define _COM_SUN_STAR_UNO_ANY_H_
+
+#include <uno/any2.h>
+#include <typelib/typedescription.h>
+#include <com/sun/star/uno/Type.h>
+#include "cppu/unotype.hxx"
+#include <rtl/alloc.h>
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** C++ class representing an IDL any.
+ This class is used to transport any type defined in IDL. The class inherits from the
+ binary C representation of uno_Any.
+ You can insert a value by either using the <<= operators or the template function makeAny().
+ No any can hold an any. You can extract values from an any by using the >>= operators which
+ return true if the any contains an assignable value (no data loss), e.g. the any contains a
+ short and you >>= it into a long variable.
+*/
+class Any : public uno_Any
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ /** @internal */
+ inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ /** @internal */
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ /** @internal */
+ inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW( () )
+ { return pMem; }
+ /** @internal */
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW( () )
+ {}
+
+ /** Default constructor: Any holds no value; its type is void.
+ */
+ inline Any() SAL_THROW( () );
+
+ /** Templated ctor. Sets a copy of the given value.
+
+ @param value value of the Any
+ */
+ template <typename T>
+ explicit inline Any( T const & value );
+ /// Ctor support for C++ bool.
+ explicit inline Any( bool value );
+
+ /** Copy constructor: Sets value of the given any.
+
+ @param rAny another any
+ */
+ inline Any( const Any & rAny ) SAL_THROW( () );
+
+ /** Constructor: Sets a copy of the given data.
+
+ @param pData_ value
+ @param rType type of value
+ */
+ inline Any( const void * pData_, const Type & rType ) SAL_THROW( () );
+
+ /** Constructor: Sets a copy of the given data.
+
+ @param pData_ value
+ @param pTypeDescr type of value
+ */
+ inline Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW( () );
+
+ /** Constructor: Sets a copy of the given data.
+
+ @param pData_ value
+ @param pType type of value
+ */
+ inline Any( const void * pData_, typelib_TypeDescriptionReference * pType ) SAL_THROW( () );
+
+ /** Destructor: Destructs any content and frees memory.
+ */
+ inline ~Any() SAL_THROW( () );
+
+ /** Assignment operator: Sets the value of the given any.
+
+ @param rAny another any (right side)
+ @return this any
+ */
+ inline Any & SAL_CALL operator = ( const Any & rAny ) SAL_THROW( () );
+
+ /** Gets the type of the set value.
+
+ @return a Type object of the set value
+ */
+ inline const Type & SAL_CALL getValueType() const SAL_THROW( () )
+ { return * reinterpret_cast< const Type * >( &pType ); }
+ /** Gets the type of the set value.
+
+ @return the UNacquired type description reference of the set value
+ */
+ inline typelib_TypeDescriptionReference * SAL_CALL getValueTypeRef() const SAL_THROW( () )
+ { return pType; }
+
+ /** Gets the type description of the set value. Provides ownership of the type description!
+ Call an explicit typelib_typedescription_release() to release afterwards.
+
+ @param a pointer to type description pointer
+ */
+ inline void SAL_CALL getValueTypeDescription( typelib_TypeDescription ** ppTypeDescr ) const SAL_THROW( () )
+ { ::typelib_typedescriptionreference_getDescription( ppTypeDescr, pType ); }
+
+ /** Gets the type class of the set value.
+
+ @return the type class of the set value
+ */
+ inline TypeClass SAL_CALL getValueTypeClass() const SAL_THROW( () )
+ { return (TypeClass)pType->eTypeClass; }
+
+ /** Gets the type name of the set value.
+
+ @return the type name of the set value
+ */
+ inline ::rtl::OUString SAL_CALL getValueTypeName() const SAL_THROW( () );
+
+ /** Tests if any contains a value.
+
+ @return true if any has a value, false otherwise
+ */
+ inline sal_Bool SAL_CALL hasValue() const SAL_THROW( () )
+ { return (typelib_TypeClass_VOID != pType->eTypeClass); }
+
+ /** Gets a pointer to the set value.
+
+ @return a pointer to the set value
+ */
+ inline const void * SAL_CALL getValue() const SAL_THROW( () )
+ { return pData; }
+
+#if ! defined(EXCEPTIONS_OFF)
+ /** Provides a value of specified type, so you can easily write e.g.
+ <pre>
+ sal_Int32 myVal = myAny.get<sal_Int32>();
+ </pre>
+ Widening conversion without data loss is taken into account.
+ Throws a
+ <type scope="com::sun::star::uno">RuntimeException</type>
+ if the specified type cannot be provided.
+
+ @return value of specified type
+ @exception <type scope="com::sun::star::uno">RuntimeException</type>
+ in case the specified type cannot be provided
+ */
+ template <typename T>
+ inline T get() const;
+#endif // ! defined(EXCEPTIONS_OFF)
+
+ /** Sets a value. If the any already contains a value, that value will be destructed
+ and its memory freed.
+
+ @param pData_ pointer to value
+ @param rType type of value
+ */
+ inline void SAL_CALL setValue( const void * pData_, const Type & rType ) SAL_THROW( () );
+ /** Sets a value. If the any already contains a value, that value will be destructed
+ and its memory freed.
+
+ @param pData_ pointer to value
+ @param pType type of value
+ */
+ inline void SAL_CALL setValue( const void * pData_, typelib_TypeDescriptionReference * pType ) SAL_THROW( () );
+ /** Sets a value. If the any already contains a value, that value will be destructed
+ and its memory freed.
+
+ @param pData_ pointer to value
+ @param pTypeDescr type description of value
+ */
+ inline void SAL_CALL setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW( () );
+
+ /** Clears this any. If the any already contains a value, that value will be destructed
+ and its memory freed. After this has been called, the any does not contain a value.
+ */
+ inline void SAL_CALL clear() SAL_THROW( () );
+
+ /** Tests whether this any is extractable to a value of given type.
+ Widening conversion without data loss is taken into account.
+
+ @param rType destination type
+ @return true if this any is extractable to value of given type (e.g. using >>= operator)
+ */
+ inline sal_Bool SAL_CALL isExtractableTo( const Type & rType ) const SAL_THROW( () );
+
+ /** Tests whether this any can provide a value of specified type.
+ Widening conversion without data loss is taken into account.
+
+ @return true if this any can provide a value of specified type
+ (e.g. using >>= operator)
+ */
+ template <typename T>
+ inline bool has() const;
+
+ /** Equality operator: compares two anys.
+ The values need not be of equal type, e.g. a short integer is compared to a long integer.
+
+ @param rAny another any (right side)
+ @return true if both any contains equal values
+ */
+ inline sal_Bool SAL_CALL operator == ( const Any & rAny ) const SAL_THROW( () );
+ /** Unequality operator: compares two anys.
+ The values need not be of equal type, e.g. a short integer is compared to a long integer.
+
+ @param rAny another any (right side)
+ @return true if both any contains unequal values
+ */
+ inline sal_Bool SAL_CALL operator != ( const Any & rAny ) const SAL_THROW( () );
+
+private:
+ // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
+ explicit Any( sal_uInt16 );
+#if defined(_MSC_VER)
+ // Omitting the following private declarations leads to an internal compiler
+ // error on MSVC (version 1310).
+ // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
+#if ! defined(EXCEPTIONS_OFF)
+ template <>
+ sal_uInt16 get<sal_uInt16>() const;
+#endif // ! defined(EXCEPTIONS_OFF)
+ template <>
+ bool has<sal_uInt16>() const;
+#endif // defined(_MSC_VER)
+};
+
+/** Template function to generically construct an any from a C++ value.
+
+ @tplparam C value type
+ @param value a value
+ @return an any
+*/
+template< class C >
+inline Any SAL_CALL makeAny( const C & value ) SAL_THROW( () );
+
+// additionally specialized for C++ bool
+template<>
+inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW( () );
+
+class BaseReference;
+class Type;
+
+/** Template binary <<= operator to set the value of an any.
+
+ @tplparam C value type
+ @param rAny destination any (left side)
+ @param value source value (right side)
+*/
+template< class C >
+inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW( () );
+
+// additionally for C++ bool:
+inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
+ SAL_THROW( () );
+
+/** Template binary >>= operator to assign a value from an any.
+ If the any does not contain a value that can be assigned without data loss, then this
+ operation will fail returning false.
+
+ @tplparam C value type
+ @param rAny source any (left side)
+ @param value destination value (right side)
+ @return true if assignment was possible without data loss
+*/
+template< class C >
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW( () );
+
+/** Template equality operator: compares set value of left side any to right side value.
+ The values need not be of equal type, e.g. a short integer is compared to a long integer.
+ This operator can be implemented as template member function, if all supported compilers
+ can cope with template member functions.
+
+ @tplparam C value type
+ @param rAny another any (left side)
+ @param value a value (right side)
+ @return true if values are equal, false otherwise
+*/
+template< class C >
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW( () );
+/** Template unequality operator: compares set value of left side any to right side value.
+ The values need not be of equal type, e.g. a short integer is compared to a long integer.
+ This operator can be implemented as template member function, if all supported compilers
+ can cope with template member functions.
+
+ @tplparam C value type
+ @param rAny another any (left side)
+ @param value a value (right side)
+ @return true if values are unequal, false otherwise
+*/
+template< class C >
+inline sal_Bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW( () );
+
+// additional specialized >>= and == operators
+// bool
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Bool & value ) SAL_THROW( () );
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW( () );
+template<>
+inline sal_Bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
+ SAL_THROW( () );
+template<>
+inline sal_Bool SAL_CALL operator == ( Any const & rAny, bool const & value )
+ SAL_THROW( () );
+// byte
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int8 & value ) SAL_THROW( () );
+// short
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW( () );
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW( () );
+// long
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW( () );
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW( () );
+// hyper
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW( () );
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW( () );
+// float
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW( () );
+// double
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW( () );
+// string
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW( () );
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW( () );
+// type
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW( () );
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW( () );
+// any
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW( () );
+// interface
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW( () );
+
+}
+}
+}
+}
+
+/** Gets the meta type of IDL type any.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type any
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Any * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::com::sun::star::uno::Any >::get();
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Any.hxx b/cppu/inc/com/sun/star/uno/Any.hxx
new file mode 100644
index 000000000000..44508556698c
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Any.hxx
@@ -0,0 +1,589 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#define _COM_SUN_STAR_UNO_ANY_HXX_
+
+#include <com/sun/star/uno/Any.h>
+#include <uno/data.h>
+#include <com/sun/star/uno/Type.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/genfunc.hxx>
+#include "cppu/unotype.hxx"
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+//__________________________________________________________________________________________________
+inline Any::Any() SAL_THROW( () )
+{
+ ::uno_any_construct( this, 0, 0, (uno_AcquireFunc)cpp_acquire );
+}
+
+//______________________________________________________________________________
+template <typename T>
+inline Any::Any( T const & value )
+{
+ ::uno_type_any_construct(
+ this, const_cast<T *>(&value),
+ ::cppu::getTypeFavourUnsigned(&value).getTypeLibType(),
+ (uno_AcquireFunc) cpp_acquire );
+}
+//______________________________________________________________________________
+inline Any::Any( bool value )
+{
+ sal_Bool b = value;
+ ::uno_type_any_construct(
+ this, &b, ::getCppuBooleanType().getTypeLibType(),
+ (uno_AcquireFunc) cpp_acquire );
+}
+
+//__________________________________________________________________________________________________
+inline Any::Any( const Any & rAny ) SAL_THROW( () )
+{
+ ::uno_type_any_construct( this, rAny.pData, rAny.pType, (uno_AcquireFunc)cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::Any( const void * pData_, const Type & rType ) SAL_THROW( () )
+{
+ ::uno_type_any_construct(
+ this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
+ (uno_AcquireFunc)cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW( () )
+{
+ ::uno_any_construct(
+ this, const_cast< void * >( pData_ ), pTypeDescr, (uno_AcquireFunc)cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::Any( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW( () )
+{
+ ::uno_type_any_construct(
+ this, const_cast< void * >( pData_ ), pType_, (uno_AcquireFunc)cpp_acquire );
+}
+//__________________________________________________________________________________________________
+inline Any::~Any() SAL_THROW( () )
+{
+ ::uno_any_destruct(
+ this, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline Any & Any::operator = ( const Any & rAny ) SAL_THROW( () )
+{
+ if (this != &rAny)
+ {
+ ::uno_type_any_assign(
+ this, rAny.pData, rAny.pType,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+ }
+ return *this;
+}
+//__________________________________________________________________________________________________
+inline ::rtl::OUString Any::getValueTypeName() const SAL_THROW( () )
+{
+ return ::rtl::OUString( pType->pTypeName );
+}
+//__________________________________________________________________________________________________
+inline void Any::setValue( const void * pData_, const Type & rType ) SAL_THROW( () )
+{
+ ::uno_type_any_assign(
+ this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline void Any::setValue( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW( () )
+{
+ ::uno_type_any_assign(
+ this, const_cast< void * >( pData_ ), pType_,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline void Any::setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW( () )
+{
+ ::uno_any_assign(
+ this, const_cast< void * >( pData_ ), pTypeDescr,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline void Any::clear() SAL_THROW( () )
+{
+ ::uno_any_clear(
+ this, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline sal_Bool Any::isExtractableTo( const Type & rType ) const SAL_THROW( () )
+{
+ return ::uno_type_isAssignableFromData(
+ rType.getTypeLibType(), pData, pType,
+ (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
+}
+
+//______________________________________________________________________________
+template <typename T>
+inline bool Any::has() const
+{
+ Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * >(0));
+ return ::uno_type_isAssignableFromData(
+ rType.getTypeLibType(), pData, pType,
+ (uno_QueryInterfaceFunc) cpp_queryInterface,
+ (uno_ReleaseFunc) cpp_release );
+}
+#if ! defined(__SUNPRO_CC)
+// not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
+template <>
+bool Any::has<sal_uInt16>() const;
+#endif // ! defined(__SUNPRO_CC)
+
+//__________________________________________________________________________________________________
+inline sal_Bool Any::operator == ( const Any & rAny ) const SAL_THROW( () )
+{
+ return ::uno_type_equalData(
+ pData, pType, rAny.pData, rAny.pType,
+ (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
+}
+//__________________________________________________________________________________________________
+inline sal_Bool Any::operator != ( const Any & rAny ) const SAL_THROW( () )
+{
+ return (! ::uno_type_equalData(
+ pData, pType, rAny.pData, rAny.pType,
+ (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release ));
+}
+
+//__________________________________________________________________________________________________
+template< class C >
+inline Any SAL_CALL makeAny( const C & value ) SAL_THROW( () )
+{
+ return Any( &value, ::cppu::getTypeFavourUnsigned(&value) );
+}
+
+// additionally specialized for C++ bool
+//______________________________________________________________________________
+template<>
+inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW( () )
+{
+ const sal_Bool b = value;
+ return Any( &b, ::getCppuBooleanType() );
+}
+
+//__________________________________________________________________________________________________
+template< class C >
+inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW( () )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
+ ::uno_type_any_assign(
+ &rAny, const_cast< C * >( &value ), rType.getTypeLibType(),
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+
+// additionally for C++ bool:
+//______________________________________________________________________________
+inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
+ SAL_THROW( () )
+{
+ sal_Bool b = value;
+ ::uno_type_any_assign(
+ &rAny, &b, ::getCppuBooleanType().getTypeLibType(),
+ (uno_AcquireFunc) cpp_acquire, (uno_ReleaseFunc) cpp_release );
+}
+
+//__________________________________________________________________________________________________
+template< class C >
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW( () )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
+ return ::uno_type_assignData(
+ &value, rType.getTypeLibType(),
+ rAny.pData, rAny.pType,
+ (uno_QueryInterfaceFunc)cpp_queryInterface,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+}
+
+// bool
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value ) SAL_THROW( () )
+{
+ if (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass)
+ {
+ value = (* reinterpret_cast< const sal_Bool * >( &rAny.pReserved ) != sal_False);
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW( () )
+{
+ return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass &&
+ (value != sal_False) == (* reinterpret_cast< const sal_Bool * >( &rAny.pReserved ) != sal_False));
+}
+
+//______________________________________________________________________________
+template<>
+inline sal_Bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
+ SAL_THROW( () )
+{
+ if (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN)
+ {
+ value = *reinterpret_cast< sal_Bool const * >(
+ &rAny.pReserved ) != sal_False;
+ return true;
+ }
+ return false;
+}
+
+//______________________________________________________________________________
+template<>
+inline sal_Bool SAL_CALL operator == ( Any const & rAny, bool const & value )
+ SAL_THROW( () )
+{
+ return (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN &&
+ (value ==
+ (*reinterpret_cast< sal_Bool const * >( &rAny.pReserved )
+ != sal_False)));
+}
+
+// byte
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value ) SAL_THROW( () )
+{
+ if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass)
+ {
+ value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
+ return sal_True;
+ }
+ return sal_False;
+}
+// short
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW( () )
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW( () )
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+// long
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW( () )
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW( () )
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved );
+ return sal_True;
+ default:
+ return sal_False;
+ }
+}
+// hyper
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW( () )
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ value = * reinterpret_cast< const sal_Int64 * >(
+ (sizeof(void *) >= sizeof(sal_Int64)) ? (void *)&rAny.pReserved : rAny.pData );
+ return sal_True;
+
+ default:
+ return sal_False;
+ }
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW( () )
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ value = * reinterpret_cast< const sal_uInt64 * >(
+ (sizeof(void *) >= sizeof(sal_uInt64)) ? (void *)&rAny.pReserved : rAny.pData );
+ return sal_True;
+
+ default:
+ return sal_False;
+ }
+}
+// float
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW( () )
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_FLOAT:
+ value = * reinterpret_cast< const float * >(
+ (sizeof(void *) >= sizeof(float)) ? (void *)&rAny.pReserved : rAny.pData );
+ return sal_True;
+
+ default:
+ return sal_False;
+ }
+}
+// double
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW( () )
+{
+ switch (rAny.pType->eTypeClass)
+ {
+ case typelib_TypeClass_BYTE:
+ value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_SHORT:
+ value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_LONG:
+ value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_UNSIGNED_LONG:
+ value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved );
+ return sal_True;
+ case typelib_TypeClass_FLOAT:
+ value = * reinterpret_cast< const float * >(
+ (sizeof(void *) >= sizeof(float)) ? (void *)&rAny.pReserved : rAny.pData );
+ return sal_True;
+ case typelib_TypeClass_DOUBLE:
+ value = * reinterpret_cast< const double * >(
+ (sizeof(void *) >= sizeof(double)) ? (void *)&rAny.pReserved : rAny.pData );
+ return sal_True;
+
+ default:
+ return sal_False;
+ }
+}
+// string
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW( () )
+{
+ if (typelib_TypeClass_STRING == rAny.pType->eTypeClass)
+ {
+ value = * reinterpret_cast< const ::rtl::OUString * >( &rAny.pReserved );
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW( () )
+{
+ return (typelib_TypeClass_STRING == rAny.pType->eTypeClass &&
+ value.equals( * reinterpret_cast< const ::rtl::OUString * >( &rAny.pReserved ) ));
+}
+// type
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW( () )
+{
+ if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass)
+ {
+ value = * reinterpret_cast< const Type * >( &rAny.pReserved );
+ return sal_True;
+ }
+ return sal_False;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW( () )
+{
+ return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass &&
+ value.equals( * reinterpret_cast< const Type * >( &rAny.pReserved ) ));
+}
+// any
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW( () )
+{
+ if (&rAny != &value)
+ {
+ ::uno_type_any_assign(
+ &value, rAny.pData, rAny.pType,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+ }
+ return sal_True;
+}
+// interface
+//__________________________________________________________________________________________________
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW( () )
+{
+ if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass)
+ {
+ return reinterpret_cast< const BaseReference * >( &rAny.pReserved )->operator == ( value );
+ }
+ return sal_False;
+}
+
+// operator to compare to an any.
+//__________________________________________________________________________________________________
+template< class C >
+inline sal_Bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW( () )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
+ return ::uno_type_equalData(
+ rAny.pData, rAny.pType,
+ const_cast< C * >( &value ), rType.getTypeLibType(),
+ (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
+}
+// operator to compare to an any. may use specialized operators ==.
+//__________________________________________________________________________________________________
+template< class C >
+inline sal_Bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW( () )
+{
+ return (! operator == ( rAny, value ));
+}
+
+#if ! defined(EXCEPTIONS_OFF)
+extern "C" rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg(
+ uno_Any const * pAny, typelib_TypeDescriptionReference * pType )
+ SAL_THROW_EXTERN_C();
+
+//______________________________________________________________________________
+template <typename T>
+T Any::get() const
+{
+ T value = T();
+ if (! (*this >>= value)) {
+ throw RuntimeException(
+ ::rtl::OUString(
+ cppu_Any_extraction_failure_msg(
+ this,
+ ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ),
+ SAL_NO_ACQUIRE ),
+ Reference<XInterface>() );
+ }
+ return value;
+}
+// not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
+template <>
+sal_uInt16 Any::get<sal_uInt16>() const;
+#endif // ! defined(EXCEPTIONS_OFF)
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Reference.h b/cppu/inc/com/sun/star/uno/Reference.h
new file mode 100644
index 000000000000..f792556dcb57
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Reference.h
@@ -0,0 +1,533 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#define _COM_SUN_STAR_UNO_REFERENCE_H_
+
+#include <rtl/alloc.h>
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+class RuntimeException;
+class XInterface;
+class Type;
+class Any;
+
+/** Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
+ Deprecated, please use SAL_NO_ACQUIRE.
+ @deprecated
+*/
+enum UnoReference_NoAcquire
+{
+ /** This enum value can be used for creating a reference granting a given interface,
+ i.e. transferring ownership to it.
+ */
+ UNO_REF_NO_ACQUIRE
+};
+
+/** This base class serves as a base class for all template reference classes and
+ has been introduced due to compiler problems with templated operators ==, =!.
+*/
+class BaseReference
+{
+protected:
+ /** the interface pointer
+ */
+ XInterface * _pInterface;
+
+ /** Queries given interface for type rType.
+
+ @param pInterface interface pointer
+ @param rType interface type
+ @return interface of demanded type (may be null)
+ */
+ inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) );
+#ifndef EXCEPTIONS_OFF
+ /** Queries given interface for type rType.
+ Throws a RuntimeException if the demanded interface cannot be queried.
+
+ @param pInterface interface pointer
+ @param rType interface type
+ @return interface of demanded type
+ */
+ inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) );
+#endif
+
+public:
+ /** Gets interface pointer. This call does not acquire the interface.
+
+ @return UNacquired interface pointer
+ */
+ inline XInterface * SAL_CALL get() const SAL_THROW( () )
+ { return _pInterface; }
+
+ /** Checks if reference is null.
+
+ @return true if reference acquires an interface, i.e. true if it is not null
+ */
+ inline sal_Bool SAL_CALL is() const SAL_THROW( () )
+ { return (0 != _pInterface); }
+
+ /** Equality operator: compares two interfaces
+ Checks if both references are null or refer to the same object.
+
+ @param rRef another interface
+ @return true if both references are null or refer to the same object, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( XInterface * pInterface ) const SAL_THROW( () );
+ /** Unequality operator: compares two interfaces
+ Checks if both references are null or refer to the same object.
+
+ @param rRef another interface
+ @return false if both references are null or refer to the same object, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( XInterface * pInterface ) const SAL_THROW( () );
+
+ /** Equality operator: compares two interfaces
+ Checks if both references are null or refer to the same object.
+
+ @param rRef another reference
+ @return true if both references are null or refer to the same object, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const BaseReference & rRef ) const SAL_THROW( () );
+ /** Unequality operator: compares two interfaces
+ Checks if both references are null or refer to the same object.
+
+ @param rRef another reference
+ @return false if both references are null or refer to the same object, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const BaseReference & rRef ) const SAL_THROW( () );
+
+ /** Needed by some STL containers.
+
+ @param rRef another reference
+ @return true, if this reference is less than rRef
+ */
+ inline sal_Bool SAL_CALL operator < ( const BaseReference & rRef ) const SAL_THROW( () );
+};
+
+/** Enum defining UNO_QUERY and UNO_REF_QUERY for implicit interface query.
+*/
+enum UnoReference_Query
+{
+ /** This enum value can be used for implicit interface query.
+ */
+ UNO_QUERY,
+ /** This enum value can be used for implicit interface query.
+ */
+ UNO_REF_QUERY
+};
+#ifndef EXCEPTIONS_OFF
+/** Enum defining UNO_QUERY_THROW and UNO_REF_QUERY_THROW for implicit interface query.
+ If the demanded interface is unavailable, then a RuntimeException is thrown.
+*/
+enum UnoReference_QueryThrow
+{
+ /** This enum value can be used for implicit interface query.
+ */
+ UNO_QUERY_THROW,
+ /** This enum value can be used for implicit interface query.
+ */
+ UNO_REF_QUERY_THROW
+};
+/** Enum defining UNO_SET_THROW for throwing if attempts are made to assign a <NULL/>
+ interface
+
+ @since UDK 3.2.8
+*/
+enum UnoReference_SetThrow
+{
+ UNO_SET_THROW
+};
+#endif
+
+/** Template reference class for interface type derived from BaseReference.
+ A special constructor given the UNO_QUERY or UNO_REF_QUERY identifier queries interfaces
+ for reference type.
+*/
+template< class interface_type >
+class Reference : public BaseReference
+{
+ /** Queries given interface for type interface_type.
+
+ @param pInterface interface pointer
+ @return interface of demanded type (may be null)
+ */
+ inline static XInterface * SAL_CALL iquery( XInterface * pInterface )
+ SAL_THROW( (RuntimeException) );
+#ifndef EXCEPTIONS_OFF
+ /** Queries given interface for type interface_type.
+ Throws a RuntimeException if the demanded interface cannot be queried.
+
+ @param pInterface interface pointer
+ @return interface of demanded type
+ */
+ inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface )
+ SAL_THROW( (RuntimeException) );
+ /** Returns the given interface if it is not <NULL/>, throws a RuntimeException otherwise.
+
+ @param pInterface interface pointer
+ @return pInterface
+ */
+ inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface )
+ SAL_THROW( (RuntimeException) );
+#endif
+
+ /** Cast from an "interface pointer" (e.g., BaseReference::_pInterface) to a
+ pointer to this interface_type.
+
+ To work around ambiguities in the case of multiple-inheritance interface
+ types (which inherit XInterface more than once), use reinterpret_cast
+ (resp. a sequence of two static_casts, to avoid warnings about
+ reinterpret_cast used between related classes) to switch from a pointer
+ to XInterface to a pointer to this derived interface_type. In
+ principle, this is not guaranteed to work. In practice, it seems to
+ work on all supported platforms.
+ */
+ static inline interface_type * castFromXInterface(XInterface * p) {
+ return static_cast< interface_type * >(static_cast< void * >(p));
+ }
+
+ /** Cast from a pointer to this interface_type to an "interface pointer"
+ (e.g., BaseReference::_pInterface).
+
+ To work around ambiguities in the case of multiple-inheritance interface
+ types (which inherit XInterface more than once), use reinterpret_cast
+ (resp. a sequence of two static_casts, to avoid warnings about
+ reinterpret_cast used between related classes) to switch from a pointer
+ to this derived interface_type to a pointer to XInterface. In
+ principle, this is not guaranteed to work. In practice, it seems to
+ work on all supported platforms.
+ */
+ static inline XInterface * castToXInterface(interface_type * p) {
+ return static_cast< XInterface * >(static_cast< void * >(p));
+ }
+
+public:
+ // these are here to force memory de/allocation to sal lib.
+ /** @internal */
+ inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ /** @internal */
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ /** @internal */
+ inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW( () )
+ { return pMem; }
+ /** @internal */
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW( () )
+ {}
+
+ /** Destructor: Releases interface if set.
+ */
+ inline ~Reference() SAL_THROW( () );
+
+ /** Default Constructor: Sets null reference.
+ */
+ inline Reference() SAL_THROW( () );
+
+ /** Copy constructor: Copies interface reference.
+
+ @param rRef another reference
+ */
+ inline Reference( const Reference< interface_type > & rRef ) SAL_THROW( () );
+ /** Constructor: Sets given interface pointer.
+
+ @param pInterface an interface pointer
+ */
+ inline Reference( interface_type * pInterface ) SAL_THROW( () );
+
+ /** Constructor: Sets given interface pointer without acquiring it.
+
+ @param pInterface another reference
+ @param dummy SAL_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline Reference( interface_type * pInterface, __sal_NoAcquire ) SAL_THROW( () );
+ /** Constructor: Sets given interface pointer without acquiring it.
+ Deprecated, please use SAL_NO_ACQUIRE version.
+
+ @deprecated
+ @param pInterface another reference
+ @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline Reference( interface_type * pInterface, UnoReference_NoAcquire ) SAL_THROW( () );
+
+ /** Constructor: Queries given interface for reference interface type (interface_type).
+
+ @param rRef another reference
+ @param dummy UNO_QUERY or UNO_REF_QUERY to force obvious distinction to other constructors
+ */
+ inline Reference( const BaseReference & rRef, UnoReference_Query ) SAL_THROW( (RuntimeException) );
+ /** Constructor: Queries given interface for reference interface type (interface_type).
+
+ @param pInterface an interface pointer
+ @param dummy UNO_QUERY to force obvious distinction to other constructors
+ */
+ inline Reference( XInterface * pInterface, UnoReference_Query ) SAL_THROW( (RuntimeException) );
+ /** Constructor: Queries given any for reference interface type (interface_type).
+
+ @param rAny an any
+ @param dummy UNO_QUERY to force obvious distinction to other constructors
+ */
+ inline Reference( const Any & rAny, UnoReference_Query ) SAL_THROW( (RuntimeException) );
+#ifndef EXCEPTIONS_OFF
+ /** Constructor: Queries given interface for reference interface type (interface_type).
+ Throws a RuntimeException if the demanded interface cannot be queried.
+
+ @param rRef another reference
+ @param dummy UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious distinction
+ to other constructors
+ */
+ inline Reference( const BaseReference & rRef, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) );
+ /** Constructor: Queries given interface for reference interface type (interface_type).
+ Throws a RuntimeException if the demanded interface cannot be queried.
+
+ @param pInterface an interface pointer
+ @param dummy UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious distinction
+ to other constructors
+ */
+ inline Reference( XInterface * pInterface, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) );
+ /** Constructor: Queries given any for reference interface type (interface_type).
+ Throws a RuntimeException if the demanded interface cannot be queried.
+
+ @param rAny an any
+ @param dummy UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious distinction
+ to other constructors
+ */
+ inline Reference( const Any & rAny, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) );
+ /** Constructor: assigns from the given interface of the same type. Throws a RuntimeException
+ if the source interface is <NULL/>.
+
+ @param rRef another interface reference of the same type
+ @param dummy UNO_SET_THROW to distinguish from default copy constructor
+
+ @since UDK 3.2.8
+ */
+ inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) );
+ /** Constructor: assigns from the given interface of the same type. Throws a RuntimeException
+ if the source interface is <NULL/>.
+
+ @param pInterface an interface pointer
+ @param dummy UNO_SET_THROW to distinguish from default assignment constructor
+
+ @since UDK 3.2.8
+ */
+ inline Reference( interface_type * pInterface, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) );
+#endif
+
+ /** Cast operator to Reference< XInterface >: Reference objects are binary compatible and
+ any interface must be derived from com.sun.star.uno.XInterface.
+ This a useful direct cast possibility.
+ */
+ inline SAL_CALL operator const Reference< XInterface > & () const SAL_THROW( () )
+ { return * reinterpret_cast< const Reference< XInterface > * >( this ); }
+
+ /** Dereference operator: Used to call interface methods.
+
+ @return UNacquired interface pointer
+ */
+ inline interface_type * SAL_CALL operator -> () const SAL_THROW( () )
+ { return castFromXInterface(_pInterface); }
+
+ /** Gets interface pointer. This call does not acquire the interface.
+
+ @return UNacquired interface pointer
+ */
+ inline interface_type * SAL_CALL get() const SAL_THROW( () )
+ { return castFromXInterface(_pInterface); }
+
+ /** Clears reference, i.e. releases interface. Reference is null after clear() call.
+ */
+ inline void SAL_CALL clear() SAL_THROW( () );
+
+ /** Sets the given interface. An interface already set will be released.
+
+ @param rRef another reference
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( const Reference< interface_type > & rRef ) SAL_THROW( () );
+ /** Sets the given interface. An interface already set will be released.
+
+ @param pInterface another interface
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( interface_type * pInterface ) SAL_THROW( () );
+
+ /** Sets interface pointer without acquiring it. An interface already set will be released.
+
+ @param pInterface an interface pointer
+ @param dummy SAL_NO_ACQUIRE to force obvious distinction to set methods
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire ) SAL_THROW( () );
+ /** Sets interface pointer without acquiring it. An interface already set will be released.
+ Deprecated, please use SAL_NO_ACQUIRE version.
+
+ @deprecated
+ @param pInterface an interface pointer
+ @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to set methods
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire ) SAL_THROW( () );
+
+ /** Queries given interface for reference interface type (interface_type) and sets it.
+ An interface already set will be released.
+
+ @param pInterface an interface pointer
+ @param dummy UNO_QUERY or UNO_REF_QUERY to force obvious distinction to set methods
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( XInterface * pInterface, UnoReference_Query ) SAL_THROW( (RuntimeException) );
+ /** Queries given interface for reference interface type (interface_type) and sets it.
+ An interface already set will be released.
+
+ @param rRef another reference
+ @param dummy UNO_QUERY or UNO_REF_QUERY to force obvious distinction to set methods
+ @return true, if non-null interface was set
+ */
+ inline sal_Bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query ) SAL_THROW( (RuntimeException) );
+
+ /** Queries given any for reference interface type (interface_type)
+ and sets it. An interface already set will be released.
+
+ @param rAny
+ an Any containing an interface
+ @param dummy
+ UNO_QUERY or UNO_REF_QUERY to force obvious distinction
+ to set methods
+ @return
+ true, if non-null interface was set
+ */
+ inline bool set( Any const & rAny, UnoReference_Query );
+
+#ifndef EXCEPTIONS_OFF
+ /** Queries given interface for reference interface type (interface_type) and sets it.
+ An interface already set will be released.
+ Throws a RuntimeException if the demanded interface cannot be set.
+
+ @param pInterface an interface pointer
+ @param dummy UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious distinction
+ to set methods
+ */
+ inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) );
+ /** Queries given interface for reference interface type (interface_type) and sets it.
+ An interface already set will be released.
+ Throws a RuntimeException if the demanded interface cannot be set.
+
+ @param rRef another reference
+ @param dummy UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious distinction
+ to set methods
+ */
+ inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) );
+
+ /** Queries given any for reference interface type (interface_type) and
+ sets it. An interface already set will be released.
+ Throws a RuntimeException if the demanded interface cannot be set.
+
+ @param rAny
+ an Any containing an interface
+ @param dummy
+ UNO_QUERY_THROW or UNO_REF_QUERY_THROW to force obvious
+ distinction to set methods
+ */
+ inline void set( Any const & rAny, UnoReference_QueryThrow );
+ /** sets the given interface
+ An interface already set will be released.
+ Throws a RuntimeException if the source interface is <NULL/>.
+
+ @param pInterface an interface pointer
+ @param dummy UNO_SET_THROW to force obvious distinction to other set methods
+
+ @since UDK 3.2.8
+ */
+ inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) );
+ /** sets the given interface
+ An interface already set will be released.
+ Throws a RuntimeException if the source interface is <NULL/>.
+
+ @param rRef an interface reference
+ @param dummy UNO_SET_THROW to force obvious distinction to other set methods
+
+ @since UDK 3.2.8
+ */
+ inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) );
+
+#endif
+
+ /** Assignment operator: Acquires given interface pointer and sets reference.
+ An interface already set will be released.
+
+ @param pInterface an interface pointer
+ @return this reference
+ */
+ inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ) SAL_THROW( () );
+ /** Assignment operator: Acquires given interface reference and sets reference.
+ An interface already set will be released.
+
+ @param rRef an interface reference
+ @return this reference
+ */
+ inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef ) SAL_THROW( () );
+
+ /** Queries given interface reference for type interface_type.
+
+ @param rRef interface reference
+ @return interface reference of demanded type (may be null)
+ */
+ inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ) SAL_THROW( (RuntimeException) );
+ /** Queries given interface for type interface_type.
+
+ @param pInterface interface pointer
+ @return interface reference of demanded type (may be null)
+ */
+ inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ) SAL_THROW( (RuntimeException) );
+};
+
+/** @internal
+ Enables boost::mem_fn and boost::bind to recognize Reference.
+*/
+template <typename T>
+inline T * get_pointer( Reference<T> const& r )
+{
+ return r.get();
+}
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Reference.hxx b/cppu/inc/com/sun/star/uno/Reference.hxx
new file mode 100644
index 000000000000..4223cc277c37
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Reference.hxx
@@ -0,0 +1,431 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
+#define _COM_SUN_STAR_UNO_REFERENCE_HXX_
+
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HDL_
+#include <com/sun/star/uno/XInterface.hdl>
+#endif
+#include <com/sun/star/uno/genfunc.hxx>
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+//__________________________________________________________________________________________________
+inline XInterface * BaseReference::iquery(
+ XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) )
+{
+ if (pInterface)
+ {
+ Any aRet( pInterface->queryInterface( rType ) );
+ if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass)
+ {
+ XInterface * pRet = static_cast< XInterface * >( aRet.pReserved );
+ aRet.pReserved = 0;
+ return pRet;
+ }
+ }
+ return 0;
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline XInterface * Reference< interface_type >::iquery(
+ XInterface * pInterface ) SAL_THROW( (RuntimeException) )
+{
+ return BaseReference::iquery(pInterface, interface_type::static_type());
+}
+#ifndef EXCEPTIONS_OFF
+extern "C" rtl_uString * SAL_CALL cppu_unsatisfied_iquery_msg(
+ typelib_TypeDescriptionReference * pType )
+ SAL_THROW_EXTERN_C();
+extern "C" rtl_uString * SAL_CALL cppu_unsatisfied_iset_msg(
+ typelib_TypeDescriptionReference * pType )
+ SAL_THROW_EXTERN_C();
+//__________________________________________________________________________________________________
+inline XInterface * BaseReference::iquery_throw(
+ XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) )
+{
+ XInterface * pQueried = iquery( pInterface, rType );
+ if (pQueried)
+ return pQueried;
+ throw RuntimeException(
+ ::rtl::OUString( cppu_unsatisfied_iquery_msg( rType.getTypeLibType() ), SAL_NO_ACQUIRE ),
+ Reference< XInterface >( pInterface ) );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline XInterface * Reference< interface_type >::iquery_throw(
+ XInterface * pInterface ) SAL_THROW( (RuntimeException) )
+{
+ return BaseReference::iquery_throw(
+ pInterface, interface_type::static_type());
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline interface_type * Reference< interface_type >::iset_throw(
+ interface_type * pInterface ) SAL_THROW( (RuntimeException) )
+{
+ if (pInterface)
+ {
+ pInterface->acquire();
+ return pInterface;
+ }
+ throw RuntimeException(
+ ::rtl::OUString( cppu_unsatisfied_iset_msg( interface_type::static_type().getTypeLibType() ), SAL_NO_ACQUIRE ),
+ NULL );
+}
+#endif
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::~Reference() SAL_THROW( () )
+{
+ if (_pInterface)
+ _pInterface->release();
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference() SAL_THROW( () )
+{
+ _pInterface = 0;
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const Reference< interface_type > & rRef ) SAL_THROW( () )
+{
+ _pInterface = rRef._pInterface;
+ if (_pInterface)
+ _pInterface->acquire();
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( interface_type * pInterface ) SAL_THROW( () )
+{
+ _pInterface = castToXInterface(pInterface);
+ if (_pInterface)
+ _pInterface->acquire();
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( interface_type * pInterface, __sal_NoAcquire ) SAL_THROW( () )
+{
+ _pInterface = castToXInterface(pInterface);
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( interface_type * pInterface, UnoReference_NoAcquire ) SAL_THROW( () )
+{
+ _pInterface = castToXInterface(pInterface);
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const BaseReference & rRef, UnoReference_Query ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iquery( rRef.get() );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( XInterface * pInterface, UnoReference_Query ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iquery( pInterface );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const Any & rAny, UnoReference_Query ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass
+ ? iquery( static_cast< XInterface * >( rAny.pReserved ) ) : 0);
+}
+#ifndef EXCEPTIONS_OFF
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const BaseReference & rRef, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iquery_throw( rRef.get() );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( XInterface * pInterface, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iquery_throw( pInterface );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const Any & rAny, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iquery_throw( typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass
+ ? static_cast< XInterface * >( rAny.pReserved ) : 0 );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iset_throw( rRef.get() );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( interface_type * pInterface, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = iset_throw( pInterface );
+}
+#endif
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::clear() SAL_THROW( () )
+{
+ if (_pInterface)
+ {
+ XInterface * const pOld = _pInterface;
+ _pInterface = 0;
+ pOld->release();
+ }
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ interface_type * pInterface ) SAL_THROW( () )
+{
+ if (pInterface)
+ castToXInterface(pInterface)->acquire();
+ XInterface * const pOld = _pInterface;
+ _pInterface = castToXInterface(pInterface);
+ if (pOld)
+ pOld->release();
+ return (0 != pInterface);
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ interface_type * pInterface, __sal_NoAcquire ) SAL_THROW( () )
+{
+ XInterface * const pOld = _pInterface;
+ _pInterface = castToXInterface(pInterface);
+ if (pOld)
+ pOld->release();
+ return (0 != pInterface);
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ interface_type * pInterface, UnoReference_NoAcquire ) SAL_THROW( () )
+{
+ return set( pInterface, SAL_NO_ACQUIRE );
+}
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ const Reference< interface_type > & rRef ) SAL_THROW( () )
+{
+ return set( castFromXInterface( rRef._pInterface ) );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ XInterface * pInterface, UnoReference_Query ) SAL_THROW( (RuntimeException) )
+{
+ return set( castFromXInterface(iquery( pInterface )), SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline sal_Bool Reference< interface_type >::set(
+ const BaseReference & rRef, UnoReference_Query ) SAL_THROW( (RuntimeException) )
+{
+ return set( castFromXInterface(iquery( rRef.get() )), SAL_NO_ACQUIRE );
+}
+
+//______________________________________________________________________________
+template< class interface_type >
+inline bool Reference< interface_type >::set(
+ Any const & rAny, UnoReference_Query )
+{
+ return set(
+ castFromXInterface(
+ iquery(
+ rAny.pType->eTypeClass == typelib_TypeClass_INTERFACE
+ ? static_cast< XInterface * >( rAny.pReserved ) : 0 )),
+ SAL_NO_ACQUIRE );
+}
+
+#ifndef EXCEPTIONS_OFF
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ XInterface * pInterface, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ set( castFromXInterface(iquery_throw( pInterface )), SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ const BaseReference & rRef, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ set( castFromXInterface(iquery_throw( rRef.get() )), SAL_NO_ACQUIRE );
+}
+
+//______________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ Any const & rAny, UnoReference_QueryThrow )
+{
+ set( castFromXInterface(
+ iquery_throw(
+ rAny.pType->eTypeClass == typelib_TypeClass_INTERFACE
+ ? static_cast< XInterface * >( rAny.pReserved ) : 0 )),
+ SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ interface_type * pInterface, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
+{
+ set( iset_throw( pInterface ), SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ const Reference< interface_type > & rRef, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
+{
+ set( rRef.get(), UNO_SET_THROW );
+}
+
+#endif
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type > & Reference< interface_type >::operator = (
+ interface_type * pInterface ) SAL_THROW( () )
+{
+ set( pInterface );
+ return *this;
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type > & Reference< interface_type >::operator = (
+ const Reference< interface_type > & rRef ) SAL_THROW( () )
+{
+ set( castFromXInterface( rRef._pInterface ) );
+ return *this;
+}
+
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type > Reference< interface_type >::query(
+ const BaseReference & rRef ) SAL_THROW( (RuntimeException) )
+{
+ return Reference< interface_type >(
+ castFromXInterface(iquery( rRef.get() )), SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type > Reference< interface_type >::query(
+ XInterface * pInterface ) SAL_THROW( (RuntimeException) )
+{
+ return Reference< interface_type >(
+ castFromXInterface(iquery( pInterface )), SAL_NO_ACQUIRE );
+}
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+inline sal_Bool BaseReference::operator == ( XInterface * pInterface ) const SAL_THROW( () )
+{
+ if (_pInterface == pInterface)
+ return sal_True;
+#ifndef EXCEPTIONS_OFF
+ try
+ {
+#endif
+ // only the query to XInterface must return the same pointer if they belong to same objects
+ Reference< XInterface > x1( _pInterface, UNO_QUERY );
+ Reference< XInterface > x2( pInterface, UNO_QUERY );
+ return (x1._pInterface == x2._pInterface);
+#ifndef EXCEPTIONS_OFF
+ }
+ catch (RuntimeException &)
+ {
+ return sal_False;
+ }
+#endif
+}
+
+//______________________________________________________________________________
+inline sal_Bool BaseReference::operator < (
+ const BaseReference & rRef ) const SAL_THROW( () )
+{
+ if (_pInterface == rRef._pInterface)
+ return sal_False;
+#if ! defined EXCEPTIONS_OFF
+ try
+ {
+#endif
+ // only the query to XInterface must return the same pointer:
+ Reference< XInterface > x1( _pInterface, UNO_QUERY );
+ Reference< XInterface > x2( rRef, UNO_QUERY );
+ return (x1._pInterface < x2._pInterface);
+#if ! defined EXCEPTIONS_OFF
+ }
+ catch (RuntimeException &)
+ {
+ return sal_False;
+ }
+#endif
+}
+
+//__________________________________________________________________________________________________
+inline sal_Bool BaseReference::operator != ( XInterface * pInterface ) const SAL_THROW( () )
+{
+ return (! operator == ( pInterface ));
+}
+//__________________________________________________________________________________________________
+inline sal_Bool BaseReference::operator == ( const BaseReference & rRef ) const SAL_THROW( () )
+{
+ return operator == ( rRef._pInterface );
+}
+//__________________________________________________________________________________________________
+inline sal_Bool BaseReference::operator != ( const BaseReference & rRef ) const SAL_THROW( () )
+{
+ return (! operator == ( rRef._pInterface ));
+}
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Sequence.h b/cppu/inc/com/sun/star/uno/Sequence.h
new file mode 100644
index 000000000000..71bb42c7413b
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Sequence.h
@@ -0,0 +1,288 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
+#define _COM_SUN_STAR_UNO_SEQUENCE_H_
+
+#include "typelib/typedescription.h"
+#include "uno/sequence2.h"
+#include "com/sun/star/uno/Type.h"
+#include "rtl/alloc.h"
+
+#if ! defined EXCEPTIONS_OFF
+#include <new>
+#endif
+
+
+namespace rtl
+{
+class ByteSequence;
+}
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** Template C++ class representing an IDL sequence. Template argument is the
+ sequence element type. C++ Sequences are reference counted and shared,
+ so the sequence keeps a handle to its data. To keep value semantics,
+ copies are only generated if the sequence is to be modified (new handle).
+
+ @tplparam E element type of sequence
+*/
+template< class E >
+class Sequence
+{
+ /** sequence handle
+ @internal
+ */
+ uno_Sequence * _pSequence;
+
+public:
+ // these are here to force memory de/allocation to sal lib.
+ /** @internal */
+ inline static void * SAL_CALL operator new ( size_t nSize )
+ SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ /** @internal */
+ inline static void SAL_CALL operator delete ( void * pMem )
+ SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ /** @internal */
+ inline static void * SAL_CALL operator new ( size_t, void * pMem )
+ SAL_THROW( () )
+ { return pMem; }
+ /** @internal */
+ inline static void SAL_CALL operator delete ( void *, void * )
+ SAL_THROW( () )
+ {}
+
+ /** Static pointer to typelib type of sequence.
+ Don't use directly, call getCppuType().
+ @internal
+ */
+ static typelib_TypeDescriptionReference * s_pType;
+
+ /** typedefs the element type of the sequence
+ */
+ typedef E ElementType;
+
+ /** Default constructor: Creates an empty sequence.
+ */
+ inline Sequence() SAL_THROW( () );
+
+ /** Copy constructor: Creates a copy of given sequence.
+
+ @param rSeq another sequence of same type
+ */
+ inline Sequence( const Sequence< E > & rSeq ) SAL_THROW( () );
+
+ /** Constructor: Takes over ownership of given sequence.
+
+ @param pSequence a sequence
+ @param dummy SAL_NO_ACQUIRE to force obvious distinction to other
+ constructors
+ */
+ inline Sequence( uno_Sequence * pSequence, __sal_NoAcquire )
+ SAL_THROW( () );
+
+ /** Constructor: Creates a copy of given elements.
+
+ @param pElement an array of elements
+ @param len length of array
+ */
+ inline Sequence( const E * pElements, sal_Int32 len );
+
+ /** Constructor: Creates a default constructed sequence of given length.
+
+ @param len initial sequence length
+ */
+ inline explicit Sequence( sal_Int32 len );
+
+ /** Destructor: Releases sequence handle. Last handle will destruct
+ elements and free memory.
+ */
+ inline ~Sequence() SAL_THROW( () );
+
+ /** Assignment operator: Acquires given sequence handle and releases
+ previously set handle.
+
+ @param rSeq another sequence of same type
+ @return this sequence
+ */
+ inline Sequence< E > & SAL_CALL operator = ( const Sequence< E > & rSeq )
+ SAL_THROW( () );
+
+ /** Gets length of the sequence.
+
+ @return length of sequence
+ */
+ inline sal_Int32 SAL_CALL getLength() const SAL_THROW( () )
+ { return _pSequence->nElements; }
+
+ /** Tests whether the sequence has elements, i.e. elements count is
+ greater than zero.
+
+ @return true, if elements count is greater than zero
+ */
+ inline sal_Bool SAL_CALL hasElements() const SAL_THROW( () )
+ { return (_pSequence->nElements > 0); }
+
+ /** Gets a pointer to elements array for reading.
+ If the sequence has a length of 0, then the returned pointer is
+ undefined.
+
+ @return pointer to elements array
+ */
+ inline const E * SAL_CALL getConstArray() const SAL_THROW( () )
+ { return reinterpret_cast< const E * >( _pSequence->elements ); }
+
+ /** Gets a pointer to elements array for reading and writing.
+ In general if the sequence has a handle acquired by other sequences
+ (reference count > 1), then a new sequence is created copy constructing
+ all elements to keep value semantics!
+ If the sequence has a length of 0, then the returned pointer is
+ undefined.
+
+ @return pointer to elements array
+ */
+ inline E * SAL_CALL getArray();
+
+ /** Non-const index operator: Obtains a reference to element indexed at
+ given position.
+ The implementation does not check for array bounds!
+ In general if the sequence has a handle acquired by other sequences
+ (reference count > 1), then a new sequence is created copy constructing
+ all elements to keep value semantics!
+
+ @param nIndex index
+ @return non-const C++ reference to element
+ */
+ inline E & SAL_CALL operator [] ( sal_Int32 nIndex );
+
+ /** Const index operator: Obtains a reference to element indexed at
+ given position. The implementation does not check for array bounds!
+
+ @param nIndex index
+ @return const C++ reference to element
+ */
+ inline const E & SAL_CALL operator [] ( sal_Int32 nIndex ) const
+ SAL_THROW( () );
+
+ /** Equality operator: Compares two sequences.
+
+ @param rSeq another sequence of same type (right side)
+ @return true if both sequences are equal, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const Sequence< E > & rSeq ) const
+ SAL_THROW( () );
+
+ /** Unequality operator: Compares two sequences.
+
+ @param rSeq another sequence of same type (right side)
+ @return false if both sequences are equal, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const Sequence< E > & rSeq ) const
+ SAL_THROW( () );
+
+ /** Reallocates sequence to new length.
+ If the new length is smaller than the former, then upper elements will
+ be destructed (and their memory freed). If the new length is greater
+ than the former, then upper (new) elements are default constructed.
+ If the sequence has a handle acquired by other sequences
+ (reference count > 1), then the remaining elements are copy constructed
+ to a new sequence handle to keep value semantics!
+
+ @param nSize new size of sequence
+ */
+ inline void SAL_CALL realloc( sal_Int32 nSize );
+
+ /** Provides UNacquired sequence handle.
+
+ @return UNacquired sequence handle
+ */
+ inline uno_Sequence * SAL_CALL get() const SAL_THROW( () )
+ { return _pSequence; }
+};
+
+/** Creates a UNO byte sequence from a SAL byte sequence.
+
+ @param rByteSequence a byte sequence
+ @return a UNO byte sequence
+*/
+inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
+ const ::rtl::ByteSequence & rByteSequence ) SAL_THROW( () );
+
+}
+}
+}
+}
+
+/** Gets the meta type of IDL sequence.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @tplparam E element type of sequence
+ @param dummy typed pointer for function signature
+ @return type of IDL sequence
+*/
+template< class E >
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< E > * )
+ SAL_THROW( () );
+
+/** Gets the meta type of IDL sequence.
+ This function has been introduced, because one cannot get the (templated)
+ cppu type out of C++ array types. Array types have special
+ getCppuArrayTypeN() functions.
+
+ @attention
+ the given element type must be the same as the template argument type!
+ @tplparam E element type of sequence
+ @param rElementType element type of sequence
+ @return type of IDL sequence
+*/
+template< class E >
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType )
+ SAL_THROW( () );
+
+/** Gets the meta type of IDL sequence< char >.
+ This function has been introduced due to ambiguities with unsigned short.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL sequence< char >
+*/
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCharSequenceCppuType() SAL_THROW( () );
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Sequence.hxx b/cppu/inc/com/sun/star/uno/Sequence.hxx
new file mode 100644
index 000000000000..bca6a1c44211
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Sequence.hxx
@@ -0,0 +1,307 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#define _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+
+#include "osl/diagnose.h"
+#include "osl/interlck.h"
+#include "com/sun/star/uno/Sequence.h"
+#include "typelib/typedescription.h"
+#include "uno/data.h"
+#include "com/sun/star/uno/genfunc.hxx"
+#include "cppu/unotype.hxx"
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+//______________________________________________________________________________
+template< class E >
+typelib_TypeDescriptionReference * Sequence< E >::s_pType = 0;
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence() SAL_THROW( () )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+ ::uno_type_sequence_construct(
+ &_pSequence, rType.getTypeLibType(),
+ 0, 0, (uno_AcquireFunc)cpp_acquire );
+ // no bad_alloc, because empty sequence is statically allocated in cppu
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence( const Sequence< E > & rSeq ) SAL_THROW( () )
+{
+ ::osl_incrementInterlockedCount( &rSeq._pSequence->nRefCount );
+ _pSequence = rSeq._pSequence;
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence(
+ uno_Sequence * pSequence, __sal_NoAcquire ) SAL_THROW( () )
+ : _pSequence( pSequence )
+{
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence( const E * pElements, sal_Int32 len )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+#if ! defined EXCEPTIONS_OFF
+ sal_Bool success =
+#endif
+ ::uno_type_sequence_construct(
+ &_pSequence, rType.getTypeLibType(),
+ const_cast< E * >( pElements ), len, (uno_AcquireFunc)cpp_acquire );
+#if ! defined EXCEPTIONS_OFF
+ if (! success)
+ throw ::std::bad_alloc();
+#endif
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::Sequence( sal_Int32 len )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+#if ! defined EXCEPTIONS_OFF
+ sal_Bool success =
+#endif
+ ::uno_type_sequence_construct(
+ &_pSequence, rType.getTypeLibType(),
+ 0, len, (uno_AcquireFunc)cpp_acquire );
+#if ! defined EXCEPTIONS_OFF
+ if (! success)
+ throw ::std::bad_alloc();
+#endif
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E >::~Sequence() SAL_THROW( () )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+ ::uno_type_destructData(
+ this, rType.getTypeLibType(), (uno_ReleaseFunc)cpp_release );
+}
+
+//______________________________________________________________________________
+template< class E >
+inline Sequence< E > & Sequence< E >::operator = ( const Sequence< E > & rSeq ) SAL_THROW( () )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+ ::uno_type_sequence_assign(
+ &_pSequence, rSeq._pSequence, rType.getTypeLibType(), (uno_ReleaseFunc)cpp_release );
+ return *this;
+}
+
+//______________________________________________________________________________
+template< class E >
+inline sal_Bool Sequence< E >::operator == ( const Sequence< E > & rSeq ) const
+ SAL_THROW( () )
+{
+ if (_pSequence == rSeq._pSequence)
+ return sal_True;
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+ return ::uno_type_equalData(
+ const_cast< Sequence< E > * >( this ), rType.getTypeLibType(),
+ const_cast< Sequence< E > * >( &rSeq ), rType.getTypeLibType(),
+ (uno_QueryInterfaceFunc)cpp_queryInterface,
+ (uno_ReleaseFunc)cpp_release );
+}
+
+//______________________________________________________________________________
+template< class E >
+inline sal_Bool Sequence< E >::operator != ( const Sequence< E > & rSeq ) const
+ SAL_THROW( () )
+{
+ return (! operator == ( rSeq ));
+}
+
+//______________________________________________________________________________
+template< class E >
+inline E * Sequence< E >::getArray()
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+#if ! defined EXCEPTIONS_OFF
+ sal_Bool success =
+#endif
+ ::uno_type_sequence_reference2One(
+ &_pSequence, rType.getTypeLibType(),
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+#if ! defined EXCEPTIONS_OFF
+ if (! success)
+ throw ::std::bad_alloc();
+#endif
+ return reinterpret_cast< E * >( _pSequence->elements );
+}
+
+//______________________________________________________________________________
+template< class E >
+inline E & Sequence< E >::operator [] ( sal_Int32 nIndex )
+{
+ OSL_ENSURE(
+ nIndex >= 0 && nIndex < getLength(),
+ "### illegal index of sequence!" );
+ return getArray()[ nIndex ];
+}
+
+//______________________________________________________________________________
+template< class E >
+inline const E & Sequence< E >::operator [] ( sal_Int32 nIndex ) const
+ SAL_THROW( () )
+{
+ OSL_ENSURE(
+ nIndex >= 0 && nIndex < getLength(),
+ "### illegal index of sequence!" );
+ return reinterpret_cast< const E * >( _pSequence->elements )[ nIndex ];
+}
+
+//______________________________________________________________________________
+template< class E >
+inline void Sequence< E >::realloc( sal_Int32 nSize )
+{
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+#if !defined EXCEPTIONS_OFF
+ sal_Bool success =
+#endif
+ ::uno_type_sequence_realloc(
+ &_pSequence, rType.getTypeLibType(), nSize,
+ (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
+#if !defined EXCEPTIONS_OFF
+ if (!success)
+ throw ::std::bad_alloc();
+#endif
+}
+
+//------------------------------------------------------------------------------
+inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
+ const ::rtl::ByteSequence & rByteSequence ) SAL_THROW( () )
+{
+ return ::com::sun::star::uno::Sequence< sal_Int8 >(
+ * reinterpret_cast< const ::com::sun::star::uno::Sequence< sal_Int8 > * >( &rByteSequence ) );
+}
+
+}
+}
+}
+}
+
+namespace cppu {
+
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourUnsigned(::com::sun::star::uno::Sequence< T > const *) {
+ if (::com::sun::star::uno::Sequence< T >::s_pType == 0) {
+ ::typelib_static_sequence_type_init(
+ &::com::sun::star::uno::Sequence< T >::s_pType,
+ (::cppu::getTypeFavourUnsigned(
+ static_cast<
+ typename ::com::sun::star::uno::Sequence< T >::ElementType * >(
+ 0)).
+ getTypeLibType()));
+ }
+ return detail::getTypeFromTypeDescriptionReference(
+ &::com::sun::star::uno::Sequence< T >::s_pType);
+}
+
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourChar(::com::sun::star::uno::Sequence< T > const *) {
+ //TODO On certain platforms with weak memory models, the following code can
+ // result in some threads observing that td points to garbage:
+ static typelib_TypeDescriptionReference * td = 0;
+ if (td == 0) {
+ ::typelib_static_sequence_type_init(
+ &td,
+ (::cppu::getTypeFavourChar(
+ static_cast<
+ typename ::com::sun::star::uno::Sequence< T >::ElementType * >(
+ 0)).
+ getTypeLibType()));
+ }
+ return detail::getTypeFromTypeDescriptionReference(&td);
+}
+
+}
+
+// generic sequence template
+template< class E >
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< E > * )
+ SAL_THROW( () )
+{
+ return ::cppu::getTypeFavourUnsigned(
+ static_cast< ::com::sun::star::uno::Sequence< E > * >(0));
+}
+
+// generic sequence template for given element type (e.g. C++ arrays)
+template< class E >
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType )
+ SAL_THROW( () )
+{
+ if (! ::com::sun::star::uno::Sequence< E >::s_pType)
+ {
+ ::typelib_static_sequence_type_init(
+ & ::com::sun::star::uno::Sequence< E >::s_pType,
+ rElementType.getTypeLibType() );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Sequence< E >::s_pType );
+}
+
+#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))
+static typelib_TypeDescriptionReference * s_pType_com_sun_star_uno_Sequence_Char = 0;
+#endif
+
+// char sequence
+inline const ::com::sun::star::uno::Type &
+SAL_CALL getCharSequenceCppuType() SAL_THROW( () )
+{
+#if !( defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500))
+ static typelib_TypeDescriptionReference * s_pType_com_sun_star_uno_Sequence_Char = 0;
+#endif
+ if (! s_pType_com_sun_star_uno_Sequence_Char)
+ {
+ const ::com::sun::star::uno::Type & rElementType = ::getCharCppuType();
+ ::typelib_static_sequence_type_init(
+ & s_pType_com_sun_star_uno_Sequence_Char,
+ rElementType.getTypeLibType() );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & s_pType_com_sun_star_uno_Sequence_Char );
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Type.h b/cppu/inc/com/sun/star/uno/Type.h
new file mode 100644
index 000000000000..61829c2c790d
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Type.h
@@ -0,0 +1,458 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_TYPE_H_
+#define _COM_SUN_STAR_UNO_TYPE_H_
+
+#include <typelib/typedescription.h>
+#ifndef _COM_SUN_STAR_UNO_TYPECLASS_HDL_
+#include <com/sun/star/uno/TypeClass.hdl>
+#endif
+#include <cppu/macros.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/alloc.h>
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
+*/
+enum UnoType_NoAcquire
+{
+ /** This enum value can be used for creating a Type object granting a given type description
+ reference, i.e. transferring ownership to it.
+ */
+ UNO_TYPE_NO_ACQUIRE
+};
+
+/** C++ class representing an IDL meta type. This class is used to represent a a type,
+ i.e. a type name and its type class.
+ Internally the type holds a C type description reference of the runtime.
+ You can obtain a full type description of a type by calling member function getDescription().
+
+ @see typelib_TypeDescriptionReference
+*/
+class Type
+{
+ /** the C typelib reference pointer
+ @internal
+ */
+ typelib_TypeDescriptionReference * _pType;
+
+public:
+ // these are here to force memory de/allocation to sal lib.
+ /** @internal */
+ inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ /** @internal */
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ /** @internal */
+ inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW( () )
+ { return pMem; }
+ /** @internal */
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW( () )
+ {}
+
+ /** Default Constructor: Type is set to void.
+ */
+ inline Type() SAL_THROW( () );
+
+ /** Constructor: Type is constructed by given name and type class.
+
+ @param eTypeClass type class of type
+ @param rTypeName name of type
+ */
+ inline Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName ) SAL_THROW( () );
+
+ /** Constructor: Type is constructed by given name and type class.
+
+ @param eTypeClass type class of type
+ @param pTypeName name of type
+ */
+ inline Type( TypeClass eTypeClass, const sal_Char * pTypeName ) SAL_THROW( () );
+
+ /** Constructor: Type is (copy) constructed by given C type description reference.
+
+ @param pType C type description reference
+ */
+ inline Type( typelib_TypeDescriptionReference * pType ) SAL_THROW( () );
+
+ /** Constructor: Type is (copy) constructed by given C type description reference
+ without acquiring it.
+
+ @param pType C type description reference
+ @param dummy UNO_TYPE_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline Type( typelib_TypeDescriptionReference * pType, UnoType_NoAcquire ) SAL_THROW( () );
+ /** Constructor: Type is (copy) constructed by given C type description reference
+ without acquiring it.
+
+ @param pType C type description reference
+ @param dummy SAL_NO_ACQUIRE to force obvious distinction to other constructors
+ */
+ inline Type( typelib_TypeDescriptionReference * pType, __sal_NoAcquire ) SAL_THROW( () );
+
+ /** Copy constructor: Type is copy constructed by given type.
+
+ @param rType another type
+ */
+ inline Type( const Type & rType ) SAL_THROW( () );
+
+ /** Destructor: Releases acquired C type description reference.
+ */
+ inline ~Type() SAL_THROW( () )
+ { ::typelib_typedescriptionreference_release( _pType ); }
+
+ /** Assignment operator: Acquires right side type and releases previously set type.
+
+ @param rType another type (right side)
+ @return this type
+ */
+ inline Type & SAL_CALL operator = ( const Type & rType ) SAL_THROW( () );
+
+ /** Gets the type class of set type.
+
+ @return type class of set type
+ */
+ inline TypeClass SAL_CALL getTypeClass() const SAL_THROW( () )
+ { return (TypeClass)_pType->eTypeClass; }
+
+ /** Gets the name of the set type.
+
+ @return name of the set type
+ */
+ inline ::rtl::OUString SAL_CALL getTypeName() const SAL_THROW( () );
+
+ /** Obtains a full type description of set type.
+
+ @param ppDescr [inout] type description
+ */
+ inline void SAL_CALL getDescription( typelib_TypeDescription ** ppDescr ) const SAL_THROW( () )
+ { ::typelib_typedescriptionreference_getDescription( ppDescr, _pType ); }
+
+ /** Gets the C typelib type description reference pointer. Does not acquire the reference!
+
+ @return UNacquired type description reference
+ */
+ inline typelib_TypeDescriptionReference * SAL_CALL getTypeLibType() const SAL_THROW( () )
+ { return _pType; }
+
+ /** Tests if values of this reflected type can be assigned by values of given type.
+ This includes widening conversion (e.g., long assignable from short), as long as there
+ is no data loss.
+
+ @param rType another type
+ @return true if values of this type can be assigned from values of given type,
+ false otherwise
+ */
+ inline sal_Bool SAL_CALL isAssignableFrom( const Type & rType ) const SAL_THROW( () )
+ { return ::typelib_typedescriptionreference_isAssignableFrom( _pType, rType._pType ); }
+
+ /** Compares two types.
+
+ @param rType another type
+ @return true if both types refer the same type, false otherwise
+ */
+ inline sal_Bool SAL_CALL equals( const Type & rType ) const SAL_THROW( () )
+ { return ::typelib_typedescriptionreference_equals( _pType, rType._pType ); }
+ /** Equality operator: Compares two types.
+
+ @param rType another type
+ @return true if both types refer the same type, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const Type & rType ) const SAL_THROW( () )
+ { return ::typelib_typedescriptionreference_equals( _pType, rType._pType ); }
+ /** Unequality operator: Compares two types.
+
+ @param rType another type
+ @return false if both types refer the same type, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const Type & rType ) const SAL_THROW( () )
+ { return (! ::typelib_typedescriptionreference_equals( _pType, rType._pType )); }
+};
+
+/** Helper class to specify a type pointer for idl arrays.
+*/
+template< class T >
+class Array
+{
+public:
+ static typelib_TypeDescriptionReference * s_pType;
+};
+
+}
+}
+}
+}
+
+/** Gets the meta type of IDL type "type".
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type "type"
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Type * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type void.
+ @return type of IDL type void
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType() SAL_THROW( () );
+/** Gets the meta type of IDL type void.
+
+ @return type of IDL type void
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType() SAL_THROW( () );
+
+/** Gets the meta type of IDL type boolean.
+
+ @return type of IDL type boolean
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType() SAL_THROW( () );
+/** Gets the meta type of IDL type boolean.
+
+ @return type of IDL type boolean
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType() SAL_THROW( () );
+/** Gets the meta type of IDL type boolean.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type boolean
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Bool * ) SAL_THROW( () );
+/** Gets the meta type of IDL type boolean.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type boolean
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
+ bool const * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type char.
+
+ @return type of IDL type char
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType() SAL_THROW( () );
+/** Gets the meta type of IDL type char.
+
+ @return type of IDL type char
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType() SAL_THROW( () );
+
+/** Gets the meta type of IDL type byte.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type byte
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int8 * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type string.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type string
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::rtl::OUString * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type short.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type short
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int16 * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type unsigned short.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type unsigned short
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt16 * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type long.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type long
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int32 * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type unsigned long.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type unsigned long
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt32 * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type hyper.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type hyper
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int64 * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type unsigned hyper.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type unsigned hyper
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt64 * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type float.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type float
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const float * ) SAL_THROW( () );
+
+/** Gets the meta type of IDL type double.
+
+ There are cases (involving templates) where uses of getCppuType are known to
+ not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
+
+ @param dummy typed pointer for function signature
+ @return type of IDL type double
+*/
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const double * ) SAL_THROW( () );
+
+/** Array template function to get meta type for one-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType1( T * pT ) SAL_THROW( () );
+/** Array template function to get meta type for two-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType2( T * pT ) SAL_THROW( () );
+/** Array template function to get meta type for three-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType3( T * pT ) SAL_THROW( () );
+/** Array template function to get meta type for four-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType4( T * pT ) SAL_THROW( () );
+/** Array template function to get meta type for five-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType5( T * pT ) SAL_THROW( () );
+/** Array template function to get meta type for six-dimensional arrays.
+
+ @param pT array pointer
+ @return type of array
+*/
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType6( T * pT ) SAL_THROW( () );
+
+/** Gets the meta type of an IDL type.
+
+ The difference between this function template (with a type parameter) and
+ the overloaded getCppuType function with a single (dummy) parameter of a
+ specific type is that this function template may not work for the UNO type
+ "unsigned short" (sal_uInt16 in C++), while the overloaded one-parameter
+ function may not work for the UNO type "char" (sal_Unicode in C++, which may
+ have the same underlying C++ type as sal_uInt16 on certain platforms).
+
+ @return type of the given IDL type
+
+ @deprecated
+ Use cppu::UnoType instead (or the internal-only cppu::getTypeFavourChar).
+ Also note that getCppuType< com::sun::star::uno::Sequence< sal_Unicode > >()
+ does not work as expected.
+
+ @since UDK 3.2.0
+*/
+template< typename T > inline const ::com::sun::star::uno::Type & SAL_CALL
+getCppuType() SAL_THROW(());
+
+/** Gets the meta type of IDL type char.
+
+ @return type of IDL type char
+
+ @deprecated
+ Use cppu::UnoType instead (or the internal-only cppu::getTypeFavourChar).
+ Also note that getCppuType< com::sun::star::uno::Sequence< sal_Unicode > >()
+ does not work as expected.
+
+ @since UDK 3.2.0
+*/
+template<> inline const ::com::sun::star::uno::Type & SAL_CALL
+getCppuType< sal_Unicode >() SAL_THROW(());
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/Type.hxx b/cppu/inc/com/sun/star/uno/Type.hxx
new file mode 100644
index 000000000000..33eba298e188
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/Type.hxx
@@ -0,0 +1,327 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
+#define _COM_SUN_STAR_UNO_TYPE_HXX_
+
+#include <osl/mutex.hxx>
+#include <com/sun/star/uno/Type.h>
+#include "cppu/unotype.hxx"
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+//__________________________________________________________________________________________________
+inline Type::Type() SAL_THROW( () )
+{
+ _pType = reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) )->getTypeLibType();
+ ::typelib_typedescriptionreference_acquire( _pType );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName ) SAL_THROW( () )
+ : _pType( 0 )
+{
+ ::typelib_typedescriptionreference_new( &_pType, (typelib_TypeClass)eTypeClass, rTypeName.pData );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( TypeClass eTypeClass, const sal_Char * pTypeName ) SAL_THROW( () )
+ : _pType( 0 )
+{
+ ::typelib_typedescriptionreference_newByAsciiName( &_pType, (typelib_TypeClass)eTypeClass, pTypeName );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( typelib_TypeDescriptionReference * pType ) SAL_THROW( () )
+ : _pType( pType )
+{
+ ::typelib_typedescriptionreference_acquire( _pType );
+}
+//__________________________________________________________________________________________________
+inline Type::Type( typelib_TypeDescriptionReference * pType, UnoType_NoAcquire ) SAL_THROW( () )
+ : _pType( pType )
+{
+}
+//__________________________________________________________________________________________________
+inline Type::Type( typelib_TypeDescriptionReference * pType, __sal_NoAcquire ) SAL_THROW( () )
+ : _pType( pType )
+{
+}
+//__________________________________________________________________________________________________
+inline Type::Type( const Type & rType ) SAL_THROW( () )
+ : _pType( rType._pType )
+{
+ ::typelib_typedescriptionreference_acquire( _pType );
+}
+//__________________________________________________________________________________________________
+inline ::rtl::OUString Type::getTypeName() const SAL_THROW( () )
+{
+ return ::rtl::OUString( _pType->pTypeName );
+}
+//__________________________________________________________________________________________________
+inline Type & Type::operator = ( const Type & rType ) SAL_THROW( () )
+{
+ ::typelib_typedescriptionreference_assign( &_pType, rType._pType );
+ return *this;
+}
+
+//__________________________________________________________________________________________________
+template< class T >
+typelib_TypeDescriptionReference * Array< T >::s_pType = 0;
+
+}
+}
+}
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Type * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::com::sun::star::uno::Type >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType() SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::cppu::UnoVoidType >::get();
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType() SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::cppu::UnoVoidType >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType() SAL_THROW( () )
+{
+ return ::cppu::UnoType< bool >::get();
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType() SAL_THROW( () )
+{
+ return ::cppu::UnoType< bool >::get();
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Bool * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< bool >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
+ bool const * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< bool >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType() SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::cppu::UnoCharType >::get();
+}
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType() SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::cppu::UnoCharType >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int8 * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::sal_Int8 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::rtl::OUString * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::rtl::OUString >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int16 * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::sal_Int16 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt16 * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int32 * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::sal_Int32 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt32 * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::sal_uInt32 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int64 * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::sal_Int64 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt64 * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< ::sal_uInt64 >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const float * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< float >::get();
+}
+
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const double * ) SAL_THROW( () )
+{
+ return ::cppu::UnoType< double >::get();
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType1( T * pT ) SAL_THROW( () )
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( *pT );
+ sal_Int32 size = sizeof( **pT );
+ sal_Int32 dim1 = sizeof( *pT ) / size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 1, dim1 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType2( T * pT ) SAL_THROW( () )
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( **pT );
+ sal_Int32 size = sizeof( ***pT );
+ sal_Int32 dim2 = sizeof( **pT ) / size;
+ sal_Int32 dim1 = sizeof( *pT ) / dim2 / size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 2, dim1, dim2 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType3( T * pT ) SAL_THROW( () )
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( ***pT );
+ sal_Int32 size = sizeof( ****pT );
+ sal_Int32 dim3 = sizeof( ***pT ) / size;
+ sal_Int32 dim2 = sizeof( **pT ) / dim3 / size;
+ sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3)/ size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 3, dim1, dim2, dim3 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType4( T * pT ) SAL_THROW( () )
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( ****pT );
+ sal_Int32 size = sizeof( *****pT );
+ sal_Int32 dim4 = sizeof( ****pT ) / size;
+ sal_Int32 dim3 = sizeof( ***pT ) / dim4 / size;
+ sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4) / size;
+ sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4) / size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 4, dim1, dim2, dim3, dim4 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType5( T * pT ) SAL_THROW( () )
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( *****pT );
+ sal_Int32 size = sizeof( ******pT );
+ sal_Int32 dim5 = sizeof( *****pT ) / size;
+ sal_Int32 dim4 = sizeof( ****pT ) / dim5 / size;
+ sal_Int32 dim3 = sizeof( ***pT ) / (dim4 * dim5) / size;
+ sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4 * dim5) / size;
+ sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4 * dim5) / size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 5, dim1, dim2, dim3, dim4, dim5 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< class T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType6( T * pT ) SAL_THROW( () )
+{
+ if (! ::com::sun::star::uno::Array< T >::s_pType)
+ {
+ const ::com::sun::star::uno::Type & rElementType =
+ ::cppu::getTypeFavourUnsigned( ******pT );
+ sal_Int32 size = sizeof( *******pT );
+ sal_Int32 dim6 = sizeof( ******pT ) / size;
+ sal_Int32 dim5 = sizeof( *****pT ) / dim6 / size;
+ sal_Int32 dim4 = sizeof( ****pT ) / (dim5 * dim6) / size;
+ sal_Int32 dim3 = sizeof( ***pT ) / (dim4 * dim5 * dim6) / size;
+ sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4 * dim5 * dim6) / size;
+ sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4 * dim5 * dim6) / size;
+ ::typelib_static_array_type_init(
+ & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
+ 6, dim1, dim2, dim3, dim4, dim5, dim6 );
+ }
+ return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
+ & ::com::sun::star::uno::Array< T >::s_pType );
+}
+
+template< typename T >
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType() SAL_THROW(())
+{
+ return ::cppu::UnoType< T >::get();
+}
+
+template<>
+inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType< sal_Unicode >()
+ SAL_THROW(())
+{
+ return ::cppu::UnoType< ::cppu::UnoCharType >::get();
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/genfunc.h b/cppu/inc/com/sun/star/uno/genfunc.h
new file mode 100644
index 000000000000..41fdebf47a31
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/genfunc.h
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_GENFUNC_H_
+#define _COM_SUN_STAR_UNO_GENFUNC_H_
+
+#include "sal/types.h"
+
+typedef struct _typelib_TypeDescriptionReference typelib_TypeDescriptionReference;
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+/** Function to acquire a C++ interface.
+
+ @param pCppI C++ interface pointer
+*/
+inline void SAL_CALL cpp_acquire( void * pCppI )
+ SAL_THROW( () );
+/** Function to release a C++ interface.
+
+ @param pCppI C++ interface pointer
+*/
+inline void SAL_CALL cpp_release( void * pCppI )
+ SAL_THROW( () );
+/** Function to query for a C++ interface.
+
+ @param pCppI C++ interface pointer
+ @param pType demanded interface type
+ @return acquired C++ interface pointer or null
+*/
+inline void * SAL_CALL cpp_queryInterface( void * pCppI, typelib_TypeDescriptionReference * pType )
+ SAL_THROW( () );
+
+}
+}
+}
+}
+
+#endif
diff --git a/cppu/inc/com/sun/star/uno/genfunc.hxx b/cppu/inc/com/sun/star/uno/genfunc.hxx
new file mode 100644
index 000000000000..b2299a35cd3d
--- /dev/null
+++ b/cppu/inc/com/sun/star/uno/genfunc.hxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_
+#define _COM_SUN_STAR_UNO_GENFUNC_HXX_
+
+#include <com/sun/star/uno/genfunc.h>
+#include <com/sun/star/uno/Any.hxx>
+
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+
+//==================================================================================================
+inline void SAL_CALL cpp_acquire( void * pCppI )
+ SAL_THROW( () )
+{
+ reinterpret_cast< XInterface * >( pCppI )->acquire();
+}
+//==================================================================================================
+inline void SAL_CALL cpp_release( void * pCppI )
+ SAL_THROW( () )
+{
+ reinterpret_cast< XInterface * >( pCppI )->release();
+}
+//==================================================================================================
+inline void * SAL_CALL cpp_queryInterface( void * pCppI, typelib_TypeDescriptionReference * pType )
+ SAL_THROW( () )
+{
+ if (pCppI)
+ {
+#ifndef EXCEPTIONS_OFF
+ try
+ {
+#endif
+ Any aRet( reinterpret_cast< XInterface * >( pCppI )->queryInterface(
+ * reinterpret_cast< const Type * >( &pType ) ) );
+ if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass)
+ {
+ XInterface * pRet = reinterpret_cast< XInterface * >( aRet.pReserved );
+ aRet.pReserved = 0;
+ return pRet;
+ }
+#ifndef EXCEPTIONS_OFF
+ }
+ catch (RuntimeException &)
+ {
+ }
+#endif
+ }
+ return 0;
+}
+
+}
+}
+}
+}
+
+#endif