summaryrefslogtreecommitdiffstats
path: root/extensions/test/ole/VisualBasic/Module1.vb
blob: 63b8bbdeb17fd897a6383c9da921ba84efa1c545 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
'
' This file is part of the LibreOffice project.
'
' This Source Code Form is subject to the terms of the Mozilla Public
' License, v. 2.0. If a copy of the MPL was not distributed with this
' file, You can obtain one at http://mozilla.org/MPL/2.0/.
'
' This file incorporates work covered by the following license notice:
'
'   Licensed to the Apache Software Foundation (ASF) under one or more
'   contributor license agreements. See the NOTICE file distributed
'   with this work for additional information regarding copyright
'   ownership. The ASF licenses this file to you under the Apache
'   License, Version 2.0 (the "License"); you may not use this file
'   except in compliance with the License. You may obtain a copy of
'   the License at http://www.apache.org/licenses/LICENSE-2.0 .
'

Option Strict Off
Option Explicit On
Module Module1

Private objServiceManager As Object
Private objCoreReflection As Object
Private objOleTest As Object
Private objEventListener As Object
'General counter
Dim i As Integer
Dim j As Integer
Dim sError As String
Dim outHyper, inHyper, retHyper As Object

Public Sub Main()
        objServiceManager = CreateObject("com.sun.star.ServiceManager")
        objCoreReflection = objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
        ' extensions/test/ole/cpnt
        objOleTest = objServiceManager.createInstance("oletest.OleTest")
        ' extensions/test/ole/EventListenerSample/VBEventListener
        objEventListener = CreateObject("VBasicEventListener.VBEventListener")
        Debug.Print(TypeName(objOleTest))


        testBasics()
        testHyper()
        testAny()
        testObjects()
        testGetStruct()
        ''dispose not working i103353
        'testImplementedInterfaces()
        testGetValueObject()
        testArrays()
        testProps()

    End Sub
	Function testProps() As Object

		Dim aToolbarItemProp1 As Object
        aToolbarItemProp1 = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
		Dim aToolbarItemProp2 As Object
        aToolbarItemProp2 = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
		Dim aToolbarItemProp3 As Object
        aToolbarItemProp3 = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
		Dim properties(2) As Object

        aToolbarItemProp1.Name = "CommandURL"
        aToolbarItemProp1.Value = "macro:///standard.module1.TestIt"
        aToolbarItemProp2.Name = "Label"
        aToolbarItemProp2.Value = "Test"
        aToolbarItemProp3.Name = "Type"
        aToolbarItemProp3.Value = 0

		properties(0) = aToolbarItemProp1
		properties(1) = aToolbarItemProp2
		properties(2) = aToolbarItemProp3


        Dim dummy(-1) As Object
        
        Dim Desktop As Object
        Desktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
		Dim Doc As Object
        Doc = Desktop.loadComponentFromURL("private:factory/swriter", "_blank", 2, dummy)
		Dim LayoutManager As Object
        LayoutManager = Doc.currentController.Frame.LayoutManager

        LayoutManager.createElement("private:resource/toolbar/user_toolbar1")
        LayoutManager.showElement("private:resource/toolbar/user_toolbar1")
		Dim ToolBar As Object
        ToolBar = LayoutManager.getElement("private:resource/toolbar/user_toolbar1")
		Dim settings As Object
        settings = ToolBar.getSettings(True)

		'the changes are here:
		Dim aany As Object
        aany = objServiceManager.Bridge_GetValueObject()
        Call aany.Set("[]com.sun.star.beans.PropertyValue", properties)
        Call settings.insertByIndex(0, aany)
        Call ToolBar.setSettings(settings)


	End Function


	Function testBasics() As Object
		' In Parameter, simple types
		'============================================
		Dim tmpVar As Object
		Dim ret As Object
		Dim outByte, inByte, retByte As Byte
		Dim outBool, inBool, retBool As Boolean
		Dim outShort, inShort, retShort As Short
		Dim outUShort, inUShort, retUShort As Short
		Dim outLong, inLong, retLong As Integer
		Dim outULong, inULong, retULong As Integer
		Dim outHyper, inHyper, retHyper As Object
		Dim outUHyper, inUHyper, retUHyper As Object
		Dim outFloat, inFloat, retFloat As Single
		Dim outDouble, inDouble, retDouble As Double
		Dim outString, inString, retString As String
		Dim retChar, inChar, outChar, retChar2 As Short
		Dim outCharAsString, inCharAsString, retCharAsString As String
		Dim outAny, inAny, retAny As Object
		Dim outType, inType, retType As Object
		Dim outXInterface, inXInterface, retXInterface As Object
		Dim outXInterface2, inXInterface2, retXInterface2 As Object


		Dim outVarByte As Object
		Dim outVarBool As Object
		Dim outVarShort As Object
		Dim outVarUShort As Object
		Dim outVarLong As Object
		Dim outVarULong As Object
		Dim outVarFloat As Object
		Dim outVarDouble As Object
		Dim outVarString As Object
		Dim outVarChar As Object
		Dim outVarAny As Object
		Dim outVarType As Object

		inByte = 10
		inBool = True
		inShort = -10
		inUShort = -100
		inLong = -1000
        inHyper = CDec("-9223372036854775808") 'lowest int64
        inUHyper = CDec("18446744073709551615") ' highest unsigned int64
		inULong = 10000
		inFloat = 3.14
		inDouble = 3.14
		inString = "Hello World!"
		inChar = 65
		inCharAsString = "A"
        inAny = "Hello World"
        inType = objServiceManager.Bridge_CreateType("[]long")
		inXInterface = objCoreReflection
		inXInterface2 = objEventListener

        retByte = objOleTest.in_methodByte(inByte)
        retBool = objOleTest.in_methodBool(inBool)
        retShort = objOleTest.in_methodShort(inShort)
        retUShort = objOleTest.in_methodUShort(inUShort)
        retLong = objOleTest.in_methodLong(inLong)
        retULong = objOleTest.in_methodULong(inULong)
        retHyper = objOleTest.in_methodHyper(inHyper)
        retUHyper = objOleTest.in_methodUHyper(inUHyper)
        retFloat = objOleTest.in_methodFloat(inFloat)
        retDouble = objOleTest.in_methodDouble(inDouble)
        retString = objOleTest.in_methodString(inString)
        retChar = objOleTest.in_methodChar(inChar)
        retChar2 = objOleTest.in_methodChar(inCharAsString)
        retAny = objOleTest.in_methodAny(inAny)
        retType = objOleTest.in_methodType(inType)
        retXInterface = objOleTest.in_methodXInterface(inXInterface) ' UNO object
        retXInterface2 = objOleTest.in_methodXInterface(inXInterface2)

        If retByte <> inByte Or retBool <> inBool Or retShort <> inShort Or retUShort <> inUShort _
            Or retLong <> inLong Or retULong <> inULong Or retHyper <> inHyper _
            Or retUHyper <> inUHyper Or retFloat <> inFloat Or retDouble <> inDouble _
            Or retString <> inString Or retChar <> inChar Or retChar2 <> Asc(inCharAsString) _
            Or retAny <> inAny Or Not (retType.Name = inType.Name) _
            Or inXInterface IsNot retXInterface Or inXInterface2 IsNot retXInterface2 Then
            sError = "in - parameter and return value test failed"
            MsgBox(sError)

        End If
 
        'Out Parameter simple types
        '================================================


        objOleTest.testout_methodByte(outByte)
        objOleTest.testout_methodFloat(outFloat)
        objOleTest.testout_methodDouble(outDouble)
        objOleTest.testout_methodBool(outBool)
        objOleTest.testout_methodShort(outShort)
        objOleTest.testout_methodUShort(outUShort)
        objOleTest.testout_methodLong(outLong)
        objOleTest.testout_methodULong(outULong)
        objOleTest.testout_methodHyper(outHyper)
        objOleTest.testout_methodUHyper(outUHyper)
        objOleTest.testout_methodString(outString)
        objOleTest.testout_methodChar(outChar)
        'outCharAsString is a string. Therefore the returned sal_Unicode value of 65 will be converted
        'to a string "65"
        objOleTest.testout_methodChar(outCharAsString)
        objOleTest.testout_methodAny(outAny)
        objOleTest.testout_methodType(outType)
        'objOleTest.in_methodXInterface (inXInterface) ' UNO object
        Call objOleTest.in_methodXInterface(inXInterface) ' UNO object
        objOleTest.testout_methodXInterface(outXInterface)
        Call objOleTest.in_methodXInterface(inXInterface2) ' COM object
        objOleTest.testout_methodXInterface(outXInterface2)

        If outByte <> inByte Or outFloat <> inFloat Or outDouble <> inDouble _
            Or outBool <> inBool Or outShort <> inShort Or outUShort <> inUShort _
            Or outLong <> inLong Or outULong <> inULong Or outHyper <> inHyper _
            Or outUHyper <> inUHyper Or outString <> inString Or outChar <> inChar _
            Or Not (outCharAsString = "65") Or outAny <> inAny _
            Or Not (outType.Name = inType.Name) Or inXInterface IsNot outXInterface _
            Or inXInterface2 IsNot outXInterface2 Then

            sError = "out - parameter test failed!"
            MsgBox(sError)
        End If

        'Out Parameter simple types (VARIANT var)
        '====================================================
        objOleTest.testout_methodByte(outVarByte)
        objOleTest.testout_methodBool(outVarBool)
        objOleTest.testout_methodChar(outVarChar)
        objOleTest.testout_methodShort(outVarShort)
        objOleTest.testout_methodUShort(outVarUShort)
        objOleTest.testout_methodLong(outVarLong)
        objOleTest.testout_methodULong(outVarULong)
        objOleTest.testout_methodString(outVarString)
        objOleTest.testout_methodFloat(outVarFloat)
        objOleTest.testout_methodDouble(outVarDouble)
        objOleTest.testout_methodAny(outVarAny)
        objOleTest.testout_methodType(outVarType)

        If outVarByte <> inByte Or outVarBool <> inBool Or outVarChar <> inChar _
            Or outVarShort <> inShort Or outVarUShort <> inUShort _
            Or outVarLong <> inLong Or outVarULong <> inULong Or outVarString <> inString _
            Or outVarFloat <> inFloat Or outVarDouble <> inDouble Or outVarAny <> inAny _
            Or Not (outVarType.Name = inType.Name) Then
            sError = "out - parameter (VARIANT) test failed!"
            MsgBox(sError)
        End If

        'In/Out simple types
        '============================================
        objOleTest.in_methodByte(0)
        objOleTest.in_methodBool(False)
        objOleTest.in_methodShort(0)
        objOleTest.in_methodUShort(0)
        objOleTest.in_methodLong(0)
        objOleTest.in_methodULong(0)
        objOleTest.in_methodHyper(0)
        objOleTest.in_methodUHyper(0)
        objOleTest.in_methodFloat(0)
        objOleTest.in_methodDouble(0)
        objOleTest.in_methodString(0)
        objOleTest.in_methodChar(0)
        objOleTest.in_methodAny(0)
        objOleTest.in_methodType(objServiceManager.Bridge_CreateType("boolean"))
        outXInterface = Nothing
        Call objOleTest.in_methodXInterface(outXInterface)

        outByte = 10
        retByte = outByte
        objOleTest.testinout_methodByte(retByte)
        objOleTest.testinout_methodByte(retByte)
        outBool = True
        retBool = outBool
        objOleTest.testinout_methodBool(retBool)
        objOleTest.testinout_methodBool(retBool)
        outShort = 10
        retShort = outShort
        objOleTest.testinout_methodShort(retShort)
        objOleTest.testinout_methodShort(retShort)
        outUShort = 20
        retUShort = outUShort
        objOleTest.testinout_methodUShort(retUShort)
        objOleTest.testinout_methodUShort(retUShort)
        outLong = 30
        retLong = outLong
        objOleTest.testinout_methodLong(retLong)
        objOleTest.testinout_methodLong(retLong)
        outULong = 40
        retULong = outULong
        objOleTest.testinout_methodULong(retLong)
        objOleTest.testinout_methodULong(retLong)
        outHyper = CDec("9223372036854775807") 'highest positive value of int64
        retHyper = outHyper
        objOleTest.testinout_methodHyper(retHyper)
        objOleTest.testinout_methodHyper(retHyper)
        outUHyper = CDec("18446744073709551615") 'highest value of unsigned int64
        retUHyper = outUHyper
        objOleTest.testinout_methodUHyper(retUHyper)
        objOleTest.testinout_methodUHyper(retUHyper)
        outFloat = 3.14
        retFloat = outFloat
        objOleTest.testinout_methodFloat(retFloat)
        objOleTest.testinout_methodFloat(retFloat)
        outDouble = 4.14
        retDouble = outDouble
        objOleTest.testinout_methodDouble(retDouble)
        objOleTest.testinout_methodDouble(retDouble)
        outString = "Hello World!"
        retString = outString
        objOleTest.testinout_methodString(retString)
        objOleTest.testinout_methodString(retString)
        outChar = 66
        retChar = outChar
        objOleTest.testinout_methodChar(retChar)
        objOleTest.testinout_methodChar(retChar)
        outCharAsString = "H"
        retCharAsString = outCharAsString
        objOleTest.testinout_methodChar(retCharAsString)
        objOleTest.testinout_methodChar(retCharAsString)
        outAny = "Hello World 2!"
        retAny = outAny
        objOleTest.testinout_methodAny(retAny)
        objOleTest.testinout_methodAny(retAny)
        outType = objServiceManager.Bridge_CreateType("long")
        retType = outType
        objOleTest.testinout_methodType(retType)
        objOleTest.testinout_methodType(retType)

        outXInterface = objCoreReflection
        retXInterface = outXInterface
        objOleTest.testinout_methodXInterface2(retXInterface)

        If outByte <> retByte Or outBool <> retBool Or outShort <> retShort _
            Or outUShort <> retUShort Or outLong <> retLong Or outULong <> retULong _
            Or outHyper <> retHyper Or outUHyper <> outUHyper _
            Or outFloat <> retFloat Or outDouble <> retDouble _
            Or outString <> retString Or outChar <> retChar _
            Or outCharAsString <> retCharAsString _
            Or outAny <> retAny Or Not (outType.Name = retType.Name) _
            Or outXInterface IsNot retXInterface Then
            sError = "in/out - parameter test failed!"
            MsgBox(sError)
        End If

        'Attributes
        objOleTest.AByte = inByte
        retByte = 0
        retByte = objOleTest.AByte
        objOleTest.AFloat = inFloat
        retFloat = 0
        retFloat = objOleTest.AFloat
        objOleTest.AType = inType
        retType = Nothing

        retType = objOleTest.AType

        If inByte <> retByte Or inFloat <> retFloat Or Not (inType.Name = retType.Name) Then
            sError = "Attributes - test failed!"
            MsgBox(sError)
        End If

    End Function
	Function testHyper() As Object

		'======================================================================
		' Other Hyper tests
		Dim emptyVar As Object
		Dim retAny As Object

		retAny = emptyVar
		inHyper = CDec("9223372036854775807") 'highest positive value of int64
		retAny = objOleTest.in_methodAny(inHyper)
		sError = "hyper test failed"
		If inHyper <> retAny Then
			MsgBox(sError)
		End If
		inHyper = CDec("-9223372036854775808") 'lowest negative value of int64
		retAny = objOleTest.in_methodAny(inHyper)

		If inHyper <> retAny Then
			MsgBox(sError)
		End If
		inHyper = CDec("18446744073709551615") 'highest positive value of unsigned int64
		retAny = objOleTest.in_methodAny(inHyper)

		If inHyper <> retAny Then
			MsgBox(sError)
		End If
		inHyper = CDec(-1)
		retAny = objOleTest.in_methodAny(inHyper)
		If inHyper <> retAny Then
			MsgBox(sError)
		End If
		inHyper = CDec(0)
		retAny = objOleTest.in_methodAny(inHyper)
		If inHyper <> retAny Then
			MsgBox(sError)
		End If

		'==============================================================================


	End Function
	Function testAny() As Object
		Dim outVAr As Object

		'Any test. We pass in an any as value object. If it is not correct converted
		'then the target component throws a RuntimeException
		Dim lengthInAny As Integer

		lengthInAny = 10
		Dim seqLongInAny(10) As Integer
		For i = 0 To lengthInAny - 1
			seqLongInAny(i) = i + 10
		Next 
		Dim anySeqLong As Object
		anySeqLong = objOleTest.Bridge_GetValueObject()
		anySeqLong.Set("[]long", seqLongInAny)
		Dim anySeqRet As Object
		Err.Clear()
		On Error Resume Next
		anySeqRet = objOleTest.other_methodAny(anySeqLong, "[]long")

		If Err.Number <> 0 Then
			MsgBox("error")
		End If
	End Function

	Function testObjects() As Object
		' COM obj
		Dim outVAr As Object
		Dim retObj As Object
		'OleTest receives a COM object that implements XEventListener
		'OleTest then calls a disposing on the object. The object then will be
		'asked if it has been called
		objEventListener.setQuiet(True)
		objEventListener.resetDisposing()
		retObj = objOleTest.in_methodInvocation(objEventListener)
		Dim ret As Object
		ret = objEventListener.disposingCalled
		If ret = False Then
			MsgBox("Error")
		End If

		'The returned object should be objEventListener, test it by calling disposing
		' takes an IDispatch as Param ( EventObject).To provide a TypeMismatch
		'we put in another IDispatch
		retObj.resetDisposing()
		retObj.disposing(objEventListener)
		If retObj.disposingCalled = False Then
			MsgBox("Error")
		End If

		' out param gives out the OleTestComponent
		'objOleTest.testout_methodXInterface retObj
		'outVAr = Null
		'retObj.testout_methodAny outVAr
		'Debug.Print "test out Interface " & CStr(outVAr)
		'If outVAr <> "I am a string in an any" Then
		'    MsgBox "error"
		'End If


		'in out
		' in: UNO object, the same is expected as out param
		' the function expects OleTest as parameter and sets a value

		Dim myAny As Object



		Dim objOleTest2 As Object
		objOleTest2 = objServiceManager.createInstance("oletest.OleTest")
		'Set a value
		objOleTest2.AttrAny2 = "VBString "

		'testinout_methodXInterfaces substitutes the argument with the object set in in_methodXInterface
		objOleTest.AttrAny2 = "VBString  this string was written in the UNO component to the inout pararmeter"
		objOleTest.in_methodXInterface(objOleTest)
		objOleTest.testinout_methodXInterface2(objOleTest2)
		Dim tmpVar As Object
		tmpVar = System.DBNull.Value
		tmpVar = objOleTest2.AttrAny2
		Debug.Print("in: Uno out: the same object // " & CStr(tmpVar))
		If tmpVar <> "VBString  this string was written in the UNO component to the inout pararmeter" Then
			MsgBox("error")
		End If


		'create a struct
		Dim structClass As Object
		structClass = objCoreReflection.forName("oletest.SimpleStruct")
		Dim structInstance As Object
		structClass.CreateObject(structInstance)
		structInstance.message = "Now we are in VB"
		Debug.Print("struct out " & structInstance.message)
		If structInstance.message <> "Now we are in VB" Then
			MsgBox("error")
		End If

		'put the struct into OleTest. The same struct will be returned with an added String
		Dim structRet As Object
		structRet = objOleTest.in_methodStruct(structInstance)
		Debug.Print("struct in - return " & structRet.message)
		If structRet.message <> "Now we are in VBThis string was set in OleTest" Then
			MsgBox("error")
		End If


	End Function
	Function testGetStruct() As Object
		'Bridge_GetStruct
		'========================================================
		Dim objDocument As Object
        objDocument = createHiddenDocument()
        'dispose not working i103353
        'objDocument.dispose()
        objDocument.close(True)
	End Function

	Function testImplementedInterfaces() As Object
		'Bridge_ImplementedInterfaces
		'=================================================
		' call a UNO function that takes an XEventListener interface
		'We provide a COM implementation (IDispatch) as EventListener
		'Open a new empty writer document

		Dim objDocument As Object
		objDocument = createHiddenDocument()
		objEventListener.resetDisposing()
		objDocument.addEventListener(objEventListener)
		objDocument.dispose()
		If objEventListener.disposingCalled = False Then
			MsgBox("Error")
		End If
	End Function

	Function testGetValueObject() As Object
		'Bridge_GetValueObject
		'==================================================
		Dim objVal As Object
		objVal = objOleTest.Bridge_GetValueObject()
		Dim arrByte(9) As Byte
		Dim countvar As Integer
		For countvar = 0 To 9
			arrByte(countvar) = countvar
		Next countvar

		objVal.Set("[]byte", arrByte)
		Dim ret As Object
		ret = 0
		ret = objOleTest.methodByte(objVal)
		'Test if ret is the same array

		Dim key As Object
		key = 0
		For	Each key In ret
			If ret(key) <> arrByte(key) Then
				MsgBox("Error")
			End If
			Debug.Print(ret(key))
		Next key

		Dim outByte As Byte
		outByte = 77
		Dim retByte As Byte
		retByte = outByte
		objVal.InitInOutParam("byte", retByte)
		objOleTest.testinout_methodByte(objVal)
		objVal.InitInOutParam("byte", retByte)
		objOleTest.testinout_methodByte(objVal)

		ret = 0
		ret = objVal.Get()
		Debug.Print(ret)
		If ret <> outByte Then
			MsgBox("error")
		End If

		objVal.InitOutParam()
		Dim inChar As Short
		inChar = 65
		objOleTest.in_methodChar(inChar)
		objOleTest.testout_methodChar(objVal) 'Returns 'A' (65)
		ret = 0
		ret = objVal.Get()
		Debug.Print(ret)
		If ret <> inChar Then
			MsgBox("error")
		End If

	End Function

	Function testArrays() As Object
		'Arrays
		'========================================
		Dim arrLong(2) As Integer
		Dim arrObj(2) As Object
		Dim countvar As Integer
		For countvar = 0 To 2
			arrLong(countvar) = countvar + 10
			Debug.Print(countvar)
			arrObj(countvar) = CreateObject("VBasicEventListener.VBEventListener")
			arrObj(countvar).setQuiet(True)
		Next 

		'Arrays always contain VARIANTS
		Dim seq() As Object
		seq = objOleTest.methodLong(arrLong)

		For countvar = 0 To 2
			Debug.Print(CStr(seq(countvar)))
			If arrLong(countvar) <> seq(countvar) Then
				MsgBox("error")
			End If
		Next 
		seq = objOleTest.methodXInterface(arrObj)
		Dim tmp As Object
		For countvar = 0 To 2
			seq(countvar).resetDisposing()
            seq(countvar).disposing(CObj(tmp))
			If seq(countvar).disposingCalled = False Then
				MsgBox("Error")
			End If
		Next 

		'Array containing interfaces (element type is VT_DISPATCH)
		Dim arEventListener(2) As Object
		For countvar = 0 To 2
			arEventListener(countvar) = CreateObject("VBasicEventListener.VBEventListener")
			arEventListener(countvar).setQuiet(True)
		Next 

		'The function calls disposing on the listeners
		seq = objOleTest.methodXEventListeners(arEventListener)
		Dim count As Object
		For countvar = 0 To 2
			If arEventListener(countvar).disposingCalled = False Then
				MsgBox("Error")
			End If
		Next 
		'Array containing interfaces (element type is VT_VARIANT which contains VT_DISPATCH
		Dim arEventListener2(2) As Object
		For countvar = 0 To 2
			arEventListener2(countvar) = CreateObject("VBasicEventListener.VBEventListener")
			arEventListener2(countvar).setQuiet(True)
		Next 
		seq = objOleTest.methodXEventListeners(arEventListener2)
		For countvar = 0 To 2
			If arEventListener2(countvar).disposingCalled = False Then
				MsgBox("Error")
			End If
		Next 

		'Variant containing Array containing interfaces (element type is VT_VARIANT which contains VT_DISPATCH
		Dim arEventListener3(2) As Object
		Dim var As Object
		For countvar = 0 To 2
			arEventListener3(countvar) = CreateObject("VBasicEventListener.VBEventListener")
			arEventListener3(countvar).setQuiet(True)
		Next 
		Dim varContAr As Object
		varContAr = VB6.CopyArray(arEventListener3)
		seq = objOleTest.methodXEventListeners(varContAr)
		For countvar = 0 To 2
			If arEventListener3(countvar).disposingCalled = False Then
				MsgBox("Error")
			End If
		Next 

		'Get a sequence created in UNO, out param is Variant ( VT_BYREF|VT_VARIANT)
		Dim seqX As Object

		objOleTest.testout_methodSequence(seqX)
		Dim key As Object
		For	Each key In seqX
			Debug.Print(CStr(seqX(key)))
			If seqX(key) <> key Then
				MsgBox("error")
			End If
		Next key
		'Get a sequence created in UNO, out param is array Variant ( VT_BYREF|VT_VARIANT|VT_ARRAY)
		Dim seqX2() As Object
		objOleTest.testout_methodSequence(seqX2)

		For	Each key In seqX2
			Debug.Print(CStr(seqX2(key)))
		Next key

		'pass it to UNO and get it back
		Dim seq7() As Object
		seq7 = objOleTest.methodLong(seqX)
		Dim key2 As Object
		For	Each key2 In seq7
			Debug.Print(CStr(seq7(key2)))
			If seqX2(key) <> key Then
				MsgBox("error")
			End If
		Next key2

		'array with starting index != 0
		Dim seqIndex(2) As Integer
        Dim seq8() As Object
		Dim longVal1, longVal2 As Integer
		longVal1 = 1
		longVal2 = 2
		seqIndex(1) = longVal1
        seqIndex(2) = longVal2
        'The bridge returns a Safearray of Variants. It does not yet convert to an _
        'array of a particular type!
        'Comparing of elements from seq8 (Object) with long values worked without _
        'explicit cast as is necessary in VS 2008. Also arrays in VS 2008 start at _
        'index 0
        seq8 = objOleTest.methodLong(seqIndex)
        If longVal1 <> CInt(seq8(1)) And longVal2 <> CInt(seq8(2)) Then
            MsgBox("error")
        End If

		'in out Array
		' arrLong is Long Array
		Dim inoutVar(2) As Object

		For countvar = 0 To 2
			inoutVar(countvar) = countvar + 10
		Next 

		objOleTest.testinout_methodSequence(inoutVar)

		countvar = 0
		For countvar = 0 To 2
			Debug.Print(CStr(inoutVar(countvar)))
			If inoutVar(countvar) <> countvar + 11 Then
				MsgBox("error")
			End If
		Next 

		'Multidimensional array
		'============================================================
		' Sequence< Sequence<long> > methodSequence( Sequence< Sequence long> >)
		' Real multidimensional array Array
		' 9 is Dim 1 (least significant) with C API
		Dim mulAr(9, 1) As Integer
		For i = 0 To 1
			For j = 0 To 9
				mulAr(j, i) = i * 10 + j
			Next j
		Next i

		Dim resMul As Object
		resMul = objOleTest.methodSequence(mulAr)

		Dim countDim1 As Integer
		Dim countDim2 As Integer
		Dim arr As Object
		For countDim2 = 0 To 1
			arr = resMul(countDim2)
			For countDim1 = 0 To 9
				Debug.Print(arr(countDim1))
				If arr(countDim1) <> mulAr(countDim1, countDim2) Then
					MsgBox("Error Multidimensional Array")
				End If
			Next countDim1
		Next countDim2
		IsArray(resMul)

		'Array of VARIANTs containing arrays
		Dim mulAr2(1) As Object
		Dim arr2(9) As Integer
		For i = 0 To 1
			' Dim arr(9) As Long
			For j = 0 To 9
				arr2(j) = i * 10 + j
			Next j
			mulAr2(i) = VB6.CopyArray(arr2)
		Next i

		resMul = 0
		resMul = objOleTest.methodSequence(mulAr2)
		arr = 0
		Dim tmpVar As Object
		For countDim2 = 0 To 1
			arr = resMul(countDim2)
			tmpVar = mulAr2(countDim2)
			For countDim1 = 0 To 9
				Debug.Print(arr(countDim1))
				If arr(countDim1) <> tmpVar(countDim1) Then
					MsgBox("Error Multidimensional Array")
				End If
			Next countDim1
		Next countDim2

		'Array containing interfaces (element type is VT_DISPATCH)
		Dim arArEventListener(1, 2) As Object
		For i = 0 To 1
			For j = 0 To 2
				arArEventListener(i, j) = CreateObject("VBasicEventListener.VBEventListener")
				arArEventListener(i, j).setQuiet(True)
			Next 
		Next 
		'The function calls disposing on the listeners
		seq = objOleTest.methodXEventListenersMul(arArEventListener)
		For i = 0 To 1
			For j = 0 To 2
				If arArEventListener(i, j).disposingCalled = False Then
					MsgBox("Error")
				End If
			Next 
		Next 

		'Array containing interfaces (element type is VT_VARIANT containing VT_DISPATCH)
		Dim arArEventListener2(1, 2) As Object
		For i = 0 To 1
			For j = 0 To 2
				arArEventListener2(i, j) = CreateObject("VBasicEventListener.VBEventListener")
				arArEventListener2(i, j).setQuiet(True)
			Next 
		Next 
		'The function calls disposing on the listeners
		seq = objOleTest.methodXEventListenersMul(arArEventListener2)
		For i = 0 To 1
			For j = 0 To 2
				If arArEventListener2(i, j).disposingCalled = False Then
					MsgBox("Error")
				End If
			Next 
		Next 

		' SAFEARRAY of VARIANTS containing SAFEARRAYs
		'The ultimate element type is VT_DISPATCH ( XEventListener)
		Dim arEventListener4(1) As Object
		Dim seq1(2) As Object
		Dim seq2(2) As Object
		For i = 0 To 2
			seq1(i) = CreateObject("VBasicEventListener.VBEventListener")
			seq2(i) = CreateObject("VBasicEventListener.VBEventListener")
			seq1(i).setQuiet(True)
			seq2(i).setQuiet(True)
		Next 
		arEventListener4(0) = VB6.CopyArray(seq1)
		arEventListener4(1) = VB6.CopyArray(seq2)
		'The function calls disposing on the listeners
		seq = objOleTest.methodXEventListenersMul(arEventListener4)
		For i = 0 To 2
			If seq1(i).disposingCalled = False Or seq2(i).disposingCalled = False Then
				MsgBox("Error")
			End If
		Next 

	End Function

	Function createHiddenDocument() As Object
		'Try to create a hidden document
		Dim objPropValue As Object
		objPropValue = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
		'Set the members. If this fails then there is an Error
        objPropValue.Name = "Hidden"
		objPropValue.Handle = -1
		objPropValue.Value = True

		'create a hidden document
		'Create the Desktop
		Dim objDesktop As Object
		objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
		'Open a new empty writer document
		Dim args(0) As Object
		args(0) = objPropValue
		createHiddenDocument = objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
	End Function
End Module