1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testiadapter.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_stoc.hxx"
37 #include <osl/diagnose.h>
39 #include <cppuhelper/servicefactory.hxx>
40 #include <cppuhelper/weak.hxx>
42 #include <test/XLanguageBindingTest.hpp>
43 #include <com/sun/star/registry/XSimpleRegistry.hpp>
44 #include <com/sun/star/registry/XImplementationRegistration.hpp>
45 #include <com/sun/star/script/XInvocation.hpp>
46 #include <com/sun/star/script/XInvocationAdapterFactory.hpp>
47 #include <com/sun/star/script/XInvocationAdapterFactory2.hpp>
48 #include <com/sun/star/lang/XComponent.hpp>
49 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
51 #include <cppuhelper/implbase1.hxx>
58 using namespace com::sun::star::uno
;
59 using namespace com::sun::star::script
;
60 using namespace com::sun::star::beans
;
61 using namespace com::sun::star::lang
;
62 using namespace com::sun::star::reflection
;
63 using namespace com::sun::star::lang
;
64 using namespace com::sun::star::registry
;
67 //==================================================================================================
68 sal_Bool
equals( const test::TestElement
& rData1
, const test::TestElement
& rData2
)
70 OSL_ENSURE( rData1
.Bool
== rData2
.Bool
, "### bool does not match!" );
71 OSL_ENSURE( rData1
.Char
== rData2
.Char
, "### char does not match!" );
72 OSL_ENSURE( rData1
.Byte
== rData2
.Byte
, "### byte does not match!" );
73 OSL_ENSURE( rData1
.Short
== rData2
.Short
, "### short does not match!" );
74 OSL_ENSURE( rData1
.UShort
== rData2
.UShort
, "### unsigned short does not match!" );
75 OSL_ENSURE( rData1
.Long
== rData2
.Long
, "### long does not match!" );
76 OSL_ENSURE( rData1
.ULong
== rData2
.ULong
, "### unsigned long does not match!" );
77 OSL_ENSURE( rData1
.Hyper
== rData2
.Hyper
, "### hyper does not match!" );
78 OSL_ENSURE( rData1
.UHyper
== rData2
.UHyper
, "### unsigned hyper does not match!" );
79 OSL_ENSURE( rData1
.Float
== rData2
.Float
, "### float does not match!" );
80 OSL_ENSURE( rData1
.Double
== rData2
.Double
, "### double does not match!" );
81 OSL_ENSURE( rData1
.Enum
== rData2
.Enum
, "### enum does not match!" );
82 OSL_ENSURE( rData1
.String
== rData2
.String
, "### string does not match!" );
83 OSL_ENSURE( rData1
.Interface
== rData2
.Interface
, "### interface does not match!" );
84 OSL_ENSURE( rData1
.Any
== rData2
.Any
, "### any does not match!" );
86 return (rData1
.Bool
== rData2
.Bool
&&
87 rData1
.Char
== rData2
.Char
&&
88 rData1
.Byte
== rData2
.Byte
&&
89 rData1
.Short
== rData2
.Short
&&
90 rData1
.UShort
== rData2
.UShort
&&
91 rData1
.Long
== rData2
.Long
&&
92 rData1
.ULong
== rData2
.ULong
&&
93 rData1
.Hyper
== rData2
.Hyper
&&
94 rData1
.UHyper
== rData2
.UHyper
&&
95 rData1
.Float
== rData2
.Float
&&
96 rData1
.Double
== rData2
.Double
&&
97 rData1
.Enum
== rData2
.Enum
&&
98 rData1
.String
== rData2
.String
&&
99 rData1
.Interface
== rData2
.Interface
&&
100 rData1
.Any
== rData2
.Any
);
102 //==================================================================================================
103 sal_Bool
equals( const test::TestData
& rData1
, const test::TestData
& rData2
)
107 if ((rData1
.Sequence
== rData2
.Sequence
) &&
108 equals( (const test::TestElement
&)rData1
, (const test::TestElement
&)rData2
) &&
109 (nLen
= rData1
.Sequence
.getLength()) == rData2
.Sequence
.getLength())
111 // once again by hand sequence ==
112 const test::TestElement
* pElements1
= rData1
.Sequence
.getConstArray();
113 const test::TestElement
* pElements2
= rData2
.Sequence
.getConstArray();
116 if (! equals( pElements1
[nLen
], pElements2
[nLen
] ))
118 OSL_ENSURE( sal_False
, "### sequence element did not match!" );
126 //==================================================================================================
127 void assign( test::TestElement
& rData
,
128 sal_Bool bBool
, sal_Unicode cChar
, sal_Int8 nByte
,
129 sal_Int16 nShort
, sal_uInt16 nUShort
,
130 sal_Int32 nLong
, sal_uInt32 nULong
,
131 sal_Int64 nHyper
, sal_uInt64 nUHyper
,
132 float fFloat
, double fDouble
,
133 test::TestEnum eEnum
, const ::rtl::OUString
& rStr
,
134 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xTest
,
135 const ::com::sun::star::uno::Any
& rAny
)
140 rData
.Short
= nShort
;
141 rData
.UShort
= nUShort
;
143 rData
.ULong
= nULong
;
144 rData
.Hyper
= nHyper
;
145 rData
.UHyper
= nUHyper
;
146 rData
.Float
= fFloat
;
147 rData
.Double
= fDouble
;
150 rData
.Interface
= xTest
;
153 //==================================================================================================
154 void assign( test::TestData
& rData
,
155 sal_Bool bBool
, sal_Unicode cChar
, sal_Int8 nByte
,
156 sal_Int16 nShort
, sal_uInt16 nUShort
,
157 sal_Int32 nLong
, sal_uInt32 nULong
,
158 sal_Int64 nHyper
, sal_uInt64 nUHyper
,
159 float fFloat
, double fDouble
,
160 test::TestEnum eEnum
, const ::rtl::OUString
& rStr
,
161 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xTest
,
162 const ::com::sun::star::uno::Any
& rAny
,
163 const com::sun::star::uno::Sequence
< test::TestElement
>& rSequence
)
165 assign( (test::TestElement
&)rData
,
166 bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, fFloat
, fDouble
,
167 eEnum
, rStr
, xTest
, rAny
);
168 rData
.Sequence
= rSequence
;
171 //==================================================================================================
172 class Test_Impl
: public WeakImplHelper1
< XLanguageBindingTest
>
174 test::TestData _aData
, _aStructData
;
178 { OSL_TRACE( "> scalar Test_Impl dtor <\n" ); }
181 virtual void SAL_CALL
setValues( sal_Bool bBool
, sal_Unicode cChar
, sal_Int8 nByte
,
182 sal_Int16 nShort
, sal_uInt16 nUShort
,
183 sal_Int32 nLong
, sal_uInt32 nULong
,
184 sal_Int64 nHyper
, sal_uInt64 nUHyper
,
185 float fFloat
, double fDouble
,
186 test::TestEnum eEnum
, const ::rtl::OUString
& rStr
,
187 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xTest
,
188 const ::com::sun::star::uno::Any
& rAny
,
189 const ::com::sun::star::uno::Sequence
<test::TestElement
>& rSequence
,
190 const test::TestData
& rStruct
)
191 throw(com::sun::star::uno::RuntimeException
);
193 virtual test::TestData SAL_CALL
setValues2( sal_Bool
& bBool
, sal_Unicode
& cChar
, sal_Int8
& nByte
,
194 sal_Int16
& nShort
, sal_uInt16
& nUShort
,
195 sal_Int32
& nLong
, sal_uInt32
& nULong
,
196 sal_Int64
& nHyper
, sal_uInt64
& nUHyper
,
197 float& fFloat
, double& fDouble
,
198 test::TestEnum
& eEnum
, rtl::OUString
& rStr
,
199 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xTest
,
200 ::com::sun::star::uno::Any
& rAny
,
201 ::com::sun::star::uno::Sequence
<test::TestElement
>& rSequence
,
202 test::TestData
& rStruct
)
203 throw(com::sun::star::uno::RuntimeException
);
205 virtual test::TestData SAL_CALL
getValues( sal_Bool
& bBool
, sal_Unicode
& cChar
, sal_Int8
& nByte
,
206 sal_Int16
& nShort
, sal_uInt16
& nUShort
,
207 sal_Int32
& nLong
, sal_uInt32
& nULong
,
208 sal_Int64
& nHyper
, sal_uInt64
& nUHyper
,
209 float& fFloat
, double& fDouble
,
210 test::TestEnum
& eEnum
, rtl::OUString
& rStr
,
211 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xTest
,
212 ::com::sun::star::uno::Any
& rAny
,
213 ::com::sun::star::uno::Sequence
< test::TestElement
>& rSequence
,
214 test::TestData
& rStruct
)
215 throw(com::sun::star::uno::RuntimeException
);
217 virtual sal_Bool SAL_CALL
getBool() throw(com::sun::star::uno::RuntimeException
)
218 { return _aData
.Bool
; }
219 virtual sal_Int8 SAL_CALL
getByte() throw(com::sun::star::uno::RuntimeException
)
220 { return _aData
.Byte
; }
221 virtual sal_Unicode SAL_CALL
getChar() throw(com::sun::star::uno::RuntimeException
)
222 { return _aData
.Char
; }
223 virtual sal_Int16 SAL_CALL
getShort() throw(com::sun::star::uno::RuntimeException
)
224 { return _aData
.Short
; }
225 virtual sal_uInt16 SAL_CALL
getUShort() throw(com::sun::star::uno::RuntimeException
)
226 { return _aData
.UShort
; }
227 virtual sal_Int32 SAL_CALL
getLong() throw(com::sun::star::uno::RuntimeException
)
228 { return _aData
.Long
; }
229 virtual sal_uInt32 SAL_CALL
getULong() throw(com::sun::star::uno::RuntimeException
)
230 { return _aData
.ULong
; }
231 virtual sal_Int64 SAL_CALL
getHyper() throw(com::sun::star::uno::RuntimeException
)
232 { return _aData
.Hyper
; }
233 virtual sal_uInt64 SAL_CALL
getUHyper() throw(com::sun::star::uno::RuntimeException
)
234 { return _aData
.UHyper
; }
235 virtual float SAL_CALL
getFloat() throw(com::sun::star::uno::RuntimeException
)
236 { return _aData
.Float
; }
237 virtual double SAL_CALL
getDouble() throw(com::sun::star::uno::RuntimeException
)
238 { return _aData
.Double
; }
239 virtual test::TestEnum SAL_CALL
getEnum() throw(com::sun::star::uno::RuntimeException
)
240 { return _aData
.Enum
; }
241 virtual rtl::OUString SAL_CALL
getString() throw(com::sun::star::uno::RuntimeException
)
242 { return _aData
.String
; }
243 virtual com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getInterface( ) throw(com::sun::star::uno::RuntimeException
)
244 { return _aData
.Interface
; }
245 virtual com::sun::star::uno::Any SAL_CALL
getAny() throw(com::sun::star::uno::RuntimeException
)
246 { return _aData
.Any
; }
247 virtual com::sun::star::uno::Sequence
< test::TestElement
> SAL_CALL
getSequence() throw(com::sun::star::uno::RuntimeException
)
248 { return _aData
.Sequence
; }
249 virtual test::TestData SAL_CALL
getStruct() throw(com::sun::star::uno::RuntimeException
)
250 { return _aStructData
; }
252 virtual void SAL_CALL
setBool( sal_Bool _bool
) throw(::com::sun::star::uno::RuntimeException
)
253 { _aData
.Bool
= _bool
; }
254 virtual void SAL_CALL
setByte( sal_Int8 _byte
) throw(::com::sun::star::uno::RuntimeException
)
255 { _aData
.Byte
= _byte
; }
256 virtual void SAL_CALL
setChar( sal_Unicode _char
) throw(::com::sun::star::uno::RuntimeException
)
257 { _aData
.Char
= _char
; }
258 virtual void SAL_CALL
setShort( sal_Int16 _short
) throw(::com::sun::star::uno::RuntimeException
)
259 { _aData
.Short
= _short
; }
260 virtual void SAL_CALL
setUShort( sal_uInt16 _ushort
) throw(::com::sun::star::uno::RuntimeException
)
261 { _aData
.UShort
= _ushort
; }
262 virtual void SAL_CALL
setLong( sal_Int32 _long
) throw(::com::sun::star::uno::RuntimeException
)
263 { _aData
.Long
= _long
; }
264 virtual void SAL_CALL
setULong( sal_uInt32 _ulong
) throw(::com::sun::star::uno::RuntimeException
)
265 { _aData
.ULong
= _ulong
; }
266 virtual void SAL_CALL
setHyper( sal_Int64 _hyper
) throw(::com::sun::star::uno::RuntimeException
)
267 { _aData
.Hyper
= _hyper
; }
268 virtual void SAL_CALL
setUHyper( sal_uInt64 _uhyper
) throw(::com::sun::star::uno::RuntimeException
)
269 { _aData
.UHyper
= _uhyper
; }
270 virtual void SAL_CALL
setFloat( float _float
) throw(::com::sun::star::uno::RuntimeException
)
271 { _aData
.Float
= _float
; }
272 virtual void SAL_CALL
setDouble( double _double
) throw(::com::sun::star::uno::RuntimeException
)
273 { _aData
.Double
= _double
; }
274 virtual void SAL_CALL
setEnum( test::TestEnum _enum
) throw(::com::sun::star::uno::RuntimeException
)
275 { _aData
.Enum
= _enum
; }
276 virtual void SAL_CALL
setString( const ::rtl::OUString
& _string
) throw(::com::sun::star::uno::RuntimeException
)
277 { _aData
.String
= _string
; }
278 virtual void SAL_CALL
setInterface( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _interface
) throw(::com::sun::star::uno::RuntimeException
)
279 { _aData
.Interface
= _interface
; }
280 virtual void SAL_CALL
setAny( const ::com::sun::star::uno::Any
& _any
) throw(::com::sun::star::uno::RuntimeException
)
281 { _aData
.Any
= _any
; }
282 virtual void SAL_CALL
setSequence( const ::com::sun::star::uno::Sequence
<test::TestElement
>& _sequence
) throw(::com::sun::star::uno::RuntimeException
)
283 { _aData
.Sequence
= _sequence
; }
284 virtual void SAL_CALL
setStruct( const test::TestData
& _struct
) throw(::com::sun::star::uno::RuntimeException
)
285 { _aStructData
= _struct
; }
287 // XLanguageBindingTest
288 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
)
289 throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
291 virtual sal_Int32 SAL_CALL
getRuntimeException() throw(::com::sun::star::uno::RuntimeException
);
292 virtual void SAL_CALL
setRuntimeException( sal_Int32 _runtimeexception
) throw(::com::sun::star::uno::RuntimeException
);
294 //==================================================================================================
295 class XLB_Invocation
: public WeakImplHelper1
< XInvocation
>
297 Reference
< XLanguageBindingTest
> _xLBT
;
300 XLB_Invocation( const Reference
< XMultiServiceFactory
> & /*xMgr*/,
301 const Reference
< XLanguageBindingTest
> & xLBT
)
306 virtual Reference
< XIntrospectionAccess
> SAL_CALL
getIntrospection() throw(::com::sun::star::uno::RuntimeException
)
307 { return Reference
< XIntrospectionAccess
>(); }
308 virtual Any SAL_CALL
invoke( const OUString
& rFunctionName
,
309 const Sequence
< Any
> & rParams
,
310 Sequence
< sal_Int16
> & rOutParamIndex
,
311 Sequence
< Any
> & rOutParam
) throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::script::CannotConvertException
, ::com::sun::star::reflection::InvocationTargetException
, ::com::sun::star::uno::RuntimeException
);
312 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
);
313 virtual Any SAL_CALL
getValue( const OUString
& rPropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
314 virtual sal_Bool SAL_CALL
hasMethod( const OUString
& rName
) throw(::com::sun::star::uno::RuntimeException
);
315 virtual sal_Bool SAL_CALL
hasProperty( const OUString
& rName
) throw(::com::sun::star::uno::RuntimeException
);
317 //__________________________________________________________________________________________________
318 Any
XLB_Invocation::invoke( const OUString
& rFunctionName
,
319 const Sequence
< Any
> & rParams
,
320 Sequence
< sal_Int16
> & rOutParamIndex
,
321 Sequence
< Any
> & rOutParam
)
322 throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::script::CannotConvertException
, ::com::sun::star::reflection::InvocationTargetException
, ::com::sun::star::uno::RuntimeException
)
324 bool bImplementedMethod
= true;
328 OSL_ASSERT( rOutParam
.getLength() == 0 );
329 OSL_ASSERT( rOutParamIndex
.getLength() == 0 );
346 Reference
< XInterface
> xInterface
;
348 Sequence
< TestElement
> aSeq
;
351 if (rFunctionName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues") ))
353 OSL_ASSERT( rParams
.getLength() == 17 );
354 aBool
= *(sal_Bool
*)rParams
[0].getValue();
355 aChar
= *(sal_Unicode
*)rParams
[1].getValue();
356 rParams
[2] >>= nByte
;
357 rParams
[3] >>= nShort
;
358 rParams
[4] >>= nUShort
;
359 rParams
[5] >>= nLong
;
360 rParams
[6] >>= nULong
;
361 rParams
[7] >>= nHyper
;
362 rParams
[8] >>= nUHyper
;
363 rParams
[9] >>= fFloat
;
364 rParams
[10] >>= fDouble
;
365 rParams
[11] >>= eEnum
;
366 rParams
[12] >>= aString
;
367 rParams
[13] >>= xInterface
;
368 rParams
[14] >>= aAny
;
369 rParams
[15] >>= aSeq
;
370 rParams
[16] >>= aData
;
372 _xLBT
->setValues( aBool
, aChar
, nByte
, nShort
, nUShort
, nLong
, nULong
,
373 nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, aString
, xInterface
,
376 rOutParamIndex
.realloc( 0 );
377 rOutParam
.realloc( 0 );
379 else if (rFunctionName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues2") ))
381 aBool
= *(sal_Bool
*)rParams
[0].getValue();
382 aChar
= *(sal_Unicode
*)rParams
[1].getValue();
383 rParams
[2] >>= nByte
;
384 rParams
[3] >>= nShort
;
385 rParams
[4] >>= nUShort
;
386 rParams
[5] >>= nLong
;
387 rParams
[6] >>= nULong
;
388 rParams
[7] >>= nHyper
;
389 rParams
[8] >>= nUHyper
;
390 rParams
[9] >>= fFloat
;
391 rParams
[10] >>= fDouble
;
392 rParams
[11] >>= eEnum
;
393 rParams
[12] >>= aString
;
394 rParams
[13] >>= xInterface
;
395 rParams
[14] >>= aAny
;
396 rParams
[15] >>= aSeq
;
397 rParams
[16] >>= aData
;
399 aRet
<<= _xLBT
->setValues2( aBool
, aChar
, nByte
, nShort
, nUShort
, nLong
, nULong
,
400 nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, aString
, xInterface
,
403 rOutParamIndex
.realloc( 17 );
404 rOutParamIndex
[0] = 0;
405 rOutParamIndex
[1] = 1;
406 rOutParamIndex
[2] = 2;
407 rOutParamIndex
[3] = 3;
408 rOutParamIndex
[4] = 4;
409 rOutParamIndex
[5] = 5;
410 rOutParamIndex
[6] = 6;
411 rOutParamIndex
[7] = 7;
412 rOutParamIndex
[8] = 8;
413 rOutParamIndex
[9] = 9;
414 rOutParamIndex
[10] = 10;
415 rOutParamIndex
[11] = 11;
416 rOutParamIndex
[12] = 12;
417 rOutParamIndex
[13] = 13;
418 rOutParamIndex
[14] = 14;
419 rOutParamIndex
[15] = 15;
420 rOutParamIndex
[16] = 16;
422 rOutParam
.realloc( 17 );
423 rOutParam
[0].setValue( &aBool
, ::getCppuBooleanType() );
424 rOutParam
[1].setValue( &aChar
, ::getCppuCharType() );
425 rOutParam
[2] <<= nByte
;
426 rOutParam
[3] <<= nShort
;
427 rOutParam
[4] <<= nUShort
;
428 rOutParam
[5] <<= nLong
;
429 rOutParam
[6] <<= nULong
;
430 rOutParam
[7] <<= nHyper
;
431 rOutParam
[8] <<= nUHyper
;
432 rOutParam
[9] <<= fFloat
;
433 rOutParam
[10] <<= fDouble
;
434 rOutParam
[11] <<= eEnum
;
435 rOutParam
[12] <<= aString
;
436 rOutParam
[13] <<= xInterface
;
437 rOutParam
[14] <<= aAny
;
438 rOutParam
[15] <<= aSeq
;
439 rOutParam
[16] <<= aData
;
441 else if (rFunctionName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("getValues") ))
443 aRet
<<= _xLBT
->getValues( aBool
, aChar
, nByte
, nShort
, nUShort
, nLong
, nULong
,
444 nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, aString
, xInterface
,
447 rOutParamIndex
.realloc( 17 );
448 rOutParamIndex
[0] = 0;
449 rOutParamIndex
[1] = 1;
450 rOutParamIndex
[2] = 2;
451 rOutParamIndex
[3] = 3;
452 rOutParamIndex
[4] = 4;
453 rOutParamIndex
[5] = 5;
454 rOutParamIndex
[6] = 6;
455 rOutParamIndex
[7] = 7;
456 rOutParamIndex
[8] = 8;
457 rOutParamIndex
[9] = 9;
458 rOutParamIndex
[10] = 10;
459 rOutParamIndex
[11] = 11;
460 rOutParamIndex
[12] = 12;
461 rOutParamIndex
[13] = 13;
462 rOutParamIndex
[14] = 14;
463 rOutParamIndex
[15] = 15;
464 rOutParamIndex
[16] = 16;
466 rOutParam
.realloc( 17 );
467 rOutParam
[0].setValue( &aBool
, ::getCppuBooleanType() );
468 rOutParam
[1].setValue( &aChar
, ::getCppuCharType() );
469 rOutParam
[2] <<= nByte
;
470 rOutParam
[3] <<= nShort
;
471 rOutParam
[4] <<= nUShort
;
472 rOutParam
[5] <<= nLong
;
473 rOutParam
[6] <<= nULong
;
474 rOutParam
[7] <<= nHyper
;
475 rOutParam
[8] <<= nUHyper
;
476 rOutParam
[9] <<= fFloat
;
477 rOutParam
[10] <<= fDouble
;
478 rOutParam
[11] <<= eEnum
;
479 rOutParam
[12] <<= aString
;
480 rOutParam
[13] <<= xInterface
;
481 rOutParam
[14] <<= aAny
;
482 rOutParam
[15] <<= aSeq
;
483 rOutParam
[16] <<= aData
;
485 else if (rFunctionName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raiseException") ))
487 aRet
<<= _xLBT
->raiseException( aBool
, aChar
, nByte
, nShort
, nUShort
, nLong
, nULong
,
488 nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, aString
, xInterface
,
491 rOutParamIndex
.realloc( 17 );
492 rOutParamIndex
[0] = 0;
493 rOutParamIndex
[1] = 1;
494 rOutParamIndex
[2] = 2;
495 rOutParamIndex
[3] = 3;
496 rOutParamIndex
[4] = 4;
497 rOutParamIndex
[5] = 5;
498 rOutParamIndex
[6] = 6;
499 rOutParamIndex
[7] = 7;
500 rOutParamIndex
[8] = 8;
501 rOutParamIndex
[9] = 9;
502 rOutParamIndex
[10] = 10;
503 rOutParamIndex
[11] = 11;
504 rOutParamIndex
[12] = 12;
505 rOutParamIndex
[13] = 13;
506 rOutParamIndex
[14] = 14;
507 rOutParamIndex
[15] = 15;
508 rOutParamIndex
[16] = 16;
510 rOutParam
.realloc( 17 );
511 rOutParam
[0].setValue( &aBool
, ::getCppuBooleanType() );
512 rOutParam
[1].setValue( &aChar
, ::getCppuCharType() );
513 rOutParam
[2] <<= nByte
;
514 rOutParam
[3] <<= nShort
;
515 rOutParam
[4] <<= nUShort
;
516 rOutParam
[5] <<= nLong
;
517 rOutParam
[6] <<= nULong
;
518 rOutParam
[7] <<= nHyper
;
519 rOutParam
[8] <<= nUHyper
;
520 rOutParam
[9] <<= fFloat
;
521 rOutParam
[10] <<= fDouble
;
522 rOutParam
[11] <<= eEnum
;
523 rOutParam
[12] <<= aString
;
524 rOutParam
[13] <<= xInterface
;
525 rOutParam
[14] <<= aAny
;
526 rOutParam
[15] <<= aSeq
;
527 rOutParam
[16] <<= aData
;
531 bImplementedMethod
= false;
534 catch (IllegalArgumentException
& rExc
)
536 // thrown by raiseException() call
537 InvocationTargetException aExc
;
538 aExc
.TargetException
<<= rExc
;
543 OSL_ENSURE( sal_False
, "### unexpected exception caught!" );
547 if (! bImplementedMethod
)
549 throw IllegalArgumentException(
550 OUString( RTL_CONSTASCII_USTRINGPARAM("not an implemented method!") ),
551 (OWeakObject
*)this, 0 );
556 //__________________________________________________________________________________________________
557 void XLB_Invocation::setValue( const OUString
& rName
, const Any
& rValue
)
558 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::script::CannotConvertException
, ::com::sun::star::reflection::InvocationTargetException
, ::com::sun::star::uno::RuntimeException
)
560 if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ))
561 _xLBT
->setBool( *(const sal_Bool
*)rValue
.getValue() );
562 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ))
563 _xLBT
->setByte( *(const sal_Int8
*)rValue
.getValue() );
564 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ))
565 _xLBT
->setChar( *(const sal_Unicode
*)rValue
.getValue() );
566 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ))
567 _xLBT
->setShort( *(const sal_Int16
*)rValue
.getValue() );
568 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ))
569 _xLBT
->setUShort( *(const sal_uInt16
*)rValue
.getValue() );
570 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ))
571 _xLBT
->setLong( *(const sal_Int32
*)rValue
.getValue() );
572 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ))
573 _xLBT
->setULong( *(const sal_uInt32
*)rValue
.getValue() );
574 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ))
575 _xLBT
->setHyper( *(const sal_Int64
*)rValue
.getValue() );
576 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ))
577 _xLBT
->setUHyper( *(const sal_uInt64
*)rValue
.getValue() );
578 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ))
579 _xLBT
->setFloat( *(const float *)rValue
.getValue() );
580 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ))
581 _xLBT
->setDouble( *(const double *)rValue
.getValue() );
582 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ))
583 _xLBT
->setEnum( *(const TestEnum
*)rValue
.getValue() );
584 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ))
585 _xLBT
->setString( *(const OUString
*)rValue
.getValue() );
586 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ))
587 _xLBT
->setInterface( *(const Reference
< XInterface
> *)rValue
.getValue() );
588 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ))
589 _xLBT
->setAny( rValue
);
590 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ))
591 _xLBT
->setSequence( *(const Sequence
< TestElement
> *)rValue
.getValue() );
592 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ))
593 _xLBT
->setStruct( *(const TestData
*)rValue
.getValue() );
594 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ))
595 _xLBT
->setRuntimeException( *(const sal_Int32
*)rValue
.getValue() );
597 //__________________________________________________________________________________________________
598 Any
XLB_Invocation::getValue( const OUString
& rName
)
599 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
)
602 if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ))
604 sal_Bool aBool
= _xLBT
->getBool();
605 aRet
.setValue( &aBool
, ::getCppuBooleanType() );
607 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ))
608 aRet
<<= _xLBT
->getByte();
609 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ))
611 sal_Unicode aChar
= _xLBT
->getChar();
612 aRet
.setValue( &aChar
, ::getCppuCharType() );
614 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ))
615 aRet
<<= _xLBT
->getShort();
616 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ))
617 aRet
<<= _xLBT
->getUShort();
618 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ))
619 aRet
<<= _xLBT
->getLong();
620 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ))
621 aRet
<<= _xLBT
->getULong();
622 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ))
623 aRet
<<= _xLBT
->getHyper();
624 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ))
625 aRet
<<= _xLBT
->getUHyper();
626 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ))
627 aRet
<<= _xLBT
->getFloat();
628 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ))
629 aRet
<<= _xLBT
->getDouble();
630 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ))
631 aRet
<<= _xLBT
->getEnum();
632 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ))
633 aRet
<<= _xLBT
->getString();
634 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ))
635 aRet
<<= _xLBT
->getInterface();
636 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ))
637 aRet
<<= _xLBT
->getAny();
638 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ))
639 aRet
<<= _xLBT
->getSequence();
640 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ))
641 aRet
<<= _xLBT
->getStruct();
642 else if (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ))
643 aRet
<<= _xLBT
->getRuntimeException();
646 //__________________________________________________________________________________________________
647 sal_Bool
XLB_Invocation::hasMethod( const OUString
& rName
)
648 throw(::com::sun::star::uno::RuntimeException
)
650 return (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raiseException") ) ||
651 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("getValues") ) ||
652 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues2") ) ||
653 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues") ) ||
654 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("acquire") ) ||
655 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("release") ) ||
656 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("queryInterface") ));
658 //__________________________________________________________________________________________________
659 sal_Bool
XLB_Invocation::hasProperty( const OUString
& rName
)
660 throw(::com::sun::star::uno::RuntimeException
)
662 return (rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ) ||
663 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ) ||
664 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ) ||
665 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ) ||
666 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ) ||
667 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ) ||
668 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ) ||
669 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ) ||
670 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ) ||
671 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ) ||
672 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ) ||
673 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ) ||
674 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ) ||
675 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ) ||
676 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ) ||
677 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ) ||
678 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ) ||
679 rName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ) );
682 //##################################################################################################
684 //__________________________________________________________________________________________________
685 void Test_Impl::setValues( sal_Bool bBool
, sal_Unicode cChar
, sal_Int8 nByte
,
686 sal_Int16 nShort
, sal_uInt16 nUShort
,
687 sal_Int32 nLong
, sal_uInt32 nULong
,
688 sal_Int64 nHyper
, sal_uInt64 nUHyper
,
689 float fFloat
, double fDouble
,
690 test::TestEnum eEnum
, const ::rtl::OUString
& rStr
,
691 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xTest
,
692 const ::com::sun::star::uno::Any
& rAny
,
693 const ::com::sun::star::uno::Sequence
<test::TestElement
>& rSequence
,
694 const test::TestData
& rStruct
)
695 throw(com::sun::star::uno::RuntimeException
)
698 bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, fFloat
, fDouble
,
699 eEnum
, rStr
, xTest
, rAny
, rSequence
);
700 _aStructData
= rStruct
;
702 //__________________________________________________________________________________________________
703 test::TestData
Test_Impl::setValues2( sal_Bool
& bBool
, sal_Unicode
& cChar
, sal_Int8
& nByte
,
704 sal_Int16
& nShort
, sal_uInt16
& nUShort
,
705 sal_Int32
& nLong
, sal_uInt32
& nULong
,
706 sal_Int64
& nHyper
, sal_uInt64
& nUHyper
,
707 float& fFloat
, double& fDouble
,
708 test::TestEnum
& eEnum
, rtl::OUString
& rStr
,
709 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xTest
,
710 ::com::sun::star::uno::Any
& rAny
,
711 ::com::sun::star::uno::Sequence
<test::TestElement
>& rSequence
,
712 test::TestData
& rStruct
)
713 throw(com::sun::star::uno::RuntimeException
)
716 bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, fFloat
, fDouble
,
717 eEnum
, rStr
, xTest
, rAny
, rSequence
);
718 _aStructData
= rStruct
;
721 //__________________________________________________________________________________________________
722 test::TestData
Test_Impl::getValues( sal_Bool
& bBool
, sal_Unicode
& cChar
, sal_Int8
& nByte
,
723 sal_Int16
& nShort
, sal_uInt16
& nUShort
,
724 sal_Int32
& nLong
, sal_uInt32
& nULong
,
725 sal_Int64
& nHyper
, sal_uInt64
& nUHyper
,
726 float& fFloat
, double& fDouble
,
727 test::TestEnum
& eEnum
, rtl::OUString
& rStr
,
728 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& xTest
,
729 ::com::sun::star::uno::Any
& rAny
,
730 ::com::sun::star::uno::Sequence
<test::TestElement
>& rSequence
,
731 test::TestData
& rStruct
)
732 throw(com::sun::star::uno::RuntimeException
)
737 nShort
= _aData
.Short
;
738 nUShort
= _aData
.UShort
;
740 nULong
= _aData
.ULong
;
741 nHyper
= _aData
.Hyper
;
742 nUHyper
= _aData
.UHyper
;
743 fFloat
= _aData
.Float
;
744 fDouble
= _aData
.Double
;
746 rStr
= _aData
.String
;
747 xTest
= _aData
.Interface
;
749 rSequence
= _aData
.Sequence
;
750 rStruct
= _aStructData
;
754 //==================================================================================================
755 sal_Bool
performTest( const Reference
<XLanguageBindingTest
> & xLBT
)
757 OSL_ENSURE( xLBT
.is(), "### no test interface!" );
760 // this data is never ever granted access to by calls other than equals(), assign()!
761 test::TestData aData
; // test against this data
763 Reference
<XInterface
> xI( *new OWeakObject() );
765 assign( (test::TestElement
&)aData
,
766 sal_True
, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
767 SAL_CONST_INT64(0x123456789abcdef0),
768 SAL_CONST_UINT64(0xfedcba9876543210),
769 (float)17.0815, 3.1415926359, TestEnum_LOLA
, OUString::createFromAscii("dumdidum"), xI
,
770 Any( &xI
, ::getCppuType( (const Reference
<XInterface
> *)0 ) ) );
772 OSL_ENSURE( aData
.Any
== xI
, "### unexpected any!" );
773 OSL_ENSURE( !(aData
.Any
!= xI
), "### unexpected any!" );
775 aData
.Sequence
= Sequence
<test::TestElement
>( (const test::TestElement
*)&aData
, 1 );
777 //================================================================================
779 // this is a manually copy of aData for first setting...
780 test::TestData aSetData
;
782 assign( (test::TestElement
&)aSetData
,
783 aData
.Bool
, aData
.Char
, aData
.Byte
, aData
.Short
, aData
.UShort
,
784 aData
.Long
, aData
.ULong
, aData
.Hyper
, aData
.UHyper
, aData
.Float
, aData
.Double
,
785 aData
.Enum
, aData
.String
, xI
,
786 Any( &xI
, ::getCppuType( (const Reference
<XInterface
> *)0 ) ) );
788 aSetData
.Sequence
= Sequence
<test::TestElement
>( (const test::TestElement
*)&aSetData
, 1 );
791 aSetData
.Bool
, aSetData
.Char
, aSetData
.Byte
, aSetData
.Short
, aSetData
.UShort
,
792 aSetData
.Long
, aSetData
.ULong
, aSetData
.Hyper
, aSetData
.UHyper
, aSetData
.Float
, aSetData
.Double
,
793 aSetData
.Enum
, aSetData
.String
, aSetData
.Interface
, aSetData
.Any
, aSetData
.Sequence
, aSetData
);
796 test::TestData aRet
, aRet2
;
798 aRet
.Bool
, aRet
.Char
, aRet
.Byte
, aRet
.Short
, aRet
.UShort
,
799 aRet
.Long
, aRet
.ULong
, aRet
.Hyper
, aRet
.UHyper
, aRet
.Float
, aRet
.Double
,
800 aRet
.Enum
, aRet
.String
, aRet
.Interface
, aRet
.Any
, aRet
.Sequence
, aRet2
);
802 OSL_ASSERT( equals( aData
, aRet
) && equals( aData
, aRet2
) );
804 // set last retrieved values
805 test::TestData aSV2ret
= xLBT
->setValues2(
806 aRet
.Bool
, aRet
.Char
, aRet
.Byte
, aRet
.Short
, aRet
.UShort
,
807 aRet
.Long
, aRet
.ULong
, aRet
.Hyper
, aRet
.UHyper
, aRet
.Float
, aRet
.Double
,
808 aRet
.Enum
, aRet
.String
, aRet
.Interface
, aRet
.Any
, aRet
.Sequence
, aRet2
);
810 OSL_ASSERT( equals( aData
, aSV2ret
) && equals( aData
, aRet2
) );
813 test::TestData aRet
, aRet2
;
814 test::TestData aGVret
= xLBT
->getValues(
815 aRet
.Bool
, aRet
.Char
, aRet
.Byte
, aRet
.Short
, aRet
.UShort
,
816 aRet
.Long
, aRet
.ULong
, aRet
.Hyper
, aRet
.UHyper
, aRet
.Float
, aRet
.Double
,
817 aRet
.Enum
, aRet
.String
, aRet
.Interface
, aRet
.Any
, aRet
.Sequence
, aRet2
);
819 OSL_ASSERT( equals( aData
, aRet
) && equals( aData
, aRet2
) && equals( aData
, aGVret
) );
821 // set last retrieved values
822 xLBT
->setBool( aRet
.Bool
);
823 xLBT
->setChar( aRet
.Char
);
824 xLBT
->setByte( aRet
.Byte
);
825 xLBT
->setShort( aRet
.Short
);
826 xLBT
->setUShort( aRet
.UShort
);
827 xLBT
->setLong( aRet
.Long
);
828 xLBT
->setULong( aRet
.ULong
);
829 xLBT
->setHyper( aRet
.Hyper
);
830 xLBT
->setUHyper( aRet
.UHyper
);
831 xLBT
->setFloat( aRet
.Float
);
832 xLBT
->setDouble( aRet
.Double
);
833 xLBT
->setEnum( aRet
.Enum
);
834 xLBT
->setString( aRet
.String
);
835 xLBT
->setInterface( aRet
.Interface
);
836 xLBT
->setAny( aRet
.Any
);
837 xLBT
->setSequence( aRet
.Sequence
);
838 xLBT
->setStruct( aRet2
);
841 test::TestData aRet
, aRet2
;
842 aRet
.Hyper
= xLBT
->getHyper();
843 aRet
.UHyper
= xLBT
->getUHyper();
844 aRet
.Float
= xLBT
->getFloat();
845 aRet
.Double
= xLBT
->getDouble();
846 aRet
.Byte
= xLBT
->getByte();
847 aRet
.Char
= xLBT
->getChar();
848 aRet
.Bool
= xLBT
->getBool();
849 aRet
.Short
= xLBT
->getShort();
850 aRet
.UShort
= xLBT
->getUShort();
851 aRet
.Long
= xLBT
->getLong();
852 aRet
.ULong
= xLBT
->getULong();
853 aRet
.Enum
= xLBT
->getEnum();
854 aRet
.String
= xLBT
->getString();
855 aRet
.Interface
= xLBT
->getInterface();
856 aRet
.Any
= xLBT
->getAny();
857 aRet
.Sequence
= xLBT
->getSequence();
858 aRet2
= xLBT
->getStruct();
860 return (equals( aData
, aRet
) && equals( aData
, aRet2
));
866 //__________________________________________________________________________________________________
867 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*/ )
868 throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
)
870 IllegalArgumentException aExc
;
871 aExc
.ArgumentPosition
= 5;
872 aExc
.Message
= OUString::createFromAscii("dum dum dum ich tanz im kreis herum...");
873 aExc
.Context
= *this;
876 //__________________________________________________________________________________________________
877 sal_Int32
Test_Impl::getRuntimeException() throw(::com::sun::star::uno::RuntimeException
)
879 RuntimeException aExc
;
880 aExc
.Message
= OUString::createFromAscii("dum dum dum ich tanz im kreis herum...");
881 aExc
.Context
= *this;
884 //__________________________________________________________________________________________________
885 void Test_Impl::setRuntimeException( sal_Int32
/*_runtimeexception*/ ) throw(::com::sun::star::uno::RuntimeException
)
887 RuntimeException aExc
;
888 aExc
.Message
= OUString::createFromAscii("dum dum dum ich tanz im kreis herum...");
889 aExc
.Context
= *this;
893 //==================================================================================================
894 sal_Bool
raiseException( const Reference
<XLanguageBindingTest
> & xLBT
)
902 test::TestData aRet
, aRet2
;
903 xLBT
->raiseException(
904 aRet
.Bool
, aRet
.Char
, aRet
.Byte
, aRet
.Short
, aRet
.UShort
,
905 aRet
.Long
, aRet
.ULong
, aRet
.Hyper
, aRet
.UHyper
, aRet
.Float
, aRet
.Double
,
906 aRet
.Enum
, aRet
.String
, aRet
.Interface
, aRet
.Any
, aRet
.Sequence
, aRet2
);
909 catch (IllegalArgumentException aExc
)
911 OSL_ENSURE( aExc
.ArgumentPosition
== 5 &&
912 // aExc.Context == xLBT &&
913 aExc
.Message
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
914 "### unexpected exception content!" );
916 Reference
<XLanguageBindingTest
> xLBT2(
917 Reference
<XLanguageBindingTest
>::query( aExc
.Context
) );
919 OSL_ENSURE( xLBT2
.is(), "### unexpected source of exception!" );
921 xLBT2
->getRuntimeException();
926 catch (const RuntimeException
& rExc
)
928 OSL_ENSURE(//rExc.Context == xLBT &&
929 rExc
.Message
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
930 "### unexpected exception content!" );
932 Reference
<XLanguageBindingTest
> xLBT2(
933 Reference
<XLanguageBindingTest
>::query( rExc
.Context
) );
935 OSL_ENSURE( xLBT2
.is(), "### unexpected source of exception!" );
937 xLBT2
->setRuntimeException( 0xcafebabe );
942 catch (Exception
& aExc
)
944 OSL_ENSURE( //aExc.Context == xLBT &&
945 aExc
.Message
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
946 "### unexpected exception content!" );
947 return (//aExc.Context == xLBT &&
948 aExc
.Message
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")));
953 //==================================================================================================
954 static sal_Bool
test_adapter( const Reference
< XMultiServiceFactory
> & xMgr
)
956 Reference
< XInvocationAdapterFactory
> xAdapFac(
957 xMgr
->createInstance( OUString::createFromAscii("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY
);
958 Reference
< XInvocationAdapterFactory2
> xAdapFac2( xAdapFac
, UNO_QUERY_THROW
);
960 Reference
< XLanguageBindingTest
> xOriginal( (XLanguageBindingTest
*)new Test_Impl() );
961 Reference
< XInvocation
> xInvok( new XLB_Invocation( xMgr
, xOriginal
) );
962 Reference
< XLanguageBindingTest
> xLBT( xAdapFac
->createAdapter(
963 xInvok
, ::getCppuType( (const Reference
< XLanguageBindingTest
> *)0 ) ), UNO_QUERY
);
964 Reference
< XLanguageBindingTest
> xLBT2(
965 xAdapFac
->createAdapter(
966 xInvok
, ::getCppuType( (const Reference
< XLanguageBindingTest
> *)0 ) ), UNO_QUERY
);
969 Reference
< XInterface
> xLBT3(
970 xAdapFac
->createAdapter(
971 xInvok
, ::getCppuType( (const Reference
< XInterface
> *)0 ) ), UNO_QUERY
);
975 ::getCppuType( (const Reference
< XLBTestBase
> *)0 ),
976 ::getCppuType( (const Reference
< XInterface
> *)0 ) };
977 Reference
< XInterface
> xLBT4(
978 xAdapFac2
->createAdapter( xInvok
, Sequence
< Type
>( ar
, 2 ) ), UNO_QUERY
);
981 Reference
< XSimpleRegistry
> xInvalidAdapter(
982 xAdapFac
->createAdapter(
983 xInvok
, ::getCppuType( (const Reference
< XSimpleRegistry
> *)0 ) ), UNO_QUERY
);
984 if (xLBT
== xInvalidAdapter
)
989 xInvalidAdapter
->isValid();
992 catch (RuntimeException
&)
996 return (performTest( xLBT
) && raiseException( xLBT
));
998 //==================================================================================================
999 static sal_Bool
test_invocation( const Reference
< XMultiServiceFactory
> & xMgr
)
1001 Reference
< XInvocationAdapterFactory
> xAdapFac(
1002 xMgr
->createInstance( OUString::createFromAscii("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY
);
1003 Reference
< XSingleServiceFactory
> xInvocFac(
1004 xMgr
->createInstance( OUString::createFromAscii("com.sun.star.script.Invocation") ), UNO_QUERY
);
1006 Reference
< XLanguageBindingTest
> xOriginal( (XLanguageBindingTest
*)new Test_Impl() );
1007 Any
aOriginal( &xOriginal
, ::getCppuType( &xOriginal
) );
1008 Reference
< XInvocation
> xInvok(
1009 xInvocFac
->createInstanceWithArguments( Sequence
< Any
>( &aOriginal
, 1 ) ), UNO_REF_QUERY
);
1011 Reference
< XLanguageBindingTest
> xLBT( xAdapFac
->createAdapter(
1012 xInvok
, ::getCppuType( (const Reference
< XLanguageBindingTest
> *)0 ) ), UNO_QUERY
);
1014 return (performTest( xLBT
) && raiseException( xLBT
));
1017 SAL_IMPLEMENT_MAIN()
1019 Reference
< XMultiServiceFactory
> xMgr( createRegistryServiceFactory(
1020 OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
1024 Reference
< XImplementationRegistration
> xImplReg(
1025 xMgr
->createInstance(
1027 RTL_CONSTASCII_USTRINGPARAM(
1028 "com.sun.star.registry.ImplementationRegistration") ) ),
1030 OSL_ENSURE( xImplReg
.is(), "### no impl reg!" );
1032 xImplReg
->registerImplementation(
1033 OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
1034 OUString::createFromAscii("invocadapt.uno" SAL_DLLEXTENSION
),
1035 Reference
< XSimpleRegistry
>() );
1036 xImplReg
->registerImplementation(
1037 OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
1038 OUString::createFromAscii("stocservices.uno" SAL_DLLEXTENSION
),
1039 Reference
< XSimpleRegistry
>() );
1040 xImplReg
->registerImplementation(
1041 OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
1042 OUString::createFromAscii("invocation.uno" SAL_DLLEXTENSION
),
1043 Reference
< XSimpleRegistry
>() );
1044 xImplReg
->registerImplementation(
1045 OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
1046 OUString::createFromAscii("reflection.uno" SAL_DLLEXTENSION
),
1047 Reference
< XSimpleRegistry
>() );
1048 xImplReg
->registerImplementation(
1049 OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
1050 OUString::createFromAscii("introspection.uno" SAL_DLLEXTENSION
),
1051 Reference
< XSimpleRegistry
>() );
1053 if (test_adapter( xMgr
))
1055 fprintf( stderr
, "> test_iadapter() succeeded.\n" );
1056 if (test_invocation( xMgr
))
1058 fprintf( stderr
, "> test_invocation() succeeded.\n" );
1062 catch (Exception
& rExc
)
1064 fprintf( stderr
, "> exception occured: " );
1065 OString
aMsg( OUStringToOString( rExc
.Message
, RTL_TEXTENCODING_ASCII_US
) );
1066 fprintf( stderr
, "%s\n", aMsg
.getStr() );
1069 Reference
< XComponent
>( xMgr
, UNO_QUERY
)->dispose();