tdf#124953: Use rangelist's combined range top-left address...
[LibreOffice.git] / include / svx / shapepropertynotifier.hxx
blob818ad4bcaccaf23744b44915f64092500ec3fea4
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_SVX_SHAPEPROPERTYNOTIFIER_HXX
21 #define INCLUDED_SVX_SHAPEPROPERTYNOTIFIER_HXX
23 #include <svx/svxdllapi.h>
24 #include <svx/shapeproperty.hxx>
26 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
27 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
29 #include <memory>
31 namespace cppu
33 class OWeakObject;
37 namespace svx
41 //= IPropertyValueProvider
43 /** a provider for a property value
45 class SVX_DLLPUBLIC IPropertyValueProvider
47 public:
48 /** returns the name of the property which this provider is responsible for
50 virtual OUString getPropertyName() const = 0;
52 /** returns the current value of the property which the provider is responsible for
54 virtual void getCurrentValue( css::uno::Any& _out_rValue ) const = 0;
56 virtual ~IPropertyValueProvider();
59 //= PropertyValueProvider
61 /** default implementation of a IPropertyValueProvider
63 This default implementation queries the object which it is constructed with for the XPropertySet interface,
64 and calls the getPropertyValue method.
66 class SVX_DLLPUBLIC PropertyValueProvider :public IPropertyValueProvider
68 public:
69 PropertyValueProvider( ::cppu::OWeakObject& _rContext, const sal_Char* _pAsciiPropertyName )
70 :m_rContext( _rContext )
71 ,m_sPropertyName( OUString::createFromAscii( _pAsciiPropertyName ) )
75 virtual OUString getPropertyName() const override;
76 virtual void getCurrentValue( css::uno::Any& _out_rValue ) const override;
78 protected:
79 ::cppu::OWeakObject& getContext() const { return m_rContext; }
80 PropertyValueProvider(const PropertyValueProvider&) = delete;
81 PropertyValueProvider& operator=(const PropertyValueProvider&) = delete;
83 private:
84 ::cppu::OWeakObject& m_rContext;
85 const OUString m_sPropertyName;
89 //= PropertyChangeNotifier
91 struct PropertyChangeNotifier_Data;
93 /** helper class for notifying XPropertyChangeListeners
95 The class is intended to be held as member of the class which does the property change broadcasting.
97 class SVX_DLLPUBLIC PropertyChangeNotifier
99 public:
100 /** constructs a notifier instance
102 @param _rOwner
103 the owner instance of the notifier. Will be used as css.lang.EventObject.Source when
104 notifying events.
106 PropertyChangeNotifier( ::cppu::OWeakObject& _rOwner, ::osl::Mutex& _rMutex );
107 ~PropertyChangeNotifier();
109 // listener maintenance
110 void addPropertyChangeListener( const OUString& _rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener );
111 void removePropertyChangeListener( const OUString& _rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener );
113 /** registers a IPropertyValueProvider
115 void registerProvider( const ShapeProperty _eProperty, const std::shared_ptr<IPropertyValueProvider>& _rProvider );
117 /** notifies changes in the given property to all registered listeners
119 If no property value provider for the given property ID is registered, this is worth an assertion in a
120 non-product build, and otherwise ignored.
122 void notifyPropertyChange( const ShapeProperty _eProperty ) const;
124 /** is called to dispose the instance
126 void disposing();
128 private:
129 PropertyChangeNotifier(const PropertyChangeNotifier&) = delete;
130 PropertyChangeNotifier& operator=(const PropertyChangeNotifier&) = delete;
132 std::unique_ptr< PropertyChangeNotifier_Data > m_xData;
139 #endif // INCLUDED_SVX_SHAPEPROPERTYNOTIFIER_HXX
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */