1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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
)
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
;
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
);
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 **)
75 if( FAILED( hr
=CoInitialize(NULL
)))
77 _tprintf(_T("CoInitialize failed \n"));
82 _Module
.Init( ObjectMap
, GetModuleHandle( NULL
));
84 if( FAILED(hr
=doTest()))
87 const TCHAR
* errMsg
= err
.ErrorMessage();
88 MessageBox( NULL
, errMsg
, "Test failed", MB_ICONERROR
);
92 MessageBox( NULL
,NULL
, "Test succeeded", MB_ICONINFORMATION
);
100 //Also supports named args
102 bool doParameterTest(const Reference
<XInvocation
> & inv
)
104 Sequence
< sal_Int16
> seqIndices
;
105 Sequence
<Any
> seqOut
;
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);
125 Sequence
<Any
> seqNamed(arArgs
, 2);
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);
137 Sequence
<Any
> seqNamed5(arArgs
, 1);
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);
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;
173 Sequence
<Any
> seqMix(arArgs1
, 4);
176 arArgs1
[1] <<= (sal_Int32
) 456;
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
);
189 Sequence
<Any
> seqMix2Out(arArgs1
, 3);
192 //in args + out, optional, positional-----------------------------------------
194 seqIndices
.realloc(0);
196 inv
->invoke(OUString(L
"optional3"), seqPositional
, seqIndices
, seqOut
);
197 seqIndices
.realloc(0);
199 inv
->invoke(OUString(L
"optional5"), seqPositional
, seqIndices
, seqOut
);
200 if ( ! checkOutArgs(seqOut
, seqIndices
, seqPositional
))
203 //2 optional args, 1 provided
204 seqIndices
.realloc(0);
206 inv
->invoke(OUString(L
"optional3"), seqPositional0
, seqIndices
, seqOut
);
207 seqIndices
.realloc(0);
209 inv
->invoke(OUString(L
"optional3"), seqPositional2
, seqIndices
, seqOut
);
210 seqIndices
.realloc(0);
212 inv
->invoke(OUString(L
"optional5"), seqPositional
, seqIndices
, seqOut
);
213 if ( ! checkOutArgs(seqOut
, seqIndices
, seqOutOpt1
))
216 //2 optional args, 0 provided
217 seqIndices
.realloc(0);
219 inv
->invoke(OUString(L
"optional3"), seqPositional0
, seqIndices
, seqOut
);
220 seqIndices
.realloc(0);
222 inv
->invoke(OUString(L
"optional3"), seqNoArgs
, seqIndices
, seqOut
);
223 seqIndices
.realloc(0);
225 inv
->invoke(OUString(L
"optional5"), seqPositional3
, seqIndices
, seqOut
);
226 if ( ! checkOutArgs(seqOut
, seqIndices
, seqOutOpt2
))
229 //named args --------------------------------------------
231 // 2 named args, correct position
232 seqIndices
.realloc(0);
234 inv
->invoke(OUString(L
"optional3"), seqPositional0
, seqIndices
, seqOut
);
235 seqIndices
.realloc(0);
237 inv
->invoke(OUString(L
"optional3"), seqNamed
, seqIndices
, seqOut
);
238 seqIndices
.realloc(0);
240 inv
->invoke(OUString(L
"optional5"), seqPositional0
, seqIndices
, seqOut
);
241 if ( ! checkOutArgs(seqOut
, seqIndices
, seqPositional
))
244 // 2named args, position differs
245 seqIndices
.realloc(0);
247 inv
->invoke(OUString(L
"optional3"), seqPositional0
, seqIndices
, seqOut
);
248 seqIndices
.realloc(0);
250 inv
->invoke(OUString(L
"optional3"), seqNamed2
, seqIndices
, seqOut
);
251 seqIndices
.realloc(0);
253 inv
->invoke(OUString(L
"optional5"), seqPositional
, seqIndices
, seqOut
);
254 if ( ! checkOutArgs(seqOut
, seqIndices
, seqPositional
))
257 //named out args, 2 named args with correct position
258 seqIndices
.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
))
267 //named out args, 2 named args with different position
268 seqIndices
.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
))
278 //2 args, 1 provided (correct order)
279 seqIndices
.realloc(0);
281 inv
->invoke(OUString(L
"optional3"), seqPositional0
, seqIndices
, seqOut
);
282 seqIndices
.realloc(0);
284 inv
->invoke(OUString(L
"optional3"), seqNamed5
, seqIndices
, seqOut
);
285 seqIndices
.realloc(0);
287 inv
->invoke(OUString(L
"optional5"), seqPositional
, seqIndices
, seqOut
);
288 if ( ! checkOutArgs(seqOut
, seqIndices
, seqOutOpt1
))
290 //2 args, 1 provided (incorrect order)
291 seqIndices
.realloc(0);
293 inv
->invoke(OUString(L
"optional3"), seqPositional0
, seqIndices
, seqOut
);
294 seqIndices
.realloc(0);
296 inv
->invoke(OUString(L
"optional3"), seqNamed6
, seqIndices
, seqOut
);
297 seqIndices
.realloc(0);
299 inv
->invoke(OUString(L
"optional5"), seqPositional
, seqIndices
, seqOut
);
300 if ( ! checkOutArgs(seqOut
, seqIndices
, seqOutOpt3
))
303 //2position + 2 2named args, correct order
304 seqIndices
.realloc(0);
306 inv
->invoke(OUString(L
"optional6"), seqMix0
, seqIndices
, seqOut
);
307 seqIndices
.realloc(0);
309 inv
->invoke(OUString(L
"optional6"), seqMix
, seqIndices
, seqOut
);
310 seqIndices
.realloc(0);
312 inv
->invoke(OUString(L
"optional7"), seqMix
, seqIndices
, seqOut
);
313 if ( ! checkOutArgs(seqOut
, seqIndices
, seqMix
))
316 // 4 in args, 1 positional, 1 named, 1 positional omitted
317 seqIndices
.realloc(0);
319 inv
->invoke(OUString(L
"optional6"), seqMix0
, seqIndices
, seqOut
);
320 seqIndices
.realloc(0);
322 inv
->invoke(OUString(L
"optional6"), seqMix2
, seqIndices
, seqOut
);
323 seqIndices
.realloc(0);
325 inv
->invoke(OUString(L
"optional7"), seqMix0
, seqIndices
, seqOut
);
326 if ( ! checkOutArgs(seqOut
, seqIndices
, seqMixOut
))
329 // 4 out args, 1 positional, 1 named, 1 positional omitted
330 seqIndices
.realloc(0);
332 inv
->invoke(OUString(L
"optional6"), seqMix2
, seqIndices
, seqOut
);
333 seqIndices
.realloc(0);
335 inv
->invoke(OUString(L
"optional7"), seqMix2Out
, seqIndices
, seqOut
);
336 if ( ! checkOutArgs(seqOut
, seqIndices
, seqMix2Out
))
342 bool doPropertyTest(const Reference
<XInvocation
> & inv
)
344 Sequence
< sal_Int16
> seqIndices
;
345 Sequence
<Any
> seqOut
;
349 Any inShort
, outShort
;
351 Any inString
, outString
;
352 Any inFloat
, outFloat
;
353 Any inDouble
, outDouble
;
354 Any inVariant
, outVariant
;
355 Any inObject
, outObject
;
356 Any inUnknown
, outUnknown
;
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"));
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"));
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"));
410 inv
->setValue(OUString(L
"prpCurrency"), inCY
);
411 outCY
= inv
->getValue(OUString(L
"prpCurrency"));
415 inv
->setValue(OUString(L
"prpDate"), inDate
);
416 outDate
= inv
->getValue(OUString(L
"prpDate"));
418 Decimal
dec(20, 0, 0xffffffff, 0xffffffff, 0x0fffffff);
420 inv
->setValue(OUString(L
"prpDecimal"), inDecimal
);
421 outDecimal
= inv
->getValue(OUString(L
"prpDecimal"));
423 SCode
code(DISP_E_BADVARTYPE
);
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
)
452 bool doPropertyWithArgumentTest(const Reference
<XInvocation
> & inv
)
454 Sequence
< sal_Int16
> seqIndices
;
455 Sequence
<Any
> seqOut
;
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);
510 inv
->invoke(OUString(L
"prpMultiArg1"), seqMultiArgPut0
, seqIndices
, seqOut
);
511 seqIndices
.realloc( 0);
513 inv
->invoke(OUString(L
"prpMultiArg1"), seqMultiArgPut1
, seqIndices
, seqOut
);
515 seqIndices
.realloc( 0);
517 Any anyRet
= inv
->invoke(OUString(L
"prpMultiArg1"), seqMultiArgGet0
,
520 if (anyRet
!= ((PropertyPutArgument
const *)seqMultiArgPut1
[2].getValue())->Value
521 || ! checkOutArgs(seqOut
, seqIndices
, Sequence
<Any
>(seqMultiArgPut1
.getArray(), 2)))
525 // test optional (one arg omitted
526 seqIndices
.realloc( 0);
528 inv
->invoke(OUString(L
"prpMultiArg1"), seqMultiArgPut0
, seqIndices
, seqOut
);
529 seqIndices
.realloc( 0);
531 inv
->invoke(OUString(L
"prpMultiArg1"), seqMultiArgPut2
, seqIndices
, seqOut
);
532 seqIndices
.realloc( 0);
534 anyRet
= inv
->invoke(OUString(L
"prpMultiArg1"), seqMultiArgGet0
,
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)))
546 //test one named arg and one omitted
547 seqIndices
.realloc( 0);
549 inv
->invoke(OUString(L
"prpMultiArg1"), seqMultiArgPut0
, seqIndices
, seqOut
);
550 seqIndices
.realloc( 0);
552 inv
->invoke(OUString(L
"prpMultiArg1"), seqMultiArgPut3
, seqIndices
, seqOut
);
553 seqIndices
.realloc( 0);
555 anyRet
= inv
->invoke(OUString(L
"prpMultiArg1"), seqMultiArgGet0
,
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)))
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);
570 inv
->invoke(OUString(L
"prpMultiArg2"), seqMultiArgPut5
, seqIndices
, seqOut
);
571 seqIndices
.realloc( 0);
573 inv
->invoke(OUString(L
"prpMultiArg2GetValues"), seqMultiVoid
, seqIndices
, seqOut
);
575 if ( ! checkOutArgs(seqOut
, seqIndices
, seqMultiVoid2
))
577 seqIndices
.realloc( 0);
579 anyRet
= inv
->invoke(OUString(L
"prpMultiArg2"), seqMultiArgPut6
,
581 seqIndices
.realloc( 0);
583 anyRet
= inv
->invoke(OUString(L
"prpMultiArg2GetValues"), seqMultiVoid
,
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
))
591 seqIndices
.realloc( 0);
593 inv
->invoke(OUString(L
"prpMultiArg3"), seqMultiArgPut5
, seqIndices
, seqOut
);
594 seqIndices
.realloc( 0);
596 inv
->invoke(OUString(L
"prpMultiArg3"), seqMultiArgPut6
, seqIndices
, seqOut
);
597 seqIndices
.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
))
606 //hasProperty, hasMethod
607 if (inv
->hasProperty("prpMultiArg1"))
609 if ( ! inv
->hasMethod("prpMultiArg1"))
611 if ( ! inv
->hasProperty("prprefLong"))
613 if (inv
->hasMethod("prprefLong"))
615 if ( ! inv
->hasMethod("inLong"))
620 bool doSimpleTest(const Reference
<XInvocation
> & inv
)
622 Sequence
< sal_Int16
> seqIndices
;
623 Sequence
<Any
> seqOut
;
627 Any inShort
, outShort
;
629 Any inString
, outString
;
630 Any inFloat
, outFloat
;
631 Any inDouble
, outDouble
;
632 Any inVariant
, outVariant
;
633 Any inObject
, outObject
;
634 Any inUnknown
, outUnknown
;
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);
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);
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);
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);
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);
680 inv
->invoke(OUString(L
"outString"), Sequence
< Any
> ( & outString
, 1 ), seqIndices
, seqOut
);
681 outString
<<= seqOut
[0];
684 inv
->invoke(OUString(L
"inFloat"), Sequence
< Any
> ( & inFloat
, 1), seqIndices
, seqOut
);
685 seqIndices
.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);
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);
701 inv
->invoke(OUString(L
"outVariant"), Sequence
< Any
> (&outVariant
, 1), seqIndices
, seqOut
);
702 outVariant
<<= seqOut
[0];
705 inv
->invoke(OUString(L
"inObject"), Sequence
< Any
> ( & inObject
, 1), seqIndices
, seqOut
);
706 seqIndices
.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);
715 inv
->invoke(OUString(L
"outUnknown"), Sequence
< Any
> (& outUnknown
, 1), seqIndices
, seqOut
);
716 outUnknown
<<= seqOut
[0];
718 Currency
cur(999999);
720 inv
->invoke(OUString(L
"inCurrency"), Sequence
<Any
>( & inCY
, 1), seqIndices
, seqOut
);
721 seqIndices
.realloc( 0);
723 inv
->invoke(OUString(L
"outCurrency"), Sequence
< Any
> (& outCY
, 1), seqIndices
, seqOut
);
728 inv
->invoke(OUString(L
"inDate"), Sequence
<Any
>( & inDate
, 1), seqIndices
, seqOut
);
729 seqIndices
.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);
736 inv
->invoke(OUString(L
"inDecimal"), Sequence
<Any
>( & inDecimal
, 1), seqIndices
, seqOut
);
737 seqIndices
.realloc( 0);
739 inv
->invoke(OUString(L
"outDecimal"), Sequence
< Any
> (& outDecimal
, 1), seqIndices
, seqOut
);
740 outDecimal
<<= seqOut
[0];
742 SCode
code(DISP_E_BADVARTYPE
);
744 inv
->invoke(OUString(L
"inSCode"), Sequence
<Any
>( & inSCode
, 1), seqIndices
, seqOut
);
745 seqIndices
.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
754 || inDate
!= outDate
|| inDecimal
!= outDecimal
|| inSCode
!= outSCode
)
760 seqIndices
.realloc( 0);
762 inv
->invoke(OUString(L
"inoutBool"), Sequence
< Any
> ( & inBool
, 1), seqIndices
, seqOut
);
763 outBool
<<= seqOut
[0];
766 seqIndices
.realloc( 0);
768 inv
->invoke(OUString(L
"inoutByte"), Sequence
< Any
> ( & inByte
, 1), seqIndices
, seqOut
);
769 outByte
<<= seqOut
[0];
772 seqIndices
.realloc( 0);
774 inv
->invoke(OUString(L
"inoutShort"), Sequence
< Any
> ( & inShort
, 1), seqIndices
, seqOut
);
775 outShort
<<= seqOut
[0];
778 seqIndices
.realloc( 0);
780 inv
->invoke(OUString(L
"inoutLong"), Sequence
< Any
> ( & inLong
, 1), seqIndices
, seqOut
);
781 outLong
<<= seqOut
[0];
784 seqIndices
.realloc( 0);
786 inv
->invoke(OUString(L
"inoutString"), Sequence
< Any
> ( & inString
, 1), seqIndices
, seqOut
);
787 outString
<<= seqOut
[0];
790 seqIndices
.realloc( 0);
792 inv
->invoke(OUString(L
"inoutFloat"), Sequence
< Any
> ( & inFloat
, 1), seqIndices
, seqOut
);
793 outFloat
<<= seqOut
[0];
796 seqIndices
.realloc( 0);
798 inv
->invoke(OUString(L
"inoutDouble"), Sequence
< Any
> ( &inDouble
, 1), seqIndices
, seqOut
);
799 outDouble
<<= seqOut
[0];
802 seqIndices
.realloc( 0);
804 inv
->invoke(OUString(L
"inoutVariant"), Sequence
< Any
> ( & inVariant
, 1), seqIndices
, seqOut
);
805 outVariant
<<= seqOut
[0];
808 seqIndices
.realloc( 0);
810 inv
->invoke(OUString(L
"inoutObject"), Sequence
< Any
> ( & inObject
, 1), seqIndices
, seqOut
);
811 outObject
<<= seqOut
[0];
814 seqIndices
.realloc( 0);
816 inv
->invoke(OUString(L
"inoutCurrency"), Sequence
< Any
> ( & inCY
, 1), seqIndices
, seqOut
);
820 seqIndices
.realloc( 0);
822 inv
->invoke(OUString(L
"inoutDate"), Sequence
< Any
> ( & inDate
, 1), seqIndices
, seqOut
);
823 outDate
<<= seqOut
[0];
826 seqIndices
.realloc( 0);
828 inv
->invoke(OUString(L
"inoutDecimal"), Sequence
< Any
> (& inDecimal
, 1), seqIndices
, seqOut
);
829 outDecimal
<<= seqOut
[0];
832 seqIndices
.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
)
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);
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);
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);
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
)
877 seqIndices
.realloc( 0);
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])
891 bool doSimpleSequenceTest(const Reference
<XInvocation
> & inv
)
894 Sequence
<sal_Int16
> seqIndices
;
895 Sequence
<Any
> seqOut
;
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
;
910 OUString arStr
[]= {L
"string0", L
"string1", L
"string2"};
911 Sequence
<OUString
> seq( arStr
, 3);
915 arAnyStrTmp
[0]<<= arStr
[0];
916 arAnyStrTmp
[1]<<= arStr
[1];
917 arAnyStrTmp
[2]<<= arStr
[2];
918 Sequence
<Any
> seq_1( arAnyStrTmp
, 3);
923 //Test sequence containing Anys of Strings
924 inv
->invoke(OUString(L
"inArray"), Sequence
< Any
> ( & inArAny
, 1), seqIndices
, seqOut
);
925 seqIndices
.realloc(0);
927 inv
->invoke(OUString(L
"outArray"), Sequence
<Any
>( & voidAny
, 1), seqIndices
, seqOut
);
928 if (inArAny
!= seqOut
[0])
931 seqIndices
.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);
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);
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);
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);
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);
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);
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);
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);
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
))
1013 seqIndices
.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
))
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
;
1074 if (! doSimpleTest(inv
))
1076 fprintf(stdout
, "### Test failed!\n");
1080 if (! doPropertyTest(inv
))
1082 fprintf(stdout
, "### Test failed!\n");
1086 if ( ! doSimpleSequenceTest(inv
))
1088 fprintf(stdout
, "### Test failed! \n");
1092 if ( ! doParameterTest(inv
))
1094 fprintf(stdout
, "### Test failed! \n");
1098 if ( ! doPropertyWithArgumentTest(inv
))
1100 fprintf(stdout
, "### Test failed! \n");
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
;
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);
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);
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");
1204 aAny
=invMfc
->invoke( OUString(L
"inString"), Sequence
< Any
> ( &aAny
, 1), seqIndices
, seqOut
);
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");
1219 anyVal4
<<= OUString(L
"this is the value of prpString");
1220 inv5
->setValue( OUString(L
"prpString"), anyVal4
);
1222 aAny
=invMfc
->invoke( OUString(L
"inObject"), Sequence
< Any
> ( &aAny
, 1), seqIndices
, seqOut
);
1225 // // out parameter MFC ActiveX
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
);
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
);
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
);
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
);
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
);
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
);
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"));
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.
1288 //VARIANT_TRUE VT_UI1
1291 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */