From 2356a480fea6cac8cccaae85c9a2b6a312a9048c Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 30 Jan 2013 17:46:38 +0100 Subject: API CHANGE: Make TypeDescriptionManager/Provider more consistent ...by letting their getByHierarchicalName methods return information about UNO constants as X(Constant)TypeDescription values, just as for (alomst -- see the odd enum member case) all other entities. This will make future changes in this area easier. The only affected client I could find so far is the core reflection service, but there might be more that I overlooked. Change-Id: I6731f2914773d49e33eeaec6e256ff2e5409ad2d --- stoc/source/corereflection/crefl.cxx | 42 +++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'stoc/source/corereflection/crefl.cxx') 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 #include +#include #include #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()) -- cgit