[Libreoffice-commits] core.git: comphelper/source include/comphelper include/svx sd/source starmath/source svtools/source svx/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Jun 12 06:36:42 UTC 2017


 comphelper/source/property/propertysethelper.cxx |   20 ++++++--------------
 include/comphelper/propertysethelper.hxx         |    4 ++--
 include/svx/unoprov.hxx                          |    2 +-
 sd/source/ui/unoidl/UnoDocumentSettings.cxx      |    8 ++++----
 starmath/source/unomodel.cxx                     |    5 ++---
 svtools/source/graphic/descriptor.cxx            |   12 +++---------
 svtools/source/graphic/descriptor.hxx            |    2 +-
 svtools/source/graphic/renderer.cxx              |   12 +++---------
 svtools/source/uno/unoimap.cxx                   |   10 +++++-----
 svx/source/unodraw/unoprov.cxx                   |   10 +++-------
 svx/source/unogallery/unogalitem.cxx             |   10 ++--------
 svx/source/unogallery/unogalitem.hxx             |    2 +-
 12 files changed, 33 insertions(+), 64 deletions(-)

New commits:
commit d4eabd5da8ea3b5ac40659c22cde19b26b3c002b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Jun 9 14:35:25 2017 +0200

    pass comphelper::PropertySetInfo around using rtl::Reference
    
    and remove some manual ref counting
    
    Change-Id: Ib78122fbbf914e87e0aef1f8fffe3952639e5b22
    Reviewed-on: https://gerrit.libreoffice.org/38607
    Tested-by: Jenkins <ci at libreoffice.org>
    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 5005fb626653..b9405ab555bf 100644
--- a/comphelper/source/property/propertysethelper.cxx
+++ b/comphelper/source/property/propertysethelper.cxx
@@ -36,15 +36,15 @@ class PropertySetHelperImpl
 public:
     PropertyMapEntry const * find( const OUString& aName ) const throw();
 
-    PropertySetInfo* mpInfo;
+    rtl::Reference<PropertySetInfo> mxInfo;
 };
 }
 
 PropertyMapEntry const * PropertySetHelperImpl::find( const OUString& aName ) const throw()
 {
-    PropertyMap::const_iterator aIter = mpInfo->getPropertyMap().find( aName );
+    PropertyMap::const_iterator aIter = mxInfo->getPropertyMap().find( aName );
 
-    if( mpInfo->getPropertyMap().end() != aIter )
+    if( mxInfo->getPropertyMap().end() != aIter )
     {
         return (*aIter).second;
     }
@@ -55,28 +55,20 @@ PropertyMapEntry const * PropertySetHelperImpl::find( const OUString& aName ) co
 }
 
 
-PropertySetHelper::PropertySetHelper( comphelper::PropertySetInfo* pInfo ) throw()
+PropertySetHelper::PropertySetHelper( rtl::Reference<comphelper::PropertySetInfo> const & xInfo ) throw()
     : mpImpl(new PropertySetHelperImpl)
 {
-    mpImpl->mpInfo = pInfo;
-    pInfo->acquire();
-}
-
-PropertySetHelper::PropertySetHelper( comphelper::PropertySetInfo* pInfo, __sal_NoAcquire ) throw()
-    : mpImpl(new PropertySetHelperImpl)
-{
-    mpImpl->mpInfo = pInfo;
+    mpImpl->mxInfo = xInfo;
 }
 
 PropertySetHelper::~PropertySetHelper() throw()
 {
-    mpImpl->mpInfo->release();
 }
 
 // XPropertySet
 Reference< XPropertySetInfo > SAL_CALL PropertySetHelper::getPropertySetInfo(  )
 {
-    return mpImpl->mpInfo;
+    return mpImpl->mxInfo.get();
 }
 
 void SAL_CALL PropertySetHelper::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
diff --git a/include/comphelper/propertysethelper.hxx b/include/comphelper/propertysethelper.hxx
index f9f150cfaa9d..a7ce8870bdab 100644
--- a/include/comphelper/propertysethelper.hxx
+++ b/include/comphelper/propertysethelper.hxx
@@ -24,6 +24,7 @@
 #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 comphelper
@@ -63,8 +64,7 @@ protected:
     virtual css::uno::Any _getPropertyDefault( const comphelper::PropertyMapEntry* pEntry );
 
 public:
-    PropertySetHelper( comphelper::PropertySetInfo* pInfo ) throw();
-    PropertySetHelper( comphelper::PropertySetInfo* pInfo, __sal_NoAcquire ) throw();
+    PropertySetHelper( rtl::Reference<comphelper::PropertySetInfo> const & xInfo ) throw();
     virtual ~PropertySetHelper() throw();
 
     // XPropertySet
diff --git a/include/svx/unoprov.hxx b/include/svx/unoprov.hxx
index 38a593092498..7d2651c6bfd8 100644
--- a/include/svx/unoprov.hxx
+++ b/include/svx/unoprov.hxx
@@ -114,7 +114,7 @@ namespace comphelper { class PropertySetInfo; }
 class SvxPropertySetInfoPool
 {
 public:
-    SVX_DLLPUBLIC static comphelper::PropertySetInfo* getOrCreate( sal_Int32 nServiceId ) throw();
+    SVX_DLLPUBLIC static rtl::Reference<comphelper::PropertySetInfo> const & getOrCreate( sal_Int32 nServiceId ) throw();
 
 private:
     static rtl::Reference<comphelper::PropertySetInfo> mxInfos[SVXUNO_SERVICEID_LASTID+1];
diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
index 4368ba73d672..da16dd12c53e 100644
--- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx
+++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
@@ -143,7 +143,7 @@ enum SdDocumentSettingsPropertyHandles
 
 #define MID_PRINTER 1
 
-    PropertySetInfo * createSettingsInfoImpl( bool bIsDraw )
+    rtl::Reference<PropertySetInfo> createSettingsInfoImpl( bool bIsDraw )
     {
         static PropertyMapEntry const aImpressSettingsInfoMap[] =
         {
@@ -204,10 +204,10 @@ enum SdDocumentSettingsPropertyHandles
             { OUString(), 0, css::uno::Type(), 0, 0 }
         };
 
-        PropertySetInfo* pInfo = new PropertySetInfo( aCommonSettingsInfoMap );
-        pInfo->add( bIsDraw ? aDrawSettingsInfoMap : aImpressSettingsInfoMap );
+        rtl::Reference<PropertySetInfo> xInfo = new PropertySetInfo( aCommonSettingsInfoMap );
+        xInfo->add( bIsDraw ? aDrawSettingsInfoMap : aImpressSettingsInfoMap );
 
-        return pInfo;
+        return xInfo;
     }
 }
 
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 31ba947b106e..5b2fbf89f60b 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -226,7 +226,7 @@ enum SmModelPropertyHandles
     HANDLE_INTEROP_GRAB_BAG,
 };
 
-static PropertySetInfo * lcl_createModelPropertyInfo ()
+static rtl::Reference<PropertySetInfo> lcl_createModelPropertyInfo ()
 {
     static PropertyMapEntry aModelPropertyInfoMap[] =
     {
@@ -300,8 +300,7 @@ static PropertySetInfo * lcl_createModelPropertyInfo ()
         { OUString("InteropGrabBag")                   , HANDLE_INTEROP_GRAB_BAG                   ,  cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(),       PROPERTY_NONE,  0                     },
         { OUString(), 0, css::uno::Type(), 0, 0 }
     };
-    PropertySetInfo *pInfo = new PropertySetInfo ( aModelPropertyInfoMap );
-    return pInfo;
+    return rtl::Reference<PropertySetInfo>( new PropertySetInfo ( aModelPropertyInfoMap ) );
 }
 
 SmModel::SmModel( SfxObjectShell *pObjSh )
diff --git a/svtools/source/graphic/descriptor.cxx b/svtools/source/graphic/descriptor.cxx
index 8bba24751935..ed47c6e3822b 100644
--- a/svtools/source/graphic/descriptor.cxx
+++ b/svtools/source/graphic/descriptor.cxx
@@ -55,7 +55,7 @@ namespace unographic {
 
 
 GraphicDescriptor::GraphicDescriptor() :
-    ::comphelper::PropertySetHelper( createPropertySetInfo(), SAL_NO_ACQUIRE ),
+    ::comphelper::PropertySetHelper( createPropertySetInfo() ),
     mpGraphic( nullptr ),
     meType( GraphicType::NONE ),
     mnBitsPerPixel ( 0 ),
@@ -232,11 +232,8 @@ uno::Sequence< sal_Int8 > SAL_CALL GraphicDescriptor::getImplementationId()
 }
 
 
-::comphelper::PropertySetInfo* GraphicDescriptor::createPropertySetInfo()
+rtl::Reference<::comphelper::PropertySetInfo> GraphicDescriptor::createPropertySetInfo()
 {
-    SolarMutexGuard aGuard;
-    ::comphelper::PropertySetInfo*  pRet = new ::comphelper::PropertySetInfo();
-
     static ::comphelper::PropertyMapEntry const aEntries[] =
     {
         { OUString( "GraphicType" ), static_cast< sal_Int32 >( UnoGraphicProperty::GraphicType ), cppu::UnoType< sal_Int8 >::get(), beans::PropertyAttribute::READONLY, 0 },
@@ -250,10 +247,7 @@ uno::Sequence< sal_Int8 > SAL_CALL GraphicDescriptor::getImplementationId()
         { OUString(), 0, css::uno::Type(), 0, 0 }
     };
 
-    pRet->acquire();
-    pRet->add( aEntries );
-
-    return pRet;
+    return rtl::Reference<::comphelper::PropertySetInfo>( new ::comphelper::PropertySetInfo(aEntries) );
 }
 
 
diff --git a/svtools/source/graphic/descriptor.hxx b/svtools/source/graphic/descriptor.hxx
index 8c1c352b64fd..d831d17ab8d1 100644
--- a/svtools/source/graphic/descriptor.hxx
+++ b/svtools/source/graphic/descriptor.hxx
@@ -77,7 +77,7 @@ public:
 
 protected:
 
-    static ::comphelper::PropertySetInfo* createPropertySetInfo();
+    static rtl::Reference<::comphelper::PropertySetInfo> createPropertySetInfo();
 
     // XInterface
     virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) override;
diff --git a/svtools/source/graphic/renderer.cxx b/svtools/source/graphic/renderer.cxx
index 1db2117506df..262d97387717 100644
--- a/svtools/source/graphic/renderer.cxx
+++ b/svtools/source/graphic/renderer.cxx
@@ -53,7 +53,7 @@ class GraphicRendererVCL : public ::cppu::OWeakAggObject,
                            public ::comphelper::PropertySetHelper,
                            public css::graphic::XGraphicRenderer
 {
-    static ::comphelper::PropertySetInfo* createPropertySetInfo();
+    static rtl::Reference<::comphelper::PropertySetInfo> createPropertySetInfo();
 
 public:
 
@@ -179,11 +179,8 @@ uno::Sequence< sal_Int8 > SAL_CALL GraphicRendererVCL::getImplementationId()
 }
 
 
-::comphelper::PropertySetInfo* GraphicRendererVCL::createPropertySetInfo()
+rtl::Reference<::comphelper::PropertySetInfo> GraphicRendererVCL::createPropertySetInfo()
 {
-    SolarMutexGuard aGuard;
-    ::comphelper::PropertySetInfo*  pRet = new ::comphelper::PropertySetInfo();
-
     static ::comphelper::PropertyMapEntry const aEntries[] =
     {
         { OUString("Device"), UNOGRAPHIC_DEVICE, cppu::UnoType<uno::Any>::get(), 0, 0 },
@@ -192,10 +189,7 @@ uno::Sequence< sal_Int8 > SAL_CALL GraphicRendererVCL::getImplementationId()
         { OUString(), 0, css::uno::Type(), 0, 0 }
     };
 
-    pRet->acquire();
-    pRet->add( aEntries );
-
-    return pRet;
+    return rtl::Reference<::comphelper::PropertySetInfo>( new ::comphelper::PropertySetInfo(aEntries) );
 }
 
 
diff --git a/svtools/source/uno/unoimap.cxx b/svtools/source/uno/unoimap.cxx
index 388b6240cb82..a99ca91662d7 100644
--- a/svtools/source/uno/unoimap.cxx
+++ b/svtools/source/uno/unoimap.cxx
@@ -105,7 +105,7 @@ public:
     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) override;
 
 private:
-    static PropertySetInfo* createPropertySetInfo( sal_uInt16 nType );
+    static rtl::Reference<PropertySetInfo> createPropertySetInfo( sal_uInt16 nType );
 
 
     sal_uInt16 mnType;
@@ -124,7 +124,7 @@ private:
 
 UNO3_GETIMPLEMENTATION_IMPL( SvUnoImageMapObject );
 
-PropertySetInfo * SvUnoImageMapObject::createPropertySetInfo( sal_uInt16 nType )
+rtl::Reference<PropertySetInfo> SvUnoImageMapObject::createPropertySetInfo( sal_uInt16 nType )
 {
     switch( nType )
     {
@@ -142,7 +142,7 @@ PropertySetInfo * SvUnoImageMapObject::createPropertySetInfo( sal_uInt16 nType )
                 { OUString(), 0, css::uno::Type(), 0, 0 }
             };
 
-            return new PropertySetInfo( aPolygonObj_Impl );
+            return rtl::Reference<PropertySetInfo>(new PropertySetInfo( aPolygonObj_Impl ));
         }
     case IMAP_OBJ_CIRCLE:
         {
@@ -159,7 +159,7 @@ PropertySetInfo * SvUnoImageMapObject::createPropertySetInfo( sal_uInt16 nType )
                 { OUString(), 0, css::uno::Type(), 0, 0 }
             };
 
-            return new PropertySetInfo( aCircleObj_Impl );
+            return rtl::Reference<PropertySetInfo>(new PropertySetInfo( aCircleObj_Impl ));
         }
     case IMAP_OBJ_RECTANGLE:
     default:
@@ -176,7 +176,7 @@ PropertySetInfo * SvUnoImageMapObject::createPropertySetInfo( sal_uInt16 nType )
                 { OUString(), 0, css::uno::Type(), 0, 0 }
             };
 
-            return new PropertySetInfo( aRectangleObj_Impl );
+            return rtl::Reference<PropertySetInfo>(new PropertySetInfo( aRectangleObj_Impl ));
         }
     }
 }
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index f0d5a1f4a686..c3cb7b9a23f3 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -1334,15 +1334,11 @@ OUString SvxUnogetInternalNameForItem(const sal_Int16 nWhich, const OUString& rA
 }
 
 
-comphelper::PropertySetInfo* SvxPropertySetInfoPool::getOrCreate( sal_Int32 nServiceId ) throw()
+rtl::Reference<comphelper::PropertySetInfo> const & SvxPropertySetInfoPool::getOrCreate( sal_Int32 nServiceId ) throw()
 {
     SolarMutexGuard aGuard;
 
-    if( nServiceId > SVXUNO_SERVICEID_LASTID )
-    {
-        OSL_FAIL( "unknown service id!" );
-        return nullptr;
-    }
+    assert( nServiceId <= SVXUNO_SERVICEID_LASTID );
 
     if( !mxInfos[ nServiceId ].is() )
     {
@@ -1365,7 +1361,7 @@ comphelper::PropertySetInfo* SvxPropertySetInfoPool::getOrCreate( sal_Int32 nSer
         }
     }
 
-    return mxInfos[ nServiceId ].get();
+    return mxInfos[ nServiceId ];
 }
 
 rtl::Reference<comphelper::PropertySetInfo> SvxPropertySetInfoPool::mxInfos[SVXUNO_SERVICEID_LASTID+1] = { nullptr };
diff --git a/svx/source/unogallery/unogalitem.cxx b/svx/source/unogallery/unogalitem.cxx
index 6de4a988eb41..8377690808eb 100644
--- a/svx/source/unogallery/unogalitem.cxx
+++ b/svx/source/unogallery/unogalitem.cxx
@@ -178,11 +178,8 @@ sal_Int8 SAL_CALL GalleryItem::getType()
 }
 
 
-::comphelper::PropertySetInfo* GalleryItem::createPropertySetInfo()
+rtl::Reference<::comphelper::PropertySetInfo> GalleryItem::createPropertySetInfo()
 {
-    SolarMutexGuard aGuard;
-    ::comphelper::PropertySetInfo*  pRet = new ::comphelper::PropertySetInfo();
-
     static ::comphelper::PropertyMapEntry const aEntries[] =
     {
         { OUString("GalleryItemType"), UNOGALLERY_GALLERYITEMTYPE, cppu::UnoType<sal_Int8>::get(),
@@ -206,10 +203,7 @@ sal_Int8 SAL_CALL GalleryItem::getType()
         { OUString(), 0, css::uno::Type(), 0, 0 }
     };
 
-    pRet->acquire();
-    pRet->add( aEntries );
-
-    return pRet;
+    return rtl::Reference<::comphelper::PropertySetInfo>( new ::comphelper::PropertySetInfo( aEntries ) );
 }
 
 void GalleryItem::_setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const uno::Any* pValues )
diff --git a/svx/source/unogallery/unogalitem.hxx b/svx/source/unogallery/unogalitem.hxx
index 54dbcd2369b9..bd1f66958767 100644
--- a/svx/source/unogallery/unogalitem.hxx
+++ b/svx/source/unogallery/unogalitem.hxx
@@ -75,7 +75,7 @@ protected:
 
 protected:
 
-    static ::comphelper::PropertySetInfo* createPropertySetInfo();
+    static rtl::Reference<::comphelper::PropertySetInfo> createPropertySetInfo();
 
 private:
 


More information about the Libreoffice-commits mailing list