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 .
23 Private objServiceManager
As Object
24 Private objCoreReflection
As Object
25 Private objOleTest
As Object
26 Private objEventListener
As Object
31 Dim outHyper
, inHyper
, retHyper
As Object
34 objServiceManager
= CreateObject("com.sun.star.ServiceManager")
35 objCoreReflection
= objServiceManager
.createInstance("com.sun.star.reflection.CoreReflection")
36 ' extensions/test/ole/cpnt
37 objOleTest
= objServiceManager
.createInstance("oletest.OleTest")
38 ' extensions/test/ole/EventListenerSample/VBEventListener
39 objEventListener
= CreateObject("VBasicEventListener.VBEventListener")
40 Debug
.Print(TypeName(objOleTest
))
48 ''dispose not working i103353
49 'testImplementedInterfaces()
55 Function testProps() As Object
57 Dim aToolbarItemProp1
As Object
58 aToolbarItemProp1
= objOleTest
.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
59 Dim aToolbarItemProp2
As Object
60 aToolbarItemProp2
= objOleTest
.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
61 Dim aToolbarItemProp3
As Object
62 aToolbarItemProp3
= objOleTest
.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
63 Dim properties(2) As Object
65 aToolbarItemProp1
.Name
= "CommandURL"
66 aToolbarItemProp1
.Value
= "macro:///standard.module1.TestIt"
67 aToolbarItemProp2
.Name
= "Label"
68 aToolbarItemProp2
.Value
= "Test"
69 aToolbarItemProp3
.Name
= "Type"
70 aToolbarItemProp3
.Value
= 0
72 properties(0) = aToolbarItemProp1
73 properties(1) = aToolbarItemProp2
74 properties(2) = aToolbarItemProp3
77 Dim dummy(-1) As Object
80 Desktop
= objServiceManager
.createInstance("com.sun.star.frame.Desktop")
82 Doc
= Desktop
.loadComponentFromURL("private:factory/swriter", "_blank", 2, dummy
)
83 Dim LayoutManager
As Object
84 LayoutManager
= Doc
.currentController
.Frame
.LayoutManager
86 LayoutManager
.createElement("private:resource/toolbar/user_toolbar1")
87 LayoutManager
.showElement("private:resource/toolbar/user_toolbar1")
89 ToolBar
= LayoutManager
.getElement("private:resource/toolbar/user_toolbar1")
90 Dim settings
As Object
91 settings
= ToolBar
.getSettings(True)
93 'the changes are here:
95 aany
= objServiceManager
.Bridge_GetValueObject()
96 Call aany
.Set("[]com.sun.star.beans.PropertyValue", properties
)
97 Call settings
.insertByIndex(0, aany
)
98 Call ToolBar
.setSettings(settings
)
104 Function testBasics() As Object
105 ' In Parameter, simple types
106 '============================================
109 Dim outByte
, inByte
, retByte
As Byte
110 Dim outBool
, inBool
, retBool
As Boolean
111 Dim outShort
, inShort
, retShort
As Short
112 Dim outUShort
, inUShort
, retUShort
As Short
113 Dim outLong
, inLong
, retLong
As Integer
114 Dim outULong
, inULong
, retULong
As Integer
115 Dim outHyper
, inHyper
, retHyper
As Object
116 Dim outUHyper
, inUHyper
, retUHyper
As Object
117 Dim outFloat
, inFloat
, retFloat
As Single
118 Dim outDouble
, inDouble
, retDouble
As Double
119 Dim outString
, inString
, retString
As String
120 Dim retChar
, inChar
, outChar
, retChar2
As Short
121 Dim outCharAsString
, inCharAsString
, retCharAsString
As String
122 Dim outAny
, inAny
, retAny
As Object
123 Dim outType
, inType
, retType
As Object
124 Dim outXInterface
, inXInterface
, retXInterface
As Object
125 Dim outXInterface2
, inXInterface2
, retXInterface2
As Object
128 Dim outVarByte
As Object
129 Dim outVarBool
As Object
130 Dim outVarShort
As Object
131 Dim outVarUShort
As Object
132 Dim outVarLong
As Object
133 Dim outVarULong
As Object
134 Dim outVarFloat
As Object
135 Dim outVarDouble
As Object
136 Dim outVarString
As Object
137 Dim outVarChar
As Object
138 Dim outVarAny
As Object
139 Dim outVarType
As Object
146 inHyper
= CDec("-9223372036854775808") 'lowest int64
147 inUHyper
= CDec("18446744073709551615") ' highest unsigned int64
151 inString
= "Hello World!"
154 inAny
= "Hello World"
155 inType
= objServiceManager
.Bridge_CreateType("[]long")
156 inXInterface
= objCoreReflection
157 inXInterface2
= objEventListener
159 retByte
= objOleTest
.in_methodByte(inByte
)
160 retBool
= objOleTest
.in_methodBool(inBool
)
161 retShort
= objOleTest
.in_methodShort(inShort
)
162 retUShort
= objOleTest
.in_methodUShort(inUShort
)
163 retLong
= objOleTest
.in_methodLong(inLong
)
164 retULong
= objOleTest
.in_methodULong(inULong
)
165 retHyper
= objOleTest
.in_methodHyper(inHyper
)
166 retUHyper
= objOleTest
.in_methodUHyper(inUHyper
)
167 retFloat
= objOleTest
.in_methodFloat(inFloat
)
168 retDouble
= objOleTest
.in_methodDouble(inDouble
)
169 retString
= objOleTest
.in_methodString(inString
)
170 retChar
= objOleTest
.in_methodChar(inChar
)
171 retChar2
= objOleTest
.in_methodChar(inCharAsString
)
172 retAny
= objOleTest
.in_methodAny(inAny
)
173 retType
= objOleTest
.in_methodType(inType
)
174 retXInterface
= objOleTest
.in_methodXInterface(inXInterface
) ' UNO object
175 retXInterface2
= objOleTest
.in_methodXInterface(inXInterface2
)
177 If retByte
<> inByte
Or retBool
<> inBool
Or retShort
<> inShort
Or retUShort
<> inUShort _
178 Or retLong
<> inLong
Or retULong
<> inULong
Or retHyper
<> inHyper _
179 Or retUHyper
<> inUHyper
Or retFloat
<> inFloat
Or retDouble
<> inDouble _
180 Or retString
<> inString
Or retChar
<> inChar
Or retChar2
<> Asc(inCharAsString
) _
181 Or retAny
<> inAny
Or Not (retType
.Name
= inType
.Name
) _
182 Or inXInterface IsNot retXInterface
Or inXInterface2 IsNot retXInterface2
Then
183 sError
= "in - parameter and return value test failed"
188 'Out Parameter simple types
189 '================================================
192 objOleTest
.testout_methodByte(outByte
)
193 objOleTest
.testout_methodFloat(outFloat
)
194 objOleTest
.testout_methodDouble(outDouble
)
195 objOleTest
.testout_methodBool(outBool
)
196 objOleTest
.testout_methodShort(outShort
)
197 objOleTest
.testout_methodUShort(outUShort
)
198 objOleTest
.testout_methodLong(outLong
)
199 objOleTest
.testout_methodULong(outULong
)
200 objOleTest
.testout_methodHyper(outHyper
)
201 objOleTest
.testout_methodUHyper(outUHyper
)
202 objOleTest
.testout_methodString(outString
)
203 objOleTest
.testout_methodChar(outChar
)
204 'outCharAsString is a string. Therefore the returned sal_Unicode value of 65 will be converted
206 objOleTest
.testout_methodChar(outCharAsString
)
207 objOleTest
.testout_methodAny(outAny
)
208 objOleTest
.testout_methodType(outType
)
209 'objOleTest.in_methodXInterface (inXInterface) ' UNO object
210 Call objOleTest
.in_methodXInterface(inXInterface
) ' UNO object
211 objOleTest
.testout_methodXInterface(outXInterface
)
212 Call objOleTest
.in_methodXInterface(inXInterface2
) ' COM object
213 objOleTest
.testout_methodXInterface(outXInterface2
)
215 If outByte
<> inByte
Or outFloat
<> inFloat
Or outDouble
<> inDouble _
216 Or outBool
<> inBool
Or outShort
<> inShort
Or outUShort
<> inUShort _
217 Or outLong
<> inLong
Or outULong
<> inULong
Or outHyper
<> inHyper _
218 Or outUHyper
<> inUHyper
Or outString
<> inString
Or outChar
<> inChar _
219 Or Not (outCharAsString
= "65") Or outAny
<> inAny _
220 Or Not (outType
.Name
= inType
.Name
) Or inXInterface IsNot outXInterface _
221 Or inXInterface2 IsNot outXInterface2
Then
223 sError
= "out - parameter test failed!"
227 'Out Parameter simple types (VARIANT var)
228 '====================================================
229 objOleTest
.testout_methodByte(outVarByte
)
230 objOleTest
.testout_methodBool(outVarBool
)
231 objOleTest
.testout_methodChar(outVarChar
)
232 objOleTest
.testout_methodShort(outVarShort
)
233 objOleTest
.testout_methodUShort(outVarUShort
)
234 objOleTest
.testout_methodLong(outVarLong
)
235 objOleTest
.testout_methodULong(outVarULong
)
236 objOleTest
.testout_methodString(outVarString
)
237 objOleTest
.testout_methodFloat(outVarFloat
)
238 objOleTest
.testout_methodDouble(outVarDouble
)
239 objOleTest
.testout_methodAny(outVarAny
)
240 objOleTest
.testout_methodType(outVarType
)
242 If outVarByte
<> inByte
Or outVarBool
<> inBool
Or outVarChar
<> inChar _
243 Or outVarShort
<> inShort
Or outVarUShort
<> inUShort _
244 Or outVarLong
<> inLong
Or outVarULong
<> inULong
Or outVarString
<> inString _
245 Or outVarFloat
<> inFloat
Or outVarDouble
<> inDouble
Or outVarAny
<> inAny _
246 Or Not (outVarType
.Name
= inType
.Name
) Then
247 sError
= "out - parameter (VARIANT) test failed!"
252 '============================================
253 objOleTest
.in_methodByte(0)
254 objOleTest
.in_methodBool(False)
255 objOleTest
.in_methodShort(0)
256 objOleTest
.in_methodUShort(0)
257 objOleTest
.in_methodLong(0)
258 objOleTest
.in_methodULong(0)
259 objOleTest
.in_methodHyper(0)
260 objOleTest
.in_methodUHyper(0)
261 objOleTest
.in_methodFloat(0)
262 objOleTest
.in_methodDouble(0)
263 objOleTest
.in_methodString(0)
264 objOleTest
.in_methodChar(0)
265 objOleTest
.in_methodAny(0)
266 objOleTest
.in_methodType(objServiceManager
.Bridge_CreateType("boolean"))
267 outXInterface
= Nothing
268 Call objOleTest
.in_methodXInterface(outXInterface
)
272 objOleTest
.testinout_methodByte(retByte
)
273 objOleTest
.testinout_methodByte(retByte
)
276 objOleTest
.testinout_methodBool(retBool
)
277 objOleTest
.testinout_methodBool(retBool
)
280 objOleTest
.testinout_methodShort(retShort
)
281 objOleTest
.testinout_methodShort(retShort
)
283 retUShort
= outUShort
284 objOleTest
.testinout_methodUShort(retUShort
)
285 objOleTest
.testinout_methodUShort(retUShort
)
288 objOleTest
.testinout_methodLong(retLong
)
289 objOleTest
.testinout_methodLong(retLong
)
292 objOleTest
.testinout_methodULong(retLong
)
293 objOleTest
.testinout_methodULong(retLong
)
294 outHyper
= CDec("9223372036854775807") 'highest positive value of int64
296 objOleTest
.testinout_methodHyper(retHyper
)
297 objOleTest
.testinout_methodHyper(retHyper
)
298 outUHyper
= CDec("18446744073709551615") 'highest value of unsigned int64
299 retUHyper
= outUHyper
300 objOleTest
.testinout_methodUHyper(retUHyper
)
301 objOleTest
.testinout_methodUHyper(retUHyper
)
304 objOleTest
.testinout_methodFloat(retFloat
)
305 objOleTest
.testinout_methodFloat(retFloat
)
307 retDouble
= outDouble
308 objOleTest
.testinout_methodDouble(retDouble
)
309 objOleTest
.testinout_methodDouble(retDouble
)
310 outString
= "Hello World!"
311 retString
= outString
312 objOleTest
.testinout_methodString(retString
)
313 objOleTest
.testinout_methodString(retString
)
316 objOleTest
.testinout_methodChar(retChar
)
317 objOleTest
.testinout_methodChar(retChar
)
318 outCharAsString
= "H"
319 retCharAsString
= outCharAsString
320 objOleTest
.testinout_methodChar(retCharAsString
)
321 objOleTest
.testinout_methodChar(retCharAsString
)
322 outAny
= "Hello World 2!"
324 objOleTest
.testinout_methodAny(retAny
)
325 objOleTest
.testinout_methodAny(retAny
)
326 outType
= objServiceManager
.Bridge_CreateType("long")
328 objOleTest
.testinout_methodType(retType
)
329 objOleTest
.testinout_methodType(retType
)
331 outXInterface
= objCoreReflection
332 retXInterface
= outXInterface
333 objOleTest
.testinout_methodXInterface2(retXInterface
)
335 If outByte
<> retByte
Or outBool
<> retBool
Or outShort
<> retShort _
336 Or outUShort
<> retUShort
Or outLong
<> retLong
Or outULong
<> retULong _
337 Or outHyper
<> retHyper
Or outUHyper
<> outUHyper _
338 Or outFloat
<> retFloat
Or outDouble
<> retDouble _
339 Or outString
<> retString
Or outChar
<> retChar _
340 Or outCharAsString
<> retCharAsString _
341 Or outAny
<> retAny
Or Not (outType
.Name
= retType
.Name
) _
342 Or outXInterface IsNot retXInterface
Then
343 sError
= "in/out - parameter test failed!"
348 objOleTest
.AByte
= inByte
350 retByte
= objOleTest
.AByte
351 objOleTest
.AFloat
= inFloat
353 retFloat
= objOleTest
.AFloat
354 objOleTest
.AType
= inType
357 retType
= objOleTest
.AType
359 If inByte
<> retByte
Or inFloat
<> retFloat
Or Not (inType
.Name
= retType
.Name
) Then
360 sError
= "Attributes - test failed!"
365 Function testHyper() As Object
367 '======================================================================
369 Dim emptyVar
As Object
373 inHyper
= CDec("9223372036854775807") 'highest positive value of int64
374 retAny
= objOleTest
.in_methodAny(inHyper
)
375 sError
= "hyper test failed"
376 If inHyper
<> retAny
Then
379 inHyper
= CDec("-9223372036854775808") 'lowest negative value of int64
380 retAny
= objOleTest
.in_methodAny(inHyper
)
382 If inHyper
<> retAny
Then
385 inHyper
= CDec("18446744073709551615") 'highest positive value of unsigned int64
386 retAny
= objOleTest
.in_methodAny(inHyper
)
388 If inHyper
<> retAny
Then
392 retAny
= objOleTest
.in_methodAny(inHyper
)
393 If inHyper
<> retAny
Then
397 retAny
= objOleTest
.in_methodAny(inHyper
)
398 If inHyper
<> retAny
Then
402 '==============================================================================
406 Function testAny() As Object
409 'Any test. We pass in an any as value object. If it is not correct converted
410 'then the target component throws a RuntimeException
411 Dim lengthInAny
As Integer
414 Dim seqLongInAny(10) As Integer
415 For i
= 0 To lengthInAny
- 1
416 seqLongInAny(i
) = i
+ 10
418 Dim anySeqLong
As Object
419 anySeqLong
= objOleTest
.Bridge_GetValueObject()
420 anySeqLong
.Set("[]long", seqLongInAny
)
421 Dim anySeqRet
As Object
424 anySeqRet
= objOleTest
.other_methodAny(anySeqLong
, "[]long")
426 If Err
.Number
<> 0 Then
431 Function testObjects() As Object
435 'OleTest receives a COM object that implements XEventListener
436 'OleTest then calls a disposing on the object. The object then will be
437 'asked if it has been called
438 objEventListener
.setQuiet(True)
439 objEventListener
.resetDisposing()
440 retObj
= objOleTest
.in_methodInvocation(objEventListener
)
442 ret
= objEventListener
.disposingCalled
447 'The returned object should be objEventListener, test it by calling disposing
448 ' takes an IDispatch as Param ( EventObject).To provide a TypeMismatch
449 'we put in another IDispatch
450 retObj
.resetDisposing()
451 retObj
.disposing(objEventListener
)
452 If retObj
.disposingCalled
= False Then
456 ' out param gives out the OleTestComponent
457 'objOleTest.testout_methodXInterface retObj
459 'retObj.testout_methodAny outVAr
460 'Debug.Print "test out Interface " & CStr(outVAr)
461 'If outVAr <> "I am a string in an any" Then
467 ' in: UNO object, the same is expected as out param
468 ' the function expects OleTest as parameter and sets a value
474 Dim objOleTest2
As Object
475 objOleTest2
= objServiceManager
.createInstance("oletest.OleTest")
477 objOleTest2
.AttrAny2
= "VBString "
479 'testinout_methodXInterfaces substitutes the argument with the object set in in_methodXInterface
480 objOleTest
.AttrAny2
= "VBString this string was written in the UNO component to the inout parameter"
481 objOleTest
.in_methodXInterface(objOleTest
)
482 objOleTest
.testinout_methodXInterface2(objOleTest2
)
484 tmpVar
= System
.DBNull
.Value
485 tmpVar
= objOleTest2
.AttrAny2
486 Debug
.Print("in: Uno out: the same object // " & CStr(tmpVar
))
487 If tmpVar
<> "VBString this string was written in the UNO component to the inout parameter" Then
493 Dim structClass
As Object
494 structClass
= objCoreReflection
.forName("oletest.SimpleStruct")
495 Dim structInstance
As Object
496 structClass
.CreateObject(structInstance
)
497 structInstance
.message
= "Now we are in VB"
498 Debug
.Print("struct out " & structInstance
.message
)
499 If structInstance
.message
<> "Now we are in VB" Then
503 'put the struct into OleTest. The same struct will be returned with an added String
504 Dim structRet
As Object
505 structRet
= objOleTest
.in_methodStruct(structInstance
)
506 Debug
.Print("struct in - return " & structRet
.message
)
507 If structRet
.message
<> "Now we are in VBThis string was set in OleTest" Then
513 Function testGetStruct() As Object
515 '========================================================
516 Dim objDocument
As Object
517 objDocument
= createHiddenDocument()
518 'dispose not working i103353
519 'objDocument.dispose()
520 objDocument
.close(True)
523 Function testImplementedInterfaces() As Object
524 'Bridge_ImplementedInterfaces
525 '=================================================
526 ' call a UNO function that takes an XEventListener interface
527 'We provide a COM implementation (IDispatch) as EventListener
528 'Open a new empty writer document
530 Dim objDocument
As Object
531 objDocument
= createHiddenDocument()
532 objEventListener
.resetDisposing()
533 objDocument
.addEventListener(objEventListener
)
534 objDocument
.dispose()
535 If objEventListener
.disposingCalled
= False Then
540 Function testGetValueObject() As Object
541 'Bridge_GetValueObject
542 '==================================================
544 objVal
= objOleTest
.Bridge_GetValueObject()
545 Dim arrByte(9) As Byte
546 Dim countvar
As Integer
547 For countvar
= 0 To 9
548 arrByte(countvar
) = countvar
551 objVal
.Set("[]byte", arrByte
)
554 ret
= objOleTest
.methodByte(objVal
)
555 'Test if ret is the same array
560 If ret(key
) <> arrByte(key
) Then
563 Debug
.Print(ret(key
))
570 objVal
.InitInOutParam("byte", retByte
)
571 objOleTest
.testinout_methodByte(objVal
)
572 objVal
.InitInOutParam("byte", retByte
)
573 objOleTest
.testinout_methodByte(objVal
)
578 If ret
<> outByte
Then
582 objVal
.InitOutParam()
585 objOleTest
.in_methodChar(inChar
)
586 objOleTest
.testout_methodChar(objVal
) 'Returns 'A' (65)
590 If ret
<> inChar
Then
596 Function testArrays() As Object
598 '========================================
599 Dim arrLong(2) As Integer
600 Dim arrObj(2) As Object
601 Dim countvar
As Integer
602 For countvar
= 0 To 2
603 arrLong(countvar
) = countvar
+ 10
604 Debug
.Print(countvar
)
605 arrObj(countvar
) = CreateObject("VBasicEventListener.VBEventListener")
606 arrObj(countvar
).setQuiet(True)
609 'Arrays always contain VARIANTS
611 seq
= objOleTest
.methodLong(arrLong
)
613 For countvar
= 0 To 2
614 Debug
.Print(CStr(seq(countvar
)))
615 If arrLong(countvar
) <> seq(countvar
) Then
619 seq
= objOleTest
.methodXInterface(arrObj
)
621 For countvar
= 0 To 2
622 seq(countvar
).resetDisposing()
623 seq(countvar
).disposing(CObj(tmp
))
624 If seq(countvar
).disposingCalled
= False Then
629 'Array containing interfaces (element type is VT_DISPATCH)
630 Dim arEventListener(2) As Object
631 For countvar
= 0 To 2
632 arEventListener(countvar
) = CreateObject("VBasicEventListener.VBEventListener")
633 arEventListener(countvar
).setQuiet(True)
636 'The function calls disposing on the listeners
637 seq
= objOleTest
.methodXEventListeners(arEventListener
)
639 For countvar
= 0 To 2
640 If arEventListener(countvar
).disposingCalled
= False Then
644 'Array containing interfaces (element type is VT_VARIANT which contains VT_DISPATCH
645 Dim arEventListener2(2) As Object
646 For countvar
= 0 To 2
647 arEventListener2(countvar
) = CreateObject("VBasicEventListener.VBEventListener")
648 arEventListener2(countvar
).setQuiet(True)
650 seq
= objOleTest
.methodXEventListeners(arEventListener2
)
651 For countvar
= 0 To 2
652 If arEventListener2(countvar
).disposingCalled
= False Then
657 'Variant containing Array containing interfaces (element type is VT_VARIANT which contains VT_DISPATCH
658 Dim arEventListener3(2) As Object
660 For countvar
= 0 To 2
661 arEventListener3(countvar
) = CreateObject("VBasicEventListener.VBEventListener")
662 arEventListener3(countvar
).setQuiet(True)
664 Dim varContAr
As Object
665 varContAr
= VB6
.CopyArray(arEventListener3
)
666 seq
= objOleTest
.methodXEventListeners(varContAr
)
667 For countvar
= 0 To 2
668 If arEventListener3(countvar
).disposingCalled
= False Then
673 'Get a sequence created in UNO, out param is Variant ( VT_BYREF|VT_VARIANT)
676 objOleTest
.testout_methodSequence(seqX
)
679 Debug
.Print(CStr(seqX(key
)))
680 If seqX(key
) <> key
Then
684 'Get a sequence created in UNO, out param is array Variant ( VT_BYREF|VT_VARIANT|VT_ARRAY)
685 Dim seqX2() As Object
686 objOleTest
.testout_methodSequence(seqX2
)
688 For Each key
In seqX2
689 Debug
.Print(CStr(seqX2(key
)))
692 'pass it to UNO and get it back
694 seq7
= objOleTest
.methodLong(seqX
)
696 For Each key2
In seq7
697 Debug
.Print(CStr(seq7(key2
)))
698 If seqX2(key
) <> key
Then
703 'array with starting index != 0
704 Dim seqIndex(2) As Integer
706 Dim longVal1
, longVal2
As Integer
709 seqIndex(1) = longVal1
710 seqIndex(2) = longVal2
711 'The bridge returns a Safearray of Variants. It does not yet convert to an _
712 'array of a particular type!
713 'Comparing of elements from seq8 (Object) with long values worked without _
714 'explicit cast as is necessary in VS 2008. Also arrays in VS 2008 start at _
716 seq8
= objOleTest
.methodLong(seqIndex
)
717 If longVal1
<> CInt(seq8(1)) And longVal2
<> CInt(seq8(2)) Then
722 ' arrLong is Long Array
723 Dim inoutVar(2) As Object
725 For countvar
= 0 To 2
726 inoutVar(countvar
) = countvar
+ 10
729 objOleTest
.testinout_methodSequence(inoutVar
)
732 For countvar
= 0 To 2
733 Debug
.Print(CStr(inoutVar(countvar
)))
734 If inoutVar(countvar
) <> countvar
+ 11 Then
739 'Multidimensional array
740 '============================================================
741 ' Sequence< Sequence<long> > methodSequence( Sequence< Sequence long> >)
742 ' Real multidimensional array Array
743 ' 9 is Dim 1 (least significant) with C API
744 Dim mulAr(9, 1) As Integer
747 mulAr(j
, i
) = i
* 10 + j
752 resMul
= objOleTest
.methodSequence(mulAr
)
754 Dim countDim1
As Integer
755 Dim countDim2
As Integer
757 For countDim2
= 0 To 1
758 arr
= resMul(countDim2
)
759 For countDim1
= 0 To 9
760 Debug
.Print(arr(countDim1
))
761 If arr(countDim1
) <> mulAr(countDim1
, countDim2
) Then
762 MsgBox("Error Multidimensional Array")
768 'Array of VARIANTs containing arrays
769 Dim mulAr2(1) As Object
770 Dim arr2(9) As Integer
776 mulAr2(i
) = VB6
.CopyArray(arr2
)
780 resMul
= objOleTest
.methodSequence(mulAr2
)
783 For countDim2
= 0 To 1
784 arr
= resMul(countDim2
)
785 tmpVar
= mulAr2(countDim2
)
786 For countDim1
= 0 To 9
787 Debug
.Print(arr(countDim1
))
788 If arr(countDim1
) <> tmpVar(countDim1
) Then
789 MsgBox("Error Multidimensional Array")
794 'Array containing interfaces (element type is VT_DISPATCH)
795 Dim arArEventListener(1, 2) As Object
798 arArEventListener(i
, j
) = CreateObject("VBasicEventListener.VBEventListener")
799 arArEventListener(i
, j
).setQuiet(True)
802 'The function calls disposing on the listeners
803 seq
= objOleTest
.methodXEventListenersMul(arArEventListener
)
806 If arArEventListener(i
, j
).disposingCalled
= False Then
812 'Array containing interfaces (element type is VT_VARIANT containing VT_DISPATCH)
813 Dim arArEventListener2(1, 2) As Object
816 arArEventListener2(i
, j
) = CreateObject("VBasicEventListener.VBEventListener")
817 arArEventListener2(i
, j
).setQuiet(True)
820 'The function calls disposing on the listeners
821 seq
= objOleTest
.methodXEventListenersMul(arArEventListener2
)
824 If arArEventListener2(i
, j
).disposingCalled
= False Then
830 ' SAFEARRAY of VARIANTS containing SAFEARRAYs
831 'The ultimate element type is VT_DISPATCH ( XEventListener)
832 Dim arEventListener4(1) As Object
833 Dim seq1(2) As Object
834 Dim seq2(2) As Object
836 seq1(i
) = CreateObject("VBasicEventListener.VBEventListener")
837 seq2(i
) = CreateObject("VBasicEventListener.VBEventListener")
838 seq1(i
).setQuiet(True)
839 seq2(i
).setQuiet(True)
841 arEventListener4(0) = VB6
.CopyArray(seq1
)
842 arEventListener4(1) = VB6
.CopyArray(seq2
)
843 'The function calls disposing on the listeners
844 seq
= objOleTest
.methodXEventListenersMul(arEventListener4
)
846 If seq1(i
).disposingCalled
= False Or seq2(i
).disposingCalled
= False Then
853 Function createHiddenDocument() As Object
854 'Try to create a hidden document
855 Dim objPropValue
As Object
856 objPropValue
= objOleTest
.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
857 'Set the members. If this fails then there is an Error
858 objPropValue
.Name
= "Hidden"
859 objPropValue
.Handle
= -1
860 objPropValue
.Value
= True
862 'create a hidden document
864 Dim objDesktop
As Object
865 objDesktop
= objServiceManager
.createInstance("com.sun.star.frame.Desktop")
866 'Open a new empty writer document
867 Dim args(0) As Object
868 args(0) = objPropValue
869 createHiddenDocument
= objDesktop
.loadComponentFromURL("private:factory/swriter", "_blank", 0, args
)