/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
switch (pTypeDescr->eTypeClass)
{ case typelib_TypeClass_VOID: case typelib_TypeClass_CHAR: case typelib_TypeClass_BOOLEAN: case typelib_TypeClass_BYTE: case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: case typelib_TypeClass_FLOAT: case typelib_TypeClass_DOUBLE: case typelib_TypeClass_STRING: case typelib_TypeClass_ANY: returnnew IdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
case typelib_TypeClass_ENUM: returnnew EnumIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
case typelib_TypeClass_STRUCT: case typelib_TypeClass_EXCEPTION: returnnew CompoundIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
case typelib_TypeClass_SEQUENCE: returnnew ArrayIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
case typelib_TypeClass_INTERFACE: returnnew InterfaceIdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
case typelib_TypeClass_TYPE: returnnew IdlClassImpl( this, pTypeDescr->pTypeName, pTypeDescr->eTypeClass, pTypeDescr );
if (aAny.hasValue())
{
aAny >>= xRet;
} else
{ // try to get _type_ by name
typelib_TypeDescription * pTD = nullptr;
typelib_typedescription_getByName( &pTD, rTypeName.pData ); if (pTD)
{
xRet = constructClass( pTD ); if (xRet.is())
_aElements.setValue( rTypeName, Any( xRet ) ); // update
typelib_typedescription_release( pTD );
}
}
return xRet;
}
// XHierarchicalNameAccess
Any IdlReflectionServiceImpl::getByHierarchicalName( const OUString & rName )
{
Any aRet( _aElements.getValue( rName ) ); if (! aRet.hasValue())
{
aRet = _xTDMgr->getByHierarchicalName( rName ); if (aRet.getValueTypeClass() == TypeClass_INTERFACE)
{ // type retrieved from tdmgr
OSL_ASSERT( (*o3tl::forceAccess<Reference<XInterface>>(aRet))->queryInterface(
cppu::UnoType<XTypeDescription>::get()).hasValue() );
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...
// try to get _type_ by name
typelib_TypeDescription * pTD = nullptr;
typelib_typedescription_getByName( &pTD, rName.pData );
const Mapping & IdlReflectionServiceImpl::getCpp2Uno()
{ if (! _aCpp2Uno.is())
{
MutexGuard aGuard( getMutexAccess() ); if (! _aCpp2Uno.is())
{
_aCpp2Uno = Mapping( CPPU_CURRENT_LANGUAGE_BINDING_NAME, u"" UNO_LB_UNO ""_ustr );
OSL_ENSURE( _aCpp2Uno.is(), "### cannot get c++ to uno mapping!" ); if (! _aCpp2Uno.is())
{ throw RuntimeException(
u"cannot get c++ to uno mapping!"_ustr,
getXWeak() );
}
}
} return _aCpp2Uno;
}
const Mapping & IdlReflectionServiceImpl::getUno2Cpp()
{ if (! _aUno2Cpp.is())
{
MutexGuard aGuard( getMutexAccess() ); if (! _aUno2Cpp.is())
{
_aUno2Cpp = Mapping( u"" UNO_LB_UNO ""_ustr, CPPU_CURRENT_LANGUAGE_BINDING_NAME );
OSL_ENSURE( _aUno2Cpp.is(), "### cannot get uno to c++ mapping!" ); if (! _aUno2Cpp.is())
{ throw RuntimeException(
u"cannot get uno to c++ mapping!"_ustr,
getXWeak() );
}
}
} return _aUno2Cpp;
}
uno_Interface * IdlReflectionServiceImpl::mapToUno( const Any & rObj, typelib_InterfaceTypeDescription * pTo )
{
Reference< XInterface > xObj; if (extract( rObj, pTo, xObj, this )) returnstatic_cast<uno_Interface *>(getCpp2Uno().mapInterface( xObj.get(), pTo ));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.