diff options
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/source/corereflection/crefl.cxx | 42 | ||||
-rw-r--r-- | stoc/source/registry_tdprovider/tdprovider.cxx | 17 |
2 files changed, 39 insertions, 20 deletions
diff --git a/stoc/source/corereflection/crefl.cxx b/stoc/source/corereflection/crefl.cxx index 3357a540ca1b..a51f58a6b35c 100644 --- a/stoc/source/corereflection/crefl.cxx +++ b/stoc/source/corereflection/crefl.cxx @@ -21,6 +21,7 @@ #include <cppuhelper/implementationentry.hxx> #include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/reflection/XConstantTypeDescription.hpp> #include <com/sun/star/reflection/XTypeDescription.hpp> #include "com/sun/star/uno/RuntimeException.hpp" @@ -283,35 +284,42 @@ Any IdlReflectionServiceImpl::getByHierarchicalName( const OUString & rName ) Any aRet( _aElements.getValue( rName ) ); if (! aRet.hasValue()) { - // first look for constants exclusivly! aRet = _xTDMgr->getByHierarchicalName( rName ); - if (aRet.getValueTypeClass() == TypeClass_INTERFACE) // if no constant, - // i.e. XTypeDescription for a type + if (aRet.getValueTypeClass() == TypeClass_INTERFACE) { // type retrieved from tdmgr OSL_ASSERT( (*(Reference< XInterface > *)aRet.getValue())->queryInterface( ::getCppuType( (const Reference< XTypeDescription > *)0 ) ).hasValue() ); - // if you are interested in a type then CALL forName()!!! - // this way is NOT recommended for types, because this method looks for constants first + css::uno::Reference< css::reflection::XConstantTypeDescription > + ctd; + if (aRet >>= ctd) + { + aRet = ctd->getConstantValue(); + } + else + { + // if you are interested in a type then CALL forName()!!! + // this way is NOT recommended for types, because this method looks for constants first - // if td manager found some type, it will be in the cache (hopefully.. we just got it) - // so the second retrieving via c typelib callback chain should succeed... + // if td manager found some type, it will be in the cache (hopefully.. we just got it) + // so the second retrieving via c typelib callback chain should succeed... - // try to get _type_ by name - typelib_TypeDescription * pTD = 0; - typelib_typedescription_getByName( &pTD, rName.pData ); + // try to get _type_ by name + typelib_TypeDescription * pTD = 0; + typelib_typedescription_getByName( &pTD, rName.pData ); - aRet.clear(); // kick XTypeDescription interface + aRet.clear(); // kick XTypeDescription interface - if (pTD) - { - Reference< XIdlClass > xIdlClass( constructClass( pTD ) ); - aRet.setValue( &xIdlClass, ::getCppuType( (const Reference< XIdlClass > *)0 ) ); - typelib_typedescription_release( pTD ); + if (pTD) + { + Reference< XIdlClass > xIdlClass( constructClass( pTD ) ); + aRet.setValue( &xIdlClass, ::getCppuType( (const Reference< XIdlClass > *)0 ) ); + typelib_typedescription_release( pTD ); + } } } - // else is constant + // else is enum member(?) // update if (aRet.hasValue()) diff --git a/stoc/source/registry_tdprovider/tdprovider.cxx b/stoc/source/registry_tdprovider/tdprovider.cxx index 87089a9adfb6..92dbc92ddeab 100644 --- a/stoc/source/registry_tdprovider/tdprovider.cxx +++ b/stoc/source/registry_tdprovider/tdprovider.cxx @@ -365,9 +365,10 @@ Any ProviderImpl::getByHierarchicalNameImpl( const OUString & rName ) aBytes.getConstArray(), aBytes.getLength(), false, TYPEREG_VERSION_1); - if (aReader.getTypeClass() == RT_TYPE_MODULE || - aReader.getTypeClass() == RT_TYPE_CONSTANTS || - aReader.getTypeClass() == RT_TYPE_ENUM) + RTTypeClass tc = aReader.getTypeClass(); + if (tc == RT_TYPE_MODULE || + tc == RT_TYPE_CONSTANTS || + tc == RT_TYPE_ENUM) { OUString aFieldName( aKey.copy( nIndex+1, aKey.getLength() - nIndex -1 ) ); sal_Int16 nPos = aReader.getFieldCount(); @@ -378,8 +379,18 @@ Any ProviderImpl::getByHierarchicalNameImpl( const OUString & rName ) break; } if (nPos >= 0) + { aRet = getRTValue( aReader.getFieldValue(nPos)); + if (tc != RT_TYPE_ENUM) + { + aRet = css::uno::makeAny< + css::uno::Reference< + css::reflection::XTypeDescription > >( + new ConstantTypeDescriptionImpl( + rName, aRet)); + } + } } } } |