Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / stoc / test / testiadapter.cxx
blob22230d6da0936fa8a76d59588985ccbb1065b212
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <stdio.h>
23 #include <sal/main.h>
24 #include <osl/diagnose.h>
26 #include <cppuhelper/servicefactory.hxx>
27 #include <cppuhelper/weak.hxx>
29 #include <test/XLanguageBindingTest.hpp>
30 #include <com/sun/star/registry/XSimpleRegistry.hpp>
31 #include <com/sun/star/registry/XImplementationRegistration.hpp>
32 #include <com/sun/star/script/XInvocation.hpp>
33 #include <com/sun/star/script/XInvocationAdapterFactory.hpp>
34 #include <com/sun/star/script/XInvocationAdapterFactory2.hpp>
35 #include <com/sun/star/lang/XComponent.hpp>
36 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38 #include <cppuhelper/implbase1.hxx>
41 using namespace test;
42 using namespace cppu;
43 using namespace osl;
44 using namespace com::sun::star::uno;
45 using namespace com::sun::star::script;
46 using namespace com::sun::star::beans;
47 using namespace com::sun::star::lang;
48 using namespace com::sun::star::reflection;
49 using namespace com::sun::star::lang;
50 using namespace com::sun::star::registry;
52 using ::rtl::OUString;
53 using ::rtl::OString;
54 using ::rtl::OUStringToOString;
57 //==================================================================================================
58 sal_Bool equals( const test::TestElement & rData1, const test::TestElement & rData2 )
60 OSL_ENSURE( rData1.Bool == rData2.Bool, "### bool does not match!" );
61 OSL_ENSURE( rData1.Char == rData2.Char, "### char does not match!" );
62 OSL_ENSURE( rData1.Byte == rData2.Byte, "### byte does not match!" );
63 OSL_ENSURE( rData1.Short == rData2.Short, "### short does not match!" );
64 OSL_ENSURE( rData1.UShort == rData2.UShort, "### unsigned short does not match!" );
65 OSL_ENSURE( rData1.Long == rData2.Long, "### long does not match!" );
66 OSL_ENSURE( rData1.ULong == rData2.ULong, "### unsigned long does not match!" );
67 OSL_ENSURE( rData1.Hyper == rData2.Hyper, "### hyper does not match!" );
68 OSL_ENSURE( rData1.UHyper == rData2.UHyper, "### unsigned hyper does not match!" );
69 OSL_ENSURE( rData1.Float == rData2.Float, "### float does not match!" );
70 OSL_ENSURE( rData1.Double == rData2.Double, "### double does not match!" );
71 OSL_ENSURE( rData1.Enum == rData2.Enum, "### enum does not match!" );
72 OSL_ENSURE( rData1.String == rData2.String, "### string does not match!" );
73 OSL_ENSURE( rData1.Interface == rData2.Interface, "### interface does not match!" );
74 OSL_ENSURE( rData1.Any == rData2.Any, "### any does not match!" );
76 return (rData1.Bool == rData2.Bool &&
77 rData1.Char == rData2.Char &&
78 rData1.Byte == rData2.Byte &&
79 rData1.Short == rData2.Short &&
80 rData1.UShort == rData2.UShort &&
81 rData1.Long == rData2.Long &&
82 rData1.ULong == rData2.ULong &&
83 rData1.Hyper == rData2.Hyper &&
84 rData1.UHyper == rData2.UHyper &&
85 rData1.Float == rData2.Float &&
86 rData1.Double == rData2.Double &&
87 rData1.Enum == rData2.Enum &&
88 rData1.String == rData2.String &&
89 rData1.Interface == rData2.Interface &&
90 rData1.Any == rData2.Any);
92 //==================================================================================================
93 sal_Bool equals( const test::TestData & rData1, const test::TestData & rData2 )
95 sal_Int32 nLen;
97 if ((rData1.Sequence == rData2.Sequence) &&
98 equals( (const test::TestElement &)rData1, (const test::TestElement &)rData2 ) &&
99 (nLen = rData1.Sequence.getLength()) == rData2.Sequence.getLength())
101 // once again by hand sequence ==
102 const test::TestElement * pElements1 = rData1.Sequence.getConstArray();
103 const test::TestElement * pElements2 = rData2.Sequence.getConstArray();
104 for ( ; nLen--; )
106 if (! equals( pElements1[nLen], pElements2[nLen] ))
108 OSL_FAIL( "### sequence element did not match!" );
109 return sal_False;
112 return sal_True;
114 return sal_False;
116 //==================================================================================================
117 void assign( test::TestElement & rData,
118 sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
119 sal_Int16 nShort, sal_uInt16 nUShort,
120 sal_Int32 nLong, sal_uInt32 nULong,
121 sal_Int64 nHyper, sal_uInt64 nUHyper,
122 float fFloat, double fDouble,
123 test::TestEnum eEnum, const ::rtl::OUString& rStr,
124 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
125 const ::com::sun::star::uno::Any& rAny )
127 rData.Bool = bBool;
128 rData.Char = cChar;
129 rData.Byte = nByte;
130 rData.Short = nShort;
131 rData.UShort = nUShort;
132 rData.Long = nLong;
133 rData.ULong = nULong;
134 rData.Hyper = nHyper;
135 rData.UHyper = nUHyper;
136 rData.Float = fFloat;
137 rData.Double = fDouble;
138 rData.Enum = eEnum;
139 rData.String = rStr;
140 rData.Interface = xTest;
141 rData.Any = rAny;
143 //==================================================================================================
144 void assign( test::TestData & rData,
145 sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
146 sal_Int16 nShort, sal_uInt16 nUShort,
147 sal_Int32 nLong, sal_uInt32 nULong,
148 sal_Int64 nHyper, sal_uInt64 nUHyper,
149 float fFloat, double fDouble,
150 test::TestEnum eEnum, const ::rtl::OUString& rStr,
151 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
152 const ::com::sun::star::uno::Any& rAny,
153 const com::sun::star::uno::Sequence< test::TestElement >& rSequence )
155 assign( (test::TestElement &)rData,
156 bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
157 eEnum, rStr, xTest, rAny );
158 rData.Sequence = rSequence;
161 //==================================================================================================
162 class Test_Impl : public WeakImplHelper1< XLanguageBindingTest >
164 test::TestData _aData, _aStructData;
166 public:
167 virtual ~Test_Impl()
168 { OSL_TRACE( "> scalar Test_Impl dtor <\n" ); }
170 // XLBTestBase
171 virtual void SAL_CALL setValues( sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
172 sal_Int16 nShort, sal_uInt16 nUShort,
173 sal_Int32 nLong, sal_uInt32 nULong,
174 sal_Int64 nHyper, sal_uInt64 nUHyper,
175 float fFloat, double fDouble,
176 test::TestEnum eEnum, const ::rtl::OUString& rStr,
177 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
178 const ::com::sun::star::uno::Any& rAny,
179 const ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
180 const test::TestData& rStruct )
181 throw(com::sun::star::uno::RuntimeException);
183 virtual test::TestData SAL_CALL setValues2( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
184 sal_Int16& nShort, sal_uInt16& nUShort,
185 sal_Int32& nLong, sal_uInt32& nULong,
186 sal_Int64& nHyper, sal_uInt64& nUHyper,
187 float& fFloat, double& fDouble,
188 test::TestEnum& eEnum, rtl::OUString& rStr,
189 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
190 ::com::sun::star::uno::Any& rAny,
191 ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
192 test::TestData& rStruct )
193 throw(com::sun::star::uno::RuntimeException);
195 virtual test::TestData SAL_CALL getValues( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
196 sal_Int16& nShort, sal_uInt16& nUShort,
197 sal_Int32& nLong, sal_uInt32& nULong,
198 sal_Int64& nHyper, sal_uInt64& nUHyper,
199 float& fFloat, double& fDouble,
200 test::TestEnum& eEnum, rtl::OUString& rStr,
201 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
202 ::com::sun::star::uno::Any& rAny,
203 ::com::sun::star::uno::Sequence< test::TestElement >& rSequence,
204 test::TestData& rStruct )
205 throw(com::sun::star::uno::RuntimeException);
207 virtual sal_Bool SAL_CALL getBool() throw(com::sun::star::uno::RuntimeException)
208 { return _aData.Bool; }
209 virtual sal_Int8 SAL_CALL getByte() throw(com::sun::star::uno::RuntimeException)
210 { return _aData.Byte; }
211 virtual sal_Unicode SAL_CALL getChar() throw(com::sun::star::uno::RuntimeException)
212 { return _aData.Char; }
213 virtual sal_Int16 SAL_CALL getShort() throw(com::sun::star::uno::RuntimeException)
214 { return _aData.Short; }
215 virtual sal_uInt16 SAL_CALL getUShort() throw(com::sun::star::uno::RuntimeException)
216 { return _aData.UShort; }
217 virtual sal_Int32 SAL_CALL getLong() throw(com::sun::star::uno::RuntimeException)
218 { return _aData.Long; }
219 virtual sal_uInt32 SAL_CALL getULong() throw(com::sun::star::uno::RuntimeException)
220 { return _aData.ULong; }
221 virtual sal_Int64 SAL_CALL getHyper() throw(com::sun::star::uno::RuntimeException)
222 { return _aData.Hyper; }
223 virtual sal_uInt64 SAL_CALL getUHyper() throw(com::sun::star::uno::RuntimeException)
224 { return _aData.UHyper; }
225 virtual float SAL_CALL getFloat() throw(com::sun::star::uno::RuntimeException)
226 { return _aData.Float; }
227 virtual double SAL_CALL getDouble() throw(com::sun::star::uno::RuntimeException)
228 { return _aData.Double; }
229 virtual test::TestEnum SAL_CALL getEnum() throw(com::sun::star::uno::RuntimeException)
230 { return _aData.Enum; }
231 virtual rtl::OUString SAL_CALL getString() throw(com::sun::star::uno::RuntimeException)
232 { return _aData.String; }
233 virtual com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getInterface( ) throw(com::sun::star::uno::RuntimeException)
234 { return _aData.Interface; }
235 virtual com::sun::star::uno::Any SAL_CALL getAny() throw(com::sun::star::uno::RuntimeException)
236 { return _aData.Any; }
237 virtual com::sun::star::uno::Sequence< test::TestElement > SAL_CALL getSequence() throw(com::sun::star::uno::RuntimeException)
238 { return _aData.Sequence; }
239 virtual test::TestData SAL_CALL getStruct() throw(com::sun::star::uno::RuntimeException)
240 { return _aStructData; }
242 virtual void SAL_CALL setBool( sal_Bool _bool ) throw(::com::sun::star::uno::RuntimeException)
243 { _aData.Bool = _bool; }
244 virtual void SAL_CALL setByte( sal_Int8 _byte ) throw(::com::sun::star::uno::RuntimeException)
245 { _aData.Byte = _byte; }
246 virtual void SAL_CALL setChar( sal_Unicode _char ) throw(::com::sun::star::uno::RuntimeException)
247 { _aData.Char = _char; }
248 virtual void SAL_CALL setShort( sal_Int16 _short ) throw(::com::sun::star::uno::RuntimeException)
249 { _aData.Short = _short; }
250 virtual void SAL_CALL setUShort( sal_uInt16 _ushort ) throw(::com::sun::star::uno::RuntimeException)
251 { _aData.UShort = _ushort; }
252 virtual void SAL_CALL setLong( sal_Int32 _long ) throw(::com::sun::star::uno::RuntimeException)
253 { _aData.Long = _long; }
254 virtual void SAL_CALL setULong( sal_uInt32 _ulong ) throw(::com::sun::star::uno::RuntimeException)
255 { _aData.ULong = _ulong; }
256 virtual void SAL_CALL setHyper( sal_Int64 _hyper ) throw(::com::sun::star::uno::RuntimeException)
257 { _aData.Hyper = _hyper; }
258 virtual void SAL_CALL setUHyper( sal_uInt64 _uhyper ) throw(::com::sun::star::uno::RuntimeException)
259 { _aData.UHyper = _uhyper; }
260 virtual void SAL_CALL setFloat( float _float ) throw(::com::sun::star::uno::RuntimeException)
261 { _aData.Float = _float; }
262 virtual void SAL_CALL setDouble( double _double ) throw(::com::sun::star::uno::RuntimeException)
263 { _aData.Double = _double; }
264 virtual void SAL_CALL setEnum( test::TestEnum _enum ) throw(::com::sun::star::uno::RuntimeException)
265 { _aData.Enum = _enum; }
266 virtual void SAL_CALL setString( const ::rtl::OUString& _string ) throw(::com::sun::star::uno::RuntimeException)
267 { _aData.String = _string; }
268 virtual void SAL_CALL setInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _interface ) throw(::com::sun::star::uno::RuntimeException)
269 { _aData.Interface = _interface; }
270 virtual void SAL_CALL setAny( const ::com::sun::star::uno::Any& _any ) throw(::com::sun::star::uno::RuntimeException)
271 { _aData.Any = _any; }
272 virtual void SAL_CALL setSequence( const ::com::sun::star::uno::Sequence<test::TestElement >& _sequence ) throw(::com::sun::star::uno::RuntimeException)
273 { _aData.Sequence = _sequence; }
274 virtual void SAL_CALL setStruct( const test::TestData& _struct ) throw(::com::sun::star::uno::RuntimeException)
275 { _aStructData = _struct; }
277 // XLanguageBindingTest
278 virtual test::TestData SAL_CALL raiseException( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, sal_Int16& nShort, sal_uInt16& nUShort, sal_Int32& nLong, sal_uInt32& nULong, sal_Int64& nHyper, sal_uInt64& nUHyper, float& fFloat, double& fDouble, test::TestEnum& eEnum, ::rtl::OUString& aString, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInterface, ::com::sun::star::uno::Any& aAny, ::com::sun::star::uno::Sequence<test::TestElement >& aSequence,test::TestData& aStruct )
279 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
281 virtual sal_Int32 SAL_CALL getRuntimeException() throw(::com::sun::star::uno::RuntimeException);
282 virtual void SAL_CALL setRuntimeException( sal_Int32 _runtimeexception ) throw(::com::sun::star::uno::RuntimeException);
284 //==================================================================================================
285 class XLB_Invocation : public WeakImplHelper1< XInvocation >
287 Reference< XLanguageBindingTest > _xLBT;
289 public:
290 XLB_Invocation( const Reference< XMultiServiceFactory > & /*xMgr*/,
291 const Reference< XLanguageBindingTest > & xLBT )
292 : _xLBT( xLBT )
295 // XInvocation
296 virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() throw(::com::sun::star::uno::RuntimeException)
297 { return Reference< XIntrospectionAccess >(); }
298 virtual Any SAL_CALL invoke( const OUString & rFunctionName,
299 const Sequence< Any > & rParams,
300 Sequence< sal_Int16 > & rOutParamIndex,
301 Sequence< Any > & rOutParam ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
302 virtual void SAL_CALL setValue( const OUString & rPropertyName, const Any & rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
303 virtual Any SAL_CALL getValue( const OUString & rPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
304 virtual sal_Bool SAL_CALL hasMethod( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
305 virtual sal_Bool SAL_CALL hasProperty( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
307 //__________________________________________________________________________________________________
308 Any XLB_Invocation::invoke( const OUString & rFunctionName,
309 const Sequence< Any > & rParams,
310 Sequence< sal_Int16 > & rOutParamIndex,
311 Sequence< Any > & rOutParam )
312 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException)
314 bool bImplementedMethod = true;
316 Any aRet;
318 OSL_ASSERT( rOutParam.getLength() == 0 );
319 OSL_ASSERT( rOutParamIndex.getLength() == 0 );
323 sal_Bool aBool;
324 sal_Unicode aChar;
325 sal_Int8 nByte;
326 sal_Int16 nShort;
327 sal_uInt16 nUShort;
328 sal_Int32 nLong;
329 sal_uInt32 nULong;
330 sal_Int64 nHyper;
331 sal_uInt64 nUHyper;
332 float fFloat;
333 double fDouble;
334 TestEnum eEnum;
335 OUString aString;
336 Reference< XInterface > xInterface;
337 Any aAny;
338 Sequence< TestElement > aSeq;
339 TestData aData;
341 if ( rFunctionName == "setValues" )
343 OSL_ASSERT( rParams.getLength() == 17 );
344 aBool = *(sal_Bool *)rParams[0].getValue();
345 aChar = *(sal_Unicode *)rParams[1].getValue();
346 rParams[2] >>= nByte;
347 rParams[3] >>= nShort;
348 rParams[4] >>= nUShort;
349 rParams[5] >>= nLong;
350 rParams[6] >>= nULong;
351 rParams[7] >>= nHyper;
352 rParams[8] >>= nUHyper;
353 rParams[9] >>= fFloat;
354 rParams[10] >>= fDouble;
355 rParams[11] >>= eEnum;
356 rParams[12] >>= aString;
357 rParams[13] >>= xInterface;
358 rParams[14] >>= aAny;
359 rParams[15] >>= aSeq;
360 rParams[16] >>= aData;
362 _xLBT->setValues( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
363 nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
364 aAny, aSeq, aData );
366 rOutParamIndex.realloc( 0 );
367 rOutParam.realloc( 0 );
369 else if ( rFunctionName == "setValues2" )
371 aBool = *(sal_Bool *)rParams[0].getValue();
372 aChar = *(sal_Unicode *)rParams[1].getValue();
373 rParams[2] >>= nByte;
374 rParams[3] >>= nShort;
375 rParams[4] >>= nUShort;
376 rParams[5] >>= nLong;
377 rParams[6] >>= nULong;
378 rParams[7] >>= nHyper;
379 rParams[8] >>= nUHyper;
380 rParams[9] >>= fFloat;
381 rParams[10] >>= fDouble;
382 rParams[11] >>= eEnum;
383 rParams[12] >>= aString;
384 rParams[13] >>= xInterface;
385 rParams[14] >>= aAny;
386 rParams[15] >>= aSeq;
387 rParams[16] >>= aData;
389 aRet <<= _xLBT->setValues2( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
390 nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
391 aAny, aSeq, aData );
393 rOutParamIndex.realloc( 17 );
394 rOutParamIndex[0] = 0;
395 rOutParamIndex[1] = 1;
396 rOutParamIndex[2] = 2;
397 rOutParamIndex[3] = 3;
398 rOutParamIndex[4] = 4;
399 rOutParamIndex[5] = 5;
400 rOutParamIndex[6] = 6;
401 rOutParamIndex[7] = 7;
402 rOutParamIndex[8] = 8;
403 rOutParamIndex[9] = 9;
404 rOutParamIndex[10] = 10;
405 rOutParamIndex[11] = 11;
406 rOutParamIndex[12] = 12;
407 rOutParamIndex[13] = 13;
408 rOutParamIndex[14] = 14;
409 rOutParamIndex[15] = 15;
410 rOutParamIndex[16] = 16;
412 rOutParam.realloc( 17 );
413 rOutParam[0].setValue( &aBool, ::getCppuBooleanType() );
414 rOutParam[1].setValue( &aChar, ::getCppuCharType() );
415 rOutParam[2] <<= nByte;
416 rOutParam[3] <<= nShort;
417 rOutParam[4] <<= nUShort;
418 rOutParam[5] <<= nLong;
419 rOutParam[6] <<= nULong;
420 rOutParam[7] <<= nHyper;
421 rOutParam[8] <<= nUHyper;
422 rOutParam[9] <<= fFloat;
423 rOutParam[10] <<= fDouble;
424 rOutParam[11] <<= eEnum;
425 rOutParam[12] <<= aString;
426 rOutParam[13] <<= xInterface;
427 rOutParam[14] <<= aAny;
428 rOutParam[15] <<= aSeq;
429 rOutParam[16] <<= aData;
431 else if ( rFunctionName == "getValues" )
433 aRet <<= _xLBT->getValues( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
434 nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
435 aAny, aSeq, aData );
437 rOutParamIndex.realloc( 17 );
438 rOutParamIndex[0] = 0;
439 rOutParamIndex[1] = 1;
440 rOutParamIndex[2] = 2;
441 rOutParamIndex[3] = 3;
442 rOutParamIndex[4] = 4;
443 rOutParamIndex[5] = 5;
444 rOutParamIndex[6] = 6;
445 rOutParamIndex[7] = 7;
446 rOutParamIndex[8] = 8;
447 rOutParamIndex[9] = 9;
448 rOutParamIndex[10] = 10;
449 rOutParamIndex[11] = 11;
450 rOutParamIndex[12] = 12;
451 rOutParamIndex[13] = 13;
452 rOutParamIndex[14] = 14;
453 rOutParamIndex[15] = 15;
454 rOutParamIndex[16] = 16;
456 rOutParam.realloc( 17 );
457 rOutParam[0].setValue( &aBool, ::getCppuBooleanType() );
458 rOutParam[1].setValue( &aChar, ::getCppuCharType() );
459 rOutParam[2] <<= nByte;
460 rOutParam[3] <<= nShort;
461 rOutParam[4] <<= nUShort;
462 rOutParam[5] <<= nLong;
463 rOutParam[6] <<= nULong;
464 rOutParam[7] <<= nHyper;
465 rOutParam[8] <<= nUHyper;
466 rOutParam[9] <<= fFloat;
467 rOutParam[10] <<= fDouble;
468 rOutParam[11] <<= eEnum;
469 rOutParam[12] <<= aString;
470 rOutParam[13] <<= xInterface;
471 rOutParam[14] <<= aAny;
472 rOutParam[15] <<= aSeq;
473 rOutParam[16] <<= aData;
475 else if ( rFunctionName == "raiseException" )
477 aRet <<= _xLBT->raiseException( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
478 nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
479 aAny, aSeq, aData );
481 rOutParamIndex.realloc( 17 );
482 rOutParamIndex[0] = 0;
483 rOutParamIndex[1] = 1;
484 rOutParamIndex[2] = 2;
485 rOutParamIndex[3] = 3;
486 rOutParamIndex[4] = 4;
487 rOutParamIndex[5] = 5;
488 rOutParamIndex[6] = 6;
489 rOutParamIndex[7] = 7;
490 rOutParamIndex[8] = 8;
491 rOutParamIndex[9] = 9;
492 rOutParamIndex[10] = 10;
493 rOutParamIndex[11] = 11;
494 rOutParamIndex[12] = 12;
495 rOutParamIndex[13] = 13;
496 rOutParamIndex[14] = 14;
497 rOutParamIndex[15] = 15;
498 rOutParamIndex[16] = 16;
500 rOutParam.realloc( 17 );
501 rOutParam[0].setValue( &aBool, ::getCppuBooleanType() );
502 rOutParam[1].setValue( &aChar, ::getCppuCharType() );
503 rOutParam[2] <<= nByte;
504 rOutParam[3] <<= nShort;
505 rOutParam[4] <<= nUShort;
506 rOutParam[5] <<= nLong;
507 rOutParam[6] <<= nULong;
508 rOutParam[7] <<= nHyper;
509 rOutParam[8] <<= nUHyper;
510 rOutParam[9] <<= fFloat;
511 rOutParam[10] <<= fDouble;
512 rOutParam[11] <<= eEnum;
513 rOutParam[12] <<= aString;
514 rOutParam[13] <<= xInterface;
515 rOutParam[14] <<= aAny;
516 rOutParam[15] <<= aSeq;
517 rOutParam[16] <<= aData;
519 else
521 bImplementedMethod = false;
524 catch (const IllegalArgumentException & rExc)
526 // thrown by raiseException() call
527 InvocationTargetException aExc;
528 aExc.TargetException <<= rExc;
529 throw aExc;
531 catch (Exception &)
533 OSL_FAIL( "### unexpected exception caught!" );
534 throw;
537 if (! bImplementedMethod)
539 throw IllegalArgumentException(
540 OUString( "not an implemented method!" ),
541 (OWeakObject *)this, 0 );
544 return aRet;
546 //__________________________________________________________________________________________________
547 void XLB_Invocation::setValue( const OUString & rName, const Any & rValue )
548 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException)
550 if ( rName == "Bool" )
551 _xLBT->setBool( *(const sal_Bool *)rValue.getValue() );
552 else if ( rName == "Byte" )
553 _xLBT->setByte( *(const sal_Int8 *)rValue.getValue() );
554 else if ( rName == "Char" )
555 _xLBT->setChar( *(const sal_Unicode *)rValue.getValue() );
556 else if ( rName == "Short" )
557 _xLBT->setShort( *(const sal_Int16 *)rValue.getValue() );
558 else if ( rName == "UShort" )
559 _xLBT->setUShort( *(const sal_uInt16 *)rValue.getValue() );
560 else if ( rName == "Long" )
561 _xLBT->setLong( *(const sal_Int32 *)rValue.getValue() );
562 else if ( rName == "ULong" )
563 _xLBT->setULong( *(const sal_uInt32 *)rValue.getValue() );
564 else if ( rName == "Hyper" )
565 _xLBT->setHyper( *(const sal_Int64 *)rValue.getValue() );
566 else if ( rName == "UHyper" )
567 _xLBT->setUHyper( *(const sal_uInt64 *)rValue.getValue() );
568 else if ( rName == "Float" )
569 _xLBT->setFloat( *(const float *)rValue.getValue() );
570 else if ( rName == "Double" )
571 _xLBT->setDouble( *(const double *)rValue.getValue() );
572 else if ( rName == "Enum" )
573 _xLBT->setEnum( *(const TestEnum *)rValue.getValue() );
574 else if ( rName == "String" )
575 _xLBT->setString( *(const OUString *)rValue.getValue() );
576 else if ( rName == "Interface" )
577 _xLBT->setInterface( *(const Reference< XInterface > *)rValue.getValue() );
578 else if ( rName == "Any" )
579 _xLBT->setAny( rValue );
580 else if ( rName == "Sequence" )
581 _xLBT->setSequence( *(const Sequence< TestElement > *)rValue.getValue() );
582 else if ( rName == "Struct" )
583 _xLBT->setStruct( *(const TestData *)rValue.getValue() );
584 else if ( rName == "RuntimeException" )
585 _xLBT->setRuntimeException( *(const sal_Int32 *)rValue.getValue() );
587 //__________________________________________________________________________________________________
588 Any XLB_Invocation::getValue( const OUString & rName )
589 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
591 Any aRet;
592 if ( rName == "Bool" )
594 sal_Bool aBool = _xLBT->getBool();
595 aRet.setValue( &aBool, ::getCppuBooleanType() );
597 else if ( rName == "Byte" )
598 aRet <<= _xLBT->getByte();
599 else if ( rName == "Char" )
601 sal_Unicode aChar = _xLBT->getChar();
602 aRet.setValue( &aChar, ::getCppuCharType() );
604 else if ( rName == "Short" )
605 aRet <<= _xLBT->getShort();
606 else if ( rName == "UShort" )
607 aRet <<= _xLBT->getUShort();
608 else if ( rName == "Long" )
609 aRet <<= _xLBT->getLong();
610 else if ( rName == "ULong" )
611 aRet <<= _xLBT->getULong();
612 else if ( rName == "Hyper" )
613 aRet <<= _xLBT->getHyper();
614 else if ( rName == "UHyper" )
615 aRet <<= _xLBT->getUHyper();
616 else if ( rName == "Float" )
617 aRet <<= _xLBT->getFloat();
618 else if ( rName == "Double" )
619 aRet <<= _xLBT->getDouble();
620 else if ( rName == "Enum" )
621 aRet <<= _xLBT->getEnum();
622 else if ( rName == "String" )
623 aRet <<= _xLBT->getString();
624 else if ( rName == "Interface" )
625 aRet <<= _xLBT->getInterface();
626 else if ( rName == "Any" )
627 aRet <<= _xLBT->getAny();
628 else if ( rName == "Sequence" )
629 aRet <<= _xLBT->getSequence();
630 else if ( rName == "Struct" )
631 aRet <<= _xLBT->getStruct();
632 else if ( rName == "RuntimeException" )
633 aRet <<= _xLBT->getRuntimeException();
634 return aRet;
636 //__________________________________________________________________________________________________
637 sal_Bool XLB_Invocation::hasMethod( const OUString & rName )
638 throw(::com::sun::star::uno::RuntimeException)
640 return (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raiseException") ) ||
641 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("getValues") ) ||
642 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues2") ) ||
643 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues") ) ||
644 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("acquire") ) ||
645 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("release") ) ||
646 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("queryInterface") ));
648 //__________________________________________________________________________________________________
649 sal_Bool XLB_Invocation::hasProperty( const OUString & rName )
650 throw(::com::sun::star::uno::RuntimeException)
652 return (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ) ||
653 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ) ||
654 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ) ||
655 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ) ||
656 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ) ||
657 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ) ||
658 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ) ||
659 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ) ||
660 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ) ||
661 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ) ||
662 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ) ||
663 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ) ||
664 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ) ||
665 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ) ||
666 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ) ||
667 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ) ||
668 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ) ||
669 rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ) );
672 //##################################################################################################
674 //__________________________________________________________________________________________________
675 void Test_Impl::setValues( sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
676 sal_Int16 nShort, sal_uInt16 nUShort,
677 sal_Int32 nLong, sal_uInt32 nULong,
678 sal_Int64 nHyper, sal_uInt64 nUHyper,
679 float fFloat, double fDouble,
680 test::TestEnum eEnum, const ::rtl::OUString& rStr,
681 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
682 const ::com::sun::star::uno::Any& rAny,
683 const ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
684 const test::TestData& rStruct )
685 throw(com::sun::star::uno::RuntimeException)
687 assign( _aData,
688 bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
689 eEnum, rStr, xTest, rAny, rSequence );
690 _aStructData = rStruct;
692 //__________________________________________________________________________________________________
693 test::TestData Test_Impl::setValues2( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
694 sal_Int16& nShort, sal_uInt16& nUShort,
695 sal_Int32& nLong, sal_uInt32& nULong,
696 sal_Int64& nHyper, sal_uInt64& nUHyper,
697 float& fFloat, double& fDouble,
698 test::TestEnum& eEnum, rtl::OUString& rStr,
699 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
700 ::com::sun::star::uno::Any& rAny,
701 ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
702 test::TestData& rStruct )
703 throw(com::sun::star::uno::RuntimeException)
705 assign( _aData,
706 bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
707 eEnum, rStr, xTest, rAny, rSequence );
708 _aStructData = rStruct;
709 return _aStructData;
711 //__________________________________________________________________________________________________
712 test::TestData Test_Impl::getValues( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
713 sal_Int16& nShort, sal_uInt16& nUShort,
714 sal_Int32& nLong, sal_uInt32& nULong,
715 sal_Int64& nHyper, sal_uInt64& nUHyper,
716 float& fFloat, double& fDouble,
717 test::TestEnum& eEnum, rtl::OUString& rStr,
718 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
719 ::com::sun::star::uno::Any& rAny,
720 ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
721 test::TestData& rStruct )
722 throw(com::sun::star::uno::RuntimeException)
724 bBool = _aData.Bool;
725 cChar = _aData.Char;
726 nByte = _aData.Byte;
727 nShort = _aData.Short;
728 nUShort = _aData.UShort;
729 nLong = _aData.Long;
730 nULong = _aData.ULong;
731 nHyper = _aData.Hyper;
732 nUHyper = _aData.UHyper;
733 fFloat = _aData.Float;
734 fDouble = _aData.Double;
735 eEnum = _aData.Enum;
736 rStr = _aData.String;
737 xTest = _aData.Interface;
738 rAny = _aData.Any;
739 rSequence = _aData.Sequence;
740 rStruct = _aStructData;
741 return _aStructData;
744 //==================================================================================================
745 sal_Bool performTest( const Reference<XLanguageBindingTest > & xLBT )
747 OSL_ENSURE( xLBT.is(), "### no test interface!" );
748 if (xLBT.is())
750 // this data is never ever granted access to by calls other than equals(), assign()!
751 test::TestData aData; // test against this data
753 Reference<XInterface > xI( *new OWeakObject() );
755 assign( (test::TestElement &)aData,
756 sal_True, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
757 SAL_CONST_INT64(0x123456789abcdef0),
758 SAL_CONST_UINT64(0xfedcba9876543210),
759 (float)17.0815, 3.1415926359, TestEnum_LOLA, OUString("dumdidum"), xI,
760 Any( &xI, ::getCppuType( (const Reference<XInterface > *)0 ) ) );
762 OSL_ENSURE( aData.Any == xI, "### unexpected any!" );
763 OSL_ENSURE( !(aData.Any != xI), "### unexpected any!" );
765 aData.Sequence = Sequence<test::TestElement >( (const test::TestElement *)&aData, 1 );
766 // aData complete
767 //================================================================================
769 // this is a manually copy of aData for first setting...
770 test::TestData aSetData;
772 assign( (test::TestElement &)aSetData,
773 aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort,
774 aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, aData.Double,
775 aData.Enum, aData.String, xI,
776 Any( &xI, ::getCppuType( (const Reference<XInterface > *)0 ) ) );
778 aSetData.Sequence = Sequence<test::TestElement >( (const test::TestElement *)&aSetData, 1 );
780 xLBT->setValues(
781 aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, aSetData.UShort,
782 aSetData.Long, aSetData.ULong, aSetData.Hyper, aSetData.UHyper, aSetData.Float, aSetData.Double,
783 aSetData.Enum, aSetData.String, aSetData.Interface, aSetData.Any, aSetData.Sequence, aSetData );
786 test::TestData aRet, aRet2;
787 xLBT->getValues(
788 aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
789 aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
790 aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
792 OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) );
794 // set last retrieved values
795 test::TestData aSV2ret = xLBT->setValues2(
796 aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
797 aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
798 aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
800 OSL_ASSERT( equals( aData, aSV2ret ) && equals( aData, aRet2 ) );
803 test::TestData aRet, aRet2;
804 test::TestData aGVret = xLBT->getValues(
805 aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
806 aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
807 aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
809 OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) && equals( aData, aGVret ) );
811 // set last retrieved values
812 xLBT->setBool( aRet.Bool );
813 xLBT->setChar( aRet.Char );
814 xLBT->setByte( aRet.Byte );
815 xLBT->setShort( aRet.Short );
816 xLBT->setUShort( aRet.UShort );
817 xLBT->setLong( aRet.Long );
818 xLBT->setULong( aRet.ULong );
819 xLBT->setHyper( aRet.Hyper );
820 xLBT->setUHyper( aRet.UHyper );
821 xLBT->setFloat( aRet.Float );
822 xLBT->setDouble( aRet.Double );
823 xLBT->setEnum( aRet.Enum );
824 xLBT->setString( aRet.String );
825 xLBT->setInterface( aRet.Interface );
826 xLBT->setAny( aRet.Any );
827 xLBT->setSequence( aRet.Sequence );
828 xLBT->setStruct( aRet2 );
831 test::TestData aRet, aRet2;
832 aRet.Hyper = xLBT->getHyper();
833 aRet.UHyper = xLBT->getUHyper();
834 aRet.Float = xLBT->getFloat();
835 aRet.Double = xLBT->getDouble();
836 aRet.Byte = xLBT->getByte();
837 aRet.Char = xLBT->getChar();
838 aRet.Bool = xLBT->getBool();
839 aRet.Short = xLBT->getShort();
840 aRet.UShort = xLBT->getUShort();
841 aRet.Long = xLBT->getLong();
842 aRet.ULong = xLBT->getULong();
843 aRet.Enum = xLBT->getEnum();
844 aRet.String = xLBT->getString();
845 aRet.Interface = xLBT->getInterface();
846 aRet.Any = xLBT->getAny();
847 aRet.Sequence = xLBT->getSequence();
848 aRet2 = xLBT->getStruct();
850 return (equals( aData, aRet ) && equals( aData, aRet2 ));
853 return sal_False;
856 //__________________________________________________________________________________________________
857 test::TestData Test_Impl::raiseException( sal_Bool& /*bBool*/, sal_Unicode& /*cChar*/, sal_Int8& /*nByte*/, sal_Int16& /*nShort*/, sal_uInt16& /*nUShort*/, sal_Int32& /*nLong*/, sal_uInt32& /*nULong*/, sal_Int64& /*nHyper*/, sal_uInt64& /*nUHyper*/, float& /*fFloat*/, double& /*fDouble*/, test::TestEnum& /*eEnum*/, ::rtl::OUString& /*aString*/, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& /*xInterface*/, ::com::sun::star::uno::Any& /*aAny*/, ::com::sun::star::uno::Sequence< test::TestElement >& /*aSequence*/, test::TestData& /*aStruct*/ )
858 throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
860 IllegalArgumentException aExc;
861 aExc.ArgumentPosition = 5;
862 aExc.Message = OUString("dum dum dum ich tanz im kreis herum...");
863 aExc.Context = *this;
864 throw aExc;
866 //__________________________________________________________________________________________________
867 sal_Int32 Test_Impl::getRuntimeException() throw(::com::sun::star::uno::RuntimeException)
869 RuntimeException aExc;
870 aExc.Message = OUString("dum dum dum ich tanz im kreis herum...");
871 aExc.Context = *this;
872 throw aExc;
874 //__________________________________________________________________________________________________
875 void Test_Impl::setRuntimeException( sal_Int32 /*_runtimeexception*/ ) throw(::com::sun::star::uno::RuntimeException)
877 RuntimeException aExc;
878 aExc.Message = OUString("dum dum dum ich tanz im kreis herum...");
879 aExc.Context = *this;
880 throw aExc;
883 //==================================================================================================
884 sal_Bool raiseException( const Reference<XLanguageBindingTest > & xLBT )
892 test::TestData aRet, aRet2;
893 xLBT->raiseException(
894 aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
895 aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
896 aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
897 return sal_False;
899 catch (const IllegalArgumentException &aExc)
901 OSL_ENSURE( aExc.ArgumentPosition == 5 &&
902 // aExc.Context == xLBT &&
903 aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
904 "### unexpected exception content!" );
906 Reference<XLanguageBindingTest > xLBT2(
907 Reference<XLanguageBindingTest >::query( aExc.Context ) );
909 OSL_ENSURE( xLBT2.is(), "### unexpected source of exception!" );
910 if (xLBT2.is())
911 xLBT2->getRuntimeException();
912 else
913 return sal_False;
916 catch (const RuntimeException & rExc)
918 OSL_ENSURE(//rExc.Context == xLBT &&
919 rExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
920 "### unexpected exception content!" );
922 Reference<XLanguageBindingTest > xLBT2(
923 Reference<XLanguageBindingTest >::query( rExc.Context ) );
925 OSL_ENSURE( xLBT2.is(), "### unexpected source of exception!" );
926 if (xLBT2.is())
927 xLBT2->setRuntimeException( 0xcafebabe );
928 else
929 return sal_False;
932 catch (const Exception & aExc)
934 OSL_ENSURE( //aExc.Context == xLBT &&
935 aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
936 "### unexpected exception content!" );
937 return (//aExc.Context == xLBT &&
938 aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")));
940 return sal_False;
943 //==================================================================================================
944 static sal_Bool test_adapter( const Reference< XMultiServiceFactory > & xMgr )
946 Reference< XInvocationAdapterFactory > xAdapFac(
947 xMgr->createInstance( OUString("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY );
948 Reference< XInvocationAdapterFactory2 > xAdapFac2( xAdapFac, UNO_QUERY_THROW );
950 Reference< XLanguageBindingTest > xOriginal( (XLanguageBindingTest *)new Test_Impl() );
951 Reference< XInvocation > xInvok( new XLB_Invocation( xMgr, xOriginal ) );
952 Reference< XLanguageBindingTest > xLBT( xAdapFac->createAdapter(
953 xInvok, ::getCppuType( (const Reference< XLanguageBindingTest > *)0 ) ), UNO_QUERY );
954 Reference< XLanguageBindingTest > xLBT2(
955 xAdapFac->createAdapter(
956 xInvok, ::getCppuType( (const Reference< XLanguageBindingTest > *)0 ) ), UNO_QUERY );
957 if (xLBT != xLBT2)
958 return sal_False;
959 Reference< XInterface > xLBT3(
960 xAdapFac->createAdapter(
961 xInvok, ::getCppuType( (const Reference< XInterface > *)0 ) ), UNO_QUERY );
962 if (xLBT != xLBT3)
963 return sal_False;
964 Type ar[ 2 ] = {
965 ::getCppuType( (const Reference< XLBTestBase > *)0 ),
966 ::getCppuType( (const Reference< XInterface > *)0 ) };
967 Reference< XInterface > xLBT4(
968 xAdapFac2->createAdapter( xInvok, Sequence< Type >( ar, 2 ) ), UNO_QUERY );
969 if (xLBT != xLBT4)
970 return sal_False;
971 Reference< XSimpleRegistry > xInvalidAdapter(
972 xAdapFac->createAdapter(
973 xInvok, ::getCppuType( (const Reference< XSimpleRegistry > *)0 ) ), UNO_QUERY );
974 if (xLBT == xInvalidAdapter)
975 return sal_False;
979 xInvalidAdapter->isValid();
980 return sal_False;
982 catch (RuntimeException &)
986 return (performTest( xLBT ) && raiseException( xLBT ));
988 //==================================================================================================
989 static sal_Bool test_invocation( const Reference< XMultiServiceFactory > & xMgr )
991 Reference< XInvocationAdapterFactory > xAdapFac(
992 xMgr->createInstance( OUString("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY );
993 Reference< XSingleServiceFactory > xInvocFac(
994 xMgr->createInstance( OUString("com.sun.star.script.Invocation") ), UNO_QUERY );
996 Reference< XLanguageBindingTest > xOriginal( (XLanguageBindingTest *)new Test_Impl() );
997 Any aOriginal( &xOriginal, ::getCppuType( &xOriginal ) );
998 Reference< XInvocation > xInvok(
999 xInvocFac->createInstanceWithArguments( Sequence< Any >( &aOriginal, 1 ) ), UNO_QUERY );
1001 Reference< XLanguageBindingTest > xLBT( xAdapFac->createAdapter(
1002 xInvok, ::getCppuType( (const Reference< XLanguageBindingTest > *)0 ) ), UNO_QUERY );
1004 return (performTest( xLBT ) && raiseException( xLBT ));
1007 SAL_IMPLEMENT_MAIN()
1009 Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory(
1010 OUString( "stoctest.rdb" ) ) );
1014 Reference< XImplementationRegistration > xImplReg(
1015 xMgr->createInstance(
1016 OUString( "com.sun.star.registry.ImplementationRegistration" ) ),
1017 UNO_QUERY );
1018 OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
1020 xImplReg->registerImplementation(
1021 OUString("com.sun.star.loader.SharedLibrary"),
1022 OUString("invocadapt.uno" SAL_DLLEXTENSION),
1023 Reference< XSimpleRegistry >() );
1024 xImplReg->registerImplementation(
1025 OUString("com.sun.star.loader.SharedLibrary"),
1026 OUString("stocservices.uno" SAL_DLLEXTENSION),
1027 Reference< XSimpleRegistry >() );
1028 xImplReg->registerImplementation(
1029 OUString("com.sun.star.loader.SharedLibrary"),
1030 OUString("invocation.uno" SAL_DLLEXTENSION),
1031 Reference< XSimpleRegistry >() );
1032 xImplReg->registerImplementation(
1033 OUString("com.sun.star.loader.SharedLibrary"),
1034 OUString("reflection.uno" SAL_DLLEXTENSION),
1035 Reference< XSimpleRegistry >() );
1036 xImplReg->registerImplementation(
1037 OUString("com.sun.star.loader.SharedLibrary"),
1038 OUString("introspection.uno" SAL_DLLEXTENSION),
1039 Reference< XSimpleRegistry >() );
1041 if (test_adapter( xMgr ))
1043 fprintf( stderr, "> test_iadapter() succeeded.\n" );
1044 if (test_invocation( xMgr ))
1046 fprintf( stderr, "> test_invocation() succeeded.\n" );
1050 catch (const Exception & rExc)
1052 fprintf( stderr, "> exception occurred: " );
1053 OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
1054 fprintf( stderr, "%s\n", aMsg.getStr() );
1057 Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
1059 return 0;
1062 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */