LibreOffice Module comphelper (master)  1
propmultiplex.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
21 #define INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
22 
23 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
24 #include <cppuhelper/implbase.hxx>
26 #include <rtl/ref.hxx>
27 #include <vector>
28 
29 namespace com::sun::star::beans { class XPropertySet; }
30 
31 //= property helper classes
32 
33 
34 namespace comphelper
35 {
36 
37 
38  class OPropertyChangeMultiplexer;
39 
40 
41  //= OPropertyChangeListener
42 
45  {
47 
49  ::osl::Mutex& m_rMutex;
50 
51  public:
52  OPropertyChangeListener(::osl::Mutex& _rMutex)
53  : m_rMutex(_rMutex) { }
54  virtual ~OPropertyChangeListener();
55 
57  virtual void _propertyChanged(const css::beans::PropertyChangeEvent& _rEvent) = 0;
59  virtual void _disposing(const css::lang::EventObject& _rSource);
60 
61  protected:
65  void disposeAdapter();
66 
67  // pseudo-private. Making it private now could break compatibility
68  void setAdapter( OPropertyChangeMultiplexer* _pAdapter );
69  };
70 
71 
72  //= OPropertyChangeMultiplexer
73 
75  class COMPHELPER_DLLPUBLIC OPropertyChangeMultiplexer :public cppu::WeakImplHelper< css::beans::XPropertyChangeListener>
76  {
78  std::vector< OUString > m_aProperties;
79  css::uno::Reference< css::beans::XPropertySet> m_xSet;
81  sal_Int32 m_nLockCount;
82  bool m_bListening : 1;
83  bool const m_bAutoSetRelease : 1;
84 
85 
86  virtual ~OPropertyChangeMultiplexer() override;
87  public:
88  OPropertyChangeMultiplexer(OPropertyChangeListener* _pListener, const css::uno::Reference< css::beans::XPropertySet>& _rxSet, bool _bAutoReleaseSet = true);
89 
90  // XEventListener
91  virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
92 
93  // XPropertyChangeListener
94  virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
95 
97  void lock();
99  void unlock();
101  sal_Int32 locked() const { return m_nLockCount; }
102 
103  void addProperty(const OUString& aPropertyName);
104  void dispose();
105  };
106 
107 
108 } // namespace comphelper
109 
110 
111 #endif // INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
112 
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::beans::XPropertySet > m_xSet
rtl::Reference< OPropertyChangeMultiplexer > m_xAdapter
OPropertyChangeListener(::osl::Mutex &_rMutex)
class SAL_NO_VTABLE XPropertySet
simple listener adapter for property sets
multiplexer for property changes
std::vector< OUString > m_aProperties
OPropertyChangeListener * m_pListener
sal_Int32 locked() const
get the lock count
#define COMPHELPER_DLLPUBLIC
void dispose()
std::shared_ptr< osl::Mutex > const & lock()