LibreOffice Module svx (master)  1
shapepropertynotifier.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_SVX_SHAPEPROPERTYNOTIFIER_HXX
21 #define INCLUDED_SVX_SHAPEPROPERTYNOTIFIER_HXX
22 
23 #include <config_options.h>
24 #include <svx/svxdllapi.h>
25 #include <svx/shapeproperty.hxx>
26 #include <rtl/ustring.hxx>
27 
28 #include <memory>
29 
30 namespace com::sun::star::beans { class XPropertyChangeListener; }
31 namespace com::sun::star::uno { class Any; }
32 namespace com::sun::star::uno { template <typename > class Reference; }
33 namespace osl { class Mutex; }
34 
35 namespace cppu
36 {
37  class OWeakObject;
38 }
39 
40 
41 namespace svx
42 {
43 
44 
45  //= IPropertyValueProvider
46 
50  {
51  public:
54  virtual OUString getPropertyName() const = 0;
55 
58  virtual void getCurrentValue( css::uno::Any& _out_rValue ) const = 0;
59 
60  virtual ~IPropertyValueProvider();
61  };
62 
63  //= PropertyValueProvider
64 
71  {
72  public:
73  PropertyValueProvider( ::cppu::OWeakObject& _rContext, const char* _pAsciiPropertyName )
74  :m_rContext( _rContext )
75  ,m_sPropertyName( OUString::createFromAscii( _pAsciiPropertyName ) )
76  {
77  }
78 
79  virtual OUString getPropertyName() const override;
80  virtual void getCurrentValue( css::uno::Any& _out_rValue ) const override;
81 
82  protected:
85  PropertyValueProvider& operator=(const PropertyValueProvider&) = delete;
86 
87  private:
89  const OUString m_sPropertyName;
90  };
91 
92 
93  //= PropertyChangeNotifier
94 
96 
102  {
103  public:
110  PropertyChangeNotifier( ::cppu::OWeakObject& _rOwner, ::osl::Mutex& _rMutex );
112 
113  // listener maintenance
114  void addPropertyChangeListener( const OUString& _rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener );
115  void removePropertyChangeListener( const OUString& _rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener );
116 
119  void registerProvider( const ShapeProperty _eProperty, const std::shared_ptr<IPropertyValueProvider>& _rProvider );
120 
126  void notifyPropertyChange( const ShapeProperty _eProperty ) const;
127 
130  void disposing();
131 
132  private:
134  PropertyChangeNotifier& operator=(const PropertyChangeNotifier&) = delete;
135 
136  std::unique_ptr< PropertyChangeNotifier_Data > m_xData;
137  };
138 
139 
140 }
141 
142 
143 #endif // INCLUDED_SVX_SHAPEPROPERTYNOTIFIER_HXX
144 
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
default implementation of an IPropertyValueProvider
::cppu::OWeakObject & getContext() const
a provider for a property value
Reference
const Reference< XComponentContext > & m_rContext
std::unique_ptr< PropertyChangeNotifier_Data > m_xData
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
OUString getPropertyName(sal_Int32 nPropertyType)
PropertyValueProvider(::cppu::OWeakObject &_rContext, const char *_pAsciiPropertyName)
::cppu::OWeakObject & m_rContext
helper class for notifying XPropertyChangeListeners