merge the formfield patch from ooo-build
[ooovba.git] / UnoControls / source / controls / OConnectionPointContainerHelper.cxx
blob49cc98a472f46b1c4a218d43c90407460f01cfc0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OConnectionPointContainerHelper.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 //______________________________________________________________________________________________________________
32 // my own include
33 //______________________________________________________________________________________________________________
35 #include "OConnectionPointContainerHelper.hxx"
37 //______________________________________________________________________________________________________________
38 // includes of other projects
39 //______________________________________________________________________________________________________________
41 //______________________________________________________________________________________________________________
42 // include of my own project
43 //______________________________________________________________________________________________________________
44 #include "OConnectionPointHelper.hxx"
46 //______________________________________________________________________________________________________________
47 // namespaces
48 //______________________________________________________________________________________________________________
50 using namespace ::rtl ;
51 using namespace ::osl ;
52 using namespace ::cppu ;
53 using namespace ::com::sun::star::uno ;
54 using namespace ::com::sun::star::lang ;
56 namespace unocontrols{
58 //______________________________________________________________________________________________________________
59 // construct/destruct
60 //______________________________________________________________________________________________________________
62 OConnectionPointContainerHelper::OConnectionPointContainerHelper( Mutex& aMutex )
63 : m_aSharedMutex ( aMutex )
64 , m_aMultiTypeContainer ( aMutex )
68 OConnectionPointContainerHelper::~OConnectionPointContainerHelper()
72 //____________________________________________________________________________________________________________
73 // XInterface
74 //____________________________________________________________________________________________________________
76 Any SAL_CALL OConnectionPointContainerHelper::queryInterface( const Type& aType ) throw( RuntimeException )
78 // Attention:
79 // Don't use mutex or guard in this method!!! Is a method of XInterface.
81 // Ask for my own supported interfaces ...
82 Any aReturn ( ::cppu::queryInterface( aType ,
83 static_cast< XConnectionPointContainer* > ( this )
87 // If searched interface not supported by this class ...
88 if ( aReturn.hasValue() == sal_False )
90 // ... ask baseclasses.
91 aReturn = OWeakObject::queryInterface( aType );
94 return aReturn ;
97 //____________________________________________________________________________________________________________
98 // XInterface
99 //____________________________________________________________________________________________________________
101 void SAL_CALL OConnectionPointContainerHelper::acquire() throw()
103 // Attention:
104 // Don't use mutex or guard in this method!!! Is a method of XInterface.
106 // Forward to baseclass
107 OWeakObject::acquire();
110 //____________________________________________________________________________________________________________
111 // XInterface
112 //____________________________________________________________________________________________________________
114 void SAL_CALL OConnectionPointContainerHelper::release() throw()
116 // Attention:
117 // Don't use mutex or guard in this method!!! Is a method of XInterface.
119 // Forward to baseclass
120 OWeakObject::release();
123 //______________________________________________________________________________________________________________
124 // XConnectionPointContainer
125 //______________________________________________________________________________________________________________
127 Sequence< Type > SAL_CALL OConnectionPointContainerHelper::getConnectionPointTypes() throw( RuntimeException )
129 // Container is threadsafe himself !
130 return m_aMultiTypeContainer.getContainedTypes();
133 //______________________________________________________________________________________________________________
134 // XConnectionPointContainer
135 //______________________________________________________________________________________________________________
137 Reference< XConnectionPoint > SAL_CALL OConnectionPointContainerHelper::queryConnectionPoint( const Type& aType ) throw( RuntimeException )
139 // Set default return value, if method failed.
140 Reference< XConnectionPoint > xConnectionPoint = Reference< XConnectionPoint >();
142 // Get all elements of the container, which have the searched type.
143 OInterfaceContainerHelper* pSpecialContainer = m_aMultiTypeContainer.getContainer( aType );
144 if ( pSpecialContainer && pSpecialContainer->getLength() > 0 )
146 // Ready for multithreading
147 MutexGuard aGuard( m_aSharedMutex );
148 // If this container contains elements, build a connectionpoint-instance.
149 OConnectionPointHelper* pNewConnectionPoint = new OConnectionPointHelper( m_aSharedMutex, this, aType );
150 xConnectionPoint = Reference< XConnectionPoint >( (OWeakObject*)pNewConnectionPoint, UNO_QUERY );
153 return xConnectionPoint ;
156 //______________________________________________________________________________________________________________
157 // XConnectionPointContainer
158 //______________________________________________________________________________________________________________
160 void SAL_CALL OConnectionPointContainerHelper::advise( const Type& aType ,
161 const Reference< XInterface >& xListener ) throw( RuntimeException )
163 // Container is threadsafe himself !
164 m_aMultiTypeContainer.addInterface( aType, xListener );
167 //______________________________________________________________________________________________________________
168 // XConnectionPointContainer
169 //______________________________________________________________________________________________________________
171 void SAL_CALL OConnectionPointContainerHelper::unadvise( const Type& aType ,
172 const Reference< XInterface >& xListener ) throw( RuntimeException )
174 // Container is threadsafe himself !
175 m_aMultiTypeContainer.removeInterface( aType, xListener );
178 //______________________________________________________________________________________________________________
179 // public but impl method!
180 // Is neccessary to get container member at OConnectionPoint-instance.
181 //______________________________________________________________________________________________________________
183 OMultiTypeInterfaceContainerHelper& OConnectionPointContainerHelper::impl_getMultiTypeContainer()
185 // Impl methods are not threadsafe!
186 // "Parent" function must do this.
187 return m_aMultiTypeContainer;
190 } // namespace unocontrols