summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-12-11 15:16:51 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-12-12 08:26:40 +0100
commita62c2a5fa5d5be465b0edab6adeb1fd16ace462f (patch)
tree47cf29b4b7a0ba3ce321ce628a6b0a6175d978d7 /comphelper
parentcff72ec4bf87c6484be97d954966309ba7a5eb8a (diff)
Don't hold css::uno::Type instances by pointer
...in comphelper::PropertyMapEntry and SfxItemPropertyMapEntry. And as the arrays of such need to be initialized dynamically anyway, also change their name members to proper OUStrings while at it. Plus some const clean-up. Change-Id: I67d4d7b5773fb020605f369daf39528bec930606
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/property/genericpropertyset.cxx10
-rw-r--r--comphelper/source/property/propertysethelper.cxx20
-rw-r--r--comphelper/source/property/propertysetinfo.cxx31
3 files changed, 26 insertions, 35 deletions
diff --git a/comphelper/source/property/genericpropertyset.cxx b/comphelper/source/property/genericpropertyset.cxx
index feb803ef1dad..e5d52a7546d0 100644
--- a/comphelper/source/property/genericpropertyset.cxx
+++ b/comphelper/source/property/genericpropertyset.cxx
@@ -157,15 +157,14 @@ void GenericPropertySet::_setPropertyValues( const PropertyMapEntry** ppEntries,
while( *ppEntries )
{
- const OUString aPropertyName( (*ppEntries)->mpName, (*ppEntries)->mnNameLen, RTL_TEXTENCODING_ASCII_US );
- OInterfaceContainerHelper * pHelper = m_aListener.getContainer(aPropertyName);
+ OInterfaceContainerHelper * pHelper = m_aListener.getContainer((*ppEntries)->maName);
- maAnyMap[ aPropertyName ] = *pValues;
+ maAnyMap[ (*ppEntries)->maName ] = *pValues;
if ( pHelper )
{
PropertyChangeEvent aEvt;
- aEvt.PropertyName = aPropertyName;
+ aEvt.PropertyName = (*ppEntries)->maName;
aEvt.NewValue = *pValues;
aGuard.clear();
pHelper->notifyEach( &XPropertyChangeListener::propertyChange, aEvt );
@@ -184,8 +183,7 @@ void GenericPropertySet::_getPropertyValues( const comphelper::PropertyMapEntry*
while( *ppEntries )
{
- const OUString aPropertyName( (*ppEntries)->mpName, (*ppEntries)->mnNameLen, RTL_TEXTENCODING_ASCII_US );
- *pValue = maAnyMap[ aPropertyName ];
+ *pValue = maAnyMap[ (*ppEntries)->maName ];
ppEntries++;
pValue++;
diff --git a/comphelper/source/property/propertysethelper.cxx b/comphelper/source/property/propertysethelper.cxx
index e1422cf21f3f..21cea0cc30bf 100644
--- a/comphelper/source/property/propertysethelper.cxx
+++ b/comphelper/source/property/propertysethelper.cxx
@@ -35,13 +35,13 @@ namespace comphelper
class PropertySetHelperImpl
{
public:
- PropertyMapEntry* find( const OUString& aName ) const throw();
+ PropertyMapEntry const * find( const OUString& aName ) const throw();
PropertySetInfo* mpInfo;
};
}
-PropertyMapEntry* PropertySetHelperImpl::find( const OUString& aName ) const throw()
+PropertyMapEntry const * PropertySetHelperImpl::find( const OUString& aName ) const throw()
{
PropertyMap::const_iterator aIter = mpInfo->getPropertyMap()->find( aName );
@@ -84,7 +84,7 @@ Reference< XPropertySetInfo > SAL_CALL PropertySetHelper::getPropertySetInfo( )
void SAL_CALL PropertySetHelper::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
{
- PropertyMapEntry* aEntries[2];
+ PropertyMapEntry const * aEntries[2];
aEntries[0] = mp->find( aPropertyName );
if( NULL == aEntries[0] )
@@ -97,7 +97,7 @@ void SAL_CALL PropertySetHelper::setPropertyValue( const OUString& aPropertyName
Any SAL_CALL PropertySetHelper::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
{
- PropertyMapEntry* aEntries[2];
+ PropertyMapEntry const * aEntries[2];
aEntries[0] = mp->find( PropertyName );
if( NULL == aEntries[0] )
@@ -141,7 +141,7 @@ void SAL_CALL PropertySetHelper::setPropertyValues( const Sequence< OUString >&
if( nCount )
{
- PropertyMapEntry** pEntries = new PropertyMapEntry*[nCount+1];
+ PropertyMapEntry const ** pEntries = new PropertyMapEntry const *[nCount+1];
pEntries[nCount] = NULL;
const OUString* pNames = aPropertyNames.getConstArray();
@@ -170,7 +170,7 @@ Sequence< Any > SAL_CALL PropertySetHelper::getPropertyValues( const Sequence< O
Sequence< Any > aValues;
if( nCount )
{
- PropertyMapEntry** pEntries = new PropertyMapEntry*[nCount+1];
+ PropertyMapEntry const ** pEntries = new PropertyMapEntry const *[nCount+1];
pEntries[nCount] = NULL;
const OUString* pNames = aPropertyNames.getConstArray();
@@ -215,7 +215,7 @@ void SAL_CALL PropertySetHelper::firePropertiesChangeEvent( const Sequence< OUSt
// XPropertyState
PropertyState SAL_CALL PropertySetHelper::getPropertyState( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
{
- PropertyMapEntry* aEntries[2];
+ PropertyMapEntry const * aEntries[2];
aEntries[0] = mp->find( PropertyName );
if( aEntries[0] == NULL )
@@ -241,7 +241,7 @@ Sequence< PropertyState > SAL_CALL PropertySetHelper::getPropertyStates( const S
sal_Bool bUnknown = sal_False;
- PropertyMapEntry** pEntries = new PropertyMapEntry*[nCount+1];
+ PropertyMapEntry const ** pEntries = new PropertyMapEntry const *[nCount+1];
sal_Int32 n;
for( n = 0; !bUnknown && (n < nCount); n++, pNames++ )
@@ -266,7 +266,7 @@ Sequence< PropertyState > SAL_CALL PropertySetHelper::getPropertyStates( const S
void SAL_CALL PropertySetHelper::setPropertyToDefault( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
{
- PropertyMapEntry *pEntry = mp->find( PropertyName );
+ PropertyMapEntry const *pEntry = mp->find( PropertyName );
if( NULL == pEntry )
throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) );
@@ -275,7 +275,7 @@ void SAL_CALL PropertySetHelper::setPropertyToDefault( const OUString& PropertyN
Any SAL_CALL PropertySetHelper::getPropertyDefault( const OUString& aPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
{
- PropertyMapEntry* pEntry = mp->find( aPropertyName );
+ PropertyMapEntry const * pEntry = mp->find( aPropertyName );
if( NULL == pEntry )
throw UnknownPropertyException( aPropertyName, static_cast< XPropertySet* >( this ) );
diff --git a/comphelper/source/property/propertysetinfo.cxx b/comphelper/source/property/propertysetinfo.cxx
index 2567a0630109..cc4984122054 100644
--- a/comphelper/source/property/propertysetinfo.cxx
+++ b/comphelper/source/property/propertysetinfo.cxx
@@ -35,7 +35,7 @@ public:
PropertyMapImpl() throw();
virtual ~PropertyMapImpl() throw();
- void add( PropertyMapEntry* pMap, sal_Int32 nCount = -1 ) throw();
+ void add( PropertyMapEntry const * pMap, sal_Int32 nCount = -1 ) throw();
void remove( const OUString& aName ) throw();
Sequence< Property > getProperties() throw();
@@ -59,30 +59,23 @@ PropertyMapImpl::~PropertyMapImpl() throw()
{
}
-void PropertyMapImpl::add( PropertyMapEntry* pMap, sal_Int32 nCount ) throw()
+void PropertyMapImpl::add( PropertyMapEntry const * pMap, sal_Int32 nCount ) throw()
{
// nCount < 0 => add all
// nCount == 0 => add nothing
// nCount > 0 => add at most nCount entries
- while( pMap->mpName && ( ( nCount < 0) || ( nCount-- > 0 ) ) )
+ while( !pMap->maName.isEmpty() && ( ( nCount < 0) || ( nCount-- > 0 ) ) )
{
- OUString aName( pMap->mpName, pMap->mnNameLen, RTL_TEXTENCODING_ASCII_US );
-
#ifdef DBG_UTIL
- PropertyMap::iterator aIter = maPropertyMap.find( aName );
+ PropertyMap::iterator aIter = maPropertyMap.find( pMap->maName );
if( aIter != maPropertyMap.end() )
{
OSL_FAIL( "Warning: PropertyMapEntry added twice, possible error!");
}
#endif
- if( NULL == pMap->mpType )
- {
- OSL_FAIL( "No type in PropertyMapEntry!");
- pMap->mpType = &::getCppuType((const sal_Int32*)0);
- }
- maPropertyMap[aName] = pMap;
+ maPropertyMap[pMap->maName] = pMap;
if( maProperties.getLength() )
maProperties.realloc( 0 );
@@ -113,11 +106,11 @@ Sequence< Property > PropertyMapImpl::getProperties() throw()
const PropertyMap::iterator aEnd = maPropertyMap.end();
while( aIter != aEnd )
{
- PropertyMapEntry* pEntry = (*aIter).second;
+ PropertyMapEntry const * pEntry = (*aIter).second;
- pProperties->Name = OUString( pEntry->mpName, pEntry->mnNameLen, RTL_TEXTENCODING_ASCII_US );
+ pProperties->Name = pEntry->maName;
pProperties->Handle = pEntry->mnHandle;
- pProperties->Type = *pEntry->mpType;
+ pProperties->Type = pEntry->maType;
pProperties->Attributes = pEntry->mnAttributes;
++pProperties;
@@ -140,9 +133,9 @@ Property PropertyMapImpl::getPropertyByName( const OUString& aName ) throw( Unkn
if( maPropertyMap.end() == aIter )
throw UnknownPropertyException( aName, NULL );
- PropertyMapEntry* pEntry = (*aIter).second;
+ PropertyMapEntry const * pEntry = (*aIter).second;
- return Property( aName, pEntry->mnHandle, *pEntry->mpType, pEntry->mnAttributes );
+ return Property( aName, pEntry->mnHandle, pEntry->maType, pEntry->mnAttributes );
}
sal_Bool PropertyMapImpl::hasPropertyByName( const OUString& aName ) throw()
@@ -157,7 +150,7 @@ PropertySetInfo::PropertySetInfo() throw()
mpMap = new PropertyMapImpl();
}
-PropertySetInfo::PropertySetInfo( PropertyMapEntry* pMap ) throw()
+PropertySetInfo::PropertySetInfo( PropertyMapEntry const * pMap ) throw()
{
mpMap = new PropertyMapImpl();
mpMap->add( pMap );
@@ -168,7 +161,7 @@ PropertySetInfo::~PropertySetInfo() throw()
delete mpMap;
}
-void PropertySetInfo::add( PropertyMapEntry* pMap ) throw()
+void PropertySetInfo::add( PropertyMapEntry const * pMap ) throw()
{
mpMap->add( pMap );
}