summaryrefslogtreecommitdiff
path: root/cppu/inc/com/sun/star/uno
diff options
context:
space:
mode:
Diffstat (limited to 'cppu/inc/com/sun/star/uno')
-rw-r--r--cppu/inc/com/sun/star/uno/Any.h12
-rw-r--r--cppu/inc/com/sun/star/uno/Any.hxx11
-rw-r--r--cppu/inc/com/sun/star/uno/Reference.h116
-rw-r--r--cppu/inc/com/sun/star/uno/Reference.hxx161
-rw-r--r--cppu/inc/com/sun/star/uno/Type.h15
5 files changed, 255 insertions, 60 deletions
diff --git a/cppu/inc/com/sun/star/uno/Any.h b/cppu/inc/com/sun/star/uno/Any.h
index 9d157ced647b..b2a934ad6eed 100644
--- a/cppu/inc/com/sun/star/uno/Any.h
+++ b/cppu/inc/com/sun/star/uno/Any.h
@@ -2,9 +2,9 @@
*
* $RCSfile: Any.h,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: dbo $ $Date: 2001-11-09 09:14:30 $
+ * last change: $Author: dbo $ $Date: 2002-08-19 07:18:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -227,6 +227,14 @@ public:
*/
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( () );
+
/** Equality operator: compares two anys.
The values need not be of equal type, e.g. a short integer is compared to a long integer.
diff --git a/cppu/inc/com/sun/star/uno/Any.hxx b/cppu/inc/com/sun/star/uno/Any.hxx
index 13981ff54820..f66331350934 100644
--- a/cppu/inc/com/sun/star/uno/Any.hxx
+++ b/cppu/inc/com/sun/star/uno/Any.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Any.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: dbo $ $Date: 2001-12-17 12:49:34 $
+ * last change: $Author: dbo $ $Date: 2002-08-19 07:18:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -166,6 +166,13 @@ inline void Any::clear() SAL_THROW( () )
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 );
+}
+//__________________________________________________________________________________________________
inline sal_Bool Any::operator == ( const Any & rAny ) const SAL_THROW( () )
{
return ::uno_type_equalData(
diff --git a/cppu/inc/com/sun/star/uno/Reference.h b/cppu/inc/com/sun/star/uno/Reference.h
index abaeed812514..88422a175f44 100644
--- a/cppu/inc/com/sun/star/uno/Reference.h
+++ b/cppu/inc/com/sun/star/uno/Reference.h
@@ -2,9 +2,9 @@
*
* $RCSfile: Reference.h,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: dbo $ $Date: 2001-11-09 09:14:30 $
+ * last change: $Author: dbo $ $Date: 2002-08-19 07:18:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -77,6 +77,7 @@ namespace uno
class RuntimeException;
class XInterface;
+class Type;
class Any;
/** Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface.
@@ -101,6 +102,26 @@ protected:
*/
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 __query( 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 __query_throw( XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) );
+#endif
+
public:
/** Gets interface pointer. This call does not acquire the interface.
@@ -114,7 +135,7 @@ public:
@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 (_pInterface != 0); }
+ { return (0 != _pInterface); }
/** Equality operator: compares two interfaces
Checks if both references are null or refer to the same object.
@@ -146,22 +167,38 @@ public:
*/
inline sal_Bool SAL_CALL operator != ( const BaseReference & rRef ) const SAL_THROW( () );
- // needed for some stl container operations, though this makes no sense on pointers
+ /** needed for some stl container operations, though this makes no sense on pointers
+ @internal
+ */
inline sal_Bool SAL_CALL operator < ( const BaseReference & rRef ) const SAL_THROW( () )
{ return (_pInterface < rRef._pInterface); }
};
-/** Enum defining UNO_QUERY and UNO_REF_QUERY for query interface constructor of reference template.
+/** Enum defining UNO_QUERY and UNO_REF_QUERY for implicit interface query.
*/
enum __UnoReference_Query
{
- /** This enum value can be used for querying interface constructor of reference template.
+ /** This enum value can be used for implicit interface query.
*/
UNO_QUERY,
- /** This enum value can be used for querying interface constructor of reference template.
+ /** 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
+};
+#endif
/** Template reference class for interface type derived from BaseReference.
A special constructor given the UNO_QUERY or UNO_REF_QUERY identifier queries interfaces
@@ -170,12 +207,23 @@ enum __UnoReference_Query
template< class interface_type >
class Reference : public BaseReference
{
- /** Queries given interface reference for type interface_type.
+ /** Queries given interface for type interface_type.
@param pInterface interface pointer
@return interface of demanded type (may be null)
*/
- inline static interface_type * SAL_CALL __query( XInterface * pInterface ) SAL_THROW( (RuntimeException) );
+ inline static interface_type * SAL_CALL __query( 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 interface_type * SAL_CALL __query_throw( XInterface * pInterface )
+ SAL_THROW( (RuntimeException) );
+#endif
public:
// these are here to force memory de/allocation to sal lib.
@@ -244,6 +292,32 @@ public:
@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) );
+#endif
/** Cast operator to Reference< XInterface >: Reference objects are binary compatible and
any interface must be derived from com.sun.star.uno.XInterface.
@@ -286,6 +360,7 @@ public:
/** 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( () );
@@ -294,6 +369,7 @@ public:
@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( () );
@@ -302,6 +378,7 @@ public:
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) );
@@ -309,9 +386,30 @@ public:
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) );
+#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) );
+#endif
/** Assignment operator: Acquires given interface pointer and sets reference.
An interface already set will be released.
diff --git a/cppu/inc/com/sun/star/uno/Reference.hxx b/cppu/inc/com/sun/star/uno/Reference.hxx
index 45907f36fbbc..3ec7ff2b0948 100644
--- a/cppu/inc/com/sun/star/uno/Reference.hxx
+++ b/cppu/inc/com/sun/star/uno/Reference.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Reference.hxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: dbo $ $Date: 2002-03-13 09:45:34 $
+ * last change: $Author: dbo $ $Date: 2002-08-19 07:18:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,62 +81,57 @@ namespace uno
{
//__________________________________________________________________________________________________
-inline sal_Bool BaseReference::operator == ( XInterface * pInterface ) const SAL_THROW( () )
+inline XInterface * BaseReference::__query(
+ XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) )
{
- 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 &)
+ if (pInterface)
{
- return sal_False;
+ Any aRet( pInterface->queryInterface( rType ) );
+ if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass)
+ {
+ XInterface * pRet = reinterpret_cast< XInterface * >( aRet.pReserved );
+ aRet.pReserved = 0;
+ return pRet;
+ }
}
-#endif
-}
-//__________________________________________________________________________________________________
-inline sal_Bool BaseReference::operator != ( XInterface * pInterface ) const SAL_THROW( () )
-{
- return (! operator == ( pInterface ));
+ return 0;
}
//__________________________________________________________________________________________________
-inline sal_Bool BaseReference::operator == ( const BaseReference & rRef ) const SAL_THROW( () )
+template< class interface_type >
+inline interface_type * Reference< interface_type >::__query(
+ XInterface * pInterface ) SAL_THROW( (RuntimeException) )
{
- return operator == ( rRef._pInterface );
+ return static_cast< interface_type * >(
+ BaseReference::__query(
+ pInterface, ::getCppuType( (const Reference< interface_type > *)0 ) ) );
}
+#ifndef EXCEPTIONS_OFF
+extern "C" rtl_uString * SAL_CALL __cppu_unsatisfied_query_msg(
+ typelib_TypeDescriptionReference * pType )
+ SAL_THROW_EXTERN_C();
//__________________________________________________________________________________________________
-inline sal_Bool BaseReference::operator != ( const BaseReference & rRef ) const SAL_THROW( () )
+inline XInterface * BaseReference::__query_throw(
+ XInterface * pInterface, const Type & rType )
+ SAL_THROW( (RuntimeException) )
{
- return (! operator == ( rRef._pInterface ));
+ XInterface * pQueried = __query( pInterface, rType );
+ if (pQueried)
+ return pQueried;
+ throw RuntimeException(
+ ::rtl::OUString( __cppu_unsatisfied_query_msg( rType.getTypeLibType() ), SAL_NO_ACQUIRE ),
+ Reference< XInterface >( pInterface ) );
}
-
-//##################################################################################################
-
//__________________________________________________________________________________________________
template< class interface_type >
-inline interface_type * Reference< interface_type >::__query(
+inline interface_type * Reference< interface_type >::__query_throw(
XInterface * pInterface ) SAL_THROW( (RuntimeException) )
{
- if (pInterface)
- {
- const Type & rType = ::getCppuType( (const Reference< interface_type > *)0 );
- Any aRet( pInterface->queryInterface( rType ) );
- if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass)
- {
- interface_type * pRet = reinterpret_cast< interface_type * >( aRet.pReserved );
- aRet.pReserved = 0;
- return pRet;
- }
- }
- return 0;
+ return static_cast< interface_type * >(
+ BaseReference::__query_throw(
+ pInterface, ::getCppuType( (const Reference< interface_type > *)0 ) ) );
}
+#endif
//__________________________________________________________________________________________________
template< class interface_type >
@@ -198,6 +193,27 @@ inline Reference< interface_type >::Reference( const Any & rAny, __UnoReference_
_pInterface = (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass
? __query( reinterpret_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 = __query_throw( rRef.get() );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( XInterface * pInterface, __UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = __query_throw( pInterface );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline Reference< interface_type >::Reference( const Any & rAny, __UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ _pInterface = __query_throw( typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass
+ ? reinterpret_cast< XInterface * >( rAny.pReserved ) : 0 );
+}
+#endif
//__________________________________________________________________________________________________
template< class interface_type >
@@ -219,7 +235,7 @@ inline sal_Bool Reference< interface_type >::set(
if (_pInterface)
_pInterface->release();
_pInterface = pInterface;
- return (pInterface != 0);
+ return (0 != pInterface);
}
//__________________________________________________________________________________________________
template< class interface_type >
@@ -229,7 +245,7 @@ inline sal_Bool Reference< interface_type >::set(
if (_pInterface)
_pInterface->release();
_pInterface = pInterface;
- return (pInterface != 0);
+ return (0 != pInterface);
}
//__________________________________________________________________________________________________
template< class interface_type >
@@ -260,6 +276,22 @@ inline sal_Bool Reference< interface_type >::set(
{
return set( __query( rRef.get() ), SAL_NO_ACQUIRE );
}
+#ifndef EXCEPTIONS_OFF
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ XInterface * pInterface, __UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ set( __query_throw( pInterface ), SAL_NO_ACQUIRE );
+}
+//__________________________________________________________________________________________________
+template< class interface_type >
+inline void Reference< interface_type >::set(
+ const BaseReference & rRef, __UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
+{
+ set( __query_throw( rRef.get() ), SAL_NO_ACQUIRE );
+}
+#endif
//__________________________________________________________________________________________________
template< class interface_type >
@@ -293,6 +325,45 @@ inline Reference< interface_type > Reference< interface_type >::query(
return Reference< interface_type >( __query( 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 != ( 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 ));
+}
+
}
}
}
diff --git a/cppu/inc/com/sun/star/uno/Type.h b/cppu/inc/com/sun/star/uno/Type.h
index 16fa64734a68..649bdd378de8 100644
--- a/cppu/inc/com/sun/star/uno/Type.h
+++ b/cppu/inc/com/sun/star/uno/Type.h
@@ -2,9 +2,9 @@
*
* $RCSfile: Type.h,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: dbo $ $Date: 2002-06-20 11:04:52 $
+ * last change: $Author: dbo $ $Date: 2002-08-19 07:18:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -211,6 +211,17 @@ public:
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