Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / comphelper / containermultiplexer.hxx
blobdc3abc1d6148d40a38e4f4c1879651e07fad0bb6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef INCLUDED_COMPHELPER_CONTAINERMULTIPLEXER_HXX
21 #define INCLUDED_COMPHELPER_CONTAINERMULTIPLEXER_HXX
23 #include <com/sun/star/container/XContainerListener.hpp>
24 #include <cppuhelper/implbase.hxx>
25 #include <comphelper/comphelperdllapi.h>
26 #include <rtl/ref.hxx>
28 namespace osl { class Mutex; }
29 namespace com::sun::star::container { class XContainer; }
32 namespace comphelper
36 class OContainerListenerAdapter;
38 //= OContainerListener
40 /** a non-UNO container listener
41 <p>Useful if you have a non-refcountable class which should act as container listener.<br/>
42 In this case, derive this class from OContainerListener, and create an adapter
43 OContainerListenerAdapter which multiplexes the changes.</p>
45 class COMPHELPER_DLLPUBLIC OContainerListener
47 friend class OContainerListenerAdapter;
48 rtl::Reference<OContainerListenerAdapter> m_xAdapter;
49 ::osl::Mutex& m_rMutex;
51 public:
52 OContainerListener(::osl::Mutex& _rMutex);
53 virtual ~OContainerListener();
55 /// @throws css::uno::RuntimeException
56 virtual void _elementInserted( const css::container::ContainerEvent& _rEvent );
57 /// @throws css::uno::RuntimeException
58 virtual void _elementRemoved( const css::container::ContainerEvent& _rEvent );
59 /// @throws css::uno::RuntimeException
60 virtual void _elementReplaced( const css::container::ContainerEvent& _rEvent );
61 /// @throws css::uno::RuntimeException
62 virtual void _disposing(const css::lang::EventObject& _rSource);
64 protected:
65 void setAdapter(OContainerListenerAdapter* _pAdapter);
68 // workaround for incremental linking bugs in MSVC2015
69 class SAL_DLLPUBLIC_TEMPLATE OContainerListenerAdapter_Base : public cppu::WeakImplHelper< css::container::XContainerListener > {};
71 class COMPHELPER_DLLPUBLIC OContainerListenerAdapter final : public OContainerListenerAdapter_Base
73 friend class OContainerListener;
75 private:
76 css::uno::Reference< css::container::XContainer >
77 m_xContainer;
78 OContainerListener* m_pListener;
80 virtual ~OContainerListenerAdapter() override;
82 public:
83 OContainerListenerAdapter(OContainerListener* _pListener,
84 const css::uno::Reference< css::container::XContainer >& _rxContainer);
86 // XEventListener
87 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
89 // XContainerListener
90 virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override;
91 virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override;
92 virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override;
94 /// dispose the object. No multiplexing anymore
95 void dispose();
100 } // namespace dbaui
103 #endif // INCLUDED_COMPHELPER_CONTAINERMULTIPLEXER_HXX
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */