LibreOffice Module UnoControls (master) 1
OConnectionPointContainerHelper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21
23
26
27// namespaces
28
29using namespace ::osl;
30using namespace ::cppu;
31using namespace ::com::sun::star::uno;
32using namespace ::com::sun::star::lang;
33
34namespace unocontrols {
35
36// construct/destruct
37
39 : m_aSharedMutex ( aMutex )
40 , m_aMultiTypeContainer ( aMutex )
41{
42}
43
45{
46}
47
48// XInterface
49
51{
52 // Attention:
53 // Don't use mutex or guard in this method!!! Is a method of XInterface.
54
55 // Ask for my own supported interfaces ...
56 Any aReturn ( ::cppu::queryInterface( aType ,
57 static_cast< XConnectionPointContainer* > ( this )
58 )
59 );
60
61 // If searched interface not supported by this class ...
62 if ( !aReturn.hasValue() )
63 {
64 // ... ask baseclasses.
65 aReturn = OWeakObject::queryInterface( aType );
66 }
67
68 return aReturn;
69}
70
71// XInterface
72
74{
75 // Attention:
76 // Don't use mutex or guard in this method!!! Is a method of XInterface.
77
78 // Forward to baseclass
79 OWeakObject::acquire();
80}
81
82// XInterface
83
85{
86 // Attention:
87 // Don't use mutex or guard in this method!!! Is a method of XInterface.
88
89 // Forward to baseclass
90 OWeakObject::release();
91}
92
93// XConnectionPointContainer
94
96{
97 // Container is threadsafe himself !
99}
100
101// XConnectionPointContainer
102
103Reference< XConnectionPoint > SAL_CALL OConnectionPointContainerHelper::queryConnectionPoint( const Type& aType )
104{
105 // Set default return value, if method failed.
106 Reference< XConnectionPoint > xConnectionPoint;
107
108 // Get all elements of the container, which have the searched type.
110 if ( pSpecialContainer && pSpecialContainer->getLength() > 0 )
111 {
112 // Ready for multithreading
113 MutexGuard aGuard( m_aSharedMutex );
114 // If this container contains elements, build a connectionpoint-instance.
115 xConnectionPoint = new OConnectionPointHelper( m_aSharedMutex, this, aType );
116 }
117
118 return xConnectionPoint;
119}
120
121// XConnectionPointContainer
122
124 const Reference< XInterface >& xListener )
125{
126 // Container is threadsafe himself !
127 m_aMultiTypeContainer.addInterface( aType, xListener );
128}
129
130// XConnectionPointContainer
131
133 const Reference< XInterface >& xListener )
134{
135 // Container is threadsafe himself !
136 m_aMultiTypeContainer.removeInterface( aType, xListener );
137}
138
139} // namespace unocontrols
140
141/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OInterfaceContainerHelper2 * getContainer(const css::uno::Type &rKey) const
sal_Int32 removeInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
sal_Int32 addInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &r)
std::vector< css::uno::Type > getContainedTypes() const
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
give answer, if interface is supported @descr The interfaces are searched by type.
virtual void SAL_CALL release() noexcept override
decrement refcount @seealso XInterface @seealso acquire() @onerror A RuntimeException is thrown.
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getConnectionPointTypes() override
virtual void SAL_CALL unadvise(const css::uno::Type &aType, const css::uno::Reference< css::uno::XInterface > &xListener) override
virtual void SAL_CALL advise(const css::uno::Type &aType, const css::uno::Reference< css::uno::XInterface > &xListener) override
virtual void SAL_CALL acquire() noexcept override
increment refcount @seealso XInterface @seealso release() @onerror A RuntimeException is thrown.
comphelper::OMultiTypeInterfaceContainerHelper2 m_aMultiTypeContainer
virtual css::uno::Reference< css::lang::XConnectionPoint > SAL_CALL queryConnectionPoint(const css::uno::Type &aType) override
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Type
std::mutex aMutex