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