diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-11-04 07:21:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-11-04 17:01:28 +0100 |
commit | 38b1497dded22a6e4176f103256b27d7f5917aba (patch) | |
tree | a518c01e15aaed0edfe791cce7bb7ad1eb2e3716 /comphelper | |
parent | 35c4646bf2ce276a926eff0c406370e152a9e2db (diff) |
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@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/property/propertysethelper.cxx | 78 |
1 files changed, 30 insertions, 48 deletions
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 ) ); |