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