1<!--***********************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 ***********************************************************-->
21<HTML>
22<HEAD>
23<META NAME="GENERATOR" Content="Microsoft Developer Studio">
24<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
25<TITLE>Document Title</TITLE>
26</HEAD>
27<BODY id=theBody>
28
29<script language="JScript">
30function callOleTest(	 id)
31{
32	var factory= new ActiveXObject("com.sun.star.ServiceManager");
33	var oletest= factory.createInstance("oletest.OleTest");
34//	alert(oletest);
35
36	switch( id)
37	{
38		case 1: // Test simple call of JScript object function from UNO
39		oletest.testInterface( new XCallback_Impl, 1);
40		break;
41
42		case 2:
43		// return value is the parameter object
44		oletest.testInterface( new XCallback_Impl, 2);
45		break;
46		//##################################################
47		// OUT parameter
48		//##################################################
49		case 3: // Test out parameter of type interface
50		oletest.testInterface( new XCallback_Impl, 3);
51		break;
52		case 4: // Test out parameter of type struct
53		oletest.testInterface( new XCallback_Impl, 4);
54		break;
55		case 5: // Test out parameter of type enum
56		oletest.testInterface( new XCallback_Impl, 5);
57		break;
58		case 6: // Test out parameter of type sequence<any>
59		oletest.testInterface( new XCallback_Impl, 6);
60		break;
61		case 7: // Test out parameter of type any
62		oletest.testInterface( new XCallback_Impl, 7);
63		break;
64		case 8: // Test out parameter of type bool
65		oletest.testInterface( new XCallback_Impl, 8);
66		break;
67		case 9: // Test out parameter of type char
68		oletest.testInterface( new XCallback_Impl, 9);
69		break;
70		case 10: // Test out parameter of type string
71		oletest.testInterface( new XCallback_Impl, 10);
72		break;
73		case 11: // Test out parameter of type float
74		oletest.testInterface( new XCallback_Impl, 11);
75		break;
76		case 12: // Test out parameter of type double
77		oletest.testInterface( new XCallback_Impl, 12);
78		break;
79		case 13: // Test out parameter of type byte
80		oletest.testInterface( new XCallback_Impl, 13);
81		break;
82		case 14: // Test out parameter of type short
83		oletest.testInterface( new XCallback_Impl, 14);
84		break;
85		case 15: // Test out parameter of type long
86		oletest.testInterface( new XCallback_Impl, 15);
87		break;
88		case 30: //  outValuesMixed
89		oletest.testInterface( new XCallback_Impl, 30);
90		break;
91		case 31: //  outValuesAll
92		oletest.testInterface( new XCallback_Impl, 31);
93		break;
94		//##################################################
95		// IN/OUT parameter
96		//##################################################
97
98		case 100: // inoutInterface
99		oletest.testInterface( new XCallback_Impl, 100);
100		break;
101		case 101: // inoutStruct
102		oletest.testInterface( new XCallback_Impl, 101);
103		break;
104		case 102: // inoutEnum
105		oletest.testInterface( new XCallback_Impl, 102);
106		break;
107		case 103: // inoutSeqAny
108		oletest.testInterface( new XCallback_Impl, 103);
109		break;
110		case 104: // inoutAny
111		oletest.testInterface( new XCallback_Impl, 104);
112		break;
113		case 105: // inoutBool
114		oletest.testInterface( new XCallback_Impl, 105);
115		break;
116		case 106: // inoutChar
117		oletest.testInterface( new XCallback_Impl, 106);
118		break;
119		case 107: // inoutString
120		oletest.testInterface( new XCallback_Impl, 107);
121		break;
122		case 108: // inoutFloat
123		oletest.testInterface( new XCallback_Impl, 108);
124		break;
125		case 109: // inoutDouble
126		oletest.testInterface( new XCallback_Impl, 109);
127		break;
128		case 110: // inoutByte
129		oletest.testInterface( new XCallback_Impl, 110);
130		break;
131		case 111: // inoutShort
132		oletest.testInterface( new XCallback_Impl, 111);
133		break;
134		case 112: // inoutLong
135		oletest.testInterface( new XCallback_Impl, 112);
136		break;
137		case 120: // inoutValuesAll
138		oletest.testInterface( new XCallback_Impl, 120);
139		break;
140		case 200: // inValues
141		oletest.testInterface( new XCallback_Impl, 200);
142		break;
143
144		// Call a COM object that has not been passed as parameter to a UNO component and
145		// hence no type information are available in the COM wrapper
146//		case 300:
147		//##################################################
148		// Attributes
149		//##################################################
150		case 400:
151		oletest.testInterface( new XCallback_Impl, 400);
152		break;
153
154		case 1000:
155		oletest.testInterface2(new MultiInterface(), 0);
156		break;
157	}
158
159}
160
161
162
163// The class --------------------------------------------
164
165function XCallback_Impl()
166{
167
168	// XCallback
169	this._environment= "JScript";
170
171	this.func1= XCallback_Impl_func1;
172	this.returnInterface= XCallback_Impl_returnInterface;
173	// #################################################
174	// OUT parameter
175	//###################################################
176	this.outInterface= XCallback_Impl_outInterface;
177	this.outStruct= XCallback_Impl_outStruct;
178	this.outEnum= XCallback_Impl_outEnum;
179	this.outSeqAny= XCallback_Impl_outSeqAny;
180	this.outAny= XCallback_Impl_outAny;
181	this.outBool= XCallback_Impl_outBool;
182	this.outChar= XCallback_Impl_outChar;
183	this.outString= XCallback_Impl_outString;
184	this.outFloat= XCallback_Impl_outFloat;
185	this.outDouble= XCallback_Impl_outDouble;
186	this.outByte= XCallback_Impl_outByte;
187	this.outShort= XCallback_Impl_outShort;
188	this.outLong= XCallback_Impl_outLong;
189	this.outValuesMixed= XCallback_Impl_outValuesMixed;
190	this.outValuesAll= XCallback_Impl_outValuesAll;
191	// #################################################
192	// IN/ OUT parameter
193	//###################################################
194	this.inoutInterface= XCallback_Impl_inoutInterface;
195	this.inoutStruct= XCallback_Impl_inoutStruct;
196	this.inoutEnum= XCallback_Impl_inoutEnum;
197	this.inoutSeqAny= XCallback_Impl_inoutSeqAny;
198	this.inoutAny= XCallback_Impl_inoutAny;
199	this.inoutBool= XCallback_Impl_inoutBool;
200	this.inoutChar= XCallback_Impl_inoutChar;
201	this.inoutString= XCallback_Impl_inoutString;
202	this.inoutFloat= XCallback_Impl_inoutFloat;
203	this.inoutDouble= XCallback_Impl_inoutDouble;
204	this.inoutByte= XCallback_Impl_inoutByte;
205	this.inoutShort= XCallback_Impl_inoutShort;
206	this.inoutLong= XCallback_Impl_inoutLong;
207	this.inoutValuesAll= XCallback_Impl_inoutValuesAll;
208	// #################################################
209	// IN parameter
210	//##################################################
211	this.inValues= XCallback_Impl_inValues;
212
213	// #################################################
214	// Attributes
215	//##################################################
216	this.simple= new XSimple_Impl();
217
218
219}
220
221
222function XCallback_Impl_func1()
223{
224	alert("XCallback_Impl_func1");
225}
226function XCallback_Impl_returnInterface()
227{
228	alert("XCallback::returnInterface called");
229	return new XSimple_Impl();
230}
231
232function XCallback_Impl_outInterface( outVal)
233{
234	outVal[0]= new XSimple_Impl();
235}
236
237function XCallback_Impl_outLong( outVal)
238{
239	alert("outLong");
240}
241function XCallback_Impl_outStruct( outVal)
242{
243	var factory= new ActiveXObject("com.sun.star.ServiceManager");
244    var starCoreReflection = factory.createInstance("com.sun.star.reflection.CoreReflection");
245    var structClass = starCoreReflection.forName("oletest.SimpleStruct");
246	var outParam= new Array();
247	structClass.createObject(outParam);
248	var aStruct= outParam[0];
249	aStruct.message= "a Struct created in JScript";
250	outVal[0]= aStruct;
251
252}
253function XCallback_Impl_outEnum( outVal)
254{
255	outVal[0]= 2;
256}
257function XCallback_Impl_outSeqAny( outVal)
258{
259	var ar= new Array(1,2,3);
260	outVal[0]= ar;
261}
262function XCallback_Impl_outAny( outVal)
263{
264	outVal[0]= "this is an Any";
265}
266function XCallback_Impl_outBool( outVal)
267{
268	outVal[0]= true;
269}
270function XCallback_Impl_outChar( outVal)
271{
272	outVal[0]= "a";
273}
274function XCallback_Impl_outString( outVal)
275{
276	outVal[0]= "This string was created in JScript";
277}
278function XCallback_Impl_outFloat( outVal)
279{
280	outVal[0]= 3.14;
281}
282function XCallback_Impl_outDouble( outVal)
283{
284	outVal[0]= 3.145;
285}
286function XCallback_Impl_outByte( outVal)
287{
288	outVal[0]= 100;
289}
290function XCallback_Impl_outShort( outVal)
291{
292	outVal[0]= 1000;
293}
294function XCallback_Impl_outLong( outVal)
295{
296	outVal[0]= 1000000;
297}
298function XCallback_Impl_outValuesMixed( inLong, outLong, inString)
299{
300	alert("inVal long: " + inLong +" inString:" + inString);
301	outLong[0]= inLong + 1;
302}
303function XCallback_Impl_outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
304				aChar, aString, aFloat, aDouble, aByte, aShort, aLong)
305{
306	this.outInterface( xSimple);
307	this.outStruct( aSimpleStruct);
308	this.outEnum( aSimpleEnum);
309	this.outSeqAny( seqAny);
310	this.outAny( aAny);
311	this.outBool( aBool);
312	this.outChar( aChar);
313	this.outString( aString);
314	this.outFloat( aFloat);
315	this.outDouble( aDouble);
316	this.outByte( aByte);
317	this.outShort( aShort);
318	this.outLong( aLong);
319}
320
321function XCallback_Impl_inoutInterface( val)
322{
323	val[0].func("calling on in parameter");
324	val[0]= new XSimple_Impl();
325}
326function XCallback_Impl_inoutStruct( val)
327{
328	alert( val[0].message);
329	val[0].message= "property message changed in JScript";
330}
331function XCallback_Impl_inoutEnum(val)
332{
333	alert("enum value +" + val);
334	val[0]= 2;
335}
336function XCallback_Impl_inoutSeqAny( val)
337{
338	var vbar = new VBArray(val[0]);
339	var seq= vbar.toArray();
340	alert( seq[0] +" "+seq[1] +" " +seq[2]);
341	val[0]= new Array("jscript1", "jscript2","jscript3");
342}
343function XCallback_Impl_inoutAny(val)
344{
345	alert( "JScript in any: " + val[0]);
346	val[0]= "a string from JScript";
347}
348function XCallback_Impl_inoutBool(val)
349{
350	alert( "JScript in bool: " + val[0]);
351	val[0]= true;
352}
353function XCallback_Impl_inoutChar(val)
354{
355	alert( "JScript in char: " + val[0]);
356	val[0]= 'b';
357}
358function XCallback_Impl_inoutString(val)
359{
360	alert( "JScript in string: " + val[0]);
361	val[0]= " a JScript string";
362}
363function XCallback_Impl_inoutFloat(val)
364{
365	alert( "JScript in float: " + val[0]);
366	val[0]= 4.14;
367}
368function XCallback_Impl_inoutDouble(val)
369{
370	alert( "JScript in double: " + val[0]);
371	val[0]= 4.145;
372}
373
374function XCallback_Impl_inoutByte(val)
375{
376	alert( "JScript in byte: " + val[0]);
377	val[0]= 100;
378}
379function XCallback_Impl_inoutShort(val)
380{
381	alert( "JScript in short: " + val[0]);
382	val[0]= 1000;
383}
384function XCallback_Impl_inoutLong(val)
385{
386	alert( "JScript in long: " + val[0]);
387	val[0]= 100000;
388}
389function XCallback_Impl_inoutValuesAll(aXSimple, aStruct, aEnum, aSeq,
390			aAny, aBool, aChar, aString,  aFloat, aDouble,
391			aByte, aShort,  aLong )
392{
393	this.inoutInterface( aXSimple);
394	this.inoutStruct( aStruct);
395	this.inoutEnum( aEnum);
396	this.inoutSeqAny( aSeq);
397	this.inoutAny( aAny);
398	this.inoutBool( aBool);
399	this.inoutChar( aChar);
400	this.inoutString( aString);
401	this.inoutFloat( aFloat);
402	this.inoutDouble( aDouble);
403	this.inoutByte( aByte);
404	this.inoutShort( aShort);
405	this.inoutLong( aLong);
406}
407
408function XCallback_Impl_inValues( aChar, aLong, aString)
409{
410	alert( "char : " + aChar + " long: " + aLong + " string: " + aString);
411}
412
413
414//################################################################
415// class MultiInterface implements XSimple, XSimple2, XSimple3
416//################################################################
417function MultiInterface()
418{
419	this._environment= "JScript";
420	this._implementedInterfaces= new Array( "oletest.XSimple", "oletest.XSimple2", "oletest.XSimple3");
421	// XSimple ---------------
422	this.getName= MultiInterface_getName;
423	this.func= MultiInterface_func;
424	this.func2= MultiInterface_func2;
425	this.func3= MultiInterface_func3;
426	// XSimple2
427	this.getName2= MultiInterface_getName2;
428	// XSimple3
429	this.getName3= MultiInterface_getName3;
430}
431
432
433function MultiInterface_getName()
434{
435	return "JScript XSimple called";
436}
437function MultiInterface_func( message)
438{
439	alert("JScript object (XSimple)-- " + message);
440}
441
442function MultiInterface_getName2()
443{
444	return "JScript XSimple2 called";
445}
446function MultiInterface_func2( message)
447{
448	alert("JScript object (XSimple2) -- " + message);
449}
450
451function MultiInterface_getName3()
452{
453	return "JScript XSimple3 called";
454}
455function MultiInterface_func3( message)
456{
457	alert("JScript object (XSimple3) -- " + message);
458}
459
460
461
462
463//XCallback_Impl_outValuesMixed( val1, outval, val2)
464//{
465//}
466//XCallback_Impl_outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
467//				aChar, aString, aFloat, aDouble, aByte, aShort, aLong, aUShort, aULong)
468//{
469//
470//}
471
472
473
474//  class XSimple_Impl----------------------------------------------------------------------
475function XSimple_Impl()
476{
477	//XSimple
478	this.func= XSimple_Impl_func;
479}
480function XSimple_Impl_func( message)
481{
482	alert( "XSimple called." + message);
483}
484
485
486</script>
487
488
489
490<h2> Object in JScript</h2>
491
492This test passes a XCallback to an UNO function of the UNO test control.
493XCallback is implemented by the JScript class XCallback_Impl. The function
494XCallback::func1 is then called from the UNO test control.
495<br>
496<button onclick='callOleTest( 1)'>go</Button>
497<br>
498On the UNO object the function testInterface is called which takes
499a XCallback as parameter. XCallback is implemented in a JScript object.The function
500returns a XSimple Interface. Then the UNO object calls XSimple::notify. This test shall
501verify the correct conversion of the return value( IDispatch JScript object) to an XSimple object.<br>
502<button onclick='callOleTest( 2)'>go</Button>
503<br>
504<h1> out parameter </h1>
505The a JScript object of class XCallback_Impl is passed to the UNO OleTest Control as parameter.
506According to the buttons the OleTest object calls a function on XCallback_Impl that has appropriate type
507as out parameter.<br>
508<button onclick='callOleTest( 3)'>interface</Button>
509<button onclick='callOleTest( 4)'>struct</Button>
510<button onclick='callOleTest( 5)'>enum</Button>
511<button onclick='callOleTest( 6)'>sequence&lt;any&gt;</Button>
512<button onclick='callOleTest( 7)'>any</Button>
513<button onclick='callOleTest( 8)'>bool</Button>
514<button onclick='callOleTest( 9)'>char</Button>
515<button onclick='callOleTest( 10)'>string</Button>
516<button onclick='callOleTest( 11)'>float</Button>
517<button onclick='callOleTest( 12)'>double</Button>
518<button onclick='callOleTest( 13)'>byte</Button>
519<button onclick='callOleTest( 14)'>short</Button>
520<button onclick='callOleTest( 15)'>long</Button>
521<br>
522Other test with out parameters <br>
523<button onclick='callOleTest( 30)'>outValuesMixed</Button>
524<button onclick='callOleTest( 31)'>outValuesAll</Button>
525<h1> in out parameter </h1>
526<button onclick='callOleTest( 100)'>interface</Button>
527<button onclick='callOleTest( 101)'>struct</Button>
528<button onclick='callOleTest( 102)'>enum</Button>
529<button onclick='callOleTest( 103)'>seqence&lt;any&gt;</Button>
530<button onclick='callOleTest( 104)'>any</Button>
531<button onclick='callOleTest( 105)'>bool</Button>
532<button onclick='callOleTest( 106)'>char</Button>
533<button onclick='callOleTest( 107)'>string</Button>
534<button onclick='callOleTest( 108)'>float</Button>
535<button onclick='callOleTest( 109)'>double</Button>
536<button onclick='callOleTest( 110)'>byte</Button>
537<button onclick='callOleTest( 111)'>short</Button>
538<button onclick='callOleTest( 112)'>long</Button>
539<br>
540<h1> Attributes </h1>
541<button onclick='callOleTest( 400)'>getting XSimple</Button>
542<br>
543
544Other tests with inout parameters <br>
545<button onclick='callOleTest( 120)'>inoutValuesAll</Button>
546<h1>in parameters </h1>
547<button onclick='callOleTest( 200)'>inValues</Button>
548
549<h1> JScript object implements several interfaces </h1>
550<button onclick='callOleTest( 1000)'>go</Button>
551
552
553
554
555</body>
556</html>
557
558
559