summaryrefslogtreecommitdiff
path: root/include/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-02-10 16:19:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-02-11 05:51:50 +0100
commit01b3187e0713243c8f71d58197da17ee87c4dbb5 (patch)
treebbeba0cb2323f37c430470d2b5c2c8f68daae19f /include/svx
parent59460f4e02cc312062d76a8fc315800129bb9219 (diff)
svx::PropertyChangeNotifier improvements
(*) rename the enum to make it's purpose more obvious (*) remove the enum header - it belongs to this class, no need to have it somewhere else (*) return property name by const&, no need to copy here (*) use a o3tl::enumarray instead of a std::unordered_map - there are only 3 entries here, and two of them are ALWAYS used, so just flatten the data structure. Change-Id: Ic496bd5220d55be1209a3243c095d461df0a02ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129788 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/svx')
-rw-r--r--include/svx/shapeproperty.hxx42
-rw-r--r--include/svx/shapepropertynotifier.hxx32
-rw-r--r--include/svx/svdobj.hxx4
3 files changed, 19 insertions, 59 deletions
diff --git a/include/svx/shapeproperty.hxx b/include/svx/shapeproperty.hxx
deleted file mode 100644
index bb0011199447..000000000000
--- a/include/svx/shapeproperty.hxx
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_SVX_SHAPEPROPERTY_HXX
-#define INCLUDED_SVX_SHAPEPROPERTY_HXX
-
-
-namespace svx
-{
-
- //= ShapeProperty
-
- enum class ShapeProperty
- {
- // generic (UNO) shape properties
- Position,
- Size,
- // text doc shape properties
- TextDocAnchor
- };
-
-}
-
-#endif // INCLUDED_SVX_SHAPEPROPERTY_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/shapepropertynotifier.hxx b/include/svx/shapepropertynotifier.hxx
index 779eb66e9485..e736545b5ad8 100644
--- a/include/svx/shapepropertynotifier.hxx
+++ b/include/svx/shapepropertynotifier.hxx
@@ -21,9 +21,9 @@
#define INCLUDED_SVX_SHAPEPROPERTYNOTIFIER_HXX
#include <svx/svxdllapi.h>
-#include <svx/shapeproperty.hxx>
#include <comphelper/multiinterfacecontainer3.hxx>
#include <rtl/ustring.hxx>
+#include <o3tl/enumarray.hxx>
#include <memory>
#include <unordered_map>
@@ -42,6 +42,17 @@ namespace cppu
namespace svx
{
+ //= ShapeProperty
+
+ enum class ShapePropertyProviderId
+ {
+ // generic (UNO) shape properties
+ Position,
+ Size,
+ // text doc shape properties
+ TextDocAnchor,
+ LAST = TextDocAnchor
+ };
//= IPropertyValueProvider
@@ -52,7 +63,7 @@ namespace svx
public:
/** returns the name of the property which this provider is responsible for
*/
- virtual OUString getPropertyName() const = 0;
+ virtual const OUString & getPropertyName() const = 0;
/** returns the current value of the property which the provider is responsible for
*/
@@ -77,7 +88,7 @@ namespace svx
{
}
- virtual OUString getPropertyName() const override;
+ virtual const OUString & getPropertyName() const override;
virtual void getCurrentValue( css::uno::Any& _out_rValue ) const override;
protected:
@@ -113,14 +124,14 @@ namespace svx
/** registers an IPropertyValueProvider
*/
- void registerProvider( const ShapeProperty _eProperty, std::unique_ptr<IPropertyValueProvider> _rProvider );
+ void registerProvider( const ShapePropertyProviderId _eProperty, std::unique_ptr<IPropertyValueProvider> _rProvider );
/** notifies changes in the given property to all registered listeners
If no property value provider for the given property ID is registered, this is worth an assertion in a
non-product build, and otherwise ignored.
*/
- void notifyPropertyChange( const ShapeProperty _eProperty ) const;
+ void notifyPropertyChange( const ShapePropertyProviderId _eProperty ) const;
/** is called to dispose the instance
*/
@@ -130,17 +141,8 @@ namespace svx
PropertyChangeNotifier(const PropertyChangeNotifier&) = delete;
PropertyChangeNotifier& operator=(const PropertyChangeNotifier&) = delete;
- struct ShapePropertyHash
- {
- size_t operator()( svx::ShapeProperty x ) const
- {
- return size_t( x );
- }
- };
- typedef std::unordered_map< ShapeProperty, std::unique_ptr<IPropertyValueProvider>, ShapePropertyHash >
- PropertyProviders;
::cppu::OWeakObject& m_rContext;
- PropertyProviders m_aProviders;
+ o3tl::enumarray<ShapePropertyProviderId, std::unique_ptr<IPropertyValueProvider>> m_aProviders;
comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XPropertyChangeListener, OUString> m_aPropertyChangeListeners;
};
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 55e62cec4e13..ebcad8a002b4 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -31,7 +31,6 @@
#include <svx/svdtypes.hxx>
#include <svx/svdobjkind.hxx>
#include <svx/svxdllapi.h>
-#include <svx/shapeproperty.hxx>
#include <tools/link.hxx>
#include <tools/weakbase.h>
#include <tools/gen.hxx>
@@ -75,6 +74,7 @@ class Fraction;
enum class PointerStyle;
class Graphic;
class SvxShape;
+namespace svx { enum class ShapePropertyProviderId; }
namespace basegfx
{
@@ -787,7 +787,7 @@ public:
// This method is equivalent to calling getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty ),
// exception that it is allowed to be called when there does not yet exist an associated SvxShape - in which
// case the method will silently return without doing anything.
- void notifyShapePropertyChange( const svx::ShapeProperty _eProperty ) const;
+ void notifyShapePropertyChange( const svx::ShapePropertyProviderId _eProperty ) const;
// transformation interface for StarOfficeAPI. This implements support for
// homogen 3x3 matrices containing the transformation of the SdrObject. At the