1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_stoc.hxx" 30 31 #include <sal/main.h> 32 #include <osl/diagnose.h> 33 34 #if OSL_DEBUG_LEVEL > 0 35 #define TEST_ENSHURE(c, m) OSL_ENSURE(c, m) 36 #else 37 #define TEST_ENSHURE(c, m) OSL_VERIFY(c) 38 #endif 39 40 #include <cppuhelper/servicefactory.hxx> 41 #include <cppuhelper/weak.hxx> 42 #include <cppuhelper/implbase1.hxx> 43 44 #include <ModuleA/XInterface1.hpp> 45 #include <ModuleC/XInterfaceA.hpp> 46 #include <ModuleC/XInterfaceB.hpp> 47 #include <ModuleC/ModuleC.hpp> 48 49 #include <com/sun/star/container/XHierarchicalNameAccess.hpp> 50 #include <com/sun/star/lang/XComponent.hpp> 51 #include <com/sun/star/reflection/XIdlReflection.hpp> 52 #include <com/sun/star/reflection/XIdlField2.hpp> 53 #include <com/sun/star/beans/XPropertySet.hpp> 54 #include <com/sun/star/registry/XSimpleRegistry.hpp> 55 #include <com/sun/star/registry/XImplementationRegistration.hpp> 56 57 #include <rtl/ustrbuf.hxx> 58 59 #include <stdio.h> 60 61 62 using namespace rtl; 63 using namespace cppu; 64 using namespace osl; 65 using namespace ModuleA; 66 using namespace ModuleB; 67 using namespace ModuleC; 68 using namespace ModuleA::ModuleB; 69 using namespace com::sun::star; 70 using namespace com::sun::star::uno; 71 using namespace com::sun::star::lang; 72 using namespace com::sun::star::beans; 73 using namespace com::sun::star::registry; 74 using namespace com::sun::star::reflection; 75 using namespace com::sun::star::container; 76 77 78 //================================================================================================== 79 class OInterfaceA : public WeakImplHelper1< XInterfaceA > 80 { 81 public: 82 83 virtual void SAL_CALL methodA(void) throw (RuntimeException) 84 {} 85 86 virtual void SAL_CALL methodB(sal_Int16 /*aShort*/) throw (RuntimeException) 87 {} 88 virtual Sequence< StructB > SAL_CALL methodC(const StructC& /*aStructC*/, StructA& /*aStructA*/) throw (RuntimeException) 89 { return Sequence< StructB >(); } 90 }; 91 92 //================================================================================================== 93 static inline bool uik_equals( const Uik & rUik1, const Uik & rUik2 ) 94 { 95 return (rUik1.m_Data1 == rUik2.m_Data1 && 96 rUik1.m_Data2 == rUik2.m_Data2 && 97 rUik1.m_Data3 == rUik2.m_Data3 && 98 rUik1.m_Data4 == rUik2.m_Data4 && 99 rUik1.m_Data5 == rUik2.m_Data5); 100 } 101 //================================================================================================== 102 static sal_Bool test_corefl( const Reference< XIdlReflection > & xRefl ) 103 { 104 Reference< XIdlClass > xClass; 105 Reference< XHierarchicalNameAccess > xHNameAccess( xRefl, UNO_QUERY ); 106 TEST_ENSHURE(xHNameAccess.is(), "### cannot get XHierarchicalNameAccess!" ); 107 108 TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.StructA"))->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 2b"); 109 TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.ExceptionB"))->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 2c"); 110 TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.ModuleB.EnumA")).is(), "test_RegCoreReflection(): error 2e"); 111 // const 112 113 TEST_ENSHURE(*(const sal_Bool *)xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstBoolean")).getValue() == aConstBoolean, "test_RegCoreReflection(): error 4c"); 114 TEST_ENSHURE(*(const sal_Int8 *)xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstByte")).getValue() == aConstByte, "test_RegCoreReflection(): error 4e"); 115 TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstShort")) == aConstShort, "test_RegCoreReflection(): error 4g"); 116 TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstUShort")) == aConstUShort, "test_RegCoreReflection(): error 4i"); 117 TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstLong")) == aConstLong, "test_RegCoreReflection(): error 4k"); 118 TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstULong")) == aConstULong, "test_RegCoreReflection(): error 4m"); 119 // TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstFloat")) == aConstFloat, "test_RegCoreReflection(): error 4o"); 120 // TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstDouble")) == aConstDouble, "test_RegCoreReflection(): error 4q"); 121 122 // Enums 123 124 xClass = xRefl->forName(OUString::createFromAscii("ModuleA.ModuleB.EnumA")); 125 126 TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 5"); 127 128 Sequence<Reference< XIdlField > > fields = xClass->getFields(); 129 130 TEST_ENSHURE( 131 (fields.getLength() == 3) && 132 (fields.getArray()[0]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_1") )) && 133 (*(EnumA*)fields.getArray()[0]->get(Any()).getValue() == EnumA_VAL_1) && 134 (fields.getArray()[1]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_2") )) && 135 (*(EnumA*)fields.getArray()[1]->get(Any()).getValue() == EnumA_VAL_2) && 136 (fields.getArray()[2]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_3") )) && 137 (*(EnumA*)fields.getArray()[2]->get(Any()).getValue() == EnumA_VAL_3), 138 "test_RegCoreReflection(): error 6"); 139 140 141 // Interface 142 143 Reference< XIdlClass > xA = xRefl->forName( OUString::createFromAscii("ModuleC.XInterfaceB") ); 144 145 xClass = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceB")); 146 147 TEST_ENSHURE(xClass == xA, "test_RegCoreReflection(): error 7"); 148 TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 7a"); 149 150 typelib_TypeDescription * pTD = 0; 151 OUString aModuleName( RTL_CONSTASCII_USTRINGPARAM("ModuleC.XInterfaceB") ); 152 typelib_typedescription_getByName( &pTD, aModuleName.pData ); 153 TEST_ENSHURE( pTD, "### cannot get typedescription for ModuleC.XInterfaceB!" ); 154 155 TEST_ENSHURE( uik_equals( *(Uik *)&((typelib_InterfaceTypeDescription *)pTD)->aUik, 156 xClass->getUik() ), 157 "test_RegCoreReflection(): error 8" ); 158 typelib_typedescription_release( pTD ); 159 160 TEST_ENSHURE(xClass->getSuperclasses().getLength() == 1, "test_RegCoreReflection(): error 9"); 161 TEST_ENSHURE(xClass->getSuperclasses().getArray()[0]->getName() == OUString::createFromAscii("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 10"); 162 TEST_ENSHURE(xClass->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11"); 163 TEST_ENSHURE(xA->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11a"); 164 TEST_ENSHURE(xClass->getMethods().getArray()[3]->getName() == OUString::createFromAscii("methodA"), "test_RegCoreReflection(): 12"); 165 TEST_ENSHURE(xClass->getMethods().getArray()[3]->getReturnType()->getTypeClass() == TypeClass_VOID, "test_RegCoreReflection(): error 13"); 166 TEST_ENSHURE(xClass->getMethods().getArray()[3]->getParameterTypes().getLength() == 0, "test_RegCoreReflection(): error 14"); 167 TEST_ENSHURE(xClass->getMethods().getArray()[3]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 15"); 168 TEST_ENSHURE(xClass->getMethods().getArray()[4]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("methodB") ), "test_RegCoreReflection(): error 16"); 169 TEST_ENSHURE(xClass->getMethods().getArray()[4]->getMode() == MethodMode_ONEWAY, "test_RegCoreReflection(): error 16a"); 170 TEST_ENSHURE(xClass->getMethods().getArray()[4]->getReturnType()->getTypeClass() == TypeClass_VOID, "test_RegCoreReflection(): error 16"); 171 TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 17"); 172 TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_SHORT, "test_RegCoreReflection(): error 18"); 173 TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aName == OUString( RTL_CONSTASCII_USTRINGPARAM("aShort") ), "test_RegCoreReflection(): error 18a"); 174 TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aType == xRefl->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("short") ) ), "test_RegCoreReflection(): error 18b"); 175 TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aMode == ParamMode_IN, "test_RegCoreReflection(): error 18c"); 176 TEST_ENSHURE(xClass->getMethods().getArray()[4]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 19"); 177 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getName() == OUString::createFromAscii("methodC"), "test_RegCoreReflection(): error 20"); 178 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getMode() == MethodMode_TWOWAY, "test_RegCoreReflection(): error 20a"); 179 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 21"); 180 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getComponentType()->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 22"); 181 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getComponentType()->getName() == OUString::createFromAscii("ModuleA.StructB"), "test_RegCoreReflection(): error 23"); 182 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getLength() == 2, "test_RegCoreReflection(): error 24"); 183 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 25"); 184 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.StructC"), "test_RegCoreReflection(): error 26"); 185 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 27"); 186 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 28"); 187 TEST_ENSHURE(xClass->getMethods().getArray()[5]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 29"); 188 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getName() == OUString::createFromAscii("methodD"), "test_RegCoreReflection(): error 30"); 189 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getReturnType()->getTypeClass() == TypeClass_INTERFACE, "test_RegCoreReflection(): error 31"); 190 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getReturnType()->getName() == OUString::createFromAscii("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 32"); 191 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 33"); 192 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_ENUM, "test_RegCoreReflection(): error 34"); 193 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.ModuleB.EnumA"), "test_RegCoreReflection(): error 35"); 194 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getLength() == 3, "test_RegCoreReflection(): error 36"); 195 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 37"); 196 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.ExceptionA"), "test_RegCoreReflection(): error 38"); 197 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 38"); 198 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getName() == OUString::createFromAscii("ModuleA.ExceptionB"), "test_RegCoreReflection(): error 39"); 199 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 40"); 200 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getName() == OUString::createFromAscii("ModuleA.ExceptionC"), "test_RegCoreReflection(): error 41"); 201 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getLength() == 3, "test_RegCoreReflection(): error 42"); 202 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getTypeClass() == TypeClass_BOOLEAN, "test_RegCoreReflection(): error 43"); 203 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getName() == OUString::createFromAscii("boolean"), "test_RegCoreReflection(): error 43a"); 204 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 44"); 205 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getName() == OUString::createFromAscii("ModuleA.StructC"), "test_RegCoreReflection(): error 45"); 206 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getTypeClass() == TypeClass_INTERFACE, "test_RegCoreReflection(): error 46"); 207 TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getName() == OUString::createFromAscii("ModuleA.XInterface1"), "test_RegCoreReflection(): error 47"); 208 209 // SequenceReflections 210 211 TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 48"); 212 TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->getComponentType().is(), "test_RegCoreReflection(): error 49"); 213 TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[][]ModuleA.StructA") )->getComponentType()->getComponentType()->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 50"); 214 TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]com.sun.star.uno.XInterface") ) == xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructC") ))->getField(OUString::createFromAscii("aInterfaceSeq"))->getType(), "test_RegCoreReflection(): error 51"); 215 216 StructC aStructC; 217 aStructC.aLong = aConstLong; 218 aStructC.aShort = aConstShort; 219 aStructC.aFloat = aConstFloat; 220 aStructC.aDouble = aConstDouble; 221 aStructC.aInterfaceSeq = Sequence<Reference<XInterface > >(); 222 223 Any aAny; 224 225 xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aInterfaceSeq"))->getType()->createObject(aAny); 226 227 TEST_ENSHURE(aAny.getValueType() == ::getCppuType( (const Sequence<Reference< XInterface > > *)0 ), "test_RegCoreReflection(): error 51a"); 228 229 Any aStructAny(&aStructC, ::getCppuType( (const StructC *) 0 )); 230 231 sal_Int32 nLong = aConstLong * 2; 232 aAny.setValue( &nLong, ::getCppuType( (const sal_Int32 *)0 ) ); 233 234 TEST_ENSHURE(*(sal_Int32*)xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructA") ))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->get( 235 Any(&aStructC, ::getCppuType( (const StructC *)0 ))).getValue() == aConstLong, "test_RegCoreReflection(): error 52"); 236 TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.StructA"))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->getAccessMode() == FieldAccessMode_READWRITE, "test_RegCoreReflection(): error 52a"); 237 Reference< XIdlField2 > rField ( xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructC") ))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") )) , UNO_QUERY ); 238 rField->set(aStructAny, aAny); 239 TEST_ENSHURE(*(sal_Int32*)xRefl->forName(OUString::createFromAscii("ModuleA.StructB"))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->get(aStructAny).getValue() == *(sal_Int32*)aAny.getValue(), "test_RegCoreReflection(): error 53"); 240 241 xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->createObject(aAny); 242 243 TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("[]ModuleA.StructA")), "test_RegCoreReflection(): error 54"); 244 xRefl->forName(OUString::createFromAscii("[][]ModuleA.StructA"))->createObject(aAny); 245 246 TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("[][]ModuleA.StructA") ), "test_RegCoreReflection(): error 56"); 247 248 // xClass = xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.XIntroTest") )); 249 250 // TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 58"); 251 // TEST_ENSHURE(xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 59"); 252 // TEST_ENSHURE(xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->getComponentType()->getName() == OUString::createFromAscii("string"), "test_RegCoreReflection(): error 60"); 253 254 // xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->createObject(aAny); 255 // TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("[]string") ), "test_RegCoreReflection(): error 61"); 256 257 TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("[][][]unsigned long"))->getComponentType()->getComponentType()->getComponentType()->getTypeClass() == TypeClass_UNSIGNED_LONG, "test_RegCoreReflection(): error 62"); 258 259 try 260 { 261 fprintf( stderr, "%1\n" ); 262 Any bla = xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->get(Any()); 263 TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 63"); 264 return sal_False; 265 } 266 catch (IllegalArgumentException &) 267 { 268 } 269 270 try 271 { 272 fprintf( stderr, "%2\n" ); 273 Any blup; 274 blup <<= aStructC; 275 Any gulp; 276 rField = Reference< XIdlField2 > ( xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString")) , UNO_QUERY); 277 rField->set( blup, gulp); 278 // xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp); 279 TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 64"); 280 return sal_False; 281 } 282 catch (IllegalArgumentException &) 283 { 284 } 285 286 try 287 { 288 fprintf( stderr, "%3\n" ); 289 Any gulp; 290 gulp <<= 3.14f; 291 Any blup; 292 blup <<= aStructC; 293 rField = Reference< XIdlField2 > ( 294 xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString")) , UNO_QUERY); 295 xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp); 296 TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 65"); 297 return sal_False; 298 } 299 catch (IllegalArgumentException &) 300 { 301 } 302 303 Any gulp; 304 gulp <<= OUString(OUString::createFromAscii("Test")); 305 Any blup; 306 blup <<= aStructC; 307 xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp); 308 309 Reference< XInterfaceA > xAI = new OInterfaceA(); 310 311 try 312 { 313 Sequence< Any > params; 314 fprintf( stderr, "%4\n" ); 315 316 Any a; 317 a <<= xAI; 318 Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params); 319 TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 66"); 320 return sal_False; 321 } 322 catch (IllegalArgumentException &) 323 { 324 } 325 326 StructA aStructA; 327 328 { 329 Sequence< Any > params(2); 330 331 params.getArray()[0].setValue(&aStructC, ::getCppuType( (const StructC *)0 )); 332 params.getArray()[1].setValue(&aStructC, ::getCppuType( (const StructC *)0 )); 333 334 Any a; 335 a <<= xAI; 336 Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params); 337 } 338 try 339 { 340 Sequence< Any > params(2); 341 342 params.getArray()[0].setValue(&aStructA, ::getCppuType( (const StructA *)0 )); 343 params.getArray()[1].setValue(&aStructA, ::getCppuType( (const StructA *)0 )); 344 345 Any a; 346 a <<= xAI; 347 Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params); 348 TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 67"); 349 return sal_False; 350 } 351 catch (IllegalArgumentException &) 352 { 353 } 354 355 Sequence< Any > params(2); 356 357 params.getArray()[0].setValue(&aStructC, ::getCppuType( (const StructC *)0 )); 358 params.getArray()[1].setValue(&aStructA, ::getCppuType( (const StructA *)0 )); 359 360 Any a; 361 a <<= xAI; 362 TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params).getValueType() 363 == ::getCppuType( (const Sequence<StructB> *)0 ), "test_RegCoreReflection(): error 68"); 364 365 return sal_True; 366 } 367 368 SAL_IMPLEMENT_MAIN() 369 { 370 sal_Bool bSucc = sal_False; 371 try 372 { 373 OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( 374 "reflection.uno" SAL_DLLEXTENSION) ); 375 376 Reference< XMultiServiceFactory > xMgr( 377 createRegistryServiceFactory( 378 OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) ); 379 Reference< XComponentContext > xContext; 380 Reference< beans::XPropertySet > xProps( xMgr, UNO_QUERY ); 381 OSL_ASSERT( xProps.is() ); 382 xProps->getPropertyValue( 383 OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= 384 xContext; 385 OSL_ASSERT( xContext.is() ); 386 387 Reference< XIdlReflection > xRefl; 388 xContext->getValueByName( 389 OUString( 390 RTL_CONSTASCII_USTRINGPARAM( 391 "/singletons/com.sun.star.reflection.theCoreReflection")) ) 392 >>= xRefl; 393 OSL_ENSURE( 394 xRefl.is(), "### CoreReflection singleton not accessable!?" ); 395 396 bSucc = test_corefl( xRefl ); 397 398 Reference< XComponent >( xContext, UNO_QUERY )->dispose(); 399 } 400 catch (Exception & rExc) 401 { 402 OSL_ENSURE( sal_False, "### exception occured!" ); 403 OString aMsg( 404 OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); 405 OSL_TRACE( "### exception occured: " ); 406 OSL_TRACE( aMsg.getStr() ); 407 OSL_TRACE( "\n" ); 408 } 409 410 printf( "testcorefl %s !\n", (bSucc ? "succeeded" : "failed") ); 411 return (bSucc ? 0 : -1); 412 } 413