basctl/inc/pch/precompiled_basctl.hxx          |    1 
 chart2/inc/pch/precompiled_chartcontroller.hxx |    1 
 chart2/inc/pch/precompiled_chartcore.hxx       |    1 
 cui/inc/pch/precompiled_cui.hxx                |    1 
 include/svx/shapeproperty.hxx                  |   42 -------------------------
 include/svx/shapepropertynotifier.hxx          |   32 ++++++++++---------
 include/svx/svdobj.hxx                         |    4 +-
 reportdesign/inc/pch/precompiled_rpt.hxx       |    1 
 reportdesign/inc/pch/precompiled_rptui.hxx     |    1 
 sd/inc/pch/precompiled_sdui.hxx                |    1 
 slideshow/inc/pch/precompiled_slideshow.hxx    |    1 
 solenv/clang-format/excludelist                |    1 
 svx/source/svdraw/svdobj.cxx                   |    6 +--
 svx/source/unodraw/shapepropertynotifier.cxx   |   24 +++++++-------
 svx/source/unodraw/unoshape.cxx                |    4 +-
 sw/inc/pch/precompiled_msword.hxx              |    1 
 sw/source/core/draw/dcontact.cxx               |    3 +
 sw/source/core/unocore/unodraw.cxx             |    2 -
 18 files changed, 39 insertions(+), 88 deletions(-)

New commits:
commit 01b3187e0713243c8f71d58197da17ee87c4dbb5
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Feb 10 16:19:46 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Feb 11 05:51:50 2022 +0100

    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.gran...@collabora.co.uk>

diff --git a/basctl/inc/pch/precompiled_basctl.hxx 
b/basctl/inc/pch/precompiled_basctl.hxx
index 27df0e92feae..ede9aaa5bbe8 100644
--- a/basctl/inc/pch/precompiled_basctl.hxx
+++ b/basctl/inc/pch/precompiled_basctl.hxx
@@ -466,7 +466,6 @@
 #include <svx/sdtaitm.hxx>
 #include <svx/sdtakitm.hxx>
 #include <svx/selectioncontroller.hxx>
-#include <svx/shapeproperty.hxx>
 #include <svx/svddef.hxx>
 #include <svx/svddrag.hxx>
 #include <svx/svddrgv.hxx>
diff --git a/chart2/inc/pch/precompiled_chartcontroller.hxx 
b/chart2/inc/pch/precompiled_chartcontroller.hxx
index cf16b908db70..b2559c3f9769 100644
--- a/chart2/inc/pch/precompiled_chartcontroller.hxx
+++ b/chart2/inc/pch/precompiled_chartcontroller.hxx
@@ -385,7 +385,6 @@
 #include <svx/sdtaitm.hxx>
 #include <svx/sdtakitm.hxx>
 #include <svx/selectioncontroller.hxx>
-#include <svx/shapeproperty.hxx>
 #include <svx/svddef.hxx>
 #include <svx/svddrag.hxx>
 #include <svx/svdedtv.hxx>
diff --git a/chart2/inc/pch/precompiled_chartcore.hxx 
b/chart2/inc/pch/precompiled_chartcore.hxx
index dd06c9bc8a90..f64e26fa63a7 100644
--- a/chart2/inc/pch/precompiled_chartcore.hxx
+++ b/chart2/inc/pch/precompiled_chartcore.hxx
@@ -241,7 +241,6 @@
 #include <svl/typedwhich.hxx>
 #include <svl/zforlist.hxx>
 #include <svx/DiagramDataInterface.hxx>
-#include <svx/shapeproperty.hxx>
 #include <svx/svdobj.hxx>
 #include <svx/svdobjkind.hxx>
 #include <svx/svdtypes.hxx>
diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx
index ddc40646e39d..ccdae65d1562 100644
--- a/cui/inc/pch/precompiled_cui.hxx
+++ b/cui/inc/pch/precompiled_cui.hxx
@@ -369,7 +369,6 @@
 #include <svx/sdtaitm.hxx>
 #include <svx/sdtakitm.hxx>
 #include <svx/sdynitm.hxx>
-#include <svx/shapeproperty.hxx>
 #include <svx/svddef.hxx>
 #include <svx/svddrag.hxx>
 #include <svx/svdedtv.hxx>
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
diff --git a/reportdesign/inc/pch/precompiled_rpt.hxx 
b/reportdesign/inc/pch/precompiled_rpt.hxx
index 57b8af3d1663..6f744ed1e3e4 100644
--- a/reportdesign/inc/pch/precompiled_rpt.hxx
+++ b/reportdesign/inc/pch/precompiled_rpt.hxx
@@ -252,7 +252,6 @@
 #include <svx/sdtaditm.hxx>
 #include <svx/sdtaitm.hxx>
 #include <svx/sdtakitm.hxx>
-#include <svx/shapeproperty.hxx>
 #include <svx/svddef.hxx>
 #include <svx/svdoattr.hxx>
 #include <svx/svdobj.hxx>
diff --git a/reportdesign/inc/pch/precompiled_rptui.hxx 
b/reportdesign/inc/pch/precompiled_rptui.hxx
index e3bf1419e116..4fef73243d89 100644
--- a/reportdesign/inc/pch/precompiled_rptui.hxx
+++ b/reportdesign/inc/pch/precompiled_rptui.hxx
@@ -379,7 +379,6 @@
 #include <svx/sdtaitm.hxx>
 #include <svx/sdtakitm.hxx>
 #include <svx/selectioncontroller.hxx>
-#include <svx/shapeproperty.hxx>
 #include <svx/svdcrtv.hxx>
 #include <svx/svddef.hxx>
 #include <svx/svddrag.hxx>
diff --git a/sd/inc/pch/precompiled_sdui.hxx b/sd/inc/pch/precompiled_sdui.hxx
index e74c431750c0..2eed698130b6 100644
--- a/sd/inc/pch/precompiled_sdui.hxx
+++ b/sd/inc/pch/precompiled_sdui.hxx
@@ -408,7 +408,6 @@
 #include <svx/sdtaitm.hxx>
 #include <svx/sdtakitm.hxx>
 #include <svx/selectioncontroller.hxx>
-#include <svx/shapeproperty.hxx>
 #include <svx/svdcrtv.hxx>
 #include <svx/svddef.hxx>
 #include <svx/svddrag.hxx>
diff --git a/slideshow/inc/pch/precompiled_slideshow.hxx 
b/slideshow/inc/pch/precompiled_slideshow.hxx
index d7501ea148cc..7670b0c95443 100644
--- a/slideshow/inc/pch/precompiled_slideshow.hxx
+++ b/slideshow/inc/pch/precompiled_slideshow.hxx
@@ -285,7 +285,6 @@
 #include <svx/sdtaditm.hxx>
 #include <svx/sdtaitm.hxx>
 #include <svx/sdtakitm.hxx>
-#include <svx/shapeproperty.hxx>
 #include <svx/svddef.hxx>
 #include <svx/svdglue.hxx>
 #include <svx/svdoattr.hxx>
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index d68935f908c1..5f8f5ec71d1c 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -5992,7 +5992,6 @@ include/svx/sdtfsitm.hxx
 include/svx/sdynitm.hxx
 include/svx/searchcharmap.hxx
 include/svx/selectioncontroller.hxx
-include/svx/shapeproperty.hxx
 include/svx/shapepropertynotifier.hxx
 include/svx/sidebar/AreaPropertyPanelBase.hxx
 include/svx/sidebar/ContextChangeEventMultiplexer.hxx
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index bc8ee3fdf848..cdae6b949c43 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -2795,10 +2795,10 @@ void SdrObject::SendUserCall(SdrUserCallType eUserCall, 
const tools::Rectangle&
     switch ( eUserCall )
     {
     case SdrUserCallType::Resize:
-        notifyShapePropertyChange( svx::ShapeProperty::Size );
+        notifyShapePropertyChange( svx::ShapePropertyProviderId::Size );
         [[fallthrough]]; // RESIZE might also imply a change of the position
     case SdrUserCallType::MoveOnly:
-        notifyShapePropertyChange( svx::ShapeProperty::Position );
+        notifyShapePropertyChange( svx::ShapePropertyProviderId::Position );
         break;
     default:
         // not interested in
@@ -2962,7 +2962,7 @@ svx::PropertyChangeNotifier& 
SdrObject::getShapePropertyChangeNotifier()
     return pSvxShape->getShapePropertyChangeNotifier();
 }
 
-void SdrObject::notifyShapePropertyChange( const svx::ShapeProperty _eProperty 
) const
+void SdrObject::notifyShapePropertyChange( const svx::ShapePropertyProviderId 
_eProperty ) const
 {
     DBG_TESTSOLARMUTEX();
 
diff --git a/svx/source/unodraw/shapepropertynotifier.cxx 
b/svx/source/unodraw/shapepropertynotifier.cxx
index 6b2262e044f1..7d1ca70c50ec 100644
--- a/svx/source/unodraw/shapepropertynotifier.cxx
+++ b/svx/source/unodraw/shapepropertynotifier.cxx
@@ -54,7 +54,7 @@ namespace svx
     //= PropertyValueProvider
 
 
-    OUString PropertyValueProvider::getPropertyName() const
+    const OUString & PropertyValueProvider::getPropertyName() const
     {
         return m_sPropertyName;
     }
@@ -76,24 +76,24 @@ namespace svx
     {
     }
 
-    void PropertyChangeNotifier::registerProvider(const ShapeProperty 
_eProperty, std::unique_ptr<IPropertyValueProvider> _rProvider)
+    void PropertyChangeNotifier::registerProvider(const 
ShapePropertyProviderId _eProperty, std::unique_ptr<IPropertyValueProvider> 
_rProvider)
     {
-        ENSURE_OR_THROW( !!_rProvider, "NULL factory not allowed." );
+        assert( _rProvider && "NULL factory not allowed." );
 
-        OSL_ENSURE( m_aProviders.find( _eProperty ) == m_aProviders.end(),
+        assert( ! m_aProviders[_eProperty] &&
             "PropertyChangeNotifier::registerProvider: factory for this ID 
already present!" );
 
-        m_aProviders.emplace( _eProperty, std::move(_rProvider));
+        m_aProviders[ _eProperty ] = std::move(_rProvider);
     }
 
-    void PropertyChangeNotifier::notifyPropertyChange( const ShapeProperty 
_eProperty ) const
+    void PropertyChangeNotifier::notifyPropertyChange( const 
ShapePropertyProviderId _eProperty ) const
     {
-        PropertyProviders::const_iterator provPos = m_aProviders.find( 
_eProperty );
-        OSL_ENSURE( provPos != m_aProviders.end(), 
"PropertyChangeNotifier::notifyPropertyChange: no factory!" );
-        if ( provPos == m_aProviders.end() )
+        auto & provPos = m_aProviders[ _eProperty ];
+        OSL_ENSURE( provPos, "PropertyChangeNotifier::notifyPropertyChange: no 
factory!" );
+        if (!provPos)
             return;
 
-        OUString sPropertyName( provPos->second->getPropertyName() );
+        const OUString & sPropertyName( provPos->getPropertyName() );
 
         ::comphelper::OInterfaceContainerHelper3<XPropertyChangeListener>* 
pPropListeners = m_aPropertyChangeListeners.getContainer( sPropertyName );
         ::comphelper::OInterfaceContainerHelper3<XPropertyChangeListener>* 
pAllListeners = m_aPropertyChangeListeners.getContainer( OUString() );
@@ -105,8 +105,8 @@ namespace svx
             PropertyChangeEvent aEvent;
             aEvent.Source = m_rContext;
             // Handle/OldValue not supported
-            aEvent.PropertyName = provPos->second->getPropertyName();
-            provPos->second->getCurrentValue( aEvent.NewValue );
+            aEvent.PropertyName = provPos->getPropertyName();
+            provPos->getCurrentValue( aEvent.NewValue );
 
             if ( pPropListeners )
                 pPropListeners->notifyEach( 
&XPropertyChangeListener::propertyChange, aEvent );
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index cb0aa12afd9a..66547561b020 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -324,9 +324,9 @@ svx::PropertyChangeNotifier& 
SvxShape::getShapePropertyChangeNotifier()
 
 void SvxShape::impl_construct()
 {
-    mpImpl->maPropertyNotifier.registerProvider( svx::ShapeProperty::Position,
+    mpImpl->maPropertyNotifier.registerProvider( 
svx::ShapePropertyProviderId::Position,
         std::make_unique<ShapePositionProvider>( *mpImpl ) );
-    mpImpl->maPropertyNotifier.registerProvider( svx::ShapeProperty::Size,
+    mpImpl->maPropertyNotifier.registerProvider( 
svx::ShapePropertyProviderId::Size,
         std::make_unique<ShapeSizeProvider>( *mpImpl ) );
 
     if ( HasSdrObject() )
diff --git a/sw/inc/pch/precompiled_msword.hxx 
b/sw/inc/pch/precompiled_msword.hxx
index 285828858c8b..035af3ef0359 100644
--- a/sw/inc/pch/precompiled_msword.hxx
+++ b/sw/inc/pch/precompiled_msword.hxx
@@ -447,7 +447,6 @@
 #include <svx/sdtaitm.hxx>
 #include <svx/sdtakitm.hxx>
 #include <svx/selectioncontroller.hxx>
-#include <svx/shapeproperty.hxx>
 #include <svx/svddef.hxx>
 #include <svx/svddrag.hxx>
 #include <svx/svdedtv.hxx>
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index d8a9ef322924..563bb61737a6 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -28,6 +28,7 @@
 #include <svx/svdview.hxx>
 #include <svx/sdr/contact/displayinfo.hxx>
 #include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/shapepropertynotifier.hxx>
 #include <drawdoc.hxx>
 #include <fmtornt.hxx>
 #include <viewimp.hxx>
@@ -1456,7 +1457,7 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
                         {
                             // --> #i102752#
                             // assure that a ShapePropertyChangeNotifier exists
-                            
maAnchoredDrawObj.DrawObj()->notifyShapePropertyChange(svx::ShapeProperty::TextDocAnchor);
+                            
maAnchoredDrawObj.DrawObj()->notifyShapePropertyChange(svx::ShapePropertyProviderId::TextDocAnchor);
                         }
                         else
                             SAL_WARN("sw.core", "SwDrawContact::Modify: no 
draw object here?");
diff --git a/sw/source/core/unocore/unodraw.cxx 
b/sw/source/core/unocore/unodraw.cxx
index 31efe7812410..4253e5e90b60 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -866,7 +866,7 @@ namespace
     void lcl_addShapePropertyEventFactories( SdrObject& _rObj, SwXShape& 
_rShape )
     {
         auto pProvider = std::make_unique<svx::PropertyValueProvider>( 
_rShape, "AnchorType" );
-        _rObj.getShapePropertyChangeNotifier().registerProvider( 
svx::ShapeProperty::TextDocAnchor, std::move(pProvider) );
+        _rObj.getShapePropertyChangeNotifier().registerProvider( 
svx::ShapePropertyProviderId::TextDocAnchor, std::move(pProvider) );
     }
 }
 

Reply via email to