bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / test / ole / OleClient / clientTest.cxx
blob675b2a66d09c235038e7aa07bf0a60febf3c2d3a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <atlbase.h>
23 CComModule _Module;
24 #include <atlcom.h>
25 #include <comdef.h>
27 #include "axhost.hxx"
29 #include <stdio.h>
30 #include "typelib/typedescription.hxx"
31 #include <com/sun/star/bridge/oleautomation/Date.hpp>
32 #include <com/sun/star/bridge/oleautomation/Currency.hpp>
33 #include <com/sun/star/bridge/oleautomation/Decimal.hpp>
34 #include <com/sun/star/bridge/oleautomation/SCode.hpp>
35 #include <com/sun/star/bridge/oleautomation/NamedArgument.hpp>
36 #include <com/sun/star/bridge/oleautomation/PropertyPutArgument.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/script/XInvocation.hpp>
39 #include <com/sun/star/uno/Reference.h>
40 #include <cppuhelper/servicefactory.hxx>
41 #include <rtl/string.h>
43 BEGIN_OBJECT_MAP(ObjectMap)
44 END_OBJECT_MAP()
46 using namespace com::sun::star::lang;
47 using namespace com::sun::star::uno;
48 using namespace com::sun::star::script;
49 using namespace com::sun::star::bridge::oleautomation;
50 using namespace cppu;
53 Reference<XInvocation> convertComObject( IUnknown* pUnk);
54 Reference<XInvocation> getComObject( OUString progId);
55 bool checkOutArgs(const Sequence<Any> & outArgs,
56 const Sequence<sal_Int16> & indices, const Sequence<Any> & values);
58 bool doSimpleTest(const Reference<XInvocation> & inv);
59 bool doSimpleSequenceTest(const Reference<XInvocation> & inv);
60 bool doParameterTest(const Reference<XInvocation> & inv);
61 bool doPropertyWithArgumentTest(const Reference<XInvocation> & inv);
62 bool equalSequences(const Any& orig, const Any& returned);
63 HRESULT doTest();
64 HRESULT doTest2( Reference<XInvocation> &);
65 Reference<XInvocation> getComObject(OUString& );
67 HRESULT InitializeParameter();
68 void printResultVariantArray( VARIANT & var);
69 void printVariant( VARIANT & var);
70 void printSequence( Sequence<Any>& val);
72 extern "C" int SAL_CALL main( int , char **)
74 HRESULT hr;
75 if( FAILED( hr=CoInitialize(NULL)))
77 _tprintf(_T("CoInitialize failed \n"));
78 return -1;
82 _Module.Init( ObjectMap, GetModuleHandle( NULL));
84 if( FAILED(hr=doTest()))
86 _com_error err( hr);
87 const TCHAR * errMsg= err.ErrorMessage();
88 MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
90 else
92 MessageBox( NULL,NULL , "Test succeeded", MB_ICONINFORMATION);
96 _Module.Term();
97 CoUninitialize();
98 return 0;
100 //Also supports named args
102 bool doParameterTest(const Reference<XInvocation> & inv)
104 Sequence< sal_Int16> seqIndices;
105 Sequence<Any> seqOut;
107 Any arArgs[2];
108 Any arArgs1[4];
110 NamedArgument arg1(OUString(L"val1"), makeAny((sal_Int32) 123));
111 NamedArgument arg2(OUString(L"val2"), makeAny((sal_Int32) 456));
112 NamedArgument arg3(OUString(L"val3"), makeAny((sal_Int32) 0xff));
113 NamedArgument arg4(OUString(L"val4"), makeAny((sal_Int32) 0xffff));
115 NamedArgument argOut1(OUString(L"val1"), Any());
116 NamedArgument argOut2(OUString(L"val2"), Any());
117 Sequence<Any> seqNoArgs;
118 arArgs[0] <<= (sal_Int32) 0;
119 arArgs[1] <<= (sal_Int32) 0;
120 Sequence<Any> seqPositional0(arArgs, 2);
123 arArgs[0] <<= arg1;
124 arArgs[1] <<= arg2;
125 Sequence<Any> seqNamed(arArgs, 2);
126 arArgs[0] <<= arg2;
127 arArgs[1] <<= arg1;
128 Sequence<Any> seqNamed2(arArgs, 2);
129 arArgs[0] <<= argOut1;
130 arArgs[1] <<= argOut2;
131 Sequence<Any> seqNamed3(arArgs, 2);
132 arArgs[0] <<= argOut2;
133 arArgs[1] <<= argOut1;
134 Sequence<Any> seqNamed4(arArgs, 2);
136 arArgs[0] <<= arg1;
137 Sequence<Any> seqNamed5(arArgs, 1);
138 arArgs[0] <<= arg2;
139 Sequence<Any> seqNamed6(arArgs, 1);
141 arArgs[0] <<= (sal_Int32) 123;
142 arArgs[1] <<= (sal_Int32) 456;
143 Sequence<Any> seqPositional(arArgs, 2);
144 arArgs[0] <<= (sal_Int32) 123;
145 Sequence<Any> seqPositional2(arArgs, 1);
147 arArgs[0].clear();
148 arArgs[1].clear();
149 Sequence<Any> seqPositional3(arArgs, 2);
151 arArgs[0] <<= (sal_Int32) 123;
152 arArgs[1] <<= SCode(DISP_E_PARAMNOTFOUND);
153 Sequence<Any> seqOutOpt1(arArgs, 2);
155 arArgs[0] <<= SCode(DISP_E_PARAMNOTFOUND);
156 arArgs[1] <<= SCode(DISP_E_PARAMNOTFOUND);
157 Sequence<Any> seqOutOpt2(arArgs, 2);
159 arArgs[0] <<= SCode(DISP_E_PARAMNOTFOUND);
160 arArgs[1] <<= (sal_Int32) 456;
161 Sequence<Any> seqOutOpt3(arArgs, 2);
163 arArgs1[0] <<= (sal_Int32) 0;
164 arArgs1[1] <<= (sal_Int32) 0;
165 arArgs1[2] <<= (sal_Int32) 0;
166 arArgs1[3] <<= (sal_Int32) 0;
167 Sequence<Any> seqMix0(arArgs1, 4);
169 arArgs1[0] <<= (sal_Int32) 123;
170 arArgs1[1] <<= (sal_Int32) 456;
171 arArgs1[2] <<= arg3;
172 arArgs1[3] <<= arg4;
173 Sequence<Any> seqMix(arArgs1, 4);
175 arArgs1[0].clear();
176 arArgs1[1] <<= (sal_Int32) 456;
177 arArgs1[2] <<= arg4;
178 Sequence<Any> seqMix2(arArgs1, 3);
180 arArgs1[0] <<= SCode(DISP_E_PARAMNOTFOUND);
181 arArgs1[1] <<= (sal_Int32) 456;
182 arArgs1[2] <<= SCode(DISP_E_PARAMNOTFOUND);
183 arArgs1[3] <<= arg4.Value;
184 Sequence<Any> seqMixOut(arArgs1, 4);
186 arArgs1[0] <<= SCode(DISP_E_PARAMNOTFOUND);
187 arArgs1[1].clear();
188 arArgs1[2] <<= arg4;
189 Sequence<Any> seqMix2Out(arArgs1, 3);
192 //in args + out, optional, positional-----------------------------------------
193 //first general test
194 seqIndices.realloc(0);
195 seqOut.realloc(0);
196 inv->invoke(OUString(L"optional3"), seqPositional, seqIndices, seqOut);
197 seqIndices.realloc(0);
198 seqOut.realloc(0);
199 inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
200 if ( ! checkOutArgs(seqOut, seqIndices, seqPositional))
201 return false;
203 //2 optional args, 1 provided
204 seqIndices.realloc(0);
205 seqOut.realloc(0);
206 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
207 seqIndices.realloc(0);
208 seqOut.realloc(0);
209 inv->invoke(OUString(L"optional3"), seqPositional2, seqIndices, seqOut);
210 seqIndices.realloc(0);
211 seqOut.realloc(0);
212 inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
213 if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt1))
214 return false;
216 //2 optional args, 0 provided
217 seqIndices.realloc(0);
218 seqOut.realloc(0);
219 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
220 seqIndices.realloc(0);
221 seqOut.realloc(0);
222 inv->invoke(OUString(L"optional3"), seqNoArgs, seqIndices, seqOut);
223 seqIndices.realloc(0);
224 seqOut.realloc(0);
225 inv->invoke(OUString(L"optional5"), seqPositional3, seqIndices, seqOut);
226 if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt2))
227 return false;
229 //named args --------------------------------------------
231 // 2 named args, correct position
232 seqIndices.realloc(0);
233 seqOut.realloc(0);
234 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
235 seqIndices.realloc(0);
236 seqOut.realloc(0);
237 inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut);
238 seqIndices.realloc(0);
239 seqOut.realloc(0);
240 inv->invoke(OUString(L"optional5"), seqPositional0, seqIndices, seqOut);
241 if ( ! checkOutArgs(seqOut, seqIndices, seqPositional))
242 return false;
244 // 2named args, position differs
245 seqIndices.realloc(0);
246 seqOut.realloc(0);
247 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
248 seqIndices.realloc(0);
249 seqOut.realloc(0);
250 inv->invoke(OUString(L"optional3"), seqNamed2, seqIndices, seqOut);
251 seqIndices.realloc(0);
252 seqOut.realloc(0);
253 inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
254 if ( ! checkOutArgs(seqOut, seqIndices, seqPositional))
255 return false;
257 //named out args, 2 named args with correct position
258 seqIndices.realloc(0);
259 seqOut.realloc(0);
260 inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut);
261 seqIndices.realloc(0);
262 seqIndices.realloc(0);
263 inv->invoke(OUString(L"optional5"), seqNamed3, seqIndices, seqOut);
264 if ( ! checkOutArgs(seqOut, seqIndices, seqNamed ))
265 return false;
267 //named out args, 2 named args with different position
268 seqIndices.realloc(0);
269 seqOut.realloc(0);
270 inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut);
271 seqIndices.realloc(0);
272 seqIndices.realloc(0);
273 inv->invoke(OUString(L"optional5"), seqNamed4, seqIndices, seqOut);
274 if ( ! checkOutArgs(seqOut, seqIndices, seqNamed2 ))
275 return false;
278 //2 args, 1 provided (correct order)
279 seqIndices.realloc(0);
280 seqOut.realloc(0);
281 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
282 seqIndices.realloc(0);
283 seqOut.realloc(0);
284 inv->invoke(OUString(L"optional3"), seqNamed5, seqIndices, seqOut);
285 seqIndices.realloc(0);
286 seqOut.realloc(0);
287 inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
288 if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt1))
289 return false;
290 //2 args, 1 provided (incorrect order)
291 seqIndices.realloc(0);
292 seqOut.realloc(0);
293 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
294 seqIndices.realloc(0);
295 seqOut.realloc(0);
296 inv->invoke(OUString(L"optional3"), seqNamed6, seqIndices, seqOut);
297 seqIndices.realloc(0);
298 seqOut.realloc(0);
299 inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
300 if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt3))
301 return false;
303 //2position + 2 2named args, correct order
304 seqIndices.realloc(0);
305 seqOut.realloc(0);
306 inv->invoke(OUString(L"optional6"), seqMix0, seqIndices, seqOut);
307 seqIndices.realloc(0);
308 seqOut.realloc(0);
309 inv->invoke(OUString(L"optional6"), seqMix, seqIndices, seqOut);
310 seqIndices.realloc(0);
311 seqOut.realloc(0);
312 inv->invoke(OUString(L"optional7"), seqMix, seqIndices, seqOut);
313 if ( ! checkOutArgs(seqOut, seqIndices, seqMix))
314 return false;
316 // 4 in args, 1 positional, 1 named, 1 positional omitted
317 seqIndices.realloc(0);
318 seqOut.realloc(0);
319 inv->invoke(OUString(L"optional6"), seqMix0, seqIndices, seqOut);
320 seqIndices.realloc(0);
321 seqOut.realloc(0);
322 inv->invoke(OUString(L"optional6"), seqMix2, seqIndices, seqOut);
323 seqIndices.realloc(0);
324 seqOut.realloc(0);
325 inv->invoke(OUString(L"optional7"), seqMix0, seqIndices, seqOut);
326 if ( ! checkOutArgs(seqOut, seqIndices, seqMixOut))
327 return false;
329 // 4 out args, 1 positional, 1 named, 1 positional omitted
330 seqIndices.realloc(0);
331 seqOut.realloc(0);
332 inv->invoke(OUString(L"optional6"), seqMix2, seqIndices, seqOut);
333 seqIndices.realloc(0);
334 seqOut.realloc(0);
335 inv->invoke(OUString(L"optional7"), seqMix2Out, seqIndices, seqOut);
336 if ( ! checkOutArgs(seqOut, seqIndices, seqMix2Out))
337 return false;
340 return true;
342 bool doPropertyTest(const Reference<XInvocation> & inv)
344 Sequence< sal_Int16> seqIndices;
345 Sequence<Any> seqOut;
347 Any inBool, outBool;
348 Any inByte, outByte;
349 Any inShort, outShort;
350 Any inLong, outLong;
351 Any inString, outString;
352 Any inFloat, outFloat;
353 Any inDouble, outDouble;
354 Any inVariant, outVariant;
355 Any inObject, outObject;
356 Any inUnknown, outUnknown;
357 Any inCY, outCY;
358 Any inDate, outDate;
359 Any inDecimal, outDecimal;
360 Any inSCode, outSCode;
361 Any inrefLong, outrefLong;
362 Any inrefVariant, outrefVariant;
363 Any inrefDecimal, outrefDecimal;
364 Any inParamsLong, outParamsLong;
365 Reference<XInterface> xintUnknown(getComObject(L"AxTestComponents.Foo"));
367 inBool <<= (sal_Bool) sal_True;
368 inv->setValue(OUString(L"prpBool"), inBool);
369 outBool = inv->getValue(OUString(L"prpBool"));
371 inByte <<= (sal_Int8) 100;
372 inv->setValue(OUString(L"prpByte"), inByte);
373 outByte = inv->getValue(OUString(L"prpByte"));
375 inShort <<= static_cast<sal_Int16>( -1);
376 inv->setValue(OUString(L"prpShort"), inShort);
377 outShort = inv->getValue(OUString(L"prpShort"));
379 inLong <<= ( sal_Int32) 1234567;
380 inv->setValue(OUString(L"prpLong"), inLong // TODO: Add your implementation code here
382 outLong = inv->getValue(OUString(L"prpLong"));
384 inString <<= OUString(L" this is clientTest.exe");
385 inv->setValue(OUString(L"prpString"), inString);
386 outString = inv->getValue(OUString(L"prpString"));
388 inFloat <<= 3.14f;
389 inv->setValue(OUString(L"prpFloat"), inFloat);
390 outFloat = inv->getValue(OUString(L"prpFloat"));
392 inDouble <<= ( double) 3.145;
393 inv->setValue(OUString(L"prpDouble"), inDouble);
394 outDouble = inv->getValue(OUString(L"prpDouble"));
396 inVariant <<= OUString(L"A string in an any");
397 inv->setValue(OUString(L"prpVariant"), inVariant);
398 outVariant = inv->getValue(OUString(L"prpVariant"));
400 inObject <<= inv;
401 inv->setValue(OUString(L"prpObject"), inObject);
402 outObject = inv->getValue(OUString(L"prpObject"));
404 inUnknown <<= xintUnknown;
405 inv->setValue(OUString(L"prpUnknown"), inUnknown);
406 outUnknown = inv->getValue(OUString(L"prpUnknown"));
408 Currency cur(99999);
409 inCY <<= cur;
410 inv->setValue(OUString(L"prpCurrency"), inCY);
411 outCY = inv->getValue(OUString(L"prpCurrency"));
413 Date d(37889.0);
414 inDate <<= d;
415 inv->setValue(OUString(L"prpDate"), inDate);
416 outDate = inv->getValue(OUString(L"prpDate"));
418 Decimal dec(20, 0, 0xffffffff, 0xffffffff, 0x0fffffff);
419 inDecimal <<= dec;
420 inv->setValue(OUString(L"prpDecimal"), inDecimal);
421 outDecimal = inv->getValue(OUString(L"prpDecimal"));
423 SCode code(DISP_E_BADVARTYPE);
424 inSCode <<= code;
425 inv->setValue(OUString(L"prpSCode"), inSCode);
426 outSCode = inv->getValue(OUString(L"prpSCode"));
428 inrefLong <<= (sal_Int32) 123456;
429 inv->setValue(OUString(L"prprefLong"), inrefLong);
430 outrefLong = inv->getValue(OUString(L"prprefLong"));
432 inrefVariant <<= OUString(L"A string in an any");
433 inv->setValue(OUString(L"prprefVariant"), inrefVariant);
434 outrefVariant = inv->getValue(OUString(L"prprefVariant"));
436 Decimal decref(20, 0, 0xffffffff, 0xffffffff, 0x0fffffff);
437 inrefDecimal <<= decref;
438 inv->setValue(OUString(L"prprefDecimal"), inrefDecimal);
439 outrefDecimal = inv->getValue(OUString(L"prprefDecimal"));
441 if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong
442 || inFloat != outFloat || inDouble != outDouble || inString != outString
443 || inVariant != outVariant || inObject != outObject
444 || inUnknown != outUnknown || inCY != outCY
445 || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode
446 || inrefLong != outrefLong ||inrefVariant != outrefVariant
447 || inrefDecimal != outrefDecimal)
448 return false;
449 return true;
452 bool doPropertyWithArgumentTest(const Reference<XInvocation> & inv)
454 Sequence< sal_Int16> seqIndices;
455 Sequence<Any> seqOut;
457 Any arMultiArgs[3];
458 arMultiArgs[0] = makeAny((sal_Int32) 0);
459 arMultiArgs[1] = makeAny((sal_Int32) 0);
460 arMultiArgs[2] <<= PropertyPutArgument(makeAny((sal_Int32) 0));
461 Sequence<Any> seqMultiArgPut0(arMultiArgs, 3);
463 arMultiArgs[0] = makeAny((sal_Int32) 1);
464 arMultiArgs[1] = makeAny((sal_Int32) 2);
465 arMultiArgs[2] <<= PropertyPutArgument(makeAny((sal_Int32) 3));
466 Sequence<Any> seqMultiArgPut1(arMultiArgs, 3);
468 arMultiArgs[0] = makeAny((sal_Int32) 1);
469 arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 3));
470 Sequence<Any> seqMultiArgPut2(arMultiArgs, 2);
472 arMultiArgs[0] <<= NamedArgument(OUString(L"val2"), makeAny((sal_Int32) 1));
473 arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 3));
474 Sequence<Any> seqMultiArgPut3(arMultiArgs, 2);
476 arMultiArgs[0] <<= NamedArgument(OUString(L"val2"), makeAny((sal_Int32) 1));
477 arMultiArgs[1] <<= NamedArgument(OUString(L"val3"), makeAny((sal_Int32) 3));
478 Sequence<Any> seqMultiArgPut4(arMultiArgs, 2);
480 arMultiArgs[0] = makeAny((sal_Int32) 0);
481 arMultiArgs[1] = makeAny((sal_Int32) 0);
482 Sequence<Any> seqMultiArgGet0(arMultiArgs, 2);
484 arMultiArgs[0] = makeAny((sal_Int32) 1);
485 arMultiArgs[1] = makeAny((sal_Int32) 2);
486 Sequence<Any> seqMultiArgGet1(arMultiArgs, 2);
487 Sequence<Any> seqMultiArgGet2(arMultiArgs, 1);
490 arMultiArgs[0] = makeAny((sal_Int32) 0);
491 arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 0));
492 Sequence<Any> seqMultiArgPut5(arMultiArgs, 2);
494 arMultiArgs[0] = makeAny((sal_Int32) 1);
495 arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 2));
496 Sequence<Any> seqMultiArgPut6(arMultiArgs, 2);
498 arMultiArgs[0].clear();
499 arMultiArgs[1].clear();
500 Sequence<Any> seqMultiVoid(arMultiArgs, 2);
502 arMultiArgs[0] = makeAny((sal_Int32) 0);
503 arMultiArgs[1] = makeAny((sal_Int32) 0);
504 Sequence<Any> seqMultiVoid2(arMultiArgs, 2);
506 //[propput, ...] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [in] VARIANT* newVal);
507 //[propget, ...] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [out, optional, retval] VARIANT* pVal);
508 seqIndices.realloc( 0);
509 seqOut.realloc(0);
510 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut);
511 seqIndices.realloc( 0);
512 seqOut.realloc(0);
513 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut1, seqIndices, seqOut);
514 //check in/out args
515 seqIndices.realloc( 0);
516 seqOut.realloc(0);
517 Any anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0,
518 seqIndices, seqOut);
520 if (anyRet != ((PropertyPutArgument const *)seqMultiArgPut1[2].getValue())->Value
521 || ! checkOutArgs(seqOut, seqIndices, Sequence<Any>(seqMultiArgPut1.getArray(), 2)))
523 return false;
525 // test optional (one arg omitted
526 seqIndices.realloc( 0);
527 seqOut.realloc(0);
528 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut);
529 seqIndices.realloc( 0);
530 seqOut.realloc(0);
531 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut2, seqIndices, seqOut);
532 seqIndices.realloc( 0);
533 seqOut.realloc(0);
534 anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0,
535 seqIndices, seqOut);
537 arMultiArgs[0] = makeAny((sal_Int32) 1);
538 arMultiArgs[1] = makeAny((SCode(DISP_E_PARAMNOTFOUND)));
540 if (anyRet != ((PropertyPutArgument const *) seqMultiArgPut2[1].getValue())->Value
541 || ! checkOutArgs(seqOut, seqIndices, Sequence<Any>(arMultiArgs, 2)))
543 return false;
546 //test one named arg and one omitted
547 seqIndices.realloc( 0);
548 seqOut.realloc(0);
549 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut);
550 seqIndices.realloc( 0);
551 seqOut.realloc(0);
552 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut3, seqIndices, seqOut);
553 seqIndices.realloc( 0);
554 seqOut.realloc(0);
555 anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0,
556 seqIndices, seqOut);
558 arMultiArgs[0] = makeAny((SCode(DISP_E_PARAMNOTFOUND)));
559 arMultiArgs[1] = ((NamedArgument const*) seqMultiArgPut3[0].getValue())->Value;
560 if (anyRet != ((PropertyPutArgument const*) seqMultiArgPut3[1].getValue())->Value
561 || ! checkOutArgs(seqOut, seqIndices, Sequence<Any>(arMultiArgs, 2)))
563 return false;
566 // [propget,...] HRESULT prpMultiArg2([in] VARIANT val1, [out, retval] VARIANT* pVal);
567 // [propput,...] HRESULT prpMultiArg2([in] VARIANT val1, [in] VARIANT newVal);
568 seqIndices.realloc( 0);
569 seqOut.realloc(0);
570 inv->invoke(OUString(L"prpMultiArg2"), seqMultiArgPut5, seqIndices, seqOut);
571 seqIndices.realloc( 0);
572 seqOut.realloc(0);
573 inv->invoke(OUString(L"prpMultiArg2GetValues"), seqMultiVoid, seqIndices, seqOut);
575 if ( ! checkOutArgs(seqOut, seqIndices, seqMultiVoid2))
576 return false;
577 seqIndices.realloc( 0);
578 seqOut.realloc(0);
579 anyRet = inv->invoke(OUString(L"prpMultiArg2"), seqMultiArgPut6,
580 seqIndices, seqOut);
581 seqIndices.realloc( 0);
582 seqOut.realloc(0);
583 anyRet = inv->invoke(OUString(L"prpMultiArg2GetValues"), seqMultiVoid,
584 seqIndices, seqOut);
586 // [propget,...] HRESULT prpMultiArg3([in,out] LONG* val1, [out, retval] LONG* pVal);
587 // [propput,...] HRESULT prpMultiArg3([in,out] LONG* val1, [in] LONG newVal);
589 if ( ! checkOutArgs(seqOut, seqIndices, seqMultiArgGet1 ))
590 return false;
591 seqIndices.realloc( 0);
592 seqOut.realloc(0);
593 inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgPut5, seqIndices, seqOut);
594 seqIndices.realloc( 0);
595 seqOut.realloc(0);
596 inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgPut6, seqIndices, seqOut);
597 seqIndices.realloc( 0);
598 seqOut.realloc(0);
599 anyRet = inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgGet2, seqIndices, seqOut);
601 if ( anyRet != ((PropertyPutArgument const*) seqMultiArgPut6[1].getValue())->Value
602 || !checkOutArgs(seqOut, seqIndices, seqMultiArgGet2))
603 return false;
606 //hasProperty, hasMethod
607 if (inv->hasProperty("prpMultiArg1"))
608 return false;
609 if ( ! inv->hasMethod("prpMultiArg1"))
610 return false;
611 if ( ! inv->hasProperty("prprefLong"))
612 return false;
613 if (inv->hasMethod("prprefLong"))
614 return false;
615 if ( ! inv->hasMethod("inLong"))
616 return false;
618 return true;
620 bool doSimpleTest(const Reference<XInvocation> & inv)
622 Sequence< sal_Int16> seqIndices;
623 Sequence<Any> seqOut;
625 Any inBool, outBool;
626 Any inByte, outByte;
627 Any inShort, outShort;
628 Any inLong, outLong;
629 Any inString, outString;
630 Any inFloat, outFloat;
631 Any inDouble, outDouble;
632 Any inVariant, outVariant;
633 Any inObject, outObject;
634 Any inUnknown, outUnknown;
635 Any inCY, outCY;
636 Any inDate, outDate;
637 Any inDecimal, outDecimal;
638 Any inSCode, outSCode;
639 Any inrefLong, outrefLong;
640 Any inrefVariant, outrefVariant;
641 Any inrefDecimal, outrefDecimal;
643 Reference<XInterface> xIntFoo(getComObject(L"AxTestComponents.Foo"));
645 // in and out parameter
647 sal_Bool aBool = sal_True;
648 inBool.setValue(&aBool, cppu::UnoType<bool>::get());
649 inv->invoke(OUString(L"inBool"), Sequence< Any > ( &inBool, 1), seqIndices, seqOut);
650 seqIndices.realloc(0);
651 seqOut.realloc(0);
652 inv->invoke(OUString(L"outBool"), Sequence< Any > ( & outBool, 1), seqIndices, seqOut);
653 outBool <<= seqOut[0];
655 inByte <<= (sal_Int8) 127;
656 inv->invoke(OUString(L"inByte"), Sequence< Any > ( & inByte, 1), seqIndices, seqOut);
657 seqIndices.realloc( 0);
658 seqOut.realloc(0);
659 inv->invoke(OUString(L"outByte"), Sequence< Any > ( & outByte, 1), seqIndices, seqOut);
660 outByte <<= seqOut[0];
662 inShort <<= static_cast<sal_Int16>(-1);
663 inv->invoke(OUString(L"inShort"), Sequence< Any > ( & inShort, 1), seqIndices, seqOut);
664 seqIndices.realloc( 0);
665 seqOut.realloc(0);
666 inv->invoke(OUString(L"outShort"), Sequence< Any > ( & outShort, 1), seqIndices, seqOut);
667 outShort <<= seqOut[0];
669 inLong <<= ( sal_Int32) 1234567;
670 inv->invoke(OUString(L"inLong"), Sequence< Any > ( & inLong, 1), seqIndices, seqOut);
671 seqIndices.realloc( 0);
672 seqOut.realloc(0);
673 inv->invoke(OUString(L"outLong"), Sequence< Any > ( & outLong, 1 ), seqIndices, seqOut);
674 outLong <<= seqOut[0];
676 inString <<= OUString(L" this is clientTest.exe");
677 inv->invoke(OUString(L"inString"), Sequence< Any > ( & inString, 1), seqIndices, seqOut);
678 seqIndices.realloc( 0);
679 seqOut.realloc(0);
680 inv->invoke(OUString(L"outString"), Sequence< Any > ( & outString, 1 ), seqIndices, seqOut);
681 outString <<= seqOut[0];
683 inFloat <<= 3.14f;
684 inv->invoke(OUString(L"inFloat"), Sequence< Any > ( & inFloat, 1), seqIndices, seqOut);
685 seqIndices.realloc( 0);
686 seqOut.realloc(0);
687 inv->invoke(OUString(L"outFloat"), Sequence< Any > ( & outFloat, 1 ), seqIndices, seqOut);
688 outFloat <<= seqOut[0];
690 inDouble <<= ( double) 3.145;
691 inv->invoke(OUString(L"inDouble"), Sequence< Any > ( & inDouble, 1), seqIndices, seqOut);
692 seqIndices.realloc( 0);
693 seqOut.realloc(0);
694 inv->invoke(OUString(L"outDouble"), Sequence< Any > ( & outDouble, 1 ), seqIndices, seqOut);
695 outDouble <<= seqOut[0];
697 inVariant <<= OUString(L" A string in an any");
698 inv->invoke(OUString(L"inVariant"), Sequence< Any > ( & inVariant, 1), seqIndices, seqOut);
699 seqIndices.realloc( 0);
700 seqOut.realloc(0);
701 inv->invoke(OUString(L"outVariant"), Sequence< Any > (&outVariant, 1), seqIndices, seqOut);
702 outVariant <<= seqOut[0];
704 inObject <<= inv;
705 inv->invoke(OUString(L"inObject"), Sequence< Any > ( & inObject, 1), seqIndices, seqOut);
706 seqIndices.realloc( 0);
707 seqOut.realloc(0);
708 inv->invoke(OUString(L"outObject"), Sequence< Any > (& outObject, 1), seqIndices, seqOut);
709 outObject <<= seqOut[0];
711 inUnknown <<= xIntFoo;
712 inv->invoke(OUString(L"inUnknown"), Sequence< Any > ( & inUnknown, 1), seqIndices, seqOut);
713 seqIndices.realloc( 0);
714 seqOut.realloc(0);
715 inv->invoke(OUString(L"outUnknown"), Sequence< Any > (& outUnknown, 1), seqIndices, seqOut);
716 outUnknown <<= seqOut[0];
718 Currency cur(999999);
719 inCY <<= cur;
720 inv->invoke(OUString(L"inCurrency"), Sequence<Any>( & inCY, 1), seqIndices, seqOut);
721 seqIndices.realloc( 0);
722 seqOut.realloc(0);
723 inv->invoke(OUString(L"outCurrency"), Sequence< Any > (& outCY, 1), seqIndices, seqOut);
724 outCY <<= seqOut[0];
726 Date dDate(37889.0);
727 inDate <<= dDate;
728 inv->invoke(OUString(L"inDate"), Sequence<Any>( & inDate, 1), seqIndices, seqOut);
729 seqIndices.realloc( 0);
730 seqOut.realloc(0);
731 inv->invoke(OUString(L"outDate"), Sequence< Any > (& outDate, 1), seqIndices, seqOut);
732 outDate <<= seqOut[0];
734 Decimal dec(3, 0, 0xffffffff, 0xffffffff, 0xfffffff0);
735 inDecimal <<= dec;
736 inv->invoke(OUString(L"inDecimal"), Sequence<Any>( & inDecimal, 1), seqIndices, seqOut);
737 seqIndices.realloc( 0);
738 seqOut.realloc(0);
739 inv->invoke(OUString(L"outDecimal"), Sequence< Any > (& outDecimal, 1), seqIndices, seqOut);
740 outDecimal <<= seqOut[0];
742 SCode code(DISP_E_BADVARTYPE);
743 inSCode <<= code;
744 inv->invoke(OUString(L"inSCode"), Sequence<Any>( & inSCode, 1), seqIndices, seqOut);
745 seqIndices.realloc( 0);
746 seqOut.realloc(0);
747 inv->invoke(OUString(L"outSCode"), Sequence< Any > (& outSCode, 1), seqIndices, seqOut);
748 outSCode <<= seqOut[0];
750 if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong
751 || inFloat != outFloat || inDouble != outDouble || inString != outString
752 || inVariant != outVariant || inObject != outObject || inUnknown != outUnknown
753 || inCY != outCY
754 || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode)
755 return false;
757 // in/out parameter
759 outBool = Any();
760 seqIndices.realloc( 0);
761 seqOut.realloc(0);
762 inv->invoke(OUString(L"inoutBool"), Sequence< Any > ( & inBool, 1), seqIndices, seqOut);
763 outBool <<= seqOut[0];
765 outByte = Any();
766 seqIndices.realloc( 0);
767 seqOut.realloc(0);
768 inv->invoke(OUString(L"inoutByte"), Sequence< Any > ( & inByte, 1), seqIndices, seqOut);
769 outByte <<= seqOut[0];
771 outShort = Any();
772 seqIndices.realloc( 0);
773 seqOut.realloc(0);
774 inv->invoke(OUString(L"inoutShort"), Sequence< Any > ( & inShort, 1), seqIndices, seqOut);
775 outShort <<= seqOut[0];
777 outLong = Any();
778 seqIndices.realloc( 0);
779 seqOut.realloc(0);
780 inv->invoke(OUString(L"inoutLong"), Sequence< Any > ( & inLong, 1), seqIndices, seqOut);
781 outLong <<= seqOut[0];
783 outString = Any();
784 seqIndices.realloc( 0);
785 seqOut.realloc(0);
786 inv->invoke(OUString(L"inoutString"), Sequence< Any > ( & inString, 1), seqIndices, seqOut);
787 outString <<= seqOut[0];
789 outFloat = Any();
790 seqIndices.realloc( 0);
791 seqOut.realloc(0);
792 inv->invoke(OUString(L"inoutFloat"), Sequence< Any > ( & inFloat, 1), seqIndices, seqOut);
793 outFloat <<= seqOut[0];
795 outDouble = Any();
796 seqIndices.realloc( 0);
797 seqOut.realloc(0);
798 inv->invoke(OUString(L"inoutDouble"), Sequence< Any > ( &inDouble, 1), seqIndices, seqOut);
799 outDouble <<= seqOut[0];
801 outVariant = Any();
802 seqIndices.realloc( 0);
803 seqOut.realloc(0);
804 inv->invoke(OUString(L"inoutVariant"), Sequence< Any > ( & inVariant, 1), seqIndices, seqOut);
805 outVariant <<= seqOut[0];
807 outObject = Any();
808 seqIndices.realloc( 0);
809 seqOut.realloc(0);
810 inv->invoke(OUString(L"inoutObject"), Sequence< Any > ( & inObject, 1), seqIndices, seqOut);
811 outObject <<= seqOut[0];
813 outCY = Any();
814 seqIndices.realloc( 0);
815 seqOut.realloc(0);
816 inv->invoke(OUString(L"inoutCurrency"), Sequence< Any > ( & inCY, 1), seqIndices, seqOut);
817 outCY <<= seqOut[0];
819 outDate = Any();
820 seqIndices.realloc( 0);
821 seqOut.realloc(0);
822 inv->invoke(OUString(L"inoutDate"), Sequence< Any > ( & inDate, 1), seqIndices, seqOut);
823 outDate <<= seqOut[0];
825 outDecimal = Any();
826 seqIndices.realloc( 0);
827 seqOut.realloc(0);
828 inv->invoke(OUString(L"inoutDecimal"), Sequence< Any > (& inDecimal, 1), seqIndices, seqOut);
829 outDecimal <<= seqOut[0];
831 outSCode = Any();
832 seqIndices.realloc(0);
833 seqOut.realloc(0);
834 inv->invoke(OUString(L"inoutSCode"), Sequence< Any > (& inSCode, 1), seqIndices, seqOut);
835 outSCode <<= seqOut[0];
837 if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong
838 || inFloat != outFloat || inDouble != outDouble || inString != outString
839 || inVariant != outVariant || inObject != outObject || inCY != outCY
840 || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode)
841 return false;
844 // in byref parameters
847 inrefLong <<= (sal_Int32) 1234;
848 inv->invoke(OUString(L"inrefLong"), Sequence<Any>( & inrefLong, 1), seqIndices, seqOut);
849 seqIndices.realloc( 0);
850 seqOut.realloc(0);
851 inv->invoke(OUString(L"outLong"), Sequence< Any > (& outrefLong, 1), seqIndices, seqOut);
852 outrefLong <<= seqOut[0];
854 inrefVariant <<= OUString(L" A string in an any");
855 inv->invoke(OUString(L"inrefVariant"), Sequence< Any > ( & inrefVariant, 1), seqIndices, seqOut);
856 seqIndices.realloc( 0);
857 seqOut.realloc(0);
858 inv->invoke(OUString(L"outVariant"), Sequence< Any > (&outrefVariant, 1), seqIndices, seqOut);
859 outrefVariant <<= seqOut[0];
861 Decimal refdec(5, 1, 0xffff, 0xff, 0x1);
862 inrefDecimal <<= refdec;
863 inv->invoke(OUString(L"inrefDecimal"), Sequence< Any > ( & inrefDecimal, 1), seqIndices, seqOut);
864 seqIndices.realloc( 0);
865 seqOut.realloc(0);
866 inv->invoke(OUString(L"outDecimal"), Sequence< Any > (&outrefDecimal, 1), seqIndices, seqOut);
867 outrefDecimal <<= seqOut[0];
869 if (inrefLong != outrefLong || inrefVariant != outrefVariant
870 || inrefDecimal != outrefDecimal)
871 return false;
874 // mixed parameter
876 // mixed1
877 seqIndices.realloc( 0);
878 seqOut.realloc(0);
879 Any param[3];
880 param[0] = inByte;
881 param[1] = inFloat;
882 param[2] = inVariant;
883 inv->invoke(OUString(L"mixed1"), Sequence< Any >(param, 3), seqIndices, seqOut);
885 if (seqOut.getLength() != 3 || inByte != seqOut[0] || inFloat != seqOut[1]
886 || inVariant != seqOut[2])
887 return false;
888 return true;
891 bool doSimpleSequenceTest(const Reference<XInvocation> & inv)
893 bool ret = true;
894 Sequence<sal_Int16> seqIndices;
895 Sequence<Any> seqOut;
896 Any voidAny;
897 Any inArAny;
898 Any outArray;
899 Any inArBool, outArBool;
900 Any inArByte, outArByte;
901 Any inArShort, outArShort;
902 Any inArLong, outArLong;
903 Any inArString, outArString;
904 Any inArFloat, outArFloat;
905 Any inArDouble, outArDouble;
906 Any inArObject, outArObject;
907 Any outVariant;
909 //Initialize arrays
910 OUString arStr[]= {L"string0", L"string1", L"string2"};
911 Sequence<OUString> seq( arStr, 3);
912 inArString <<= seq;
914 Any arAnyStrTmp[3];
915 arAnyStrTmp[0]<<= arStr[0];
916 arAnyStrTmp[1]<<= arStr[1];
917 arAnyStrTmp[2]<<= arStr[2];
918 Sequence<Any> seq_1( arAnyStrTmp, 3);
919 inArAny <<= seq_1;
921 // in, out Sequences
923 //Test sequence containing Anys of Strings
924 inv->invoke(OUString(L"inArray"), Sequence< Any > ( & inArAny, 1), seqIndices, seqOut);
925 seqIndices.realloc(0);
926 seqOut.realloc(0);
927 inv->invoke(OUString(L"outArray"), Sequence<Any>( & voidAny, 1), seqIndices, seqOut);
928 if (inArAny != seqOut[0])
929 return false;
931 seqIndices.realloc(0);
932 seqOut.realloc(0);
933 inv->invoke(OUString(L"inArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut);
934 inv->invoke(OUString(L"outArray"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
935 outArray <<= seqOut[0];
937 sal_Int8 arByte[]={1,2,3};
938 Sequence<sal_Int8> seqByte(arByte, 3);
939 inArByte <<= seqByte;
940 inv->invoke(OUString(L"inSequenceByte"),Sequence<Any>( & inArByte, 1), seqIndices, seqOut);
941 seqIndices.realloc(0);
942 seqOut.realloc(0);
943 inv->invoke(OUString(L"outSequenceByte"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
944 outArByte <<= seqOut[0];
946 sal_Int16 arShort[]={4,5,6};
947 Sequence<sal_Int16> seqShort(arShort, 3);
948 inArShort<<= seqShort;
949 inv->invoke(OUString(L"inSequenceShort"),Sequence< Any >( & inArShort, 1), seqIndices, seqOut);
950 seqIndices.realloc(0);
951 seqOut.realloc(0);
952 inv->invoke(OUString(L"outSequenceShort"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
953 outArShort <<= seqOut[0];
955 sal_Int32 arLong[] = {7,8,9};
956 Sequence<sal_Int32> seqLong(arLong, 3);
957 inArLong <<= seqLong;
958 inv->invoke(OUString(L"inSequenceLong"),Sequence< Any > ( & inArLong, 1), seqIndices, seqOut);
959 seqIndices.realloc(0);
960 seqOut.realloc(0);
961 inv->invoke(OUString(L"outSequenceLong"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
962 outArLong <<= seqOut[0];
964 inv->invoke(OUString(L"inSequenceLong"),Sequence< Any > ( & inArLong, 1), seqIndices, seqOut);
965 seqIndices.realloc(0);
966 seqOut.realloc(0);
967 inv->invoke(OUString(L"outSequenceLong"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
968 outArLong <<= seqOut[0];
970 inv->invoke( OUString(L"inSequenceString"),Sequence< Any > ( & inArString, 1), seqIndices, seqOut);
971 seqIndices.realloc(0);
972 seqOut.realloc(0);
973 inv->invoke(OUString(L"outSequenceString"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
974 outArString <<= seqOut[0];
976 float arFloat[]={3.14f, 31.4f, 314.f};
977 Sequence<float> seqFloat( arFloat, 3);
978 inArFloat <<= seqFloat;
979 inv->invoke( OUString(L"inSequenceFloat"),Sequence< Any > ( & inArFloat, 1), seqIndices, seqOut);
980 seqIndices.realloc(0);
981 seqOut.realloc(0);
982 inv->invoke(OUString(L"outSequenceFloat"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
983 outArFloat <<= seqOut[0];
985 double arDouble[]={3.145, 31.45, 3145.};
986 Sequence<double> seqDouble( arDouble, 3);
987 inArDouble <<= seqDouble;
988 inv->invoke(OUString(L"inSequenceDouble"),Sequence< Any >( & inArDouble, 1), seqIndices, seqOut);
989 seqIndices.realloc(0);
990 seqOut.realloc(0);
991 inv->invoke(OUString(L"outSequenceDouble"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
992 outArDouble <<= seqOut[0];
994 Sequence<Reference<XInvocation> > seqObj(2);
995 seqObj[0]= getComObject(L"AxTestComponents.Basic");
996 seqObj[1]= getComObject(L"AxTestComponents.Basic");
997 inArObject <<= seqObj;
998 inv->invoke(OUString(L"inSequenceObject"),Sequence< Any >( & inArObject, 1), seqIndices, seqOut);
999 seqIndices.realloc(0);
1000 seqOut.realloc(0);
1001 inv->invoke(OUString(L"outSequenceObject"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
1002 outArObject <<= seqOut[0];
1004 if ( ! equalSequences(inArByte, outArByte) || ! equalSequences(inArShort, outArShort)
1005 || ! equalSequences(inArLong, outArLong) || ! equalSequences(inArString, outArray)
1006 || ! equalSequences(inArFloat, outArFloat) || ! equalSequences(inArDouble, outArDouble)
1007 || ! equalSequences(inArString, outArString) || ! equalSequences(inArObject, outArObject))
1008 return false;
1011 // in/out Sequences
1013 seqIndices.realloc(0);
1014 seqOut.realloc(0);
1015 inv->invoke(OUString(L"inoutArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut);
1016 inv->invoke(OUString(L"inoutArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut);
1017 outArray <<= seqOut[0];
1019 inv->invoke(OUString(L"inoutSequenceByte"), Sequence<Any>( & inArByte, 1), seqIndices, seqOut);
1020 inv->invoke(OUString(L"inoutSequenceByte"), Sequence<Any>( & inArByte, 1), seqIndices, seqOut);
1021 outArByte <<= seqOut[0];
1023 inv->invoke(OUString(L"inoutSequenceShort"), Sequence<Any>( & inArShort, 1), seqIndices, seqOut);
1024 inv->invoke(OUString(L"inoutSequenceShort"), Sequence<Any>( & inArShort, 1), seqIndices, seqOut);
1025 outArShort <<= seqOut[0];
1027 inv->invoke(OUString(L"inoutSequenceLong"), Sequence<Any>( & inArLong, 1), seqIndices, seqOut);
1028 inv->invoke(OUString(L"inoutSequenceLong"), Sequence< Any >( & inArLong, 1), seqIndices, seqOut);
1029 outArLong <<= seqOut[0];
1031 inv->invoke(OUString(L"inoutSequenceString"), Sequence<Any>( & inArString, 1), seqIndices, seqOut);
1032 inv->invoke(OUString(L"inoutSequenceString"), Sequence<Any>( & inArString, 1), seqIndices, seqOut);
1033 outArString <<= seqOut[0];
1035 inv->invoke(OUString(L"inoutSequenceFloat"), Sequence<Any>( & inArFloat, 1), seqIndices, seqOut);
1036 inv->invoke(OUString(L"inoutSequenceFloat"), Sequence<Any>( & inArFloat, 1), seqIndices, seqOut);
1037 outArFloat <<= seqOut[0];
1039 inv->invoke(OUString(L"inoutSequenceDouble"), Sequence<Any>( & inArDouble, 1), seqIndices, seqOut);
1040 inv->invoke(OUString(L"inoutSequenceDouble"), Sequence<Any>( & inArDouble, 1), seqIndices, seqOut);
1041 outArDouble <<= seqOut[0];
1043 inv->invoke(OUString(L"inoutSequenceObject"), Sequence<Any>( & inArObject, 1), seqIndices, seqOut);
1044 inv->invoke(OUString(L"inoutSequenceObject"), Sequence<Any>( & inArObject, 1), seqIndices, seqOut);
1045 outArObject <<= seqOut[0];
1047 if ( ! equalSequences(inArByte, outArByte) || ! equalSequences(inArShort, outArShort)
1048 || ! equalSequences(inArLong, outArLong) || ! equalSequences(inArString, outArray)
1049 || ! equalSequences(inArFloat, outArFloat) || ! equalSequences(inArDouble, outArDouble)
1050 || ! equalSequences(inArString, outArString) || ! equalSequences(inArObject, outArObject))
1051 return false;
1053 return ret;
1056 HRESULT doTest()
1058 HRESULT hr= S_OK;
1059 USES_CONVERSION;
1060 Reference<XInvocation> inv= getComObject( L"AxTestComponents.Basic");
1062 HostWin* pWin= new HostWin( L"MFCCONTROL.MfcControlCtrl.1");
1063 CComPtr<IUnknown> spUnk= pWin->GetHostedControl();
1064 Reference<XInvocation> invMfc= convertComObject( spUnk.p);
1066 Sequence< sal_Int16> seqIndices;
1067 Sequence<Any> seqOut;
1069 Any aAny;
1070 Any anyOut;
1071 char buff[1024];
1072 Any seqAny;
1074 if (! doSimpleTest(inv))
1076 fprintf(stdout, "### Test failed!\n");
1077 return E_FAIL;
1080 if (! doPropertyTest(inv))
1082 fprintf(stdout, "### Test failed!\n");
1083 return E_FAIL;
1086 if ( ! doSimpleSequenceTest(inv))
1088 fprintf(stdout, "### Test failed! \n");
1089 return E_FAIL;
1092 if ( ! doParameterTest(inv))
1094 fprintf(stdout, "### Test failed! \n");
1095 return E_FAIL;
1098 if ( ! doPropertyWithArgumentTest(inv))
1100 fprintf(stdout, "### Test failed! \n");
1101 return E_FAIL;
1105 // // in multi Sequences
1107 // // inMulDimArrayLong
1108 sal_Int32 arLongi[]={1,2,3};
1109 sal_Int32 arLongi2[]={4,5,6,7};
1110 sal_Int32 arLongi3[]={8,9,10,11,12};
1112 Sequence<sal_Int32> seqLongi1( arLongi, 3);
1113 Sequence<sal_Int32> seqLongi2( arLongi2, 4);
1114 Sequence<sal_Int32> seqLongi3( arLongi3, 5);
1116 Sequence< Sequence< sal_Int32 > > seq2i(3);
1117 seq2i[0]= seqLongi1;
1118 seq2i[1]= seqLongi2;
1119 seq2i[2]= seqLongi3;
1120 seqAny<<= seq2i;
1121 // dimension length 3,5
1122 inv->invoke( OUString(L"inMulDimArrayLong"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
1124 //inMulDimArrayVariant
1125 inv->invoke( OUString(L"inMulDimArrayVariant"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
1127 //inMulDimArrayLong2
1128 sal_Int32 arLongii1[]={1,2,3};
1129 sal_Int32 arLongii2[]={4,5,6,7};
1130 sal_Int32 arLongii3[]={8,9,10,11,12};
1131 sal_Int32 arLongii4[]={13,14,15,16};
1132 sal_Int32 arLongii5[]={17,18,19};
1134 Sequence<sal_Int32> seqLongii1( arLongii1, 3);
1135 Sequence<sal_Int32> seqLongii2( arLongii2, 4);
1136 Sequence<sal_Int32> seqLongii3( arLongii3, 5);
1137 Sequence<sal_Int32> seqLongii4( arLongii4, 4);
1138 Sequence<sal_Int32> seqLongii5( arLongii5, 3);
1140 Sequence< Sequence< sal_Int32 > > seq2ii(3);
1141 Sequence< Sequence< sal_Int32> > seq2ii2(2);
1142 seq2ii[0]= seqLongii1;
1143 seq2ii[1]= seqLongii2;
1144 seq2ii[2]= seqLongii3;
1146 seq2ii2[0]= seqLongii4;
1147 seq2ii2[1]= seqLongii5;
1149 Sequence< Sequence< Sequence< sal_Int32> > > seq3ii(2);
1150 seq3ii[0]=seq2ii;
1151 seq3ii[1]=seq2ii2;
1152 seqAny<<= seq3ii;
1153 inv->invoke( OUString(L"inMulDimArrayLong2"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
1155 // inMulDimArrayByte2
1156 sal_Int8 arByteii1[]={1,2,3};
1157 sal_Int8 arByteii2[]={4,5,6,7};
1158 sal_Int8 arByteii3[]={8,9,10,11,12};
1159 sal_Int8 arByteii4[]={13,14,15,16};
1160 sal_Int8 arByteii5[]={17,18,19};
1162 Sequence<sal_Int8> seqByteii1( arByteii1, 3);
1163 Sequence<sal_Int8> seqByteii2( arByteii2, 4);
1164 Sequence<sal_Int8> seqByteii3( arByteii3, 5);
1165 Sequence<sal_Int8> seqByteii4( arByteii4, 4);
1166 Sequence<sal_Int8> seqByteii5( arByteii5, 3);
1168 Sequence< Sequence< sal_Int8 > > seq2Byteii(3);
1169 Sequence< Sequence< sal_Int8> > seq2Byteii2(2);
1170 seq2Byteii[0]= seqByteii1;
1171 seq2Byteii[1]= seqByteii2;
1172 seq2Byteii[2]= seqByteii3;
1174 seq2Byteii2[0]= seqByteii4;
1175 seq2Byteii2[1]= seqByteii5;
1177 Sequence< Sequence< Sequence< sal_Int8> > > seq3Byteii(2);
1178 seq3Byteii[0]=seq2Byteii;
1179 seq3Byteii[1]=seq2Byteii2;
1180 seqAny<<= seq3Byteii;
1181 inv->invoke( OUString(L"inMulDimArrayByte2"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
1184 // Tests with a MFC ActiveX control, ( pure dispinterface)
1187 // in parameter MFC ActiveX
1189 // unsigned char is not supported by MFC
1190 // aAny <<= ( sal_Int8) 127;
1191 // invMfc->invoke( OUString(L"inByte"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1192 if ( ! invMfc.is())
1193 return hr;
1194 aAny <<= static_cast<sal_Int16>(-1);
1195 aAny= invMfc->invoke( OUString(L"inShort"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1198 aAny <<= ( sal_Int32) 1234567;
1199 aAny=invMfc->invoke( OUString(L"inLong"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1200 sal_Int32 retLong= *(sal_Int32*)aAny.getValue();
1202 OUString str_1(L" this is clientTest.exe");
1203 aAny <<= str_1;
1204 aAny=invMfc->invoke( OUString(L"inString"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1205 aAny>>= str_1;
1207 aAny <<= ( float) 3.14;
1208 aAny=invMfc->invoke( OUString(L"inFloat"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1210 aAny <<= ( double) 3.145;
1211 aAny=invMfc->invoke( OUString(L"inDouble"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1213 aAny <<= OUString( L" A string in an any");
1214 aAny=invMfc->invoke( OUString(L"inVariant"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1217 Reference < XInvocation > inv5= getComObject(L"AxTestComponents.Basic");
1218 Any anyVal4;
1219 anyVal4 <<= OUString(L"this is the value of prpString");
1220 inv5->setValue( OUString(L"prpString"), anyVal4);
1221 aAny <<= inv5;
1222 aAny=invMfc->invoke( OUString(L"inObject"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1225 // // out parameter MFC ActiveX
1228 // // outShort
1229 aAny= invMfc->invoke( OUString(L"outShort"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1230 anyOut<<= seqOut[0];
1231 sprintf(buff, "MFC outShort %d", *(sal_Int16*)anyOut.getValue());
1232 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1234 // outLong
1235 aAny= invMfc->invoke( OUString(L"outLong"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1236 anyOut<<= seqOut[0];
1237 sprintf(buff, "MFC outLong %d", *(sal_Int32*)anyOut.getValue());
1238 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1240 // outString
1241 aAny= invMfc->invoke( OUString(L"outString"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1242 anyOut<<= seqOut[0];
1243 sprintf(buff, "MFC outString %S", ((OUString*)anyOut.getValue())->getStr());
1244 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1246 // outFloat
1247 aAny= invMfc->invoke( OUString(L"outFloat"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1248 anyOut<<= seqOut[0];
1249 sprintf(buff, "MFC outFloat %f", *(float*)anyOut.getValue());
1250 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1252 // outDouble
1253 aAny= invMfc->invoke( OUString(L"outDouble"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1254 anyOut<<= seqOut[0];
1255 sprintf(buff, "MFC outFloat %f", *(double*)anyOut.getValue());
1256 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1258 // outVariant
1259 // we expect a string!! ( VT_BSTR)
1260 aAny= invMfc->invoke( OUString(L"outVariant"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1261 anyOut<<= seqOut[0];
1262 sprintf(buff, "MFC outVariant %S", ((OUString*)anyOut.getValue())->getStr());
1263 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1265 // outDouble
1266 aAny= invMfc->invoke( OUString(L"outObject"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1267 Reference<XInvocation> invOut5;
1268 seqOut[0]>>= invOut5;
1269 // we assume that an object of AxTestControls.Basic is being returned.
1270 anyOut= invOut5->getValue( OUString(L"prpString"));
1271 OUString tmpStr;
1272 anyOut>>=tmpStr;
1273 sprintf(buff, "MFC outObject, property: %S", tmpStr.getStr());
1274 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1277 // Sequence parameter MFC ActiveX
1279 // Sequences are not directly supported.
1282 delete pWin;
1283 return hr;
1288 //VARIANT_TRUE VT_UI1
1291 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */