Bump for 3.6-28
[LibreOffice.git] / UnoControls / source / controls / OConnectionPointContainerHelper.cxx
blobc5bd8cfce1e9d12f9669b407ac928fd3e57bc3f6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 //______________________________________________________________________________________________________________
30 // my own include
31 //______________________________________________________________________________________________________________
33 #include "OConnectionPointContainerHelper.hxx"
35 //______________________________________________________________________________________________________________
36 // includes of other projects
37 //______________________________________________________________________________________________________________
39 //______________________________________________________________________________________________________________
40 // include of my own project
41 //______________________________________________________________________________________________________________
42 #include "OConnectionPointHelper.hxx"
44 //______________________________________________________________________________________________________________
45 // namespaces
46 //______________________________________________________________________________________________________________
48 using namespace ::rtl ;
49 using namespace ::osl ;
50 using namespace ::cppu ;
51 using namespace ::com::sun::star::uno ;
52 using namespace ::com::sun::star::lang ;
54 namespace unocontrols{
56 //______________________________________________________________________________________________________________
57 // construct/destruct
58 //______________________________________________________________________________________________________________
60 OConnectionPointContainerHelper::OConnectionPointContainerHelper( Mutex& aMutex )
61 : m_aSharedMutex ( aMutex )
62 , m_aMultiTypeContainer ( aMutex )
66 OConnectionPointContainerHelper::~OConnectionPointContainerHelper()
70 //____________________________________________________________________________________________________________
71 // XInterface
72 //____________________________________________________________________________________________________________
74 Any SAL_CALL OConnectionPointContainerHelper::queryInterface( const Type& aType ) throw( RuntimeException )
76 // Attention:
77 // Don't use mutex or guard in this method!!! Is a method of XInterface.
79 // Ask for my own supported interfaces ...
80 Any aReturn ( ::cppu::queryInterface( aType ,
81 static_cast< XConnectionPointContainer* > ( this )
85 // If searched interface not supported by this class ...
86 if ( aReturn.hasValue() == sal_False )
88 // ... ask baseclasses.
89 aReturn = OWeakObject::queryInterface( aType );
92 return aReturn ;
95 //____________________________________________________________________________________________________________
96 // XInterface
97 //____________________________________________________________________________________________________________
99 void SAL_CALL OConnectionPointContainerHelper::acquire() throw()
101 // Attention:
102 // Don't use mutex or guard in this method!!! Is a method of XInterface.
104 // Forward to baseclass
105 OWeakObject::acquire();
108 //____________________________________________________________________________________________________________
109 // XInterface
110 //____________________________________________________________________________________________________________
112 void SAL_CALL OConnectionPointContainerHelper::release() throw()
114 // Attention:
115 // Don't use mutex or guard in this method!!! Is a method of XInterface.
117 // Forward to baseclass
118 OWeakObject::release();
121 //______________________________________________________________________________________________________________
122 // XConnectionPointContainer
123 //______________________________________________________________________________________________________________
125 Sequence< Type > SAL_CALL OConnectionPointContainerHelper::getConnectionPointTypes() throw( RuntimeException )
127 // Container is threadsafe himself !
128 return m_aMultiTypeContainer.getContainedTypes();
131 //______________________________________________________________________________________________________________
132 // XConnectionPointContainer
133 //______________________________________________________________________________________________________________
135 Reference< XConnectionPoint > SAL_CALL OConnectionPointContainerHelper::queryConnectionPoint( const Type& aType ) throw( RuntimeException )
137 // Set default return value, if method failed.
138 Reference< XConnectionPoint > xConnectionPoint = Reference< XConnectionPoint >();
140 // Get all elements of the container, which have the searched type.
141 OInterfaceContainerHelper* pSpecialContainer = m_aMultiTypeContainer.getContainer( aType );
142 if ( pSpecialContainer && pSpecialContainer->getLength() > 0 )
144 // Ready for multithreading
145 MutexGuard aGuard( m_aSharedMutex );
146 // If this container contains elements, build a connectionpoint-instance.
147 OConnectionPointHelper* pNewConnectionPoint = new OConnectionPointHelper( m_aSharedMutex, this, aType );
148 xConnectionPoint = Reference< XConnectionPoint >( (OWeakObject*)pNewConnectionPoint, UNO_QUERY );
151 return xConnectionPoint ;
154 //______________________________________________________________________________________________________________
155 // XConnectionPointContainer
156 //______________________________________________________________________________________________________________
158 void SAL_CALL OConnectionPointContainerHelper::advise( const Type& aType ,
159 const Reference< XInterface >& xListener ) throw( RuntimeException )
161 // Container is threadsafe himself !
162 m_aMultiTypeContainer.addInterface( aType, xListener );
165 //______________________________________________________________________________________________________________
166 // XConnectionPointContainer
167 //______________________________________________________________________________________________________________
169 void SAL_CALL OConnectionPointContainerHelper::unadvise( const Type& aType ,
170 const Reference< XInterface >& xListener ) throw( RuntimeException )
172 // Container is threadsafe himself !
173 m_aMultiTypeContainer.removeInterface( aType, xListener );
176 //______________________________________________________________________________________________________________
177 // public but impl method!
178 // Is neccessary to get container member at OConnectionPoint-instance.
179 //______________________________________________________________________________________________________________
181 OMultiTypeInterfaceContainerHelper& OConnectionPointContainerHelper::impl_getMultiTypeContainer()
183 // Impl methods are not threadsafe!
184 // "Parent" function must do this.
185 return m_aMultiTypeContainer;
188 } // namespace unocontrols
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */