Kaydet (Commit) 45c0a617 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Simplify comphelper::PropertyInfo

...as its sole two uses (in sw) are already fine with initializing arrays of
it dynamically, there is no harm in changing it and thereby getting rid of the
last use of comphelper/TypeGeneration.hxx.

Change-Id: I11931dbbec48dac5a694a59cf6425206c806fbfb
üst dbbcdd87
......@@ -18,10 +18,8 @@
*/
#include <comphelper/ChainablePropertySetInfo.hxx>
#include <comphelper/TypeGeneration.hxx>
using ::comphelper::PropertyInfo;
using ::comphelper::GenerateCppuType;
using ::comphelper::ChainablePropertySetInfo;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Type;
......@@ -33,7 +31,7 @@ using ::com::sun::star::beans::Property;
using ::com::sun::star::beans::XPropertySetInfo;
using ::com::sun::star::beans::UnknownPropertyException;
ChainablePropertySetInfo::ChainablePropertySetInfo( PropertyInfo* pMap )
ChainablePropertySetInfo::ChainablePropertySetInfo( PropertyInfo const * pMap )
throw()
{
add ( pMap );
......@@ -44,7 +42,7 @@ ChainablePropertySetInfo::~ChainablePropertySetInfo()
{
}
void ChainablePropertySetInfo::add( PropertyInfo* pMap, sal_Int32 nCount )
void ChainablePropertySetInfo::add( PropertyInfo const * pMap, sal_Int32 nCount )
throw()
{
// nCount < 0 => add all
......@@ -53,16 +51,15 @@ void ChainablePropertySetInfo::add( PropertyInfo* pMap, sal_Int32 nCount )
if( maProperties.getLength() )
maProperties.realloc( 0 );
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
PropertyInfoHash::iterator aIter = maMap.find( aName );
PropertyInfoHash::iterator aIter = maMap.find( pMap->maName );
if( aIter != maMap.end() )
OSL_FAIL( "Warning: PropertyInfo added twice, possible error!");
#endif
maMap[aName] = pMap++;
maMap[pMap->maName] = pMap;
++pMap;
}
}
......@@ -85,13 +82,11 @@ Sequence< ::Property > SAL_CALL ChainablePropertySetInfo::getProperties()
for (PropertyInfoHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()); aIter != aEnd; ++aIter, ++pProperties)
{
PropertyInfo* pInfo = (*aIter).second;
PropertyInfo const * pInfo = (*aIter).second;
pProperties->Name = OUString( pInfo->mpName, pInfo->mnNameLen, RTL_TEXTENCODING_ASCII_US );
pProperties->Name = pInfo->maName;
pProperties->Handle = pInfo->mnHandle;
const Type* pType;
GenerateCppuType ( pInfo->meCppuType, pType);
pProperties->Type = *pType;
pProperties->Type = pInfo->maType;
pProperties->Attributes = pInfo->mnAttributes;
}
}
......@@ -106,13 +101,11 @@ Property SAL_CALL ChainablePropertySetInfo::getPropertyByName( const OUString& r
if ( maMap.end() == aIter )
throw UnknownPropertyException( rName, *this );
PropertyInfo *pInfo = (*aIter).second;
PropertyInfo const *pInfo = (*aIter).second;
Property aProperty;
aProperty.Name = OUString( pInfo->mpName, pInfo->mnNameLen, RTL_TEXTENCODING_ASCII_US );
aProperty.Name = pInfo->maName;
aProperty.Handle = pInfo->mnHandle;
const Type* pType = &aProperty.Type;
GenerateCppuType ( pInfo->meCppuType, pType );
aProperty.Type = *pType;
aProperty.Type = pInfo->maType;
aProperty.Attributes = pInfo->mnAttributes;
return aProperty;
}
......
......@@ -18,10 +18,8 @@
*/
#include <comphelper/MasterPropertySetInfo.hxx>
#include <comphelper/TypeGeneration.hxx>
using ::comphelper::PropertyInfo;
using ::comphelper::GenerateCppuType;
using ::comphelper::MasterPropertySetInfo;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Type;
......@@ -33,7 +31,7 @@ using ::com::sun::star::beans::Property;
using ::com::sun::star::beans::XPropertySetInfo;
using ::com::sun::star::beans::UnknownPropertyException;
MasterPropertySetInfo::MasterPropertySetInfo( PropertyInfo* pMap )
MasterPropertySetInfo::MasterPropertySetInfo( PropertyInfo const * pMap )
throw()
{
add ( pMap );
......@@ -50,7 +48,7 @@ MasterPropertySetInfo::~MasterPropertySetInfo()
}
}
void MasterPropertySetInfo::add( PropertyInfo* pMap, sal_Int32 nCount, sal_uInt8 nMapId )
void MasterPropertySetInfo::add( PropertyInfo const * pMap, sal_Int32 nCount, sal_uInt8 nMapId )
throw()
{
// nCount < 0 => add all
......@@ -59,16 +57,14 @@ void MasterPropertySetInfo::add( PropertyInfo* pMap, sal_Int32 nCount, sal_uInt8
if( maProperties.getLength() )
maProperties.realloc( 0 );
for ( ; pMap->mpName && ( ( nCount < 0 ) || ( nCount > 0 ) ); --nCount, ++pMap )
for ( ; !pMap->maName.isEmpty() && ( ( nCount < 0 ) || ( nCount > 0 ) ); --nCount, ++pMap )
{
OUString aName( pMap->mpName, pMap->mnNameLen, RTL_TEXTENCODING_ASCII_US );
#ifdef DBG_UTIL
PropertyDataHash::iterator aIter = maMap.find( aName );
PropertyDataHash::iterator aIter = maMap.find( pMap->maName );
if( aIter != maMap.end() )
OSL_FAIL( "Warning: PropertyInfo added twice, possible error!");
#endif
maMap[aName] = new PropertyData ( nMapId, pMap );
maMap[pMap->maName] = new PropertyData ( nMapId, pMap );
}
}
......@@ -102,13 +98,11 @@ Sequence< ::Property > SAL_CALL MasterPropertySetInfo::getProperties()
for (PropertyDataHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()) ; aIter != aEnd; ++aIter, ++pProperties)
{
PropertyInfo* pInfo = (*aIter).second->mpInfo;
PropertyInfo const * pInfo = (*aIter).second->mpInfo;
pProperties->Name = OUString( pInfo->mpName, pInfo->mnNameLen, RTL_TEXTENCODING_ASCII_US );
pProperties->Name = pInfo->maName;
pProperties->Handle = pInfo->mnHandle;
const Type* pType;
GenerateCppuType ( pInfo->meCppuType, pType);
pProperties->Type = *pType;
pProperties->Type = pInfo->maType;
pProperties->Attributes = pInfo->mnAttributes;
}
}
......@@ -123,13 +117,11 @@ Property SAL_CALL MasterPropertySetInfo::getPropertyByName( const OUString& rNam
if ( maMap.end() == aIter )
throw UnknownPropertyException( rName, *this );
PropertyInfo *pInfo = (*aIter).second->mpInfo;
PropertyInfo const *pInfo = (*aIter).second->mpInfo;
Property aProperty;
aProperty.Name = OUString( pInfo->mpName, pInfo->mnNameLen, RTL_TEXTENCODING_ASCII_US );
aProperty.Name = pInfo->maName;
aProperty.Handle = pInfo->mnHandle;
const Type* pType;
GenerateCppuType ( pInfo->meCppuType, pType );
aProperty.Type = *pType;
aProperty.Type = pInfo->maType;
aProperty.Attributes = pInfo->mnAttributes;
return aProperty;
......
......@@ -23,7 +23,6 @@
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <comphelper/PropertyInfoHash.hxx>
#include <cppuhelper/implbase1.hxx>
#include <comphelper/TypeGeneration.hxx>
#include <comphelper/comphelperdllapi.h>
/*
......@@ -44,13 +43,13 @@ namespace comphelper
PropertyInfoHash maMap;
com::sun::star::uno::Sequence < com::sun::star::beans::Property > maProperties;
public:
ChainablePropertySetInfo( PropertyInfo * pMap )
ChainablePropertySetInfo( PropertyInfo const * pMap )
throw();
virtual ~ChainablePropertySetInfo()
throw();
void add( PropertyInfo* pMap, sal_Int32 nCount = -1 )
void add( PropertyInfo const * pMap, sal_Int32 nCount = -1 )
throw();
void remove( const OUString& aName )
throw();
......
......@@ -22,7 +22,6 @@
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <comphelper/PropertyInfoHash.hxx>
#include <cppuhelper/implbase1.hxx>
#include <comphelper/TypeGeneration.hxx>
#include <comphelper/comphelperdllapi.h>
namespace comphelper
......@@ -36,11 +35,11 @@ namespace comphelper
PropertyDataHash maMap;
com::sun::star::uno::Sequence < com::sun::star::beans::Property > maProperties;
public:
MasterPropertySetInfo( PropertyInfo * pMap )
MasterPropertySetInfo( PropertyInfo const * pMap )
throw();
virtual ~MasterPropertySetInfo()
throw();
void add( PropertyInfo* pMap, sal_Int32 nCount = -1, sal_uInt8 nMapId = 0 )
void add( PropertyInfo const * pMap, sal_Int32 nCount = -1, sal_uInt8 nMapId = 0 )
throw();
void add( PropertyInfoHash &rHash, sal_uInt8 nMapId )
throw();
......
......@@ -21,31 +21,30 @@
#define INCLUDED_COMPHELPER_PROPERTYINFOHASH_HXX
#include <rtl/ustring.hxx>
#include <comphelper/TypeGeneration.hxx>
#include <com/sun/star/uno/Type.hxx>
#include <boost/unordered_map.hpp>
namespace comphelper
{
struct PropertyInfo
{
const sal_Char* mpName;
sal_uInt16 mnNameLen;
OUString maName;
sal_Int32 mnHandle;
CppuTypes meCppuType;
css::uno::Type maType;
sal_Int16 mnAttributes;
sal_uInt8 mnMemberId;
};
struct PropertyData
{
sal_uInt8 mnMapId;
PropertyInfo *mpInfo;
PropertyData ( sal_uInt8 nMapId, PropertyInfo *pInfo )
PropertyInfo const *mpInfo;
PropertyData ( sal_uInt8 nMapId, PropertyInfo const *pInfo )
: mnMapId ( nMapId )
, mpInfo ( pInfo ) {}
};
}
typedef boost::unordered_map < OUString,
::comphelper::PropertyInfo*,
::comphelper::PropertyInfo const *,
OUStringHash > PropertyInfoHash;
typedef boost::unordered_map < OUString,
::comphelper::PropertyData*,
......
......@@ -435,7 +435,6 @@
#include <com/sun/star/xml/sax/Writer.hpp>
#include <comphelper/ChainablePropertySetInfo.hxx>
#include <comphelper/MasterPropertySetInfo.hxx>
#include <comphelper/TypeGeneration.hxx>
#include <comphelper/accessibleeventnotifier.hxx>
#include <comphelper/accessiblekeybindinghelper.hxx>
#include <comphelper/accessibletexthelper.hxx>
......
This diff is collapsed.
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