[Libreoffice-commits] core.git: comphelper/source include/comphelper

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 4 16:02:04 UTC 2020


 comphelper/source/property/propertysethelper.cxx |   78 ++++++++---------------
 include/comphelper/propertysethelper.hxx         |    6 -
 2 files changed, 32 insertions(+), 52 deletions(-)

New commits:
commit 38b1497dded22a6e4176f103256b27d7f5917aba
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Wed Nov 4 07:21:15 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Nov 4 17:01:28 2020 +0100

    remove pimpl from PropertySetHelper
    
    Change-Id: I20e72b5927d64a69aacd3d4de117a7736d53eea4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105275
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/comphelper/source/property/propertysethelper.cxx b/comphelper/source/property/propertysethelper.cxx
index f397cdc13925..5f0f043987ee 100644
--- a/comphelper/source/property/propertysethelper.cxx
+++ b/comphelper/source/property/propertysethelper.cxx
@@ -30,36 +30,20 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::lang;
 
-namespace comphelper
-{
-class PropertySetHelperImpl
-{
-public:
-    PropertyMapEntry const * find( const OUString& aName ) const throw();
-
-    rtl::Reference<PropertySetInfo> mxInfo;
-};
-}
-
-PropertyMapEntry const * PropertySetHelperImpl::find( const OUString& aName ) const throw()
+static PropertyMapEntry const * find( rtl::Reference<PropertySetInfo>& mxInfo, const OUString& aName ) throw()
 {
     PropertyMap::const_iterator aIter = mxInfo->getPropertyMap().find( aName );
 
     if( mxInfo->getPropertyMap().end() != aIter )
-    {
         return (*aIter).second;
-    }
     else
-    {
         return nullptr;
-    }
 }
 
 
 PropertySetHelper::PropertySetHelper( rtl::Reference<comphelper::PropertySetInfo> const & xInfo ) throw()
-    : mpImpl(new PropertySetHelperImpl)
+    : mxInfo(xInfo)
 {
-    mpImpl->mxInfo = xInfo;
 }
 
 PropertySetHelper::~PropertySetHelper() throw()
@@ -69,13 +53,13 @@ PropertySetHelper::~PropertySetHelper() throw()
 // XPropertySet
 Reference< XPropertySetInfo > SAL_CALL PropertySetHelper::getPropertySetInfo(  )
 {
-    return mpImpl->mxInfo.get();
+    return mxInfo.get();
 }
 
 void SAL_CALL PropertySetHelper::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
 {
     PropertyMapEntry const * aEntries[2];
-    aEntries[0] = mpImpl->find( aPropertyName );
+    aEntries[0] = find( mxInfo, aPropertyName );
 
     if( nullptr == aEntries[0] )
         throw UnknownPropertyException( aPropertyName, static_cast< XPropertySet* >( this ) );
@@ -88,7 +72,7 @@ void SAL_CALL PropertySetHelper::setPropertyValue( const OUString& aPropertyName
 Any SAL_CALL PropertySetHelper::getPropertyValue( const OUString& PropertyName )
 {
     PropertyMapEntry const * aEntries[2];
-    aEntries[0] = mpImpl->find( PropertyName );
+    aEntries[0] = find( mxInfo, PropertyName );
 
     if( nullptr == aEntries[0] )
         throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) );
@@ -140,7 +124,7 @@ void SAL_CALL PropertySetHelper::setPropertyValues( const Sequence< OUString >&
     sal_Int32 n;
     for( n = 0; !bUnknown && ( n < nCount ); n++, pNames++ )
     {
-        pEntries[n] = mpImpl->find( *pNames );
+        pEntries[n] = find( mxInfo, *pNames );
         bUnknown = nullptr == pEntries[n];
     }
 
@@ -155,32 +139,30 @@ Sequence< Any > SAL_CALL PropertySetHelper::getPropertyValues(const Sequence< OU
 {
     const sal_Int32 nCount = rPropertyNames.getLength();
 
-    Sequence< Any > aValues;
-    if( nCount )
-    {
-        std::unique_ptr<PropertyMapEntry const *[]> pEntries(new PropertyMapEntry const *[nCount+1]);
-        pEntries[nCount] = nullptr;
-        const OUString* pNames = rPropertyNames.getConstArray();
-
-        bool bUnknown = false;
-        sal_Int32 n;
-        for( n = 0; !bUnknown && ( n < nCount ); n++, pNames++ )
-        {
-            pEntries[n] = mpImpl->find( *pNames );
-            bUnknown = nullptr == pEntries[n];
-        }
+    if( !nCount )
+        return Sequence< Any >();
 
-        if( !bUnknown )
-        {
-            aValues.realloc(nCount);
-            _getPropertyValues( pEntries.get(), aValues.getArray() );
-        }
+    std::unique_ptr<PropertyMapEntry const *[]> pEntries(new PropertyMapEntry const *[nCount+1]);
+    const OUString* pNames = rPropertyNames.getConstArray();
 
-        if( bUnknown )
-            throw RuntimeException( *pNames, static_cast< XPropertySet* >( this ) );
+    bool bUnknown = false;
+    sal_Int32 n;
+    for( n = 0; !bUnknown && ( n < nCount ); n++, pNames++ )
+    {
+        pEntries[n] = find( mxInfo, *pNames );
+        bUnknown = nullptr == pEntries[n];
     }
 
-    return aValues;
+    if( !bUnknown )
+    {
+        pEntries[nCount] = nullptr;
+        Sequence< Any > aValues(nCount);
+        aValues.realloc(nCount);
+        _getPropertyValues( pEntries.get(), aValues.getArray() );
+        return aValues;
+    }
+    else
+        throw RuntimeException( *pNames, static_cast< XPropertySet* >( this ) );
 }
 
 void SAL_CALL PropertySetHelper::addPropertiesChangeListener( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& )
@@ -203,7 +185,7 @@ PropertyState SAL_CALL PropertySetHelper::getPropertyState( const OUString& Prop
 {
     PropertyMapEntry const * aEntries[2];
 
-    aEntries[0] = mpImpl->find( PropertyName );
+    aEntries[0] = find( mxInfo, PropertyName );
     if( aEntries[0] == nullptr )
         throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) );
 
@@ -232,7 +214,7 @@ Sequence< PropertyState > SAL_CALL PropertySetHelper::getPropertyStates( const S
         sal_Int32 n;
         for( n = 0; !bUnknown && (n < nCount); n++, pNames++ )
         {
-            pEntries[n] = mpImpl->find( *pNames );
+            pEntries[n] = find( mxInfo, *pNames );
             bUnknown = nullptr == pEntries[n];
         }
 
@@ -250,7 +232,7 @@ Sequence< PropertyState > SAL_CALL PropertySetHelper::getPropertyStates( const S
 
 void SAL_CALL PropertySetHelper::setPropertyToDefault( const OUString& PropertyName )
 {
-    PropertyMapEntry const *pEntry  = mpImpl->find( PropertyName );
+    PropertyMapEntry const *pEntry  = find(mxInfo, PropertyName );
     if( nullptr == pEntry )
         throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) );
 
@@ -259,7 +241,7 @@ void SAL_CALL PropertySetHelper::setPropertyToDefault( const OUString& PropertyN
 
 Any SAL_CALL PropertySetHelper::getPropertyDefault( const OUString& aPropertyName )
 {
-    PropertyMapEntry const * pEntry = mpImpl->find( aPropertyName );
+    PropertyMapEntry const * pEntry = find(mxInfo, aPropertyName );
     if( nullptr == pEntry )
         throw UnknownPropertyException( aPropertyName, static_cast< XPropertySet* >( this ) );
 
diff --git a/include/comphelper/propertysethelper.hxx b/include/comphelper/propertysethelper.hxx
index 763a0b91b0a7..9c348b50c7c1 100644
--- a/include/comphelper/propertysethelper.hxx
+++ b/include/comphelper/propertysethelper.hxx
@@ -24,22 +24,20 @@
 #include <com/sun/star/beans/XPropertyState.hpp>
 #include <com/sun/star/beans/XMultiPropertySet.hpp>
 #include <comphelper/comphelperdllapi.h>
+#include <rtl/ref.hxx>
 #include <memory>
 
-namespace rtl { template <class reference_type> class Reference; }
-
 namespace comphelper
 {
 class PropertySetInfo;
 struct PropertyMapEntry;
-class PropertySetHelperImpl;
 
 class COMPHELPER_DLLPUBLIC PropertySetHelper : public css::beans::XPropertySet,
                           public css::beans::XPropertyState,
                           public css::beans::XMultiPropertySet
 {
 private:
-    std::unique_ptr<PropertySetHelperImpl> mpImpl;
+    rtl::Reference<PropertySetInfo> mxInfo;
 
 protected:
     /// @throws css::beans::UnknownPropertyException


More information about the Libreoffice-commits mailing list