summaryrefslogtreecommitdiff
path: root/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 /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 'svx')
-rw-r--r--svx/source/svdraw/svdobj.cxx6
-rw-r--r--svx/source/unodraw/shapepropertynotifier.cxx24
-rw-r--r--svx/source/unodraw/unoshape.cxx4
3 files changed, 17 insertions, 17 deletions
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() )