bump product version to 4.2.0.1
[LibreOffice.git] / include / comphelper / containermultiplexer.hxx
blob3ae623f8013fe88873e10d5cb488edb71395f38f
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/XContainer.hpp>
24 #include <cppuhelper/implbase1.hxx>
25 #include <osl/mutex.hxx>
26 #include <comphelper/comphelperdllapi.h>
28 //.........................................................................
29 namespace comphelper
31 //.........................................................................
33 class OContainerListenerAdapter;
34 //=====================================================================
35 //= OContainerListener
36 //=====================================================================
37 /** a non-UNO container listener
38 <p>Useful if you have a non-refcountable class which should act as container listener.<br/>
39 In this case, derive this class from OContainerListener, and create an adapter
40 OContainerListenerAdapter which multiplexes the changes.</p>
42 class COMPHELPER_DLLPUBLIC OContainerListener
44 friend class OContainerListenerAdapter;
45 protected:
46 OContainerListenerAdapter* m_pAdapter;
47 ::osl::Mutex& m_rMutex;
49 public:
50 OContainerListener(::osl::Mutex& _rMutex);
51 virtual ~OContainerListener();
53 virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
54 virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent& _Event ) throw(::com::sun::star::uno::RuntimeException);
55 virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
56 virtual void _disposing(const ::com::sun::star::lang::EventObject& _rSource) throw( ::com::sun::star::uno::RuntimeException);
58 protected:
59 void setAdapter(OContainerListenerAdapter* _pAdapter);
62 //=====================================================================
63 //= OContainerListenerAdapter
64 //=====================================================================
65 class COMPHELPER_DLLPUBLIC OContainerListenerAdapter
66 :public cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener >
68 friend class OContainerListener;
70 protected:
71 ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >
72 m_xContainer;
73 OContainerListener* m_pListener;
74 sal_Int32 m_nLockCount;
76 virtual ~OContainerListenerAdapter();
78 public:
79 OContainerListenerAdapter(OContainerListener* _pListener,
80 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _rxContainer);
82 // XEventListener
83 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException);
85 // XContainerListener
86 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
87 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
88 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
90 // locking the multiplexer
91 sal_Int32 locked() const { return m_nLockCount; }
93 /// dispose the object. No multiplexing anymore
94 void dispose();
96 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >&
97 getContainer() const { return m_xContainer; }
100 //.........................................................................
101 } // namespace dbaui
102 //.........................................................................
104 #endif // INCLUDED_COMPHELPER_CONTAINERMULTIPLEXER_HXX
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */