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 .
20 #ifndef INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
21 #define INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
23 #include <comphelper/propstate.hxx>
24 #include <cppuhelper/implbase.hxx>
25 #include <comphelper/comphelperdllapi.h>
28 //= property helper classes
35 class OPropertyChangeMultiplexer
;
38 //= OPropertyChangeListener
40 /// simple listener adapter for property sets
41 class COMPHELPER_DLLPUBLIC OPropertyChangeListener
43 friend class OPropertyChangeMultiplexer
;
45 OPropertyChangeMultiplexer
* m_pAdapter
;
46 ::osl::Mutex
& m_rMutex
;
49 OPropertyChangeListener(::osl::Mutex
& _rMutex
)
50 : m_pAdapter(nullptr), m_rMutex(_rMutex
) { }
51 virtual ~OPropertyChangeListener();
53 virtual void _propertyChanged(const css::beans::PropertyChangeEvent
& _rEvent
)
54 throw (css::uno::RuntimeException
, std::exception
) = 0;
55 virtual void _disposing(const css::lang::EventObject
& _rSource
)
56 throw( css::uno::RuntimeException
, std::exception
);
59 /** If the derivee also owns the mutex which we know as reference, then call this within your
62 void disposeAdapter();
64 // pseudo-private. Making it private now could break compatibility
65 void setAdapter( OPropertyChangeMultiplexer
* _pAdapter
);
69 //= OPropertyChangeMultiplexer
71 /// multiplexer for property changes
72 class COMPHELPER_DLLPUBLIC OPropertyChangeMultiplexer
:public cppu::WeakImplHelper
< css::beans::XPropertyChangeListener
>
74 friend class OPropertyChangeListener
;
75 std::vector
< OUString
> m_aProperties
;
76 css::uno::Reference
< css::beans::XPropertySet
> m_xSet
;
77 OPropertyChangeListener
* m_pListener
;
78 sal_Int32 m_nLockCount
;
79 bool m_bListening
: 1;
80 bool m_bAutoSetRelease
: 1;
83 virtual ~OPropertyChangeMultiplexer();
85 OPropertyChangeMultiplexer(OPropertyChangeListener
* _pListener
, const css::uno::Reference
< css::beans::XPropertySet
>& _rxSet
, bool _bAutoReleaseSet
= true);
88 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) throw( css::uno::RuntimeException
, std::exception
) override
;
90 // XPropertyChangeListener
91 virtual void SAL_CALL
propertyChange( const css::beans::PropertyChangeEvent
& evt
) throw( css::uno::RuntimeException
, std::exception
) override
;
95 /// incremental unlock
97 /// get the lock count
98 sal_Int32
locked() const { return m_nLockCount
; }
100 void addProperty(const OUString
& aPropertyName
);
105 } // namespace comphelper
108 #endif // INCLUDED_COMPHELPER_PROPMULTIPLEX_HXX
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */