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