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