sd/inc/stlsheet.hxx         |   12 +++++
 sd/source/core/stlsheet.cxx |  101 +++++++++++++++++++++++++++++++++++---------
 2 files changed, 94 insertions(+), 19 deletions(-)

New commits:
commit f234fe77a0070927b8ae2ba3309f63aa718624f5
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Aug 4 11:33:09 2021 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Aug 4 15:50:46 2021 +0200

    SdStyleSheet: implement XMultiPropertySet
    
    Reduces broadcast frequency
    
    Change-Id: I25f4281e792aa6bb42a11d3566e7d4e64e833f4a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119992
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sd/inc/stlsheet.hxx b/sd/inc/stlsheet.hxx
index 105eb4cd797a..645259e9e8fc 100644
--- a/sd/inc/stlsheet.hxx
+++ b/sd/inc/stlsheet.hxx
@@ -22,6 +22,7 @@
 #include <rtl/ref.hxx>
 
 #include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/beans/XPropertyState.hpp>
@@ -43,6 +44,7 @@ struct SfxItemPropertyMapEntry;
 
 typedef cppu::ImplInheritanceHelper< SfxUnoStyleSheet,
                                     css::beans::XPropertySet,
+                                    css::beans::XMultiPropertySet,
                                     css::lang::XServiceInfo,
                                     css::beans::XPropertyState,
                                     css::util::XModifyBroadcaster,
@@ -109,6 +111,13 @@ public:
     virtual void SAL_CALL addVetoableChangeListener( const OUString& 
PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& 
aListener ) override;
     virtual void SAL_CALL removeVetoableChangeListener( const OUString& 
PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& 
aListener ) override;
 
+    // XMultiPropertySet
+    virtual void SAL_CALL setPropertyValues(const 
css::uno::Sequence<OUString>& aPropertyNames, const 
css::uno::Sequence<css::uno::Any>& aValues) override;
+    virtual css::uno::Sequence<css::uno::Any> SAL_CALL getPropertyValues(const 
css::uno::Sequence<OUString>& aPropertyNames) override;
+    virtual void SAL_CALL addPropertiesChangeListener(const 
css::uno::Sequence<OUString>& aPropertyNames, const 
css::uno::Reference<css::beans::XPropertiesChangeListener>& xListener) override;
+    virtual void SAL_CALL removePropertiesChangeListener(const 
css::uno::Reference<css::beans::XPropertiesChangeListener>& xListener) override;
+    virtual void SAL_CALL firePropertiesChangeEvent(const 
css::uno::Sequence<OUString>& aPropertyNames, const 
css::uno::Reference<css::beans::XPropertiesChangeListener>& xListener) override;
+
     // XPropertyState
     virtual css::beans::PropertyState SAL_CALL getPropertyState( const 
OUString& PropertyName ) override;
     virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL 
getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) 
override;
@@ -130,6 +139,9 @@ private:
     /// @throws css::uno::RuntimeException
     static const SfxItemPropertyMapEntry* getPropertyMapEntry( 
std::u16string_view rPropertyName );
 
+    void setPropertyValue_Impl(const OUString& aPropertyName, const 
css::uno::Any& aValue);
+    css::uno::Any getPropertyValue_Impl(const OUString& PropertyName);
+
     virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
     virtual             ~SdStyleSheet() override;
 
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index 9f87290c52f2..533a9846557f 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -951,20 +951,12 @@ void SAL_CALL SdStyleSheet::setParentStyle( const 
OUString& rParentName  )
     }
 }
 
-// XPropertySet
+// XPropertySet/XMultiPropertySet utility functions
 
-Reference< XPropertySetInfo > SdStyleSheet::getPropertySetInfo()
-{
-    throwIfDisposed();
-    static Reference< XPropertySetInfo > xInfo = 
GetStylePropertySet().getPropertySetInfo();
-    return xInfo;
-}
-
-void SAL_CALL SdStyleSheet::setPropertyValue( const OUString& aPropertyName, 
const Any& aValue )
+// Does not broadcast
+// Must be guarded by solar mutex; must not be disposed
+void SdStyleSheet::setPropertyValue_Impl(const OUString& aPropertyName, const 
css::uno::Any& aValue)
 {
-    SolarMutexGuard aGuard;
-    throwIfDisposed();
-
     const SfxItemPropertyMapEntry* pEntry = getPropertyMapEntry( aPropertyName 
);
     if( pEntry == nullptr )
     {
@@ -1058,16 +1050,11 @@ void SAL_CALL SdStyleSheet::setPropertyValue( const 
OUString& aPropertyName, con
     }
 
     rStyleSet.Put( aSet );
-    Broadcast(SfxHint(SfxHintId::DataChanged));
-
 }
 
-Any SAL_CALL SdStyleSheet::getPropertyValue( const OUString& PropertyName )
+// Must be guarded by solar mutex; must not be disposed
+css::uno::Any SdStyleSheet::getPropertyValue_Impl(const OUString& PropertyName)
 {
-    SolarMutexGuard aGuard;
-
-    throwIfDisposed();
-
     const SfxItemPropertyMapEntry* pEntry = getPropertyMapEntry( PropertyName 
);
     if( pEntry == nullptr )
     {
@@ -1164,7 +1151,32 @@ Any SAL_CALL SdStyleSheet::getPropertyValue( const 
OUString& PropertyName )
     }
 
     return aAny;
+}
+
+// XPropertySet
+
+Reference< XPropertySetInfo > SdStyleSheet::getPropertySetInfo()
+{
+    throwIfDisposed();
+    static Reference< XPropertySetInfo > xInfo = 
GetStylePropertySet().getPropertySetInfo();
+    return xInfo;
+}
 
+void SAL_CALL SdStyleSheet::setPropertyValue( const OUString& aPropertyName, 
const Any& aValue )
+{
+    SolarMutexGuard aGuard;
+    throwIfDisposed();
+
+    setPropertyValue_Impl(aPropertyName, aValue);
+    Broadcast(SfxHint(SfxHintId::DataChanged));
+}
+
+Any SAL_CALL SdStyleSheet::getPropertyValue( const OUString& PropertyName )
+{
+    SolarMutexGuard aGuard;
+    throwIfDisposed();
+
+    return getPropertyValue_Impl(PropertyName);
 }
 
 void SAL_CALL SdStyleSheet::addPropertyChangeListener( const OUString& , const 
Reference< XPropertyChangeListener >&  ) {}
@@ -1172,6 +1184,57 @@ void SAL_CALL 
SdStyleSheet::removePropertyChangeListener( const OUString& , cons
 void SAL_CALL SdStyleSheet::addVetoableChangeListener( const OUString& , const 
Reference< XVetoableChangeListener >&  ) {}
 void SAL_CALL SdStyleSheet::removeVetoableChangeListener( const OUString& , 
const Reference< XVetoableChangeListener >&  ) {}
 
+// XMultiPropertySet
+
+void SAL_CALL SdStyleSheet::setPropertyValues(const 
css::uno::Sequence<OUString>& aPropertyNames,
+                                              const 
css::uno::Sequence<css::uno::Any>& aValues)
+{
+    const sal_Int32 nCount = aPropertyNames.getLength();
+
+    if (nCount != aValues.getLength())
+        throw css::lang::IllegalArgumentException();
+
+    if (!nCount)
+        return;
+
+    SolarMutexGuard aGuard;
+    throwIfDisposed();
+
+    for (sal_Int32 i = 0; i < nCount; ++i)
+    {
+        try
+        {
+            setPropertyValue_Impl(aPropertyNames[i], aValues[i]);
+        }
+        catch (const css::beans::UnknownPropertyException&)
+        {
+            DBG_UNHANDLED_EXCEPTION("sd");
+        }
+    }
+
+    Broadcast(SfxHint(SfxHintId::DataChanged));
+}
+
+css::uno::Sequence<css::uno::Any>
+SAL_CALL SdStyleSheet::getPropertyValues(const css::uno::Sequence<OUString>& 
aPropertyNames)
+{
+    SolarMutexGuard aGuard;
+    throwIfDisposed();
+
+    const sal_Int32 nCount = aPropertyNames.getLength();
+    css::uno::Sequence<css::uno::Any> aValues(nCount);
+    Any* pAny = aValues.getArray();
+
+    for (sal_Int32 i = 0; i < nCount; ++i)
+        pAny[i] = getPropertyValue_Impl(aPropertyNames[i]);
+
+    return aValues;
+}
+
+void SAL_CALL SdStyleSheet::addPropertiesChangeListener(const 
css::uno::Sequence<OUString>&, const 
css::uno::Reference<css::beans::XPropertiesChangeListener>&) {}
+void SAL_CALL SdStyleSheet::removePropertiesChangeListener(const 
css::uno::Reference<css::beans::XPropertiesChangeListener>&) {}
+void SAL_CALL SdStyleSheet::firePropertiesChangeEvent(const 
css::uno::Sequence<OUString>&, const 
css::uno::Reference<css::beans::XPropertiesChangeListener>&) {}
+
 // XPropertyState
 
 PropertyState SAL_CALL SdStyleSheet::getPropertyState( const OUString& 
PropertyName )

Reply via email to