Adapt PyUNO getConstantByName to previous TypeDescriptionMgr API CHANGE

Change-Id: I5a91c6c6dce103a8e4daa1572a638e1968a48fd8
This commit is contained in:
Stephan Bergmann
2013-01-30 18:13:26 +01:00
parent 2356a480fe
commit bd2c4e8dc4

View File

@@ -37,6 +37,7 @@
#include <uno/current_context.hxx> #include <uno/current_context.hxx>
#include <cppuhelper/bootstrap.hxx> #include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/reflection/XConstantTypeDescription.hpp>
#include <com/sun/star/reflection/XIdlReflection.hpp> #include <com/sun/star/reflection/XIdlReflection.hpp>
#include <com/sun/star/reflection/XIdlClass.hpp> #include <com/sun/star/reflection/XIdlClass.hpp>
#include <com/sun/star/registry/InvalidRegistryException.hpp> #include <com/sun/star/registry/InvalidRegistryException.hpp>
@@ -477,18 +478,17 @@ static PyObject *getConstantByName(
{ {
OUString typeName ( OUString::createFromAscii( name ) ); OUString typeName ( OUString::createFromAscii( name ) );
Runtime runtime; Runtime runtime;
Any a = runtime.getImpl()->cargo->xTdMgr->getByHierarchicalName(typeName); css::uno::Reference< css::reflection::XConstantTypeDescription > td;
if( a.getValueType().getTypeClass() == if (!(runtime.getImpl()->cargo->xTdMgr->getByHierarchicalName(
com::sun::star::uno::TypeClass_INTERFACE ) typeName)
>>= td))
{ {
// a idl constant cannot be an instance of an uno-object, thus
// this cannot be a constant
OUStringBuffer buf; OUStringBuffer buf;
buf.appendAscii( "pyuno.getConstantByName: " ).append( typeName ); buf.appendAscii( "pyuno.getConstantByName: " ).append( typeName );
buf.appendAscii( "is not a constant" ); buf.appendAscii( "is not a constant" );
throw RuntimeException(buf.makeStringAndClear(), Reference< XInterface > () ); throw RuntimeException(buf.makeStringAndClear(), Reference< XInterface > () );
} }
PyRef constant = runtime.any2PyObject( a ); PyRef constant = runtime.any2PyObject( td->getConstantValue() );
ret = constant.getAcquired(); ret = constant.getAcquired();
} }
} }