| File: | cppuhelper/source/tdmgr.cxx |
| Location: | line 432, column 13 |
| Description: | Access to field 'eTypeClass' results in a dereference of a null pointer (loaded from variable 'p') |
| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||||
| 2 | /************************************************************************* | |||||
| 3 | * | |||||
| 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |||||
| 5 | * | |||||
| 6 | * Copyright 2000, 2010 Oracle and/or its affiliates. | |||||
| 7 | * | |||||
| 8 | * OpenOffice.org - a multi-platform office productivity suite | |||||
| 9 | * | |||||
| 10 | * This file is part of OpenOffice.org. | |||||
| 11 | * | |||||
| 12 | * OpenOffice.org is free software: you can redistribute it and/or modify | |||||
| 13 | * it under the terms of the GNU Lesser General Public License version 3 | |||||
| 14 | * only, as published by the Free Software Foundation. | |||||
| 15 | * | |||||
| 16 | * OpenOffice.org is distributed in the hope that it will be useful, | |||||
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| 19 | * GNU Lesser General Public License version 3 for more details | |||||
| 20 | * (a copy is included in the LICENSE file that accompanied this code). | |||||
| 21 | * | |||||
| 22 | * You should have received a copy of the GNU Lesser General Public License | |||||
| 23 | * version 3 along with OpenOffice.org. If not, see | |||||
| 24 | * <http://www.openoffice.org/license.html> | |||||
| 25 | * for a copy of the LGPLv3 License. | |||||
| 26 | * | |||||
| 27 | ************************************************************************/ | |||||
| 28 | ||||||
| 29 | ||||||
| 30 | #include "sal/config.h" | |||||
| 31 | ||||||
| 32 | #include <vector> | |||||
| 33 | ||||||
| 34 | #include <sal/alloca.h> | |||||
| 35 | ||||||
| 36 | #include <osl/diagnose.h> | |||||
| 37 | #include <rtl/alloc.h> | |||||
| 38 | #include <rtl/ustring.hxx> | |||||
| 39 | ||||||
| 40 | #include <uno/mapping.hxx> | |||||
| 41 | ||||||
| 42 | #include <cppuhelper/bootstrap.hxx> | |||||
| 43 | #include <cppuhelper/implbase1.hxx> | |||||
| 44 | #include <typelib/typedescription.h> | |||||
| 45 | ||||||
| 46 | #include <com/sun/star/lang/XComponent.hpp> | |||||
| 47 | #include <com/sun/star/container/XHierarchicalNameAccess.hpp> | |||||
| 48 | #include <com/sun/star/reflection/XTypeDescription.hpp> | |||||
| 49 | #include <com/sun/star/reflection/XEnumTypeDescription.hpp> | |||||
| 50 | #include <com/sun/star/reflection/XIndirectTypeDescription.hpp> | |||||
| 51 | #include <com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp> | |||||
| 52 | #include <com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp> | |||||
| 53 | #include <com/sun/star/reflection/XMethodParameter.hpp> | |||||
| 54 | #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp> | |||||
| 55 | #include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp> | |||||
| 56 | #include <com/sun/star/reflection/XCompoundTypeDescription.hpp> | |||||
| 57 | #include <com/sun/star/reflection/XStructTypeDescription.hpp> | |||||
| 58 | #include <com/sun/star/reflection/XUnionTypeDescription.hpp> | |||||
| 59 | #include "com/sun/star/uno/RuntimeException.hpp" | |||||
| 60 | ||||||
| 61 | #include "boost/scoped_array.hpp" | |||||
| 62 | ||||||
| 63 | using namespace ::rtl; | |||||
| 64 | using namespace ::com::sun::star; | |||||
| 65 | using namespace ::com::sun::star::uno; | |||||
| 66 | using namespace ::com::sun::star::reflection; | |||||
| 67 | ||||||
| 68 | ||||||
| 69 | namespace cppu | |||||
| 70 | { | |||||
| 71 | ||||||
| 72 | static typelib_TypeDescription * createCTD( | |||||
| 73 | Reference< container::XHierarchicalNameAccess > const & access, | |||||
| 74 | const Reference< XTypeDescription > & xType ); | |||||
| 75 | ||||||
| 76 | //================================================================================================== | |||||
| 77 | inline static sal_Int64 coerceToInt64( const Any & rVal ) | |||||
| 78 | { | |||||
| 79 | switch (rVal.getValueTypeClass()) | |||||
| 80 | { | |||||
| 81 | case TypeClass_CHAR: | |||||
| 82 | return *(sal_Unicode *)rVal.getValue(); | |||||
| 83 | case TypeClass_BOOLEAN: | |||||
| 84 | return (*(sal_Bool *)rVal.getValue() ? 1 : 0); | |||||
| 85 | case TypeClass_BYTE: | |||||
| 86 | return *(sal_Int8 *)rVal.getValue(); | |||||
| 87 | case TypeClass_SHORT: | |||||
| 88 | return *(sal_Int16 *)rVal.getValue(); | |||||
| 89 | case TypeClass_UNSIGNED_SHORT: | |||||
| 90 | return *(sal_uInt16 *)rVal.getValue(); | |||||
| 91 | case TypeClass_LONG: | |||||
| 92 | return *(sal_Int32 *)rVal.getValue(); | |||||
| 93 | case TypeClass_UNSIGNED_LONG: | |||||
| 94 | return *(sal_uInt32 *)rVal.getValue(); | |||||
| 95 | case TypeClass_HYPER: | |||||
| 96 | return *(sal_Int64 *)rVal.getValue(); | |||||
| 97 | case TypeClass_UNSIGNED_HYPER: | |||||
| 98 | return *(sal_uInt64 *)rVal.getValue(); | |||||
| 99 | case TypeClass_ENUM: | |||||
| 100 | return *(int *)rVal.getValue(); | |||||
| 101 | default: | |||||
| 102 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "102" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); | |||||
| 103 | return 0; | |||||
| 104 | } | |||||
| 105 | } | |||||
| 106 | //================================================================================================== | |||||
| 107 | inline static typelib_TypeDescription * createCTD( | |||||
| 108 | const Reference< XUnionTypeDescription > & xType ) | |||||
| 109 | { | |||||
| 110 | typelib_TypeDescription * pRet = 0; | |||||
| 111 | if (xType.is()) | |||||
| 112 | { | |||||
| 113 | OUString aTypeName( xType->getName() ); | |||||
| 114 | ||||||
| 115 | // discriminant type | |||||
| 116 | Reference< XTypeDescription > xDiscrTD( xType->getDiscriminantType() ); | |||||
| 117 | OUString aDiscrTypeName( xDiscrTD->getName() ); | |||||
| 118 | typelib_TypeDescriptionReference * pDiscrTypeRef = 0; | |||||
| 119 | typelib_typedescriptionreference_new( &pDiscrTypeRef, | |||||
| 120 | (typelib_TypeClass)xDiscrTD->getTypeClass(), | |||||
| 121 | aDiscrTypeName.pData ); | |||||
| 122 | // default member type | |||||
| 123 | Reference< XTypeDescription > xDefaultMemberTD( xType->getDefaultMemberType() ); | |||||
| 124 | OUString aDefMemberTypeName( xDefaultMemberTD->getName() ); | |||||
| 125 | typelib_TypeDescriptionReference * pDefMemberTypeRef = 0; | |||||
| 126 | typelib_typedescriptionreference_new( &pDefMemberTypeRef, | |||||
| 127 | (typelib_TypeClass)xDefaultMemberTD->getTypeClass(), | |||||
| 128 | aDefMemberTypeName.pData ); | |||||
| 129 | // init array | |||||
| 130 | Sequence< Any > aDiscriminants( xType->getDiscriminants() ); | |||||
| 131 | Sequence< Reference< XTypeDescription > > aMemberTypes( xType->getMemberTypes() ); | |||||
| 132 | Sequence< OUString > aMemberNames( xType->getMemberNames() ); | |||||
| 133 | sal_Int32 nMembers = aDiscriminants.getLength(); | |||||
| 134 | OSL_ASSERT( nMembers == aMemberNames.getLength() && nMembers == aMemberTypes.getLength() )do { if (true && (!(nMembers == aMemberNames.getLength () && nMembers == aMemberTypes.getLength()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "134" ": "), "OSL_ASSERT: %s", "nMembers == aMemberNames.getLength() && nMembers == aMemberTypes.getLength()" ); } } while (false); | |||||
| 135 | ||||||
| 136 | const Any * pDiscriminants = aDiscriminants.getConstArray(); | |||||
| 137 | const Reference< XTypeDescription > * pMemberTypes = aMemberTypes.getConstArray(); | |||||
| 138 | const OUString * pMemberNames = aMemberNames.getConstArray(); | |||||
| 139 | ||||||
| 140 | typelib_Union_Init * pMembers = (typelib_Union_Init *)alloca( nMembers * sizeof(typelib_Union_Init) )__builtin_alloca (nMembers * sizeof(typelib_Union_Init)); | |||||
| 141 | ||||||
| 142 | sal_Int32 nPos; | |||||
| 143 | for ( nPos = nMembers; nPos--; ) | |||||
| 144 | { | |||||
| 145 | typelib_Union_Init & rEntry = pMembers[nPos]; | |||||
| 146 | // member discriminant | |||||
| 147 | rEntry.nDiscriminant = coerceToInt64( pDiscriminants[nPos] ); | |||||
| 148 | // member type | |||||
| 149 | OUString aMemberTypeName( pMemberTypes[nPos]->getName() ); | |||||
| 150 | rEntry.pTypeRef = 0; | |||||
| 151 | typelib_typedescriptionreference_new( &rEntry.pTypeRef, | |||||
| 152 | (typelib_TypeClass)pMemberTypes[nPos]->getTypeClass(), | |||||
| 153 | aMemberTypeName.pData ); | |||||
| 154 | // member name | |||||
| 155 | rEntry.pMemberName = pMemberNames[nPos].pData; | |||||
| 156 | } | |||||
| 157 | ||||||
| 158 | typelib_typedescription_newUnion( &pRet, aTypeName.pData, | |||||
| 159 | pDiscrTypeRef, | |||||
| 160 | coerceToInt64( xType->getDefaultDiscriminant() ), | |||||
| 161 | pDefMemberTypeRef, | |||||
| 162 | nMembers, pMembers ); | |||||
| 163 | ||||||
| 164 | for ( nPos = nMembers; nPos--; ) | |||||
| 165 | { | |||||
| 166 | typelib_typedescriptionreference_release( pMembers[nPos].pTypeRef ); | |||||
| 167 | } | |||||
| 168 | ||||||
| 169 | typelib_typedescriptionreference_release( pDiscrTypeRef ); | |||||
| 170 | typelib_typedescriptionreference_release( pDefMemberTypeRef ); | |||||
| 171 | } | |||||
| 172 | return pRet; | |||||
| 173 | } | |||||
| 174 | //================================================================================================== | |||||
| 175 | inline static typelib_TypeDescription * createCTD( | |||||
| 176 | const Reference< XCompoundTypeDescription > & xType ) | |||||
| 177 | { | |||||
| 178 | typelib_TypeDescription * pRet = 0; | |||||
| 179 | if (xType.is()) | |||||
| 180 | { | |||||
| 181 | typelib_TypeDescription * pBaseType = createCTD( | |||||
| 182 | Reference< XCompoundTypeDescription >::query( xType->getBaseType() ) ); | |||||
| 183 | if (pBaseType) | |||||
| 184 | typelib_typedescription_register( &pBaseType ); | |||||
| 185 | ||||||
| 186 | // construct member init array | |||||
| 187 | const Sequence<Reference< XTypeDescription > > & rMemberTypes = xType->getMemberTypes(); | |||||
| 188 | const Sequence< OUString > & rMemberNames = xType->getMemberNames(); | |||||
| 189 | ||||||
| 190 | const Reference< XTypeDescription > * pMemberTypes = rMemberTypes.getConstArray(); | |||||
| 191 | const OUString * pMemberNames = rMemberNames.getConstArray(); | |||||
| 192 | ||||||
| 193 | sal_Int32 nMembers = rMemberTypes.getLength(); | |||||
| 194 | OSL_ENSURE( nMembers == rMemberNames.getLength(), "### lens differ!" )do { if (true && (!(nMembers == rMemberNames.getLength ()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "194" ": "), "%s", "### lens differ!"); } } while (false); | |||||
| 195 | ||||||
| 196 | OUString aTypeName( xType->getName() ); | |||||
| 197 | ||||||
| 198 | typelib_CompoundMember_Init * pMemberInits = (typelib_CompoundMember_Init *)alloca(__builtin_alloca (sizeof(typelib_CompoundMember_Init) * nMembers ) | |||||
| 199 | sizeof(typelib_CompoundMember_Init) * nMembers )__builtin_alloca (sizeof(typelib_CompoundMember_Init) * nMembers ); | |||||
| 200 | ||||||
| 201 | sal_Int32 nPos; | |||||
| 202 | for ( nPos = nMembers; nPos--; ) | |||||
| 203 | { | |||||
| 204 | typelib_CompoundMember_Init & rInit = pMemberInits[nPos]; | |||||
| 205 | rInit.eTypeClass = (typelib_TypeClass)pMemberTypes[nPos]->getTypeClass(); | |||||
| 206 | ||||||
| 207 | OUString aMemberTypeName( pMemberTypes[nPos]->getName() ); | |||||
| 208 | rtl_uString_acquire( rInit.pTypeName = aMemberTypeName.pData ); | |||||
| 209 | ||||||
| 210 | // string is held by rMemberNames | |||||
| 211 | rInit.pMemberName = pMemberNames[nPos].pData; | |||||
| 212 | } | |||||
| 213 | ||||||
| 214 | typelib_typedescription_new( | |||||
| 215 | &pRet, | |||||
| 216 | (typelib_TypeClass)xType->getTypeClass(), | |||||
| 217 | aTypeName.pData, | |||||
| 218 | (pBaseType ? pBaseType->pWeakRef : 0), | |||||
| 219 | nMembers, pMemberInits ); | |||||
| 220 | ||||||
| 221 | // cleanup | |||||
| 222 | for ( nPos = nMembers; nPos--; ) | |||||
| 223 | { | |||||
| 224 | rtl_uString_release( pMemberInits[nPos].pTypeName ); | |||||
| 225 | } | |||||
| 226 | if (pBaseType) | |||||
| 227 | typelib_typedescription_release( pBaseType ); | |||||
| 228 | } | |||||
| 229 | return pRet; | |||||
| 230 | } | |||||
| 231 | //================================================================================================== | |||||
| 232 | inline static typelib_TypeDescription * createCTD( | |||||
| 233 | Reference< container::XHierarchicalNameAccess > const & access, | |||||
| 234 | const Reference< XStructTypeDescription > & xType ) | |||||
| 235 | { | |||||
| 236 | typelib_TypeDescription * pRet = 0; | |||||
| 237 | if (xType.is() && xType->getTypeParameters().getLength() == 0) | |||||
| 238 | { | |||||
| 239 | typelib_TypeDescription * pBaseType = createCTD( | |||||
| 240 | access, xType->getBaseType() ); | |||||
| 241 | if (pBaseType) | |||||
| 242 | typelib_typedescription_register( &pBaseType ); | |||||
| 243 | ||||||
| 244 | // construct member init array | |||||
| 245 | const Sequence<Reference< XTypeDescription > > & rMemberTypes = xType->getMemberTypes(); | |||||
| 246 | const Sequence< OUString > & rMemberNames = xType->getMemberNames(); | |||||
| 247 | ||||||
| 248 | const Reference< XTypeDescription > * pMemberTypes = rMemberTypes.getConstArray(); | |||||
| 249 | const OUString * pMemberNames = rMemberNames.getConstArray(); | |||||
| 250 | ||||||
| 251 | sal_Int32 nMembers = rMemberTypes.getLength(); | |||||
| 252 | OSL_ENSURE( nMembers == rMemberNames.getLength(), "### lens differ!" )do { if (true && (!(nMembers == rMemberNames.getLength ()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "252" ": "), "%s", "### lens differ!"); } } while (false); | |||||
| 253 | ||||||
| 254 | OUString aTypeName( xType->getName() ); | |||||
| 255 | ||||||
| 256 | typelib_StructMember_Init * pMemberInits = (typelib_StructMember_Init *)alloca(__builtin_alloca (sizeof(typelib_StructMember_Init) * nMembers ) | |||||
| 257 | sizeof(typelib_StructMember_Init) * nMembers )__builtin_alloca (sizeof(typelib_StructMember_Init) * nMembers ); | |||||
| 258 | ||||||
| 259 | Sequence< Reference< XTypeDescription > > templateMemberTypes; | |||||
| 260 | sal_Int32 i = aTypeName.indexOf('<'); | |||||
| 261 | if (i >= 0) { | |||||
| 262 | Reference< XStructTypeDescription > templateDesc( | |||||
| 263 | access->getByHierarchicalName(aTypeName.copy(0, i)), | |||||
| 264 | UNO_QUERY_THROW); | |||||
| 265 | OSL_ASSERT(do { if (true && (!(templateDesc->getTypeParameters ().getLength() == xType->getTypeArguments().getLength()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "267" ": "), "OSL_ASSERT: %s", "templateDesc->getTypeParameters().getLength() == xType->getTypeArguments().getLength()" ); } } while (false) | |||||
| 266 | templateDesc->getTypeParameters().getLength()do { if (true && (!(templateDesc->getTypeParameters ().getLength() == xType->getTypeArguments().getLength()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "267" ": "), "OSL_ASSERT: %s", "templateDesc->getTypeParameters().getLength() == xType->getTypeArguments().getLength()" ); } } while (false) | |||||
| 267 | == xType->getTypeArguments().getLength())do { if (true && (!(templateDesc->getTypeParameters ().getLength() == xType->getTypeArguments().getLength()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "267" ": "), "OSL_ASSERT: %s", "templateDesc->getTypeParameters().getLength() == xType->getTypeArguments().getLength()" ); } } while (false); | |||||
| 268 | templateMemberTypes = templateDesc->getMemberTypes(); | |||||
| 269 | OSL_ASSERT(templateMemberTypes.getLength() == nMembers)do { if (true && (!(templateMemberTypes.getLength() == nMembers))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "269" ": "), "OSL_ASSERT: %s", "templateMemberTypes.getLength() == nMembers" ); } } while (false); | |||||
| 270 | } | |||||
| 271 | ||||||
| 272 | sal_Int32 nPos; | |||||
| 273 | for ( nPos = nMembers; nPos--; ) | |||||
| 274 | { | |||||
| 275 | typelib_StructMember_Init & rInit = pMemberInits[nPos]; | |||||
| 276 | rInit.aBase.eTypeClass | |||||
| 277 | = (typelib_TypeClass)pMemberTypes[nPos]->getTypeClass(); | |||||
| 278 | ||||||
| 279 | OUString aMemberTypeName( pMemberTypes[nPos]->getName() ); | |||||
| 280 | rtl_uString_acquire( | |||||
| 281 | rInit.aBase.pTypeName = aMemberTypeName.pData ); | |||||
| 282 | ||||||
| 283 | // string is held by rMemberNames | |||||
| 284 | rInit.aBase.pMemberName = pMemberNames[nPos].pData; | |||||
| 285 | ||||||
| 286 | rInit.bParameterizedType = templateMemberTypes.getLength() != 0 | |||||
| 287 | && (templateMemberTypes[nPos]->getTypeClass() | |||||
| 288 | == TypeClass_UNKNOWN); | |||||
| 289 | } | |||||
| 290 | ||||||
| 291 | typelib_typedescription_newStruct( | |||||
| 292 | &pRet, | |||||
| 293 | aTypeName.pData, | |||||
| 294 | (pBaseType ? pBaseType->pWeakRef : 0), | |||||
| 295 | nMembers, pMemberInits ); | |||||
| 296 | ||||||
| 297 | // cleanup | |||||
| 298 | for ( nPos = nMembers; nPos--; ) | |||||
| 299 | { | |||||
| 300 | rtl_uString_release( pMemberInits[nPos].aBase.pTypeName ); | |||||
| 301 | } | |||||
| 302 | if (pBaseType) | |||||
| 303 | typelib_typedescription_release( pBaseType ); | |||||
| 304 | } | |||||
| 305 | return pRet; | |||||
| 306 | } | |||||
| 307 | //================================================================================================== | |||||
| 308 | inline static typelib_TypeDescription * createCTD( | |||||
| 309 | const Reference< XInterfaceAttributeTypeDescription2 > & xAttribute ) | |||||
| 310 | { | |||||
| 311 | typelib_TypeDescription * pRet = 0; | |||||
| 312 | if (xAttribute.is()) | |||||
| 313 | { | |||||
| 314 | OUString aMemberName( xAttribute->getName() ); | |||||
| 315 | Reference< XTypeDescription > xType( xAttribute->getType() ); | |||||
| 316 | OUString aMemberTypeName( xType->getName() ); | |||||
| 317 | std::vector< rtl_uString * > getExc; | |||||
| 318 | Sequence< Reference< XCompoundTypeDescription > > getExcs( | |||||
| 319 | xAttribute->getGetExceptions() ); | |||||
| 320 | for (sal_Int32 i = 0; i != getExcs.getLength(); ++i) | |||||
| 321 | { | |||||
| 322 | OSL_ASSERT( getExcs[i].is() )do { if (true && (!(getExcs[i].is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "322" ": "), "OSL_ASSERT: %s", "getExcs[i].is()"); } } while (false); | |||||
| 323 | getExc.push_back( getExcs[i]->getName().pData ); | |||||
| 324 | } | |||||
| 325 | std::vector< rtl_uString * > setExc; | |||||
| 326 | Sequence< Reference< XCompoundTypeDescription > > setExcs( | |||||
| 327 | xAttribute->getSetExceptions() ); | |||||
| 328 | for (sal_Int32 i = 0; i != setExcs.getLength(); ++i) | |||||
| 329 | { | |||||
| 330 | OSL_ASSERT( setExcs[i].is() )do { if (true && (!(setExcs[i].is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "330" ": "), "OSL_ASSERT: %s", "setExcs[i].is()"); } } while (false); | |||||
| 331 | setExc.push_back( setExcs[i]->getName().pData ); | |||||
| 332 | } | |||||
| 333 | typelib_typedescription_newExtendedInterfaceAttribute( | |||||
| 334 | (typelib_InterfaceAttributeTypeDescription **)&pRet, | |||||
| 335 | xAttribute->getPosition(), | |||||
| 336 | aMemberName.pData, // name | |||||
| 337 | (typelib_TypeClass)xType->getTypeClass(), | |||||
| 338 | aMemberTypeName.pData, // type name | |||||
| 339 | xAttribute->isReadOnly(), | |||||
| 340 | getExc.size(), getExc.empty() ? 0 : &getExc[0], | |||||
| 341 | setExc.size(), setExc.empty() ? 0 : &setExc[0] ); | |||||
| 342 | } | |||||
| 343 | return pRet; | |||||
| 344 | } | |||||
| 345 | //================================================================================================== | |||||
| 346 | static typelib_TypeDescription * createCTD( | |||||
| 347 | const Reference< XInterfaceMethodTypeDescription > & xMethod ) | |||||
| 348 | { | |||||
| 349 | typelib_TypeDescription * pRet = 0; | |||||
| 350 | if (xMethod.is()) | |||||
| 351 | { | |||||
| 352 | Reference< XTypeDescription > xReturnType( xMethod->getReturnType() ); | |||||
| 353 | ||||||
| 354 | // init all params | |||||
| 355 | const Sequence<Reference< XMethodParameter > > & rParams = xMethod->getParameters(); | |||||
| 356 | const Reference< XMethodParameter > * pParams = rParams.getConstArray(); | |||||
| 357 | sal_Int32 nParams = rParams.getLength(); | |||||
| 358 | ||||||
| 359 | typelib_Parameter_Init * pParamInit = (typelib_Parameter_Init *)alloca(__builtin_alloca (sizeof(typelib_Parameter_Init) * nParams) | |||||
| 360 | sizeof(typelib_Parameter_Init) * nParams )__builtin_alloca (sizeof(typelib_Parameter_Init) * nParams); | |||||
| 361 | ||||||
| 362 | sal_Int32 nPos; | |||||
| 363 | for ( nPos = nParams; nPos--; ) | |||||
| 364 | { | |||||
| 365 | const Reference< XMethodParameter > & xParam = pParams[nPos]; | |||||
| 366 | const Reference< XTypeDescription > & xType = xParam->getType(); | |||||
| 367 | typelib_Parameter_Init & rInit = pParamInit[xParam->getPosition()]; | |||||
| 368 | ||||||
| 369 | rInit.eTypeClass = (typelib_TypeClass)xType->getTypeClass(); | |||||
| 370 | OUString aParamTypeName( xType->getName() ); | |||||
| 371 | rtl_uString_acquire( rInit.pTypeName = aParamTypeName.pData ); | |||||
| 372 | OUString aParamName( xParam->getName() ); | |||||
| 373 | rtl_uString_acquire( rInit.pParamName = aParamName.pData ); | |||||
| 374 | rInit.bIn = xParam->isIn(); | |||||
| 375 | rInit.bOut = xParam->isOut(); | |||||
| 376 | } | |||||
| 377 | ||||||
| 378 | // init all exception strings | |||||
| 379 | const Sequence<Reference< XTypeDescription > > & rExceptions = xMethod->getExceptions(); | |||||
| 380 | const Reference< XTypeDescription > * pExceptions = rExceptions.getConstArray(); | |||||
| 381 | sal_Int32 nExceptions = rExceptions.getLength(); | |||||
| 382 | rtl_uString ** ppExceptionNames = (rtl_uString **)alloca(__builtin_alloca (sizeof(rtl_uString *) * nExceptions) | |||||
| 383 | sizeof(rtl_uString *) * nExceptions )__builtin_alloca (sizeof(rtl_uString *) * nExceptions); | |||||
| 384 | ||||||
| 385 | for ( nPos = nExceptions; nPos--; ) | |||||
| 386 | { | |||||
| 387 | OUString aExceptionTypeName( pExceptions[nPos]->getName() ); | |||||
| 388 | rtl_uString_acquire( ppExceptionNames[nPos] = aExceptionTypeName.pData ); | |||||
| 389 | } | |||||
| 390 | ||||||
| 391 | OUString aTypeName( xMethod->getName() ); | |||||
| 392 | OUString aReturnTypeName( xReturnType->getName() ); | |||||
| 393 | ||||||
| 394 | typelib_typedescription_newInterfaceMethod( | |||||
| 395 | (typelib_InterfaceMethodTypeDescription **)&pRet, | |||||
| 396 | xMethod->getPosition(), | |||||
| 397 | xMethod->isOneway(), | |||||
| 398 | aTypeName.pData, | |||||
| 399 | (typelib_TypeClass)xReturnType->getTypeClass(), | |||||
| 400 | aReturnTypeName.pData, | |||||
| 401 | nParams, pParamInit, | |||||
| 402 | nExceptions, ppExceptionNames ); | |||||
| 403 | ||||||
| 404 | for ( nPos = nParams; nPos--; ) | |||||
| 405 | { | |||||
| 406 | rtl_uString_release( pParamInit[nPos].pTypeName ); | |||||
| 407 | rtl_uString_release( pParamInit[nPos].pParamName ); | |||||
| 408 | } | |||||
| 409 | for ( nPos = nExceptions; nPos--; ) | |||||
| 410 | { | |||||
| 411 | rtl_uString_release( ppExceptionNames[nPos] ); | |||||
| 412 | } | |||||
| 413 | } | |||||
| 414 | return pRet; | |||||
| 415 | } | |||||
| 416 | //================================================================================================== | |||||
| 417 | inline static typelib_TypeDescription * createCTD( | |||||
| 418 | Reference< container::XHierarchicalNameAccess > const & access, | |||||
| 419 | const Reference< XInterfaceTypeDescription2 > & xType ) | |||||
| 420 | { | |||||
| 421 | typelib_TypeDescription * pRet = 0; | |||||
| 422 | if (xType.is()) | |||||
| 423 | { | |||||
| 424 | Sequence< Reference< XTypeDescription > > aBases(xType->getBaseTypes()); | |||||
| 425 | sal_Int32 nBases = aBases.getLength(); | |||||
| 426 | // Exploit the fact that a typelib_TypeDescription for an interface type | |||||
| 427 | // is also the typelib_TypeDescriptionReference for that type: | |||||
| 428 | boost::scoped_array< typelib_TypeDescription * > aBaseTypes( | |||||
| 429 | new typelib_TypeDescription *[nBases]); | |||||
| 430 | {for (sal_Int32 i = 0; i < nBases; ++i) { | |||||
| 431 | typelib_TypeDescription * p = createCTD(access, aBases[i]); | |||||
| 432 | OSL_ASSERT(do { if (true && (!(!((p->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (p->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "433" ": "), "OSL_ASSERT: %s", "!TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(p->eTypeClass)" ); } } while (false) | |||||
| ||||||
| 433 | !TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(p->eTypeClass))do { if (true && (!(!((p->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (p->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "433" ": "), "OSL_ASSERT: %s", "!TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(p->eTypeClass)" ); } } while (false); | |||||
| 434 | typelib_typedescription_register(&p); | |||||
| 435 | aBaseTypes[i] = p; | |||||
| 436 | }} | |||||
| 437 | typelib_TypeDescriptionReference ** pBaseTypeRefs | |||||
| 438 | = reinterpret_cast< typelib_TypeDescriptionReference ** >( | |||||
| 439 | aBaseTypes.get()); | |||||
| 440 | ||||||
| 441 | // construct all member refs | |||||
| 442 | const Sequence<Reference< XInterfaceMemberTypeDescription > > & rMembers = xType->getMembers(); | |||||
| 443 | sal_Int32 nMembers = rMembers.getLength(); | |||||
| 444 | ||||||
| 445 | typelib_TypeDescriptionReference ** ppMemberRefs = (typelib_TypeDescriptionReference **)alloca(__builtin_alloca (sizeof(typelib_TypeDescriptionReference *) * nMembers) | |||||
| 446 | sizeof(typelib_TypeDescriptionReference *) * nMembers )__builtin_alloca (sizeof(typelib_TypeDescriptionReference *) * nMembers); | |||||
| 447 | ||||||
| 448 | const Reference< XInterfaceMemberTypeDescription > * pMembers = rMembers.getConstArray(); | |||||
| 449 | ||||||
| 450 | OUString aTypeName( xType->getName() ); | |||||
| 451 | ||||||
| 452 | sal_Int32 nPos; | |||||
| 453 | for ( nPos = nMembers; nPos--; ) | |||||
| 454 | { | |||||
| 455 | OUString aMemberTypeName( pMembers[nPos]->getName() ); | |||||
| 456 | ppMemberRefs[nPos] = 0; | |||||
| 457 | typelib_typedescriptionreference_new( | |||||
| 458 | ppMemberRefs + nPos, | |||||
| 459 | (typelib_TypeClass)pMembers[nPos]->getTypeClass(), | |||||
| 460 | aMemberTypeName.pData ); | |||||
| 461 | } | |||||
| 462 | ||||||
| 463 | Uik uik = xType->getUik(); | |||||
| 464 | ||||||
| 465 | typelib_typedescription_newMIInterface( | |||||
| 466 | (typelib_InterfaceTypeDescription **)&pRet, | |||||
| 467 | aTypeName.pData, | |||||
| 468 | uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5, | |||||
| 469 | nBases, pBaseTypeRefs, | |||||
| 470 | nMembers, ppMemberRefs ); | |||||
| 471 | ||||||
| 472 | // cleanup refs and base type | |||||
| 473 | {for (int i = 0; i < nBases; ++i) { | |||||
| 474 | typelib_typedescription_release(aBaseTypes[i]); | |||||
| 475 | }} | |||||
| 476 | ||||||
| 477 | for ( nPos = nMembers; nPos--; ) | |||||
| 478 | { | |||||
| 479 | typelib_typedescriptionreference_release( ppMemberRefs[nPos] ); | |||||
| 480 | } | |||||
| 481 | } | |||||
| 482 | return pRet; | |||||
| 483 | } | |||||
| 484 | //================================================================================================== | |||||
| 485 | inline static typelib_TypeDescription * createCTD( const Reference< XEnumTypeDescription > & xType ) | |||||
| 486 | { | |||||
| 487 | typelib_TypeDescription * pRet = 0; | |||||
| 488 | if (xType.is()) | |||||
| 489 | { | |||||
| 490 | OUString aTypeName( xType->getName() ); | |||||
| 491 | Sequence< OUString > aNames( xType->getEnumNames() ); | |||||
| 492 | OSL_ASSERT( sizeof(OUString) == sizeof(rtl_uString *) )do { if (true && (!(sizeof(OUString) == sizeof(rtl_uString *)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "492" ": "), "OSL_ASSERT: %s", "sizeof(OUString) == sizeof(rtl_uString *)" ); } } while (false); // !!! | |||||
| 493 | Sequence< sal_Int32 > aValues( xType->getEnumValues() ); | |||||
| 494 | ||||||
| 495 | typelib_typedescription_newEnum( | |||||
| 496 | &pRet, aTypeName.pData, xType->getDefaultEnumValue(), | |||||
| 497 | aNames.getLength(), | |||||
| 498 | (rtl_uString **)aNames.getConstArray(), | |||||
| 499 | const_cast< sal_Int32 * >( aValues.getConstArray() ) ); | |||||
| 500 | } | |||||
| 501 | return pRet; | |||||
| 502 | } | |||||
| 503 | //================================================================================================== | |||||
| 504 | inline static typelib_TypeDescription * createCTD( | |||||
| 505 | Reference< container::XHierarchicalNameAccess > const & access, | |||||
| 506 | const Reference< XIndirectTypeDescription > & xType ) | |||||
| 507 | { | |||||
| 508 | typelib_TypeDescription * pRet = 0; | |||||
| 509 | if (xType.is()) | |||||
| ||||||
| 510 | { | |||||
| 511 | typelib_TypeDescription * pRefType = createCTD( | |||||
| 512 | access, xType->getReferencedType() ); | |||||
| 513 | typelib_typedescription_register( &pRefType ); | |||||
| 514 | ||||||
| 515 | OUString aTypeName( xType->getName() ); | |||||
| 516 | ||||||
| 517 | typelib_typedescription_new( | |||||
| 518 | &pRet, | |||||
| 519 | (typelib_TypeClass)xType->getTypeClass(), | |||||
| 520 | aTypeName.pData, | |||||
| 521 | pRefType->pWeakRef, | |||||
| 522 | 0, 0 ); | |||||
| 523 | ||||||
| 524 | // cleanup | |||||
| 525 | typelib_typedescription_release( pRefType ); | |||||
| 526 | } | |||||
| 527 | return pRet; | |||||
| 528 | } | |||||
| 529 | ||||||
| 530 | //================================================================================================== | |||||
| 531 | static typelib_TypeDescription * createCTD( | |||||
| 532 | Reference< container::XHierarchicalNameAccess > const & access, | |||||
| 533 | const Reference< XTypeDescription > & xType ) | |||||
| 534 | { | |||||
| 535 | typelib_TypeDescription * pRet = 0; | |||||
| 536 | ||||||
| 537 | if (xType.is()) | |||||
| 538 | { | |||||
| 539 | switch (xType->getTypeClass()) | |||||
| 540 | { | |||||
| 541 | // built in types | |||||
| 542 | case TypeClass_VOID: | |||||
| 543 | { | |||||
| 544 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("void")(&("void")[0]), ((sal_Int32)((sizeof ("void") / sizeof (( "void")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 545 | typelib_typedescription_new( &pRet, typelib_TypeClass_VOID, aTypeName.pData, 0, 0, 0 ); | |||||
| 546 | break; | |||||
| 547 | } | |||||
| 548 | case TypeClass_CHAR: | |||||
| 549 | { | |||||
| 550 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("char")(&("char")[0]), ((sal_Int32)((sizeof ("char") / sizeof (( "char")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 551 | typelib_typedescription_new( &pRet, typelib_TypeClass_CHAR, aTypeName.pData, 0, 0, 0 ); | |||||
| 552 | break; | |||||
| 553 | } | |||||
| 554 | case TypeClass_BOOLEAN: | |||||
| 555 | { | |||||
| 556 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("boolean")(&("boolean")[0]), ((sal_Int32)((sizeof ("boolean") / sizeof (("boolean")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 557 | typelib_typedescription_new( &pRet, typelib_TypeClass_BOOLEAN, aTypeName.pData, 0, 0, 0 ); | |||||
| 558 | break; | |||||
| 559 | } | |||||
| 560 | case TypeClass_BYTE: | |||||
| 561 | { | |||||
| 562 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("byte")(&("byte")[0]), ((sal_Int32)((sizeof ("byte") / sizeof (( "byte")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 563 | typelib_typedescription_new( &pRet, typelib_TypeClass_BYTE, aTypeName.pData, 0, 0, 0 ); | |||||
| 564 | break; | |||||
| 565 | } | |||||
| 566 | case TypeClass_SHORT: | |||||
| 567 | { | |||||
| 568 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("short")(&("short")[0]), ((sal_Int32)((sizeof ("short") / sizeof ( ("short")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 569 | typelib_typedescription_new( &pRet, typelib_TypeClass_SHORT, aTypeName.pData, 0, 0, 0 ); | |||||
| 570 | break; | |||||
| 571 | } | |||||
| 572 | case TypeClass_UNSIGNED_SHORT: | |||||
| 573 | { | |||||
| 574 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("unsigned short")(&("unsigned short")[0]), ((sal_Int32)((sizeof ("unsigned short" ) / sizeof (("unsigned short")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 575 | typelib_typedescription_new( &pRet, typelib_TypeClass_UNSIGNED_SHORT, aTypeName.pData, 0, 0, 0 ); | |||||
| 576 | break; | |||||
| 577 | } | |||||
| 578 | case TypeClass_LONG: | |||||
| 579 | { | |||||
| 580 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("long")(&("long")[0]), ((sal_Int32)((sizeof ("long") / sizeof (( "long")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 581 | typelib_typedescription_new( &pRet, typelib_TypeClass_LONG, aTypeName.pData, 0, 0, 0 ); | |||||
| 582 | break; | |||||
| 583 | } | |||||
| 584 | case TypeClass_UNSIGNED_LONG: | |||||
| 585 | { | |||||
| 586 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("unsigned long")(&("unsigned long")[0]), ((sal_Int32)((sizeof ("unsigned long" ) / sizeof (("unsigned long")[0]))-1)), (((rtl_TextEncoding) 11 )) ); | |||||
| 587 | typelib_typedescription_new( &pRet, typelib_TypeClass_UNSIGNED_LONG, aTypeName.pData, 0, 0, 0 ); | |||||
| 588 | break; | |||||
| 589 | } | |||||
| 590 | case TypeClass_HYPER: | |||||
| 591 | { | |||||
| 592 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("hyper")(&("hyper")[0]), ((sal_Int32)((sizeof ("hyper") / sizeof ( ("hyper")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 593 | typelib_typedescription_new( &pRet, typelib_TypeClass_HYPER, aTypeName.pData, 0, 0, 0 ); | |||||
| 594 | break; | |||||
| 595 | } | |||||
| 596 | case TypeClass_UNSIGNED_HYPER: | |||||
| 597 | { | |||||
| 598 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("unsigned hyper")(&("unsigned hyper")[0]), ((sal_Int32)((sizeof ("unsigned hyper" ) / sizeof (("unsigned hyper")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 599 | typelib_typedescription_new( &pRet, typelib_TypeClass_UNSIGNED_HYPER, aTypeName.pData, 0, 0, 0 ); | |||||
| 600 | break; | |||||
| 601 | } | |||||
| 602 | case TypeClass_FLOAT: | |||||
| 603 | { | |||||
| 604 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("float")(&("float")[0]), ((sal_Int32)((sizeof ("float") / sizeof ( ("float")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 605 | typelib_typedescription_new( &pRet, typelib_TypeClass_FLOAT, aTypeName.pData, 0, 0, 0 ); | |||||
| 606 | break; | |||||
| 607 | } | |||||
| 608 | case TypeClass_DOUBLE: | |||||
| 609 | { | |||||
| 610 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("double")(&("double")[0]), ((sal_Int32)((sizeof ("double") / sizeof (("double")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 611 | typelib_typedescription_new( &pRet, typelib_TypeClass_DOUBLE, aTypeName.pData, 0, 0, 0 ); | |||||
| 612 | break; | |||||
| 613 | } | |||||
| 614 | case TypeClass_STRING: | |||||
| 615 | { | |||||
| 616 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("string")(&("string")[0]), ((sal_Int32)((sizeof ("string") / sizeof (("string")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 617 | typelib_typedescription_new( &pRet, typelib_TypeClass_STRING, aTypeName.pData, 0, 0, 0 ); | |||||
| 618 | break; | |||||
| 619 | } | |||||
| 620 | case TypeClass_TYPE: | |||||
| 621 | { | |||||
| 622 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("type")(&("type")[0]), ((sal_Int32)((sizeof ("type") / sizeof (( "type")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 623 | typelib_typedescription_new( &pRet, typelib_TypeClass_TYPE, aTypeName.pData, 0, 0, 0 ); | |||||
| 624 | break; | |||||
| 625 | } | |||||
| 626 | case TypeClass_ANY: | |||||
| 627 | { | |||||
| 628 | OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("any")(&("any")[0]), ((sal_Int32)((sizeof ("any") / sizeof (("any" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 629 | typelib_typedescription_new( &pRet, typelib_TypeClass_ANY, aTypeName.pData, 0, 0, 0 ); | |||||
| 630 | break; | |||||
| 631 | } | |||||
| 632 | ||||||
| 633 | case TypeClass_UNION: | |||||
| 634 | pRet = createCTD( Reference< XUnionTypeDescription >::query( xType ) ); | |||||
| 635 | break; | |||||
| 636 | case TypeClass_EXCEPTION: | |||||
| 637 | pRet = createCTD( Reference< XCompoundTypeDescription >::query( xType ) ); | |||||
| 638 | break; | |||||
| 639 | case TypeClass_STRUCT: | |||||
| 640 | pRet = createCTD( | |||||
| 641 | access, Reference< XStructTypeDescription >::query( xType ) ); | |||||
| 642 | break; | |||||
| 643 | case TypeClass_ENUM: | |||||
| 644 | pRet = createCTD( Reference< XEnumTypeDescription >::query( xType ) ); | |||||
| 645 | break; | |||||
| 646 | case TypeClass_TYPEDEF: | |||||
| 647 | { | |||||
| 648 | Reference< XIndirectTypeDescription > xTypedef( xType, UNO_QUERY ); | |||||
| 649 | if (xTypedef.is()) | |||||
| 650 | pRet = createCTD( access, xTypedef->getReferencedType() ); | |||||
| 651 | break; | |||||
| 652 | } | |||||
| 653 | case TypeClass_SEQUENCE: | |||||
| 654 | pRet = createCTD( | |||||
| 655 | access, Reference< XIndirectTypeDescription >::query( xType ) ); | |||||
| 656 | break; | |||||
| 657 | case TypeClass_INTERFACE: | |||||
| 658 | pRet = createCTD( | |||||
| 659 | access, | |||||
| 660 | Reference< XInterfaceTypeDescription2 >::query( xType ) ); | |||||
| 661 | break; | |||||
| 662 | case TypeClass_INTERFACE_METHOD: | |||||
| 663 | pRet = createCTD( Reference< XInterfaceMethodTypeDescription >::query( xType ) ); | |||||
| 664 | break; | |||||
| 665 | case TypeClass_INTERFACE_ATTRIBUTE: | |||||
| 666 | pRet = createCTD( Reference< XInterfaceAttributeTypeDescription2 >::query( xType ) ); | |||||
| 667 | break; | |||||
| 668 | default: | |||||
| 669 | break; | |||||
| 670 | } | |||||
| 671 | } | |||||
| 672 | ||||||
| 673 | return pRet; | |||||
| 674 | } | |||||
| 675 | ||||||
| 676 | ||||||
| 677 | //================================================================================================== | |||||
| 678 | extern "C" | |||||
| 679 | { | |||||
| 680 | static void SAL_CALL typelib_callback( | |||||
| 681 | void * pContext, typelib_TypeDescription ** ppRet, rtl_uString * pTypeName ) | |||||
| 682 | { | |||||
| 683 | OSL_ENSURE( pContext && ppRet && pTypeName, "### null ptr!" )do { if (true && (!(pContext && ppRet && pTypeName))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "683" ": "), "%s", "### null ptr!"); } } while (false); | |||||
| 684 | if (ppRet) | |||||
| 685 | { | |||||
| 686 | if (*ppRet) | |||||
| 687 | { | |||||
| 688 | ::typelib_typedescription_release( *ppRet ); | |||||
| 689 | *ppRet = 0; | |||||
| 690 | } | |||||
| 691 | if (pContext && pTypeName) | |||||
| 692 | { | |||||
| 693 | Reference< container::XHierarchicalNameAccess > access( | |||||
| 694 | reinterpret_cast< container::XHierarchicalNameAccess * >( | |||||
| 695 | pContext)); | |||||
| 696 | try | |||||
| 697 | { | |||||
| 698 | OUString const & rTypeName = OUString::unacquired( &pTypeName ); | |||||
| 699 | Reference< XTypeDescription > xTD; | |||||
| 700 | if (access->getByHierarchicalName(rTypeName ) >>= xTD) | |||||
| 701 | { | |||||
| 702 | *ppRet = createCTD( access, xTD ); | |||||
| 703 | } | |||||
| 704 | } | |||||
| 705 | catch (container::NoSuchElementException & exc) | |||||
| 706 | { | |||||
| 707 | (void) exc; // avoid warning about unused variable | |||||
| 708 | OSL_TRACE(do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "711" ": "), "typelibrary type not available: %s", OUStringToOString ( exc.Message, (((rtl_TextEncoding) 76)) ).getStr()); } } while (false) | |||||
| 709 | "typelibrary type not available: %s",do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "711" ": "), "typelibrary type not available: %s", OUStringToOString ( exc.Message, (((rtl_TextEncoding) 76)) ).getStr()); } } while (false) | |||||
| 710 | OUStringToOString(do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "711" ": "), "typelibrary type not available: %s", OUStringToOString ( exc.Message, (((rtl_TextEncoding) 76)) ).getStr()); } } while (false) | |||||
| 711 | exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() )do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "711" ": "), "typelibrary type not available: %s", OUStringToOString ( exc.Message, (((rtl_TextEncoding) 76)) ).getStr()); } } while (false); | |||||
| 712 | } | |||||
| 713 | catch (Exception & exc) | |||||
| 714 | { | |||||
| 715 | (void) exc; // avoid warning about unused variable | |||||
| 716 | OSL_TRACE(do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "719" ": "), "%s", OUStringToOString( exc.Message, (((rtl_TextEncoding ) 76)) ).getStr()); } } while (false) | |||||
| 717 | "%s",do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "719" ": "), "%s", OUStringToOString( exc.Message, (((rtl_TextEncoding ) 76)) ).getStr()); } } while (false) | |||||
| 718 | OUStringToOString(do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "719" ": "), "%s", OUStringToOString( exc.Message, (((rtl_TextEncoding ) 76)) ).getStr()); } } while (false) | |||||
| 719 | exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() )do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "719" ": "), "%s", OUStringToOString( exc.Message, (((rtl_TextEncoding ) 76)) ).getStr()); } } while (false); | |||||
| 720 | } | |||||
| 721 | } | |||||
| 722 | } | |||||
| 723 | } | |||||
| 724 | } | |||||
| 725 | ||||||
| 726 | //================================================================================================== | |||||
| 727 | class EventListenerImpl | |||||
| 728 | : public WeakImplHelper1< lang::XEventListener > | |||||
| 729 | { | |||||
| 730 | Reference< container::XHierarchicalNameAccess > m_xTDMgr; | |||||
| 731 | ||||||
| 732 | public: | |||||
| 733 | inline EventListenerImpl( | |||||
| 734 | Reference< container::XHierarchicalNameAccess > const & xTDMgr ) | |||||
| 735 | SAL_THROW(()) | |||||
| 736 | : m_xTDMgr( xTDMgr ) | |||||
| 737 | {} | |||||
| 738 | ||||||
| 739 | // XEventListener | |||||
| 740 | virtual void SAL_CALL disposing( lang::EventObject const & rEvt ) | |||||
| 741 | throw (RuntimeException); | |||||
| 742 | }; | |||||
| 743 | //__________________________________________________________________________________________________ | |||||
| 744 | void EventListenerImpl::disposing( lang::EventObject const & rEvt ) | |||||
| 745 | throw (RuntimeException) | |||||
| 746 | { | |||||
| 747 | if (rEvt.Source != m_xTDMgr) { | |||||
| 748 | OSL_ASSERT(false)do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/tdmgr.cxx" ":" "748" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); | |||||
| 749 | } | |||||
| 750 | // deregister of c typelib callback | |||||
| 751 | ::typelib_typedescription_revokeCallback( m_xTDMgr.get(), typelib_callback ); | |||||
| 752 | } | |||||
| 753 | ||||||
| 754 | //================================================================================================== | |||||
| 755 | sal_Bool SAL_CALL installTypeDescriptionManager( | |||||
| 756 | Reference< container::XHierarchicalNameAccess > const & xTDMgr_c ) | |||||
| 757 | SAL_THROW(()) | |||||
| 758 | { | |||||
| 759 | uno::Environment curr_env(Environment::getCurrent()); | |||||
| 760 | uno::Environment target_env(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV))(&("gcc3")[0]), ((sal_Int32)((sizeof ("gcc3") / sizeof (( "gcc3")[0]))-1)), (((rtl_TextEncoding) 11)))); | |||||
| 761 | ||||||
| 762 | uno::Mapping curr2target(curr_env, target_env); | |||||
| 763 | ||||||
| 764 | ||||||
| 765 | Reference<container::XHierarchicalNameAccess> xTDMgr( | |||||
| 766 | reinterpret_cast<container::XHierarchicalNameAccess *>( | |||||
| 767 | curr2target.mapInterface(xTDMgr_c.get(), ::getCppuType(&xTDMgr_c))), | |||||
| 768 | SAL_NO_ACQUIRE); | |||||
| 769 | ||||||
| 770 | Reference< lang::XComponent > xComp( xTDMgr, UNO_QUERY ); | |||||
| 771 | if (xComp.is()) | |||||
| 772 | { | |||||
| 773 | xComp->addEventListener( new EventListenerImpl( xTDMgr ) ); | |||||
| 774 | // register c typelib callback | |||||
| 775 | ::typelib_typedescription_registerCallback( xTDMgr.get(), typelib_callback ); | |||||
| 776 | return sal_True((sal_Bool)1); | |||||
| 777 | } | |||||
| 778 | return sal_False((sal_Bool)0); | |||||
| 779 | } | |||||
| 780 | ||||||
| 781 | } // end namespace cppu | |||||
| 782 | ||||||
| 783 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |