2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <META NAME=
"GENERATOR" Content=
"Microsoft Developer Studio">
21 <META HTTP-EQUIV=
"Content-Type" content=
"text/html; charset=iso-8859-1">
22 <TITLE>Document Title
</TITLE>
26 <script language=
"JScript">
27 function callOleTest( id)
29 var factory= new ActiveXObject(
"com.sun.star.ServiceManager");
30 var oletest= factory.createInstance(
"oletest.OleTest");
35 case
1: // Test simple call of JScript object function from UNO
36 oletest.testInterface( new XCallback_Impl,
1);
40 // return value is the parameter object
41 oletest.testInterface( new XCallback_Impl,
2);
46 case
3: // Test out parameter of type interface
47 oletest.testInterface( new XCallback_Impl,
3);
49 case
4: // Test out parameter of type struct
50 oletest.testInterface( new XCallback_Impl,
4);
52 case
5: // Test out parameter of type enum
53 oletest.testInterface( new XCallback_Impl,
5);
55 case
6: // Test out parameter of type sequence
<any>
56 oletest.testInterface( new XCallback_Impl,
6);
58 case
7: // Test out parameter of type any
59 oletest.testInterface( new XCallback_Impl,
7);
61 case
8: // Test out parameter of type bool
62 oletest.testInterface( new XCallback_Impl,
8);
64 case
9: // Test out parameter of type char
65 oletest.testInterface( new XCallback_Impl,
9);
67 case
10: // Test out parameter of type string
68 oletest.testInterface( new XCallback_Impl,
10);
70 case
11: // Test out parameter of type float
71 oletest.testInterface( new XCallback_Impl,
11);
73 case
12: // Test out parameter of type double
74 oletest.testInterface( new XCallback_Impl,
12);
76 case
13: // Test out parameter of type byte
77 oletest.testInterface( new XCallback_Impl,
13);
79 case
14: // Test out parameter of type short
80 oletest.testInterface( new XCallback_Impl,
14);
82 case
15: // Test out parameter of type long
83 oletest.testInterface( new XCallback_Impl,
15);
85 case
30: // outValuesMixed
86 oletest.testInterface( new XCallback_Impl,
30);
88 case
31: // outValuesAll
89 oletest.testInterface( new XCallback_Impl,
31);
95 case
100: // inoutInterface
96 oletest.testInterface( new XCallback_Impl,
100);
98 case
101: // inoutStruct
99 oletest.testInterface( new XCallback_Impl,
101);
101 case
102: // inoutEnum
102 oletest.testInterface( new XCallback_Impl,
102);
104 case
103: // inoutSeqAny
105 oletest.testInterface( new XCallback_Impl,
103);
107 case
104: // inoutAny
108 oletest.testInterface( new XCallback_Impl,
104);
110 case
105: // inoutBool
111 oletest.testInterface( new XCallback_Impl,
105);
113 case
106: // inoutChar
114 oletest.testInterface( new XCallback_Impl,
106);
116 case
107: // inoutString
117 oletest.testInterface( new XCallback_Impl,
107);
119 case
108: // inoutFloat
120 oletest.testInterface( new XCallback_Impl,
108);
122 case
109: // inoutDouble
123 oletest.testInterface( new XCallback_Impl,
109);
125 case
110: // inoutByte
126 oletest.testInterface( new XCallback_Impl,
110);
128 case
111: // inoutShort
129 oletest.testInterface( new XCallback_Impl,
111);
131 case
112: // inoutLong
132 oletest.testInterface( new XCallback_Impl,
112);
134 case
120: // inoutValuesAll
135 oletest.testInterface( new XCallback_Impl,
120);
137 case
200: // inValues
138 oletest.testInterface( new XCallback_Impl,
200);
141 // Call a COM object that has not been passed as parameter to a UNO component and
142 // hence no type information is available in the COM wrapper
148 oletest.testInterface( new XCallback_Impl,
400);
152 oletest.testInterface2(new MultiInterface(),
0);
160 // The class --------------------------------------------
162 function XCallback_Impl()
165 this._environment=
"JScript";
167 this.func1= XCallback_Impl_func1;
168 this.returnInterface= XCallback_Impl_returnInterface;
169 // #################################################
172 this.outInterface= XCallback_Impl_outInterface;
173 this.outStruct= XCallback_Impl_outStruct;
174 this.outEnum= XCallback_Impl_outEnum;
175 this.outSeqAny= XCallback_Impl_outSeqAny;
176 this.outAny= XCallback_Impl_outAny;
177 this.outBool= XCallback_Impl_outBool;
178 this.outChar= XCallback_Impl_outChar;
179 this.outString= XCallback_Impl_outString;
180 this.outFloat= XCallback_Impl_outFloat;
181 this.outDouble= XCallback_Impl_outDouble;
182 this.outByte= XCallback_Impl_outByte;
183 this.outShort= XCallback_Impl_outShort;
184 this.outLong= XCallback_Impl_outLong;
185 this.outValuesMixed= XCallback_Impl_outValuesMixed;
186 this.outValuesAll= XCallback_Impl_outValuesAll;
187 // #################################################
190 this.inoutInterface= XCallback_Impl_inoutInterface;
191 this.inoutStruct= XCallback_Impl_inoutStruct;
192 this.inoutEnum= XCallback_Impl_inoutEnum;
193 this.inoutSeqAny= XCallback_Impl_inoutSeqAny;
194 this.inoutAny= XCallback_Impl_inoutAny;
195 this.inoutBool= XCallback_Impl_inoutBool;
196 this.inoutChar= XCallback_Impl_inoutChar;
197 this.inoutString= XCallback_Impl_inoutString;
198 this.inoutFloat= XCallback_Impl_inoutFloat;
199 this.inoutDouble= XCallback_Impl_inoutDouble;
200 this.inoutByte= XCallback_Impl_inoutByte;
201 this.inoutShort= XCallback_Impl_inoutShort;
202 this.inoutLong= XCallback_Impl_inoutLong;
203 this.inoutValuesAll= XCallback_Impl_inoutValuesAll;
204 // #################################################
207 this.inValues= XCallback_Impl_inValues;
209 // #################################################
212 this.simple= new XSimple_Impl();
218 function XCallback_Impl_func1()
220 alert(
"XCallback_Impl_func1");
222 function XCallback_Impl_returnInterface()
224 alert(
"XCallback::returnInterface called");
225 return new XSimple_Impl();
228 function XCallback_Impl_outInterface( outVal)
230 outVal[
0]= new XSimple_Impl();
233 function XCallback_Impl_outLong( outVal)
237 function XCallback_Impl_outStruct( outVal)
239 var factory= new ActiveXObject(
"com.sun.star.ServiceManager");
240 var starCoreReflection = factory.createInstance(
"com.sun.star.reflection.CoreReflection");
241 var structClass = starCoreReflection.forName(
"oletest.SimpleStruct");
242 var outParam= new Array();
243 structClass.createObject(outParam);
244 var aStruct= outParam[
0];
245 aStruct.message=
"a Struct created in JScript";
249 function XCallback_Impl_outEnum( outVal)
253 function XCallback_Impl_outSeqAny( outVal)
255 var ar= new Array(
1,
2,
3);
258 function XCallback_Impl_outAny( outVal)
260 outVal[
0]=
"this is an Any";
262 function XCallback_Impl_outBool( outVal)
266 function XCallback_Impl_outChar( outVal)
270 function XCallback_Impl_outString( outVal)
272 outVal[
0]=
"This string was created in JScript";
274 function XCallback_Impl_outFloat( outVal)
278 function XCallback_Impl_outDouble( outVal)
282 function XCallback_Impl_outByte( outVal)
286 function XCallback_Impl_outShort( outVal)
290 function XCallback_Impl_outLong( outVal)
294 function XCallback_Impl_outValuesMixed( inLong, outLong, inString)
296 alert(
"inVal long: " + inLong +
" inString:" + inString);
297 outLong[
0]= inLong +
1;
299 function XCallback_Impl_outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
300 aChar, aString, aFloat, aDouble, aByte, aShort, aLong)
302 this.outInterface( xSimple);
303 this.outStruct( aSimpleStruct);
304 this.outEnum( aSimpleEnum);
305 this.outSeqAny( seqAny);
307 this.outBool( aBool);
308 this.outChar( aChar);
309 this.outString( aString);
310 this.outFloat( aFloat);
311 this.outDouble( aDouble);
312 this.outByte( aByte);
313 this.outShort( aShort);
314 this.outLong( aLong);
317 function XCallback_Impl_inoutInterface( val)
319 val[
0].func(
"calling on in parameter");
320 val[
0]= new XSimple_Impl();
322 function XCallback_Impl_inoutStruct( val)
324 alert( val[
0].message);
325 val[
0].message=
"property message changed in JScript";
327 function XCallback_Impl_inoutEnum(val)
329 alert(
"enum value +" + val);
332 function XCallback_Impl_inoutSeqAny( val)
334 var vbar = new VBArray(val[
0]);
335 var seq= vbar.toArray();
336 alert( seq[
0] +
" "+seq[
1] +
" " +seq[
2]);
337 val[
0]= new Array(
"jscript1",
"jscript2",
"jscript3");
339 function XCallback_Impl_inoutAny(val)
341 alert(
"JScript in any: " + val[
0]);
342 val[
0]=
"a string from JScript";
344 function XCallback_Impl_inoutBool(val)
346 alert(
"JScript in bool: " + val[
0]);
349 function XCallback_Impl_inoutChar(val)
351 alert(
"JScript in char: " + val[
0]);
354 function XCallback_Impl_inoutString(val)
356 alert(
"JScript in string: " + val[
0]);
357 val[
0]=
" a JScript string";
359 function XCallback_Impl_inoutFloat(val)
361 alert(
"JScript in float: " + val[
0]);
364 function XCallback_Impl_inoutDouble(val)
366 alert(
"JScript in double: " + val[
0]);
370 function XCallback_Impl_inoutByte(val)
372 alert(
"JScript in byte: " + val[
0]);
375 function XCallback_Impl_inoutShort(val)
377 alert(
"JScript in short: " + val[
0]);
380 function XCallback_Impl_inoutLong(val)
382 alert(
"JScript in long: " + val[
0]);
385 function XCallback_Impl_inoutValuesAll(aXSimple, aStruct, aEnum, aSeq,
386 aAny, aBool, aChar, aString, aFloat, aDouble,
387 aByte, aShort, aLong )
389 this.inoutInterface( aXSimple);
390 this.inoutStruct( aStruct);
391 this.inoutEnum( aEnum);
392 this.inoutSeqAny( aSeq);
393 this.inoutAny( aAny);
394 this.inoutBool( aBool);
395 this.inoutChar( aChar);
396 this.inoutString( aString);
397 this.inoutFloat( aFloat);
398 this.inoutDouble( aDouble);
399 this.inoutByte( aByte);
400 this.inoutShort( aShort);
401 this.inoutLong( aLong);
404 function XCallback_Impl_inValues( aChar, aLong, aString)
406 alert(
"char : " + aChar +
" long: " + aLong +
" string: " + aString);
411 // class MultiInterface implements XSimple, XSimple2, XSimple3
413 function MultiInterface()
415 this._environment=
"JScript";
416 this._implementedInterfaces= new Array(
"oletest.XSimple",
"oletest.XSimple2",
"oletest.XSimple3");
417 // XSimple ---------------
418 this.getName= MultiInterface_getName;
419 this.func= MultiInterface_func;
420 this.func2= MultiInterface_func2;
421 this.func3= MultiInterface_func3;
423 this.getName2= MultiInterface_getName2;
425 this.getName3= MultiInterface_getName3;
429 function MultiInterface_getName()
431 return
"JScript XSimple called";
433 function MultiInterface_func( message)
435 alert(
"JScript object (XSimple)-- " + message);
438 function MultiInterface_getName2()
440 return
"JScript XSimple2 called";
442 function MultiInterface_func2( message)
444 alert(
"JScript object (XSimple2) -- " + message);
447 function MultiInterface_getName3()
449 return
"JScript XSimple3 called";
451 function MultiInterface_func3( message)
453 alert(
"JScript object (XSimple3) -- " + message);
459 //XCallback_Impl_outValuesMixed( val1, outval, val2)
462 //XCallback_Impl_outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
463 // aChar, aString, aFloat, aDouble, aByte, aShort, aLong, aUShort, aULong)
470 // class XSimple_Impl----------------------------------------------------------------------
471 function XSimple_Impl()
474 this.func= XSimple_Impl_func;
476 function XSimple_Impl_func( message)
478 alert(
"XSimple called." + message);
486 <h2> Object in JScript
</h2>
488 This test passes a XCallback to a UNO function of the UNO test control.
489 XCallback is implemented by the JScript class XCallback_Impl. The function
490 XCallback::func1 is then called from the UNO test control.
492 <button onclick='callOleTest(
1)'
>go
</Button>
494 On the UNO object the function testInterface is called which takes
495 a XCallback as parameter. XCallback is implemented in a JScript object.The function
496 returns a XSimple Interface. Then the UNO object calls XSimple::notify. This test shall
497 verify the correct conversion of the return value( IDispatch JScript object) to an XSimple object.
<br>
498 <button onclick='callOleTest(
2)'
>go
</Button>
500 <h1> out parameter
</h1>
501 The a JScript object of class XCallback_Impl is passed to the UNO OleTest Control as parameter.
502 According to the buttons the OleTest object calls a function on XCallback_Impl that has appropriate type
503 as out parameter.
<br>
504 <button onclick='callOleTest(
3)'
>interface
</Button>
505 <button onclick='callOleTest(
4)'
>struct
</Button>
506 <button onclick='callOleTest(
5)'
>enum
</Button>
507 <button onclick='callOleTest(
6)'
>sequence
<any
></Button>
508 <button onclick='callOleTest(
7)'
>any
</Button>
509 <button onclick='callOleTest(
8)'
>bool
</Button>
510 <button onclick='callOleTest(
9)'
>char
</Button>
511 <button onclick='callOleTest(
10)'
>string
</Button>
512 <button onclick='callOleTest(
11)'
>float
</Button>
513 <button onclick='callOleTest(
12)'
>double
</Button>
514 <button onclick='callOleTest(
13)'
>byte
</Button>
515 <button onclick='callOleTest(
14)'
>short
</Button>
516 <button onclick='callOleTest(
15)'
>long
</Button>
518 Other test without parameters
<br>
519 <button onclick='callOleTest(
30)'
>outValuesMixed
</Button>
520 <button onclick='callOleTest(
31)'
>outValuesAll
</Button>
521 <h1> in out parameter
</h1>
522 <button onclick='callOleTest(
100)'
>interface
</Button>
523 <button onclick='callOleTest(
101)'
>struct
</Button>
524 <button onclick='callOleTest(
102)'
>enum
</Button>
525 <button onclick='callOleTest(
103)'
>sequence
<any
></Button>
526 <button onclick='callOleTest(
104)'
>any
</Button>
527 <button onclick='callOleTest(
105)'
>bool
</Button>
528 <button onclick='callOleTest(
106)'
>char
</Button>
529 <button onclick='callOleTest(
107)'
>string
</Button>
530 <button onclick='callOleTest(
108)'
>float
</Button>
531 <button onclick='callOleTest(
109)'
>double
</Button>
532 <button onclick='callOleTest(
110)'
>byte
</Button>
533 <button onclick='callOleTest(
111)'
>short
</Button>
534 <button onclick='callOleTest(
112)'
>long
</Button>
536 <h1> Attributes
</h1>
537 <button onclick='callOleTest(
400)'
>getting XSimple
</Button>
540 Other tests with inout parameters
<br>
541 <button onclick='callOleTest(
120)'
>inoutValuesAll
</Button>
542 <h1>in parameters
</h1>
543 <button onclick='callOleTest(
200)'
>inValues
</Button>
545 <h1> JScript object implements several interfaces
</h1>
546 <button onclick='callOleTest(
1000)'
>go
</Button>