8 COMPATIBILITYMODE(true)
11 MsgBox
"Test Failed!!!"
13 MsgBox
"Test Succeeded"
18 Function runtest() As Integer
19 Dim inBool
As Boolean, inBool2
As Boolean, outBool
As Boolean
20 Dim inByte
As Integer, inByte2
As Integer
21 Dim inShort
As Integer, inShort2
As Integer
22 Dim inLong
As Long, inLong2
As Long, inLong3
As Long, inLong4
As Long
23 Dim inString
As String, inString2
As String
24 Dim inFloat
As Single, inFloat2
As Single
25 Dim inDouble
As Double, inDouble2
As Double
26 Dim inVariant
, inVariant2
28 Dim inDate
As Date,inDate2
As Date, outDate
As Date
29 Dim inCurrency
As Currency, inCurrency2
As Currency, outCurrency
As Currency
30 Dim inSCode
As New com
.sun
.star
.bridge
.oleautomation
.SCode
31 Dim inSCode2
As New com
.sun
.star
.bridge
.oleautomation
.SCode
32 Dim inDecimal
As Variant, inDecimal2
As Variant, outDecimal
As Variant
33 Dim inrefDecimal
As Variant, outrefDecimal
As Variant
34 Dim outSCode
As New com
.sun
.star
.bridge
.oleautomation
.SCode
35 Dim outByte
As Integer
36 Dim outShort
As Integer
37 Dim outLong
, outLong2
As Long
38 Dim outString
As String
39 Dim outFloat
As Single
40 Dim outDouble
As Double
42 'bug #109936 causes an errOr when outObject is used As out param
43 Dim inObject
As Object, inObject2
As Object, outObject
As Object
44 Dim objNOTHING
As Object
45 Dim inUnknown
As Object, inUnknown2
As Object, outUnknown
As Object
47 Dim inArray
, outArray
, outArray2
49 Dim arString(1) As String
50 arString(0)= "String one"
51 arString(1)= "String two"
54 factory
= createUnoService("com.sun.star.bridge.OleObjectFactory")
56 obj
= factory
.createInstance("AxTestComponents.Basic")
59 objFoo
= factory
.createInstance("AxTestComponents.Foo")
62 'in parameter -------------------------------------------------------------------
67 inString
= "Hello World"
72 inCurrency
= 12345.6789
73 inSCode
.Value
= &h80020004
74 inDecimal
= CDec("-9223372036854775808") 'lowest int64
80 obj
.inString(inString
)
82 obj
.inDouble(inDouble
)
83 obj
.inVariant(inVariant
)
84 'obj.prpString= "a string property"
86 obj
.inArray(arString())
88 obj
.inCurrency(inCurrency
)
91 obj
.inDecimal(inDecimal
)
93 'out parameter -------------------------------------------------------------------------
99 obj
.outShort(outShort
)
103 obj
.outFloat(outFloat
)
105 obj
.outDouble(outDouble
)
107 obj
.outString(outString
)
109 obj
.outVariant(outVariant
)
111 obj
.outObject(outObject
)
113 obj
.outArray(outArray
)
115 obj
.outCurrency(outCurrency
)
116 obj
.outSCode(outSCode
)
117 obj
.outUnknown(outUnknown
)
118 obj
.outDecimal(outDecimal
)
121 If inBool
<> outBool
Or inByte
<> outByte
Or inShort
<> outShort
Or inLong
<> outLong
Or _
122 inFloat
<> outFloat
Or inDouble
<> outDouble
Or inString
<> outString
Or _
123 inVariant
<> outVariant
Or NOT equalUnoObjects(obj
, outObject
) Or NOT _
124 equalArrays(arString(), outArray()) Or inDate
<> outDate
Or inCurrency
<> outCurrency
Or _
125 inSCode
.Value
<> outSCode
.Value
Or Not equalUnoObjects(objFoo
, outUnknown
) Or _
126 inDecimal
<> outDecimal
Then
132 'in-out parameter -------------------------------------------------------------
133 'implementation of inout methods returns the previously set value in out param
136 obj
.inoutBool(inBool2
)
138 obj
.inoutBool(outBool
)
141 obj
.inoutByte(inByte2
)
143 obj
.inoutByte(outByte
)
146 obj
.inShort(inShort2
)
148 obj
.inoutShort(outShort
)
151 obj
.inoutLong(inLong2
)
153 obj
.inoutLong(outLong
)
156 obj
.inoutFloat(inFloat2
)
158 obj
.inoutFloat(outFloat
)
161 obj
.inoutDouble(inDouble2
)
163 obj
.inoutDouble(outDouble
)
166 obj
.inoutString(inString2
)
168 obj
.inoutString(outString
)
170 inVariant2
= inVariant
171 obj
.inoutVariant(inVariant2
)
173 obj
.inoutVariant(outVariant
)
174 inObject
= factory
.createInstance("AxTestComponents.Basic")
176 obj
.inoutObject(inObject2
)
178 obj
.inoutObject(outObject
)
181 obj
.inoutArray(inAr2
)
183 obj
.outArray(outArray())
186 obj
.inoutDate(inDate2
)
188 obj
.inoutDate(outDate
)
189 inCurrency
= 1234.5678
190 inCurrency2
= inCurrency
191 obj
.inoutCurrency(inCurrency2
)
193 obj
.inoutCurrency(outCurrency
)
194 inSCode
.Value
= &h80020004
196 obj
.inoutSCode(inSCode2
)
198 obj
.inoutSCode(outSCode
)
200 inUnknown2
= inUnknown
201 obj
.inoutUnknown(inUnknown2
)
203 obj
.inoutUnknown(outUnknown
)
204 inDecimal
= CDec("18446744073709551615") 'highest positiv value of unsigne int64
205 inDecimal2
= inDecimal
206 obj
.inoutDecimal(inDecimal2
)
208 obj
.inoutDecimal(outDecimal
)
210 If inBool
<> outBool
Or inByte
<> outByte
Or inShort
<> outShort
Or inLong
<> outLong
Or _
211 inFloat
<> outFloat
Or inDouble
<> outDouble
Or inString
<> outString
Or _
212 inVariant
<> outVariant
Or NOT equalUnoObjects(inObject
, outObject
) Or _
213 NOT equalArrays(inAr
, outArray
) Or inDate
<> outDate
Or inCurrency
<> outCurrency
Or _
214 inSCode
.Value
<> outSCode
.Value
Or Not equalUnoObjects(inUnknown
, outUnknown
) Or _
215 inDecimal
<> outDecimal
Then
220 'properties -------------------------------------------------------------------------
224 outBool
= obj
.prpBool
231 obj
.prpShort
= inShort
232 outShort
= obj
.prpShort
239 obj
.prpFloat
= inFloat
240 outFloat
= obj
.prpFloat
243 obj
.prpDouble
= inDouble
244 outDouble
= obj
.prpDouble
247 obj
.prpString
= inString
248 outString
= obj
.prpString
250 outObject
= objNOTHING
251 obj
.prpObject
= inObject
252 outObject
= obj
.prpObject
255 obj
.prpVariant
= inVariant
256 outVariant
= obj
.prpVariant
259 obj
.prpArray
= inArray()
260 outArray
= obj
.prpArray
264 outDate
= obj
.prpDate
265 inCurrency
= 1234.5678
267 obj
.prpCurrency
= inCurrency
268 outCurrency
= obj
.prpCurrency
269 inSCode
.Value
= &h80020004
271 obj
.prpSCode
= inSCode
272 outSCode
= obj
.prpSCode
275 obj
.prpUnknown
= inUnknown
276 outUnknown
= obj
.prpUnknown
277 inDecimal
= CDec("18446744073709551615")' highest unsigned int64
279 obj
.prpDecimal
= inDecimal
280 outDecimal
= obj
.prpDecimal
282 If inBool
<> outBool
Or inByte
<> outByte
Or inShort
<> outShort
Or inLong
<> outLong
Or _
283 inFloat
<> outFloat
Or inDouble
<> outDouble
Or inString
<> outString
Or _
284 inVariant
<> outVariant
Or NOT equalUnoObjects(inObject
, outObject
) Or _
285 NOT equalArrays(inArray
, outArray
) Or inDate
<> outDate
Or inCurrency
<> outCurrency
Or _
286 inSCode
.Value
<> outSCode
.Value
Or Not equalUnoObjects(inUnknown
, outUnknown
) Or _
287 inDecimal
<> outDecimal
Then
292 ' ref parameter ------------------------------------------------------------------------
297 obj
.inrefLong(inLong
)
302 obj
.inrefVariant(inVariant
)
303 obj
.outVariant(outVariant
)
304 If inLong
<> outLong
Or inVariant
<> outVariant
Then
310 obj
.prprefLong
= inLong
311 outLong
= obj
.prprefLong
313 obj
.prprefVariant
= inVariant
314 outVariant
= obj
.prprefVariant
315 If inLong
<> outLong
Or inVariant
<> outVariant
Then
321 'vararg --------------------------------------------------------------------------------
325 obj
.varargfunc1(inLong
)
328 obj
.varargfunc2(outLong
, outArray
)
329 If inLong
<> outLong
Then
333 len1
= UBound(outArray
) - LBound(outArray
) +1
339 obj
.varargfunc1(inLong
, inLong2
, inLong3
)
340 obj
.varargfunc2(outLong
, outArray
)
341 len1
= UBound(outArray
) - LBound(outArray
) +1
342 If len1
<> 2 Or outArray(0) <> inLong2
Or outArray(1) <> inLong3
Then
348 'defaultvalue ---------------------------------------------------------------------------
353 'defaults are: 1, 2, 4
354 'The third parameter is a VARIANT with a default value of 4. COM gives it the type BSTR
356 obj
.defaultvalue2(inLong
, inFloat
, inVariant
)
357 If inLong
<> 1 Or inFloat
<> 2 Or inVariant
<> "4" Then
367 obj
.defaultvalue1(inLong
, inFloat
)
368 obj
.defaultvalue2(inLong
, inFloat
, inVariant
)
369 If inLong
<> inLong2
Or inFloat
<> inFloat2
Or inVariant
<> "4" Then
374 'optional parameters ----------------------------------------------------------------
377 obj
.optional1(inLong
)
378 obj
.optional2(outLong
)
379 If inLong
<> outLong
Then
386 obj
.optional1(inLong
, inLong2
)
387 obj
.optional2(outLong
, outLong2
)
388 If inLong
<> outLong
AND inLong2
<> outLong2
Then
395 obj
.optional1(inLong
, inLong2
)
396 obj
.optional1(inLong
)
397 obj
.optional2(outLong
, outLong2
)
398 If inLong
<> outLong
AND inLong2
<> outLong2
Then
408 obj
.optional3(inLong
, inLong2
)
409 obj
.optional4(outLong
, outLong2
) 'outLong = 10, outLong2 = 100
410 If inLong
<> outLong
AND inLong2
<> outLong2
Then
418 obj
.optional4(inLong
, inLong
)
421 obj
.optional5(outLong
, outLong2
)
422 If inLong3
<> outLong
AND inLong4
<> outLong2
Then
429 obj
.optional3(inLong
)
430 obj
.optional4(outLong
)
431 If inLong
<> outLong
Then
438 obj
.optional4(inLong
)
439 obj
.optional5(outLong
)
440 If inLong2
<> outLong
Then
445 'named arguments-------------------------------------------------------------------------
446 'all args As named args, different order
447 obj
.optional6(0, 0, 0, 0)
452 obj
.optional6(val4
:= inLong4
, val3
:=inLong3
, val2
:=inLong2
, val1
:= inLong
)
459 obj
.optional7(outLong
, outLong2
, outLong3
, outLong4
)
460 If inLong
<> outLong
Or inLong2
<> outLong2 _
461 Or inLong3
<> outLong3
Or inLong4
<> outLong4
Then
466 'mixed positional and named args with omitted args
467 Dim scode_paramNotFound
As New com
.sun
.star
.bridge
.oleautomation
.SCode
468 scode_paramNotFound
.Value
= &h80020004
470 obj
.optional6(0, 0, 0, 0)
471 'val1 and val3 will be DISP_E_PARAMNOTFOUND
472 obj
.optional6(, inLong2
, val4
:=inLong4
)
473 Dim outSCode1
, outSCode2
474 obj
.optional7(outSCode
, outLong2
, outSCode2
, outLong4
)
475 If outSCode
.Value
<> scode_paramNotFound
.Value
Or inLong2
<> outLong2 _
476 Or outSCode2
.Value
<> scode_paramNotFound
.Value
Or inLong4
<> outLong4
Then
481 'mixed positional and named args with ommitted args as out -args
486 obj
.optional6(inLong
, inLong2
, inLong3
, inLong4
)
489 obj
.optional7(,outLong2
, val3
:= outLong3
)
490 If inLong2
<> outLong2
Or inLong3
<> outLong3
Then
495 'test properties with additional arguments ------------------------------------
502 obj
.prpMultiArg1(0,0) = 0
503 'obj.prpMultiArg1 = 0
504 obj
.prpMultiArg1(inLong
,inLong2
) = inLong3
505 outLong3
= obj
.prpMultiArg1(outLong
, outLong2
)
506 If outLong
<> 10 Or outLong2
<> 02 Or outLong3
<> 30 Then
513 obj
.prpMultiArg1(0,0) = 0
514 obj
.prpMultiArg1(1) = 3
515 outLong2
= obj
.prpMultiArg1(outLong
)
516 If outLong
<> 1 Or outLong2
<> 3 Then
523 obj
.prpMultiArg1(0,0) = 0
524 obj
.prpMultiArg1(val2
:= 1) = 3
525 outLong2
= obj
.prpMultiArg1(val2
:=outLong
)
526 If outLong
<> 1 Or outLong2
<> 3 Then
533 obj
.prpMultiArg2(0) = 0
534 outLong
= obj
.prpMultiArg2GetValues(outLong
, outLong2
)
535 If outLong
<> 0 Or outLong2
<> 0 Then
543 obj
.prpMultiArg2(1) = 2
544 obj
.prpMultiArg2GetValues(outLong
, outLong2
)
545 If outLong
<> 1 Or outLong2
<> 2 Then
552 ' other tests ------------------------------------------------------------------
553 obj
.inObject(NOTHING)
555 'bridge should return an XInterface any with null pointer
556 'A basic errOr should occur if this is not the case
557 obj
.outObject(outObject
)
559 If Not IsNull(outObject
) Then
563 'Decimal passed by reference
564 inrefDecimal
= CDec("9223372036854775807") 'highest positiv value of int64
565 obj
.inrefDecimal(inrefDecimal
)
567 obj
.outDecimal(outrefDecimal
)
568 If inrefDecimal
<> outrefDecimal
Then
573 ' Test Automation object with dual interfaces ------------------------------------
574 dim dispatcher
as object
575 dim oExplorer
as object
576 dispatcher
= createUnoService("com.sun.star.bridge.OleObjectFactory")
577 oExplorer
= dispatcher
.createInstance("InternetExplorer.Application")
578 If Not IsNull(oExplorer
) Then
579 oExplorer
.visible
= true
580 oExplorer
.Navigate2("http://www.openoffice.org")
582 MsgBox("Could not perform test with Internet Explorer!")
588 'One dimensional arrays with simple types.
589 'lower bound must be 0
590 Function equalArrays(ar1
, ar2
)
593 len1
= UBound(ar1
) - LBound(ar1
) + 1
594 len2
= UBound(ar2
) - LBound(ar2
) + 1
600 FOr counter
= 0 To len1
- 1
601 If ar1(counter
) <> ar2(counter
) Then