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