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 
25 
26 // namespaces
27 
28 using namespace ::osl;
29 using namespace ::cppu;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::lang;
32 
33 namespace unocontrols {
34 
35 // construct/destruct
36 
38  : m_aSharedMutex ( aMutex )
39  , m_aMultiTypeContainer ( aMutex )
40 {
41 }
42 
44 {
45 }
46 
47 // XInterface
48 
50 {
51  // Attention:
52  // Don't use mutex or guard in this method!!! Is a method of XInterface.
53 
54  // Ask for my own supported interfaces ...
55  Any aReturn ( ::cppu::queryInterface( aType ,
56  static_cast< XConnectionPointContainer* > ( this )
57  )
58  );
59 
60  // If searched interface not supported by this class ...
61  if ( !aReturn.hasValue() )
62  {
63  // ... ask baseclasses.
64  aReturn = OWeakObject::queryInterface( aType );
65  }
66 
67  return aReturn;
68 }
69 
70 // XInterface
71 
73 {
74  // Attention:
75  // Don't use mutex or guard in this method!!! Is a method of XInterface.
76 
77  // Forward to baseclass
78  OWeakObject::acquire();
79 }
80 
81 // XInterface
82 
84 {
85  // Attention:
86  // Don't use mutex or guard in this method!!! Is a method of XInterface.
87 
88  // Forward to baseclass
89  OWeakObject::release();
90 }
91 
92 // XConnectionPointContainer
93 
95 {
96  // Container is threadsafe himself !
98 }
99 
100 // XConnectionPointContainer
101 
102 Reference< XConnectionPoint > SAL_CALL OConnectionPointContainerHelper::queryConnectionPoint( const Type& aType )
103 {
104  // Set default return value, if method failed.
105  Reference< XConnectionPoint > xConnectionPoint;
106 
107  // Get all elements of the container, which have the searched type.
108  OInterfaceContainerHelper* pSpecialContainer = m_aMultiTypeContainer.getContainer( aType );
109  if ( pSpecialContainer && pSpecialContainer->getLength() > 0 )
110  {
111  // Ready for multithreading
112  MutexGuard aGuard( m_aSharedMutex );
113  // If this container contains elements, build a connectionpoint-instance.
114  xConnectionPoint = new OConnectionPointHelper( m_aSharedMutex, this, aType );
115  }
116 
117  return xConnectionPoint;
118 }
119 
120 // XConnectionPointContainer
121 
122 void SAL_CALL OConnectionPointContainerHelper::advise( const Type& aType ,
123  const Reference< XInterface >& xListener )
124 {
125  // Container is threadsafe himself !
126  m_aMultiTypeContainer.addInterface( aType, xListener );
127 }
128 
129 // XConnectionPointContainer
130 
131 void SAL_CALL OConnectionPointContainerHelper::unadvise( const Type& aType ,
132  const Reference< XInterface >& xListener )
133 {
134  // Container is threadsafe himself !
135  m_aMultiTypeContainer.removeInterface( aType, xListener );
136 }
137 
138 } // namespace unocontrols
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type
sal_Int32 SAL_CALL removeInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
virtual void SAL_CALL advise(const css::uno::Type &aType, const css::uno::Reference< css::uno::XInterface > &xListener) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
give answer, if interface is supported The interfaces are searched by type.
virtual void SAL_CALL acquire() override
increment refcount XInterface release() A RuntimeException is thrown.
sal_Int32 SAL_CALL addInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &r)
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 css::uno::Reference< css::lang::XConnectionPoint > SAL_CALL queryConnectionPoint(const css::uno::Type &aType) override
::cppu::OMultiTypeInterfaceContainerHelper m_aMultiTypeContainer
css::uno::Sequence< css::uno::Type > SAL_CALL getContainedTypes() const
virtual void SAL_CALL release() override
decrement refcount XInterface acquire() A RuntimeException is thrown.
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
OInterfaceContainerHelper *SAL_CALL getContainer(const css::uno::Type &rKey) const