tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / extensions / test / ole / callUnoToJava.htm
blob5374adbfa53d3a4ec2bcd6c9633dfe4eda3425df
1 <!--
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 .
17 -->
18 <HTML>
19 <HEAD>
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>
23 </HEAD>
24 <BODY id=theBody>
26 <script language="JScript">
27 function callOleTest( id)
29 var factory= new ActiveXObject("com.sun.star.ServiceManager");
30 var oletest= factory.createInstance("oletest.OleTest");
31 // alert(oletest);
33 switch( id)
35 case 1: // Test simple call of JScript object function from UNO
36 oletest.testInterface( new XCallback_Impl, 1);
37 break;
39 case 2:
40 // return value is the parameter object
41 oletest.testInterface( new XCallback_Impl, 2);
42 break;
44 // OUT parameter
46 case 3: // Test out parameter of type interface
47 oletest.testInterface( new XCallback_Impl, 3);
48 break;
49 case 4: // Test out parameter of type struct
50 oletest.testInterface( new XCallback_Impl, 4);
51 break;
52 case 5: // Test out parameter of type enum
53 oletest.testInterface( new XCallback_Impl, 5);
54 break;
55 case 6: // Test out parameter of type sequence<any>
56 oletest.testInterface( new XCallback_Impl, 6);
57 break;
58 case 7: // Test out parameter of type any
59 oletest.testInterface( new XCallback_Impl, 7);
60 break;
61 case 8: // Test out parameter of type bool
62 oletest.testInterface( new XCallback_Impl, 8);
63 break;
64 case 9: // Test out parameter of type char
65 oletest.testInterface( new XCallback_Impl, 9);
66 break;
67 case 10: // Test out parameter of type string
68 oletest.testInterface( new XCallback_Impl, 10);
69 break;
70 case 11: // Test out parameter of type float
71 oletest.testInterface( new XCallback_Impl, 11);
72 break;
73 case 12: // Test out parameter of type double
74 oletest.testInterface( new XCallback_Impl, 12);
75 break;
76 case 13: // Test out parameter of type byte
77 oletest.testInterface( new XCallback_Impl, 13);
78 break;
79 case 14: // Test out parameter of type short
80 oletest.testInterface( new XCallback_Impl, 14);
81 break;
82 case 15: // Test out parameter of type long
83 oletest.testInterface( new XCallback_Impl, 15);
84 break;
85 case 30: // outValuesMixed
86 oletest.testInterface( new XCallback_Impl, 30);
87 break;
88 case 31: // outValuesAll
89 oletest.testInterface( new XCallback_Impl, 31);
90 break;
92 // IN/OUT parameter
95 case 100: // inoutInterface
96 oletest.testInterface( new XCallback_Impl, 100);
97 break;
98 case 101: // inoutStruct
99 oletest.testInterface( new XCallback_Impl, 101);
100 break;
101 case 102: // inoutEnum
102 oletest.testInterface( new XCallback_Impl, 102);
103 break;
104 case 103: // inoutSeqAny
105 oletest.testInterface( new XCallback_Impl, 103);
106 break;
107 case 104: // inoutAny
108 oletest.testInterface( new XCallback_Impl, 104);
109 break;
110 case 105: // inoutBool
111 oletest.testInterface( new XCallback_Impl, 105);
112 break;
113 case 106: // inoutChar
114 oletest.testInterface( new XCallback_Impl, 106);
115 break;
116 case 107: // inoutString
117 oletest.testInterface( new XCallback_Impl, 107);
118 break;
119 case 108: // inoutFloat
120 oletest.testInterface( new XCallback_Impl, 108);
121 break;
122 case 109: // inoutDouble
123 oletest.testInterface( new XCallback_Impl, 109);
124 break;
125 case 110: // inoutByte
126 oletest.testInterface( new XCallback_Impl, 110);
127 break;
128 case 111: // inoutShort
129 oletest.testInterface( new XCallback_Impl, 111);
130 break;
131 case 112: // inoutLong
132 oletest.testInterface( new XCallback_Impl, 112);
133 break;
134 case 120: // inoutValuesAll
135 oletest.testInterface( new XCallback_Impl, 120);
136 break;
137 case 200: // inValues
138 oletest.testInterface( new XCallback_Impl, 200);
139 break;
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
143 // case 300:
145 // Attributes
147 case 400:
148 oletest.testInterface( new XCallback_Impl, 400);
149 break;
151 case 1000:
152 oletest.testInterface2(new MultiInterface(), 0);
153 break;
160 // The class --------------------------------------------
162 function XCallback_Impl()
164 // XCallback
165 this._environment= "JScript";
167 this.func1= XCallback_Impl_func1;
168 this.returnInterface= XCallback_Impl_returnInterface;
169 // #################################################
170 // OUT parameter
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 // #################################################
188 // IN/ OUT parameter
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 // #################################################
205 // IN parameter
207 this.inValues= XCallback_Impl_inValues;
209 // #################################################
210 // Attributes
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)
235 alert("outLong");
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";
246 outVal[0]= aStruct;
249 function XCallback_Impl_outEnum( outVal)
251 outVal[0]= 2;
253 function XCallback_Impl_outSeqAny( outVal)
255 var ar= new Array(1,2,3);
256 outVal[0]= ar;
258 function XCallback_Impl_outAny( outVal)
260 outVal[0]= "this is an Any";
262 function XCallback_Impl_outBool( outVal)
264 outVal[0]= true;
266 function XCallback_Impl_outChar( outVal)
268 outVal[0]= "a";
270 function XCallback_Impl_outString( outVal)
272 outVal[0]= "This string was created in JScript";
274 function XCallback_Impl_outFloat( outVal)
276 outVal[0]= 3.14;
278 function XCallback_Impl_outDouble( outVal)
280 outVal[0]= 3.145;
282 function XCallback_Impl_outByte( outVal)
284 outVal[0]= 100;
286 function XCallback_Impl_outShort( outVal)
288 outVal[0]= 1000;
290 function XCallback_Impl_outLong( outVal)
292 outVal[0]= 1000000;
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);
306 this.outAny( aAny);
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);
330 val[0]= 2;
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]);
347 val[0]= true;
349 function XCallback_Impl_inoutChar(val)
351 alert( "JScript in char: " + val[0]);
352 val[0]= 'b';
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]);
362 val[0]= 4.14;
364 function XCallback_Impl_inoutDouble(val)
366 alert( "JScript in double: " + val[0]);
367 val[0]= 4.145;
370 function XCallback_Impl_inoutByte(val)
372 alert( "JScript in byte: " + val[0]);
373 val[0]= 100;
375 function XCallback_Impl_inoutShort(val)
377 alert( "JScript in short: " + val[0]);
378 val[0]= 1000;
380 function XCallback_Impl_inoutLong(val)
382 alert( "JScript in long: " + val[0]);
383 val[0]= 100000;
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;
422 // XSimple2
423 this.getName2= MultiInterface_getName2;
424 // XSimple3
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()
473 //XSimple
474 this.func= XSimple_Impl_func;
476 function XSimple_Impl_func( message)
478 alert( "XSimple called." + message);
482 </script>
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.
491 <br>
492 <button onclick='callOleTest( 1)'>go</Button>
493 <br>
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>
499 <br>
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&lt;any&gt;</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>
517 <br>
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&lt;any&gt;</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>
535 <br>
536 <h1> Attributes </h1>
537 <button onclick='callOleTest( 400)'>getting XSimple</Button>
538 <br>
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>
551 </body>
552 </html>