bump product version to 4.2.0.1
[LibreOffice.git] / include / comphelper / propmultiplex.hxx
blob02799f9ab049e71ca365585c7e50e436551108e7
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_PROPMULTIPLEX_HXX
21 #define INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
23 #include <comphelper/propstate.hxx>
24 #include <cppuhelper/implbase1.hxx>
25 #include <comphelper/comphelperdllapi.h>
27 //=========================================================================
28 //= property helper classes
29 //=========================================================================
31 //.........................................................................
32 namespace comphelper
34 //.........................................................................
36 class OPropertyChangeMultiplexer;
38 //==================================================================
39 //= OPropertyChangeListener
40 //==================================================================
41 /// simple listener adapter for property sets
42 class COMPHELPER_DLLPUBLIC OPropertyChangeListener
44 friend class OPropertyChangeMultiplexer;
46 OPropertyChangeMultiplexer* m_pAdapter;
47 ::osl::Mutex& m_rMutex;
49 public:
50 OPropertyChangeListener(::osl::Mutex& _rMutex)
51 : m_pAdapter(NULL), m_rMutex(_rMutex) { }
52 virtual ~OPropertyChangeListener();
54 virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException) = 0;
55 virtual void _disposing(const ::com::sun::star::lang::EventObject& _rSource) throw( ::com::sun::star::uno::RuntimeException);
57 protected:
58 /** If the derivee also owns the mutex which we know as reference, then call this within your
59 derivee's dtor.
61 void disposeAdapter();
63 // pseudo-private. Making it private now could break compatibility
64 void setAdapter( OPropertyChangeMultiplexer* _pAdapter );
67 //==================================================================
68 //= OPropertyChangeMultiplexer
69 //==================================================================
70 /// multiplexer for property changes
71 class COMPHELPER_DLLPUBLIC OPropertyChangeMultiplexer :public cppu::WeakImplHelper1< ::com::sun::star::beans::XPropertyChangeListener>
73 friend class OPropertyChangeListener;
74 ::com::sun::star::uno::Sequence< OUString > m_aProperties;
75 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xSet;
76 OPropertyChangeListener* m_pListener;
77 sal_Int32 m_nLockCount;
78 sal_Bool m_bListening : 1;
79 sal_Bool m_bAutoSetRelease : 1;
82 virtual ~OPropertyChangeMultiplexer();
83 public:
84 OPropertyChangeMultiplexer(OPropertyChangeListener* _pListener, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxSet, sal_Bool _bAutoReleaseSet = sal_True);
86 // XEventListener
87 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException);
89 // XPropertyChangeListener
90 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);
92 /// incremental lock
93 void lock();
94 /// incremental unlock
95 void unlock();
96 /// get the lock count
97 sal_Int32 locked() const { return m_nLockCount; }
99 void addProperty(const OUString& aPropertyName);
100 void dispose();
103 //.........................................................................
104 } // namespace comphelper
105 //.........................................................................
107 #endif // INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */