Kaydet (Commit) d4eabd5d authored tarafından Noel Grandin's avatar Noel Grandin

pass comphelper::PropertySetInfo around using rtl::Reference

and remove some manual ref counting

Change-Id: Ib78122fbbf914e87e0aef1f8fffe3952639e5b22
Reviewed-on: https://gerrit.libreoffice.org/38607Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 089ff7a3
......@@ -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 )
......
......@@ -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
......
......@@ -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];
......
......@@ -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;
}
}
......
......@@ -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 )
......
......@@ -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) );
}
......
......@@ -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;
......
......@@ -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) );
}
......
......@@ -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 ));
}
}
}
......
......@@ -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 };
......
......@@ -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 )
......
......@@ -75,7 +75,7 @@ protected:
protected:
static ::comphelper::PropertySetInfo* createPropertySetInfo();
static rtl::Reference<::comphelper::PropertySetInfo> createPropertySetInfo();
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment