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 
20 #ifndef INCLUDED_UNOCONTROLS_SOURCE_INC_OCONNECTIONPOINTHELPER_HXX
21 #define INCLUDED_UNOCONTROLS_SOURCE_INC_OCONNECTIONPOINTHELPER_HXX
22 
23 #include <com/sun/star/lang/XConnectionPoint.hpp>
24 #include <cppuhelper/weak.hxx>
25 #include <cppuhelper/weakref.hxx>
26 
27 namespace com::sun::star::lang { class XConnectionPointContainer; }
28 namespace unocontrols { class OConnectionPointContainerHelper; }
29 
30 namespace unocontrols {
31 
32 class OConnectionPointHelper    :   public  css::lang::XConnectionPoint
33                                 ,   public  ::cppu::OWeakObject
34 {
35 public:
36     OConnectionPointHelper( ::osl::Mutex&                       aMutex                      ,
37                             OConnectionPointContainerHelper*    pContainerImplementation    ,
38                             css::uno::Type const &              aType                       );
39 
40     virtual ~OConnectionPointHelper() override;
41 
42     //  XInterface
43 
44     /**
45         @short      give answer, if interface is supported
46         @descr      The interfaces are searched by type.
47 
48         @seealso    XInterface
49 
50         @param      "rType" is the type of searched interface.
51 
52         @return     Any     information about found interface
53 
54         @onerror    A RuntimeException is thrown.
55     */
56 
57     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
58 
59     /**
60         @short      increment refcount
61         @seealso    XInterface
62         @seealso    release()
63         @onerror    A RuntimeException is thrown.
64     */
65 
66     virtual void SAL_CALL acquire() throw() override;
67 
68     /**
69         @short      decrement refcount
70         @seealso    XInterface
71         @seealso    acquire()
72         @onerror    A RuntimeException is thrown.
73     */
74 
75     virtual void SAL_CALL release() throw() override;
76 
77     //  XConnectionPoint
78 
79     virtual css::uno::Type SAL_CALL getConnectionType() override;
80 
81     virtual css::uno::Reference< css::lang::XConnectionPointContainer > SAL_CALL getConnectionPointContainer() override;
82 
83     virtual void SAL_CALL advise(
84         const css::uno::Reference< css::uno::XInterface >& xListener
85     ) override;
86 
87     virtual void SAL_CALL unadvise( const css::uno::Reference< css::uno::XInterface >& xListener ) override;
88 
89     virtual css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > SAL_CALL getConnections() override;
90 
91 private:
92     bool impl_LockContainer();
93 
94     void impl_UnlockContainer();
95 
96 private:
97 
98     ::osl::Mutex&                                                     m_aSharedMutex;
99     css::uno::WeakReference< css::lang::XConnectionPointContainer >   m_oContainerWeakReference;   // Reference to container-class!. Don't use Reference<...>
100                                                                                             // It is a ring-reference => and must be a wekreference!
101     OConnectionPointContainerHelper*                                  m_pContainerImplementation;
102     css::uno::Type const                                                    m_aInterfaceType;
103     css::uno::Reference< css::uno::XInterface >                       m_xLock;
104 };
105 
106 }
107 
108 #endif // INCLUDED_UNOCONTROLS_SOURCE_INC_OCONNECTIONPOINTHELPER_HXX
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
111