LibreOffice Module comphelper (master) 1
propmultiplex2.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#pragma once
20
21#include <com/sun/star/beans/XPropertyChangeListener.hpp>
24#include <rtl/ref.hxx>
25#include <mutex>
26#include <vector>
27
29{
30class XPropertySet;
31}
32
33//= property helper classes
34
35namespace comphelper
36{
37class OPropertyChangeMultiplexer2;
38
39//= OPropertyChangeListener
40
43{
45
47
48public:
50
52 virtual void _propertyChanged(const css::beans::PropertyChangeEvent& _rEvent) = 0;
53
54protected:
58 void disposeAdapter(std::unique_lock<std::mutex>& rGuard);
59
60private:
61 void setAdapter(std::unique_lock<std::mutex>& rGuard, OPropertyChangeMultiplexer2* _pAdapter);
62};
63
64//= OPropertyChangeMultiplexer2
65// A copy of OPropertyChangeMultiplexer except that it uses std::mutex instead osl::Mutex
66
68// workaround for incremental linking bugs in MSVC2019
69class SAL_DLLPUBLIC_TEMPLATE OPropertyChangeMultiplexer_Base2
70 : public cppu::WeakImplHelper<css::beans::XPropertyChangeListener>
71{
72};
75{
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
84 void onListenerDestruction();
85 virtual ~OPropertyChangeMultiplexer2() override;
86
87public:
88 OPropertyChangeMultiplexer2(std::mutex& rMutex, std::unique_lock<std::mutex>& rGuard,
89 OPropertyChangeListener2* _pListener,
90 const css::uno::Reference<css::beans::XPropertySet>& _rxSet);
91
92 // XEventListener
93 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
94
95 // XPropertyChangeListener
96 virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override;
97
99 void lock();
101 void unlock();
103 sal_Int32 locked() const { return m_nLockCount; }
104
105 void addProperty(const OUString& aPropertyName);
106 void dispose(std::unique_lock<std::mutex>& rGuard);
107};
108
109} // namespace comphelper
110
111/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
simple listener adapter for property sets
virtual void _propertyChanged(const css::beans::PropertyChangeEvent &_rEvent)=0
rtl::Reference< OPropertyChangeMultiplexer2 > m_xAdapter
sal_Int32 locked() const
get the lock count
css::uno::Reference< css::beans::XPropertySet > m_xSet
OPropertyChangeListener2 * m_pListener
multiplexer for property changes
#define COMPHELPER_DLLPUBLIC
class SAL_NO_VTABLE XPropertySet
std::shared_ptr< osl::Mutex > const & lock()
void dispose()
std::mutex mutex
Definition: random.cxx:41