1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "OConnectionPointContainerHelper.hxx"
22 #include "OConnectionPointHelper.hxx"
24 //______________________________________________________________________________________________________________
26 //______________________________________________________________________________________________________________
28 using namespace ::rtl
;
29 using namespace ::osl
;
30 using namespace ::cppu
;
31 using namespace ::com::sun::star::uno
;
32 using namespace ::com::sun::star::lang
;
34 namespace unocontrols
{
36 //______________________________________________________________________________________________________________
38 //______________________________________________________________________________________________________________
40 OConnectionPointContainerHelper::OConnectionPointContainerHelper( Mutex
& aMutex
)
41 : m_aSharedMutex ( aMutex
)
42 , m_aMultiTypeContainer ( aMutex
)
46 OConnectionPointContainerHelper::~OConnectionPointContainerHelper()
50 //____________________________________________________________________________________________________________
52 //____________________________________________________________________________________________________________
54 Any SAL_CALL
OConnectionPointContainerHelper::queryInterface( const Type
& aType
) throw( RuntimeException
)
57 // Don't use mutex or guard in this method!!! Is a method of XInterface.
59 // Ask for my own supported interfaces ...
60 Any
aReturn ( ::cppu::queryInterface( aType
,
61 static_cast< XConnectionPointContainer
* > ( this )
65 // If searched interface not supported by this class ...
66 if ( aReturn
.hasValue() == sal_False
)
68 // ... ask baseclasses.
69 aReturn
= OWeakObject::queryInterface( aType
);
75 //____________________________________________________________________________________________________________
77 //____________________________________________________________________________________________________________
79 void SAL_CALL
OConnectionPointContainerHelper::acquire() throw()
82 // Don't use mutex or guard in this method!!! Is a method of XInterface.
84 // Forward to baseclass
85 OWeakObject::acquire();
88 //____________________________________________________________________________________________________________
90 //____________________________________________________________________________________________________________
92 void SAL_CALL
OConnectionPointContainerHelper::release() throw()
95 // Don't use mutex or guard in this method!!! Is a method of XInterface.
97 // Forward to baseclass
98 OWeakObject::release();
101 //______________________________________________________________________________________________________________
102 // XConnectionPointContainer
103 //______________________________________________________________________________________________________________
105 Sequence
< Type
> SAL_CALL
OConnectionPointContainerHelper::getConnectionPointTypes() throw( RuntimeException
)
107 // Container is threadsafe himself !
108 return m_aMultiTypeContainer
.getContainedTypes();
111 //______________________________________________________________________________________________________________
112 // XConnectionPointContainer
113 //______________________________________________________________________________________________________________
115 Reference
< XConnectionPoint
> SAL_CALL
OConnectionPointContainerHelper::queryConnectionPoint( const Type
& aType
) throw( RuntimeException
)
117 // Set default return value, if method failed.
118 Reference
< XConnectionPoint
> xConnectionPoint
= Reference
< XConnectionPoint
>();
120 // Get all elements of the container, which have the searched type.
121 OInterfaceContainerHelper
* pSpecialContainer
= m_aMultiTypeContainer
.getContainer( aType
);
122 if ( pSpecialContainer
&& pSpecialContainer
->getLength() > 0 )
124 // Ready for multithreading
125 MutexGuard
aGuard( m_aSharedMutex
);
126 // If this container contains elements, build a connectionpoint-instance.
127 OConnectionPointHelper
* pNewConnectionPoint
= new OConnectionPointHelper( m_aSharedMutex
, this, aType
);
128 xConnectionPoint
= Reference
< XConnectionPoint
>( (OWeakObject
*)pNewConnectionPoint
, UNO_QUERY
);
131 return xConnectionPoint
;
134 //______________________________________________________________________________________________________________
135 // XConnectionPointContainer
136 //______________________________________________________________________________________________________________
138 void SAL_CALL
OConnectionPointContainerHelper::advise( const Type
& aType
,
139 const Reference
< XInterface
>& xListener
) throw( RuntimeException
)
141 // Container is threadsafe himself !
142 m_aMultiTypeContainer
.addInterface( aType
, xListener
);
145 //______________________________________________________________________________________________________________
146 // XConnectionPointContainer
147 //______________________________________________________________________________________________________________
149 void SAL_CALL
OConnectionPointContainerHelper::unadvise( const Type
& aType
,
150 const Reference
< XInterface
>& xListener
) throw( RuntimeException
)
152 // Container is threadsafe himself !
153 m_aMultiTypeContainer
.removeInterface( aType
, xListener
);
156 //______________________________________________________________________________________________________________
157 // public but impl method!
158 // Is necessary to get container member at OConnectionPoint-instance.
159 //______________________________________________________________________________________________________________
161 OMultiTypeInterfaceContainerHelper
& OConnectionPointContainerHelper::impl_getMultiTypeContainer()
163 // Impl methods are not threadsafe!
164 // "Parent" function must do this.
165 return m_aMultiTypeContainer
;
168 } // namespace unocontrols
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */