1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
22 #include <cppuhelper/implbase.hxx>
23 #include <comphelper/comphelperdllapi.h>
24 #include <rtl/ref.hxx>
28 namespace com::sun::star::beans
33 //= property helper classes
37 class OPropertyChangeMultiplexer2
;
39 //= OPropertyChangeListener
41 /// simple listener adapter for property sets
42 class COMPHELPER_DLLPUBLIC OPropertyChangeListener2
44 friend class OPropertyChangeMultiplexer2
;
46 rtl::Reference
<OPropertyChangeMultiplexer2
> m_xAdapter
;
49 virtual ~OPropertyChangeListener2();
51 /// @throws css::uno::RuntimeException
52 virtual void _propertyChanged(const css::beans::PropertyChangeEvent
& _rEvent
) = 0;
55 /** If the derivee also owns the mutex which we know as reference, then call this within your
58 void disposeAdapter(std::unique_lock
<std::mutex
>& rGuard
);
61 void setAdapter(std::unique_lock
<std::mutex
>& rGuard
, OPropertyChangeMultiplexer2
* _pAdapter
);
64 //= OPropertyChangeMultiplexer2
65 // A copy of OPropertyChangeMultiplexer except that it uses std::mutex instead osl::Mutex
67 /// multiplexer for property changes
68 // workaround for incremental linking bugs in MSVC2019
69 class SAL_DLLPUBLIC_TEMPLATE OPropertyChangeMultiplexer_Base2
70 : public cppu::WeakImplHelper
<css::beans::XPropertyChangeListener
>
73 class COMPHELPER_DLLPUBLIC OPropertyChangeMultiplexer2 final
74 : public OPropertyChangeMultiplexer_Base2
76 friend class OPropertyChangeListener2
;
78 std::vector
<OUString
> m_aProperties
;
79 css::uno::Reference
<css::beans::XPropertySet
> m_xSet
;
80 OPropertyChangeListener2
* m_pListener
;
81 sal_Int32 m_nLockCount
;
82 bool m_bListening
: 1;
83 bool const m_bAutoSetRelease
: 1;
85 void onListenerDestruction();
86 virtual ~OPropertyChangeMultiplexer2() override
;
89 OPropertyChangeMultiplexer2(std::mutex
& rMutex
, std::unique_lock
<std::mutex
>& rGuard
,
90 OPropertyChangeListener2
* _pListener
,
91 const css::uno::Reference
<css::beans::XPropertySet
>& _rxSet
,
92 bool _bAutoReleaseSet
= true);
95 virtual void SAL_CALL
disposing(const css::lang::EventObject
& Source
) override
;
97 // XPropertyChangeListener
98 virtual void SAL_CALL
propertyChange(const css::beans::PropertyChangeEvent
& evt
) override
;
102 /// incremental unlock
104 /// get the lock count
105 sal_Int32
locked() const { return m_nLockCount
; }
107 void addProperty(const OUString
& aPropertyName
);
108 void dispose(std::unique_lock
<std::mutex
>& rGuard
);
111 } // namespace comphelper
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */