summaryrefslogtreecommitdiff
path: root/cppuhelper
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2001-06-07 10:11:29 +0000
committerDaniel Boelzle <dbo@openoffice.org>2001-06-07 10:11:29 +0000
commitd6015b89e2c155ba93538b15864b7c6f48b9f1e8 (patch)
tree5188daea21d21001fa87396196c330bf2dac20c2 /cppuhelper
parentbfc5da2da9df0a0809fc9b77a4a926b21d3d6704 (diff)
#87052# no STL exports from cppuhelper lib
Diffstat (limited to 'cppuhelper')
-rw-r--r--cppuhelper/inc/cppuhelper/component.hxx45
-rw-r--r--cppuhelper/inc/cppuhelper/interfacecontainer.h91
-rw-r--r--cppuhelper/inc/cppuhelper/interfacecontainer.hxx6
-rw-r--r--cppuhelper/inc/cppuhelper/propshlp.hxx90
-rw-r--r--cppuhelper/source/component.cxx57
-rw-r--r--cppuhelper/source/implbase.cxx72
-rw-r--r--cppuhelper/source/interfacecontainer.cxx315
7 files changed, 624 insertions, 52 deletions
diff --git a/cppuhelper/inc/cppuhelper/component.hxx b/cppuhelper/inc/cppuhelper/component.hxx
index f828a1f782df..386442d8ecba 100644
--- a/cppuhelper/inc/cppuhelper/component.hxx
+++ b/cppuhelper/inc/cppuhelper/component.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: component.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jsc $ $Date: 2001-05-28 13:22:46 $
+ * last change: $Author: dbo $ $Date: 2001-06-07 11:11:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,14 +83,13 @@
namespace cppu
{
-/**
- The helper implementation for a basic broadcaster. This implementation
- supports aggregation and weak references.
-
- @author Markus Meyer
- @since 98/04/12
- */
-class OComponentHelper : public ::cppu::WeakAggImplHelper1< ::com::sun::star::lang::XComponent >
+/** The helper implementation for a basic broadcaster. This implementation
+ supports aggregation and weak references.
+*/
+class OComponentHelper
+ : public ::cppu::OWeakAggObject
+ , public ::com::sun::star::lang::XTypeProvider
+ , public ::com::sun::star::lang::XComponent
{
public:
/**
@@ -106,13 +105,25 @@ public:
double delete and than call dispose.<BR> Note in this situation no destructor
of derived classes are called.
*/
- ~OComponentHelper() SAL_THROW( (::com::sun::star::uno::RuntimeException) );
+ virtual ~OComponentHelper() SAL_THROW( (::com::sun::star::uno::RuntimeException) );
// XInterface
- virtual void SAL_CALL release() throw();
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire()
+ throw ();
+ virtual void SAL_CALL release()
+ throw ();
// XTypeProvider getImplementationId() has to be implemented separately!
- virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException) = 0;
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw(::com::sun::star::uno::RuntimeException) = 0;
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ throw (::com::sun::star::uno::RuntimeException);
// XComponent
virtual void SAL_CALL dispose()
@@ -129,17 +140,17 @@ protected:
Called in the dispose method after the listeners are notified.
In this situation rBHelper.bDisposed is false
and rBHelper.bDisposing is true.
- */
+ */
virtual void SAL_CALL disposing();
/**
Contains a mutex, a listener container and the dispose states.
Subclasses should only modify the listener container.
- */
+ */
OBroadcastHelper rBHelper;
private:
- OComponentHelper( const OComponentHelper & ) SAL_THROW( () );
- OComponentHelper & operator = ( const OComponentHelper & ) SAL_THROW( () );
+ inline OComponentHelper( const OComponentHelper & ) SAL_THROW( () );
+ inline OComponentHelper & operator = ( const OComponentHelper & ) SAL_THROW( () );
};
}
diff --git a/cppuhelper/inc/cppuhelper/interfacecontainer.h b/cppuhelper/inc/cppuhelper/interfacecontainer.h
index 3ae6aafe47d0..dea13d50251b 100644
--- a/cppuhelper/inc/cppuhelper/interfacecontainer.h
+++ b/cppuhelper/inc/cppuhelper/interfacecontainer.h
@@ -2,9 +2,9 @@
*
* $RCSfile: interfacecontainer.h,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: dbo $ $Date: 2001-05-21 09:14:50 $
+ * last change: $Author: dbo $ $Date: 2001-06-07 11:11:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -429,10 +429,89 @@ struct hashType_Impl
};
-typedef OMultiTypeInterfaceContainerHelperVar<
- ::com::sun::star::uno::Type,
- hashType_Impl,
- std::equal_to< ::com::sun::star::uno::Type > > OMultiTypeInterfaceContainerHelper;
+/** Specialized class for key type com::sun::star::uno::Type,
+ without explicit usage of STL symbols.
+*/
+class OMultiTypeInterfaceContainerHelper
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () )
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () )
+ {}
+
+ /**
+ Create a container of interface containers.
+
+ @param rMutex the mutex to protect multi thread access.
+ The lifetime must be longer than the lifetime
+ of this object.
+ */
+ OMultiTypeInterfaceContainerHelper( ::osl::Mutex & ) SAL_THROW( () );
+ /**
+ Delete all containers.
+ */
+ ~OMultiTypeInterfaceContainerHelper() SAL_THROW( () );
+
+ /**
+ Return all id's under which at least one interface is added.
+ */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getContainedTypes() const SAL_THROW( () );
+
+ /**
+ Return the container created under this key.
+ @return the container created under this key. If the container
+ was not created, null was returned.
+ */
+ OInterfaceContainerHelper * SAL_CALL getContainer( const ::com::sun::star::uno::Type & rKey ) const SAL_THROW( () );
+
+ /**
+ Insert an element in the container specified with the key. The position is not specified.
+ @param rKey the id of the container.
+ @param rxIFace the added interface. It is allowed to insert null or
+ the same pointer more than once.
+ @return the new count of elements in the container.
+ */
+ sal_Int32 SAL_CALL addInterface(
+ const ::com::sun::star::uno::Type & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r )
+ SAL_THROW( () );
+
+ /**
+ Remove an element from the container specified with the key.
+ It uses the equal definition of uno objects to remove the interfaces.
+ @param rKey the id of the container.
+ @param rxIFace the removed interface.
+ @return the new count of elements in the container.
+ */
+ sal_Int32 SAL_CALL removeInterface(
+ const ::com::sun::star::uno::Type & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace )
+ SAL_THROW( () );
+
+ /**
+ Call disposing on all object in the container that
+ support XEventListener. Than clear the container.
+ */
+ void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW( () );
+ /**
+ Remove all elements of all containers. Does not delete the container.
+ */
+ void SAL_CALL clear() SAL_THROW( () );
+
+ typedef ::com::sun::star::uno::Type keyType;
+private:
+ void *m_pMap;
+ ::osl::Mutex & rMutex;
+
+ inline OMultiTypeInterfaceContainerHelper( const OMultiTypeInterfaceContainerHelper & ) SAL_THROW( () );
+ inline OMultiTypeInterfaceContainerHelper & operator = ( const OMultiTypeInterfaceContainerHelper & ) SAL_THROW( () );
+};
typedef OBroadcastHelperVar< OMultiTypeInterfaceContainerHelper , OMultiTypeInterfaceContainerHelper::keyType > OBroadcastHelper;
diff --git a/cppuhelper/inc/cppuhelper/interfacecontainer.hxx b/cppuhelper/inc/cppuhelper/interfacecontainer.hxx
index 86c7c1c988a0..28a6e0947c3e 100644
--- a/cppuhelper/inc/cppuhelper/interfacecontainer.hxx
+++ b/cppuhelper/inc/cppuhelper/interfacecontainer.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: interfacecontainer.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: dbo $ $Date: 2001-03-09 12:15:26 $
+ * last change: $Author: dbo $ $Date: 2001-06-07 11:11:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -229,7 +229,7 @@ void OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::clear(
while( iter != end )
{
- ((OInterfaceContainerHelper*)(*iter)).second->clear();
+ ((OInterfaceContainerHelper*)(*iter).second)->clear();
++iter;
}
}
diff --git a/cppuhelper/inc/cppuhelper/propshlp.hxx b/cppuhelper/inc/cppuhelper/propshlp.hxx
index e91a922e3a39..c0b659182281 100644
--- a/cppuhelper/inc/cppuhelper/propshlp.hxx
+++ b/cppuhelper/inc/cppuhelper/propshlp.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propshlp.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jsc $ $Date: 2001-05-28 13:22:46 $
+ * last change: $Author: dbo $ $Date: 2001-06-07 11:11:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -253,8 +253,90 @@ struct hashInt32_Impl
size_t operator()(const sal_Int32 & i) const SAL_THROW( () )
{ return i; }
};
-typedef OMultiTypeInterfaceContainerHelperVar< sal_Int32, hashInt32_Impl, equalInt32_Impl >
- OMultiTypeInterfaceContainerHelperInt32;
+/** Specialized class for key type sal_Int32,
+ without explicit usage of STL symbols.
+*/
+class OMultiTypeInterfaceContainerHelperInt32
+{
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () )
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () )
+ {}
+
+ /**
+ Create a container of interface containers.
+
+ @param rMutex the mutex to protect multi thread access.
+ The lifetime must be longer than the lifetime
+ of this object.
+ */
+ OMultiTypeInterfaceContainerHelperInt32( ::osl::Mutex & ) SAL_THROW( () );
+ /**
+ Delete all containers.
+ */
+ ~OMultiTypeInterfaceContainerHelperInt32() SAL_THROW( () );
+
+ /**
+ Return all id's under which at least one interface is added.
+ */
+ ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const SAL_THROW( () );
+
+ /**
+ Return the container created under this key.
+ @return the container created under this key. If the container
+ was not created, null was returned.
+ */
+ OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const SAL_THROW( () );
+
+ /**
+ Insert an element in the container specified with the key. The position is not specified.
+ @param rKey the id of the container.
+ @param rxIFace the added interface. It is allowed to insert null or
+ the same pointer more than once.
+ @return the new count of elements in the container.
+ */
+ sal_Int32 SAL_CALL addInterface(
+ const sal_Int32 & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r )
+ SAL_THROW( () );
+
+ /**
+ Remove an element from the container specified with the key.
+ It uses the equal definition of uno objects to remove the interfaces.
+ @param rKey the id of the container.
+ @param rxIFace the removed interface.
+ @return the new count of elements in the container.
+ */
+ sal_Int32 SAL_CALL removeInterface(
+ const sal_Int32 & rKey,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace )
+ SAL_THROW( () );
+
+ /**
+ Call disposing on all object in the container that
+ support XEventListener. Than clear the container.
+ */
+ void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW( () );
+ /**
+ Remove all elements of all containers. Does not delete the container.
+ */
+ void SAL_CALL clear() SAL_THROW( () );
+
+ typedef sal_Int32 keyType;
+private:
+ void *m_pMap;
+ ::osl::Mutex & rMutex;
+
+ inline OMultiTypeInterfaceContainerHelperInt32( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_THROW( () );
+ inline OMultiTypeInterfaceContainerHelperInt32 & operator = ( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_THROW( () );
+};
+
/**
diff --git a/cppuhelper/source/component.cxx b/cppuhelper/source/component.cxx
index 504e9cfc8efe..8c9735fb0d91 100644
--- a/cppuhelper/source/component.cxx
+++ b/cppuhelper/source/component.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: component.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: dbo $ $Date: 2001-03-09 12:15:28 $
+ * last change: $Author: dbo $ $Date: 2001-06-07 11:11:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,11 +68,14 @@
#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
#include <cppuhelper/queryinterface.hxx>
#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
using namespace osl;
+using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
-using namespace com::sun::star::lang;
namespace cppu
{
@@ -80,19 +83,38 @@ namespace cppu
// ----------------------------------------------------
// class OComponentHelper
// ----------------------------------------------------
+
OComponentHelper::OComponentHelper( Mutex & rMutex ) SAL_THROW( () )
: rBHelper( rMutex )
{
}
-
-/**
- * Call dispose if not previous called.
- */
OComponentHelper::~OComponentHelper() SAL_THROW( (RuntimeException) )
{
}
-// XInterface
+Any OComponentHelper::queryInterface( Type const & rType ) throw (RuntimeException)
+{
+ return OWeakAggObject::queryInterface( rType );
+}
+Any OComponentHelper::queryAggregation( Type const & rType ) throw (RuntimeException)
+{
+ if (rType == ::getCppuType( (Reference< lang::XComponent > const *)0 ))
+ {
+ void * p = static_cast< lang::XComponent * >( this );
+ return Any( &p, rType );
+ }
+ else if (rType == ::getCppuType( (Reference< lang::XTypeProvider > const *)0 ))
+ {
+ void * p = static_cast< lang::XTypeProvider * >( this );
+ return Any( &p, rType );
+ }
+ return OWeakAggObject::queryAggregation( rType );
+}
+void OComponentHelper::acquire() throw ()
+{
+ OWeakAggObject::acquire();
+}
+
void OComponentHelper::release() throw()
{
Reference<XInterface > x( xDelegator );
@@ -125,6 +147,25 @@ void OComponentHelper::release() throw()
OWeakAggObject::release();
}
+Sequence< Type > OComponentHelper::getTypes() throw (RuntimeException)
+{
+ static OTypeCollection * s_pTypes = 0;
+ if (! s_pTypes)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_pTypes)
+ {
+ static OTypeCollection s_aTypes(
+ ::getCppuType( (const Reference< lang::XComponent > *)0 ),
+ ::getCppuType( (const Reference< lang::XTypeProvider > *)0 ),
+ ::getCppuType( (const Reference< XAggregation > *)0 ),
+ ::getCppuType( (const Reference< XWeak > *)0 ) );
+ s_pTypes = &s_aTypes;
+ }
+ }
+ return s_pTypes->getTypes();
+}
+
// XComponent
void OComponentHelper::disposing()
{
diff --git a/cppuhelper/source/implbase.cxx b/cppuhelper/source/implbase.cxx
index 0ccc9a79bbb6..bc58853b07bb 100644
--- a/cppuhelper/source/implbase.cxx
+++ b/cppuhelper/source/implbase.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: implbase.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: dbo $ $Date: 2001-05-21 09:14:53 $
+ * last change: $Author: dbo $ $Date: 2001-06-07 11:11:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -285,7 +285,14 @@ void WeakComponentImplHelperBase::release()
{
if (1 == m_refCount && !rBHelper.bDisposed)
{
- dispose();
+ try
+ {
+ dispose();
+ }
+ catch (...)
+ {
+ OSL_ENSURE( 0, "### unexpected exception caught!" );
+ }
}
OWeakObject::release();
}
@@ -298,9 +305,18 @@ void WeakComponentImplHelperBase::dispose()
{
rBHelper.bInDispose = sal_True;
aGuard.clear();
- lang::EventObject aEvt( static_cast< OWeakObject * >( this ) );
- rBHelper.aLC.disposeAndClear( aEvt );
- disposing();
+ try
+ {
+ lang::EventObject aEvt( static_cast< OWeakObject * >( this ) );
+ rBHelper.aLC.disposeAndClear( aEvt );
+ disposing();
+ }
+ catch (...)
+ {
+ rBHelper.bDisposed = sal_True;
+ rBHelper.bInDispose = sal_False;
+ throw;
+ }
rBHelper.bDisposed = sal_True;
rBHelper.bInDispose = sal_False;
}
@@ -310,7 +326,15 @@ void WeakComponentImplHelperBase::addEventListener(
Reference< lang::XEventListener > const & xListener )
throw (RuntimeException)
{
- rBHelper.addListener( ::getCppuType( &xListener ), xListener );
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ {
+ lang::EventObject aEvt( static_cast< OWeakObject * >( this ) );
+ xListener->disposing( aEvt );
+ }
+ else
+ {
+ rBHelper.addListener( ::getCppuType( &xListener ), xListener );
+ }
}
//__________________________________________________________________________________________________
void WeakComponentImplHelperBase::removeEventListener(
@@ -366,7 +390,14 @@ void WeakAggComponentImplHelperBase::release()
Reference< XInterface > x( xDelegator );
if (!x.is() && 1 == m_refCount && !rBHelper.bDisposed)
{
- dispose();
+ try
+ {
+ dispose();
+ }
+ catch (...)
+ {
+ OSL_ENSURE( 0, "### unexpected exception caught!" );
+ }
}
OWeakAggObject::release();
}
@@ -379,9 +410,18 @@ void WeakAggComponentImplHelperBase::dispose()
{
rBHelper.bInDispose = sal_True;
aGuard.clear();
- lang::EventObject aEvt( static_cast< OWeakObject * >( this ) );
- rBHelper.aLC.disposeAndClear( aEvt );
- disposing();
+ try
+ {
+ lang::EventObject aEvt( static_cast< OWeakObject * >( this ) );
+ rBHelper.aLC.disposeAndClear( aEvt );
+ disposing();
+ }
+ catch (...)
+ {
+ rBHelper.bDisposed = sal_True;
+ rBHelper.bInDispose = sal_False;
+ throw;
+ }
rBHelper.bDisposed = sal_True;
rBHelper.bInDispose = sal_False;
}
@@ -391,7 +431,15 @@ void WeakAggComponentImplHelperBase::addEventListener(
Reference< lang::XEventListener > const & xListener )
throw (RuntimeException)
{
- rBHelper.addListener( ::getCppuType( &xListener ), xListener );
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ {
+ lang::EventObject aEvt( static_cast< OWeakObject * >( this ) );
+ xListener->disposing( aEvt );
+ }
+ else
+ {
+ rBHelper.addListener( ::getCppuType( &xListener ), xListener );
+ }
}
//__________________________________________________________________________________________________
void WeakAggComponentImplHelperBase::removeEventListener(
diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx
index 954ea219ef8a..d6cbb1aa0f06 100644
--- a/cppuhelper/source/interfacecontainer.cxx
+++ b/cppuhelper/source/interfacecontainer.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: interfacecontainer.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jbu $ $Date: 2001-05-17 12:56:41 $
+ * last change: $Author: dbo $ $Date: 2001-06-07 11:11:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,6 +61,7 @@
#include <cppuhelper/interfacecontainer.hxx>
#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/propshlp.hxx>
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
@@ -406,6 +407,316 @@ void OInterfaceContainerHelper::clear() SAL_THROW( () )
aGuard.clear();
}
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+// specialized class for type
+
+typedef ::std::hash_map< Type , void* , hashType_Impl , ::std::equal_to< Type > > t_type2ptr;
+
+OMultiTypeInterfaceContainerHelper::OMultiTypeInterfaceContainerHelper( Mutex & rMutex_ )
+ SAL_THROW( () )
+ : rMutex( rMutex_ )
+{
+ m_pMap = new t_type2ptr();
+}
+OMultiTypeInterfaceContainerHelper::~OMultiTypeInterfaceContainerHelper()
+ SAL_THROW( () )
+{
+ t_type2ptr * pMap = (t_type2ptr *)m_pMap;
+ t_type2ptr::iterator iter = pMap->begin();
+ t_type2ptr::iterator end = pMap->end();
+
+ while( iter != end )
+ {
+ delete (OInterfaceContainerHelper*)(*iter).second;
+ (*iter).second = 0;
+ ++iter;
+ }
+ delete pMap;
+}
+Sequence< Type > OMultiTypeInterfaceContainerHelper::getContainedTypes() const
+ SAL_THROW( () )
+{
+ t_type2ptr * pMap = (t_type2ptr *)m_pMap;
+ t_type2ptr::size_type nSize;
+
+ ::osl::MutexGuard aGuard( rMutex );
+ if( nSize = pMap->size() )
+ {
+ ::com::sun::star::uno::Sequence< Type > aInterfaceTypes( nSize );
+ Type * pArray = aInterfaceTypes.getArray();
+
+ t_type2ptr::iterator iter = pMap->begin();
+ t_type2ptr::iterator end = pMap->end();
+
+ sal_Int32 i = 0;
+ while( iter != end )
+ {
+ // are interfaces added to this container?
+ if( ((OInterfaceContainerHelper*)(*iter).second)->getLength() )
+ // yes, put the type in the array
+ pArray[i++] = (*iter).first;
+ iter++;
+ }
+ if( i != nSize ) {
+ // may be empty container, reduce the sequence to the right size
+ aInterfaceTypes = ::com::sun::star::uno::Sequence< Type >( pArray, i );
+ }
+ return aInterfaceTypes;
+ }
+ return ::com::sun::star::uno::Sequence< Type >();
+}
+OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelper::getContainer( const Type & rKey ) const
+ SAL_THROW( () )
+{
+ ::osl::MutexGuard aGuard( rMutex );
+
+ t_type2ptr * pMap = (t_type2ptr *)m_pMap;
+ t_type2ptr::iterator iter = pMap->find( rKey );
+ if( iter != pMap->end() )
+ return (OInterfaceContainerHelper*) (*iter).second;
+ return 0;
+}
+sal_Int32 OMultiTypeInterfaceContainerHelper::addInterface(
+ const Type & rKey, const Reference< XInterface > & rListener )
+ SAL_THROW( () )
+{
+ ::osl::MutexGuard aGuard( rMutex );
+ t_type2ptr * pMap = (t_type2ptr *)m_pMap;
+ t_type2ptr::iterator iter = pMap->find( rKey );
+ if( iter == pMap->end() )
+ {
+ OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex );
+ (*pMap)[rKey] = pLC;
+ return pLC->addInterface( rListener );
+ }
+ else
+ return ((OInterfaceContainerHelper*)(*iter).second)->addInterface( rListener );
+}
+sal_Int32 OMultiTypeInterfaceContainerHelper::removeInterface(
+ const Type & rKey, const Reference< XInterface > & rListener )
+ SAL_THROW( () )
+{
+ ::osl::MutexGuard aGuard( rMutex );
+
+ // search container with id nUik
+ t_type2ptr * pMap = (t_type2ptr *)m_pMap;
+ t_type2ptr::iterator iter = pMap->find( rKey );
+ // container found?
+ if( iter != pMap->end() )
+ return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener );
+
+ // no container with this id. Always return 0
+ return 0;
+}
+void OMultiTypeInterfaceContainerHelper::disposeAndClear( const EventObject & rEvt )
+ SAL_THROW( () )
+{
+ t_type2ptr::size_type nSize = 0;
+ OInterfaceContainerHelper ** ppListenerContainers = NULL;
+ {
+ ::osl::MutexGuard aGuard( rMutex );
+ t_type2ptr * pMap = (t_type2ptr *)m_pMap;
+ if( nSize = pMap->size() )
+ {
+ typedef OInterfaceContainerHelper* ppp;
+ ppListenerContainers = new ppp[nSize];
+ //ppListenerContainers = new (ListenerContainer*)[nSize];
+
+ t_type2ptr::iterator iter = pMap->begin();
+ t_type2ptr::iterator end = pMap->end();
+
+ t_type2ptr::size_type i = 0;
+ while( iter != end )
+ {
+ ppListenerContainers[i++] = (OInterfaceContainerHelper*)(*iter).second;
+ ++iter;
+ }
+ }
+ }
+
+ // create a copy, because do not fire event in a guarded section
+ for( t_type2ptr::size_type i = 0;
+ i < nSize; i++ )
+ {
+ if( ppListenerContainers[i] )
+ ppListenerContainers[i]->disposeAndClear( rEvt );
+ }
+
+ delete [] ppListenerContainers;
+}
+void OMultiTypeInterfaceContainerHelper::clear()
+ SAL_THROW( () )
+{
+ ::osl::MutexGuard aGuard( rMutex );
+ t_type2ptr * pMap = (t_type2ptr *)m_pMap;
+ t_type2ptr::iterator iter = pMap->begin();
+ t_type2ptr::iterator end = pMap->end();
+
+ while( iter != end )
+ {
+ ((OInterfaceContainerHelper*)(*iter).second)->clear();
+ ++iter;
+ }
+}
+
+
+//##################################################################################################
+//##################################################################################################
+//##################################################################################################
+
+// specialized class for long
+
+typedef ::std::hash_map< sal_Int32 , void* , hashInt32_Impl , equalInt32_Impl > t_long2ptr;
+
+OMultiTypeInterfaceContainerHelperInt32::OMultiTypeInterfaceContainerHelperInt32( Mutex & rMutex_ )
+ SAL_THROW( () )
+ : rMutex( rMutex_ )
+{
+ m_pMap = new t_long2ptr();
+}
+OMultiTypeInterfaceContainerHelperInt32::~OMultiTypeInterfaceContainerHelperInt32()
+ SAL_THROW( () )
+{
+ t_long2ptr * pMap = (t_long2ptr *)m_pMap;
+ t_long2ptr::iterator iter = pMap->begin();
+ t_long2ptr::iterator end = pMap->end();
+
+ while( iter != end )
+ {
+ delete (OInterfaceContainerHelper*)(*iter).second;
+ (*iter).second = 0;
+ ++iter;
+ }
+ delete pMap;
+}
+Sequence< sal_Int32 > OMultiTypeInterfaceContainerHelperInt32::getContainedTypes() const
+ SAL_THROW( () )
+{
+ t_long2ptr * pMap = (t_long2ptr *)m_pMap;
+ t_long2ptr::size_type nSize;
+
+ ::osl::MutexGuard aGuard( rMutex );
+ if( nSize = pMap->size() )
+ {
+ ::com::sun::star::uno::Sequence< sal_Int32 > aInterfaceTypes( nSize );
+ sal_Int32 * pArray = aInterfaceTypes.getArray();
+
+ t_long2ptr::iterator iter = pMap->begin();
+ t_long2ptr::iterator end = pMap->end();
+
+ sal_Int32 i = 0;
+ while( iter != end )
+ {
+ // are interfaces added to this container?
+ if( ((OInterfaceContainerHelper*)(*iter).second)->getLength() )
+ // yes, put the type in the array
+ pArray[i++] = (*iter).first;
+ iter++;
+ }
+ if( i != nSize ) {
+ // may be empty container, reduce the sequence to the right size
+ aInterfaceTypes = ::com::sun::star::uno::Sequence< sal_Int32 >( pArray, i );
+ }
+ return aInterfaceTypes;
+ }
+ return ::com::sun::star::uno::Sequence< sal_Int32 >();
+}
+OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelperInt32::getContainer( const sal_Int32 & rKey ) const
+ SAL_THROW( () )
+{
+ ::osl::MutexGuard aGuard( rMutex );
+
+ t_long2ptr * pMap = (t_long2ptr *)m_pMap;
+ t_long2ptr::iterator iter = pMap->find( rKey );
+ if( iter != pMap->end() )
+ return (OInterfaceContainerHelper*) (*iter).second;
+ return 0;
+}
+sal_Int32 OMultiTypeInterfaceContainerHelperInt32::addInterface(
+ const sal_Int32 & rKey, const Reference< XInterface > & rListener )
+ SAL_THROW( () )
+{
+ ::osl::MutexGuard aGuard( rMutex );
+ t_long2ptr * pMap = (t_long2ptr *)m_pMap;
+ t_long2ptr::iterator iter = pMap->find( rKey );
+ if( iter == pMap->end() )
+ {
+ OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex );
+ (*pMap)[rKey] = pLC;
+ return pLC->addInterface( rListener );
+ }
+ else
+ return ((OInterfaceContainerHelper*)(*iter).second)->addInterface( rListener );
+}
+sal_Int32 OMultiTypeInterfaceContainerHelperInt32::removeInterface(
+ const sal_Int32 & rKey, const Reference< XInterface > & rListener )
+ SAL_THROW( () )
+{
+ ::osl::MutexGuard aGuard( rMutex );
+
+ // search container with id nUik
+ t_long2ptr * pMap = (t_long2ptr *)m_pMap;
+ t_long2ptr::iterator iter = pMap->find( rKey );
+ // container found?
+ if( iter != pMap->end() )
+ return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener );
+
+ // no container with this id. Always return 0
+ return 0;
+}
+void OMultiTypeInterfaceContainerHelperInt32::disposeAndClear( const EventObject & rEvt )
+ SAL_THROW( () )
+{
+ t_long2ptr::size_type nSize = 0;
+ OInterfaceContainerHelper ** ppListenerContainers = NULL;
+ {
+ ::osl::MutexGuard aGuard( rMutex );
+ t_long2ptr * pMap = (t_long2ptr *)m_pMap;
+ if( nSize = pMap->size() )
+ {
+ typedef OInterfaceContainerHelper* ppp;
+ ppListenerContainers = new ppp[nSize];
+ //ppListenerContainers = new (ListenerContainer*)[nSize];
+
+ t_long2ptr::iterator iter = pMap->begin();
+ t_long2ptr::iterator end = pMap->end();
+
+ t_long2ptr::size_type i = 0;
+ while( iter != end )
+ {
+ ppListenerContainers[i++] = (OInterfaceContainerHelper*)(*iter).second;
+ ++iter;
+ }
+ }
+ }
+
+ // create a copy, because do not fire event in a guarded section
+ for( t_long2ptr::size_type i = 0;
+ i < nSize; i++ )
+ {
+ if( ppListenerContainers[i] )
+ ppListenerContainers[i]->disposeAndClear( rEvt );
+ }
+
+ delete [] ppListenerContainers;
+}
+void OMultiTypeInterfaceContainerHelperInt32::clear()
+ SAL_THROW( () )
+{
+ ::osl::MutexGuard aGuard( rMutex );
+ t_long2ptr * pMap = (t_long2ptr *)m_pMap;
+ t_long2ptr::iterator iter = pMap->begin();
+ t_long2ptr::iterator end = pMap->end();
+
+ while( iter != end )
+ {
+ ((OInterfaceContainerHelper*)(*iter).second)->clear();
+ ++iter;
+ }
+}
}