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 <svx/svxdllapi.h>
24 #include <svx/shapeproperty.hxx>
26 #include <rtl/ustring.hxx>
27 
28 #include <memory>
29 #include <unordered_map>
30 
31 namespace com::sun::star::beans { class XPropertyChangeListener; }
32 namespace com::sun::star::uno { class Any; }
33 namespace com::sun::star::uno { template <typename > class Reference; }
34 namespace osl { class Mutex; }
35 
36 namespace cppu
37 {
38  class OWeakObject;
39 }
40 
41 
42 namespace svx
43 {
44 
45 
46  //= IPropertyValueProvider
47 
51  {
52  public:
55  virtual OUString getPropertyName() const = 0;
56 
59  virtual void getCurrentValue( css::uno::Any& _out_rValue ) const = 0;
60 
61  virtual ~IPropertyValueProvider();
62  };
63 
64  //= PropertyValueProvider
65 
72  {
73  public:
74  PropertyValueProvider( ::cppu::OWeakObject& _rContext, const char* _pAsciiPropertyName )
75  :m_rContext( _rContext )
76  ,m_sPropertyName( OUString::createFromAscii( _pAsciiPropertyName ) )
77  {
78  }
79 
80  virtual OUString getPropertyName() const override;
81  virtual void getCurrentValue( css::uno::Any& _out_rValue ) const override;
82 
83  protected:
86  PropertyValueProvider& operator=(const PropertyValueProvider&) = delete;
87 
88  private:
90  const OUString m_sPropertyName;
91  };
92 
93 
99  {
100  public:
107  PropertyChangeNotifier( ::cppu::OWeakObject& _rOwner, ::osl::Mutex& _rMutex );
109 
110  // listener maintenance
111  void addPropertyChangeListener( const OUString& _rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener );
112  void removePropertyChangeListener( const OUString& _rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& _rxListener );
113 
116  void registerProvider( const ShapeProperty _eProperty, const std::shared_ptr<IPropertyValueProvider>& _rProvider );
117 
123  void notifyPropertyChange( const ShapeProperty _eProperty ) const;
124 
127  void disposing();
128 
129  private:
131  PropertyChangeNotifier& operator=(const PropertyChangeNotifier&) = delete;
132 
134  {
135  size_t operator()( svx::ShapeProperty x ) const
136  {
137  return size_t( x );
138  }
139  };
140  typedef std::unordered_map< ShapeProperty, std::shared_ptr<IPropertyValueProvider>, ShapePropertyHash >
145  };
146 
147 
148 }
149 
150 
151 #endif // INCLUDED_SVX_SHAPEPROPERTYNOTIFIER_HXX
152 
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
default implementation of an IPropertyValueProvider
::cppu::OWeakObject & getContext() const
std::unordered_map< ShapeProperty, std::shared_ptr< IPropertyValueProvider >, ShapePropertyHash > PropertyProviders
a provider for a property value
Reference
const Reference< XComponentContext > & m_rContext
size_t operator()(svx::ShapeProperty x) const
comphelper::OMultiTypeInterfaceContainerHelperVar2< OUString > m_aPropertyChangeListeners
#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