cid#1636693 COPY_INSTEAD_OF_MOVE
[LibreOffice.git] / include / comphelper / containermultiplexer.hxx
blob4c0b782be4341133f3ff96709e3178bd360aed59
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 <config_options.h>
24 #include <com/sun/star/container/XContainerListener.hpp>
25 #include <cppuhelper/implbase.hxx>
26 #include <comphelper/comphelperdllapi.h>
27 #include <rtl/ref.hxx>
29 namespace osl { class Mutex; }
30 namespace com::sun::star::container { class XContainer; }
33 namespace comphelper
37 class OContainerListenerAdapter;
39 //= OContainerListener
41 /** a non-UNO container listener
42 <p>Useful if you have a non-refcountable class which should act as container listener.<br/>
43 In this case, derive this class from OContainerListener, and create an adapter
44 OContainerListenerAdapter which multiplexes the changes.</p>
46 class UNLESS_MERGELIBS_MORE(COMPHELPER_DLLPUBLIC) OContainerListener
48 friend class OContainerListenerAdapter;
49 rtl::Reference<OContainerListenerAdapter> m_xAdapter;
50 ::osl::Mutex& m_rMutex;
52 public:
53 OContainerListener(::osl::Mutex& _rMutex);
54 virtual ~OContainerListener();
56 /// @throws css::uno::RuntimeException
57 virtual void _elementInserted( const css::container::ContainerEvent& _rEvent );
58 /// @throws css::uno::RuntimeException
59 virtual void _elementRemoved( const css::container::ContainerEvent& _rEvent );
60 /// @throws css::uno::RuntimeException
61 virtual void _elementReplaced( const css::container::ContainerEvent& _rEvent );
62 /// @throws css::uno::RuntimeException
63 virtual void _disposing(const css::lang::EventObject& _rSource);
65 protected:
66 void setAdapter(OContainerListenerAdapter* _pAdapter);
69 // workaround for incremental linking bugs in MSVC2015
70 class SAL_DLLPUBLIC_TEMPLATE OContainerListenerAdapter_Base : public cppu::WeakImplHelper< css::container::XContainerListener > {};
72 class UNLESS_MERGELIBS_MORE(COMPHELPER_DLLPUBLIC) OContainerListenerAdapter final : public OContainerListenerAdapter_Base
74 friend class OContainerListener;
76 private:
77 css::uno::Reference< css::container::XContainer >
78 m_xContainer;
79 OContainerListener* m_pListener;
81 virtual ~OContainerListenerAdapter() override;
83 public:
84 OContainerListenerAdapter(OContainerListener* _pListener,
85 const css::uno::Reference< css::container::XContainer >& _rxContainer);
87 // XEventListener
88 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
90 // XContainerListener
91 virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override;
92 virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override;
93 virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override;
95 /// dispose the object. No multiplexing anymore
96 void dispose();
101 } // namespace dbaui
104 #endif // INCLUDED_COMPHELPER_CONTAINERMULTIPLEXER_HXX
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */