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 22 23 24Option Explicit On 25Option Strict On 26 27imports System 28imports uno 29imports uno.util 30imports unoidl.com.sun.star.lang 31imports unoidl.com.sun.star.uno 32imports unoidl.com.sun.star.test.bridge 33imports System.Windows.Forms 34imports System.Diagnostics 35imports System.Reflection 36 37 38Namespace vb_testobj 39Public Class VBBridgeTestObject 40 Inherits WeakBase 41 Implements XRecursiveCall, XBridgeTest2 42 43 Private m_xContext As XComponentContext 44 45 Public Sub New (xContext As XComponentContext) 46 MyBase.New 47 m_xContext = xContext 48 End Sub 49 50 Private m_bool As Boolean 51 Private m_char As Char 52 Private m_byte As Byte 53 Private m_short As Short 54 Private m_ushort As UInt16 55 Private m_long As Integer 56 Private m_ulong As UInt32 57 Private m_hyper As Long 58 Private m_uhyper As UInt64 59 Private m_float As Single 60 Private m_double As Double 61 Private m_string As String 62 Private m_xInterface As Object 63 Private m_any As Any 64 Private m_testEnum As TestEnum = TestEnum.TEST 65 Private m_testElements() As TestElement = New TestElement(){} 66 Private m_testDataElements As TestDataElements = New TestDataElements 67 Private m_nLastCallId As Integer = 0 68 Private m_bFirstCall As Boolean = True 69 Private m_bSequenceOfCallTestPassed As Boolean = True 70 71 Private m_arBool() As Boolean 72 Private m_arChar() As Char 73 Private m_arByte() As Byte 74 Private m_arShort() As Short 75 Private m_arLong() As Integer 76 Private m_arHyper() As Long 77 Private m_arUShort() As UInt16 78 Private m_arULong() As UInt32 79 Private m_arUHyper() As UInt64 80 Private m_arString() As String 81 Private m_arFloat() As Single 82 Private m_arDouble() As Double 83 Private m_arEnum() As TestEnum 84 Private m_arObject() As Object 85 Private m_arLong2()() As Integer 86 Private m_arLong3()()() As Integer 87 Private m_arAny() As Any 88 89 Public Overridable Sub setValues( _ 90 bBool As Boolean, aChar As Char, nByte As Byte, nShort As Short, _ 91 nUShort As UInt16, nLong As Integer, nULong As UInt32, _ 92 nHyper As Long, nUHyper As UInt64, fFloat As Single, _ 93 fDouble As Double, testEnum As TestEnum, str As String, _ 94 xInterface As Object, any As Any, testElements() As TestElement, _ 95 testDataElements As TestDataElements) _ 96 Implements XBridgeTest2.setValues 97#if DEBUG 98 ' Console.WriteLine( "##### " + GetType().FullName + ".setValues:" + any ) 99#endif 100 m_bool = bBool 101 m_char = aChar 102 m_byte = nByte 103 m_short = nShort 104 m_ushort = nUShort 105 m_long = nLong 106 m_ulong = nULong 107 m_hyper = nHyper 108 m_uhyper = nUHyper 109 m_float = fFloat 110 m_double = fDouble 111 m_testEnum = testEnum 112 m_string = str 113 m_xInterface = xInterface 114 m_any = any 115 m_testElements = testElements 116 m_testDataElements = testDataElements 117 End Sub 118 119 Public Overridable Function setValues2( _ 120 ByRef io_bool As Boolean, ByRef io_char As Char, _ 121 ByRef io_byte As Byte, ByRef io_short As Short, _ 122 ByRef io_ushort As UInt16, ByRef io_long As Integer, _ 123 ByRef io_ulong As UInt32, ByRef io_hyper As Long, _ 124 ByRef io_uhyper As UInt64, ByRef io_float As Single, _ 125 ByRef io_double As Double, ByRef io_testEnum As TestEnum, _ 126 ByRef io_string As String, ByRef io_xInterface As Object, _ 127 ByRef io_any As Any, ByRef io_testElements() As TestElement, _ 128 ByRef io_testDataElements As TestDataElements) As TestDataElements _ 129 Implements XBridgeTest2.setValues2 130 131#if DEBUG 132 'Console.WriteLine( "##### " + GetType().FullName + ".setValues2:" + io_any ) 133#endif 134 135 m_bool = io_bool 136 m_char = io_char 137 m_byte = io_byte 138 m_short = io_short 139 m_ushort = io_ushort 140 m_long = io_long 141 m_ulong = io_ulong 142 m_hyper = io_hyper 143 m_uhyper = io_uhyper 144 m_float = io_float 145 m_double = io_double 146 m_testEnum = io_testEnum 147 m_string = io_string 148 m_xInterface = io_xInterface 149 m_any = io_any 150 m_testElements = DirectCast(io_testElements.Clone(), TestElement()) 151 m_testDataElements = io_testDataElements 152 153 Dim temp As TestElement = io_testElements(0) 154 io_testElements(0) = io_testElements(1) 155 io_testElements(1) = temp 156 157 Return m_testDataElements 158 End Function 159 160 Public Overridable Function getValues( _ 161 ByRef o_bool As Boolean, ByRef o_char As Char, _ 162 ByRef o_byte As Byte, ByRef o_short As Short, _ 163 ByRef o_ushort As UInt16, ByRef o_long As Integer, _ 164 ByRef o_ulong As UInt32, ByRef o_hyper As Long, _ 165 ByRef o_uhyper As UInt64, ByRef o_float As Single, _ 166 ByRef o_double As Double, ByRef o_testEnum As TestEnum, _ 167 ByRef o_string As String, ByRef o_xInterface As Object, _ 168 ByRef o_any As Any, ByRef o_testElements() As TestElement, _ 169 ByRef o_testDataElements As TestDataElements) As TestDataElements _ 170 Implements XBridgeTest2.getValues 171#if DEBUG 172 'Console.WriteLine( "##### " + GetType().FullName + ".getValues" ) 173#endif 174 175 o_bool = m_bool 176 o_char = m_char 177 o_byte = m_byte 178 o_short = m_short 179 o_ushort = m_ushort 180 o_long = m_long 181 o_ulong = m_ulong 182 o_hyper = m_hyper 183 o_uhyper = m_uhyper 184 o_float = m_float 185 o_double = m_double 186 o_testEnum = m_testEnum 187 o_string = m_string 188 o_xInterface = m_xInterface 189 o_any = m_any 190 o_testElements = m_testElements 191 o_testDataElements = m_testDataElements 192 193 Return m_testDataElements 194 End Function 195 196 ' Attributes --------------------------------------------------------- 197 Public Overridable Property Bool As Boolean _ 198 Implements XBridgeTest2.Bool 199 Get 200 Return m_bool 201 End Get 202 Set (Value As Boolean) 203 m_bool = value 204 End Set 205 End Property 206 207 Public Overridable Property [Byte] As Byte _ 208 Implements XBridgeTest2.Byte 209 Get 210 Return m_byte 211 End Get 212 Set (Value As Byte) 213 m_byte = value 214 End Set 215 End Property 216 217 Public Overridable Property [Char] As Char _ 218 Implements XBridgeTest2.Char 219 Get 220 Return m_char 221 End Get 222 Set (Value As Char) 223 m_char = value 224 End Set 225 End Property 226 227 Public Overridable Property [Short] As Short _ 228 Implements XBridgeTest2.Short 229 Get 230 Return m_short 231 End Get 232 Set (Value As Short) 233 m_short = value 234 End Set 235 End Property 236 237 Public Overridable Property [UShort] As UInt16 _ 238 Implements XBridgeTest2.UShort 239 Get 240 Return m_ushort 241 End Get 242 Set (Value As UInt16) 243 m_ushort = value 244 End Set 245 End Property 246 247 Public Overridable Property [Long] As Integer _ 248 Implements XBridgeTest2.Long 249 Get 250 Return m_long 251 End Get 252 Set (Value As Integer) 253 m_long = value 254 End Set 255 End Property 256 257 Public Overridable Property [ULong]() As UInt32 _ 258 Implements XBridgeTest2.ULong 259 Get 260 Return m_ulong 261 End Get 262 Set (Value As UInt32) 263 m_ulong = value 264 End Set 265 End Property 266 267 Public Overridable Property Hyper As Long _ 268 Implements XBridgeTest2.Hyper 269 Get 270 Return m_hyper 271 End Get 272 Set (Value As Long) 273 m_hyper = value 274 End Set 275 End Property 276 277 Public Overridable Property UHyper As UInt64 _ 278 Implements XBridgeTest2.UHyper 279 Get 280 Return m_uhyper 281 End Get 282 Set (Value As UInt64) 283 m_uhyper = value 284 End Set 285 End Property 286 287 Public Overridable Property Float As Single _ 288 Implements XBridgeTest2.Float 289 Get 290 Return m_float 291 End Get 292 Set (Value As Single) 293 m_float = value 294 End Set 295 End Property 296 297 Public Overridable Property [Double] As Double _ 298 Implements XBridgeTest2.Double 299 Get 300 Return m_double 301 End Get 302 Set (Value As Double) 303 m_double = value 304 End Set 305 End Property 306 307 Public Overridable Property [Enum] As TestEnum _ 308 Implements XBridgeTest2.Enum 309 Get 310 Return m_testEnum 311 End Get 312 Set (Value As TestEnum) 313 m_testEnum = value 314 End Set 315 End Property 316 317 Public Overridable Property [String] As String _ 318 Implements XBridgeTest2.String 319 Get 320 Return m_string 321 End Get 322 Set (Value As String) 323 m_string = value 324 End Set 325 End Property 326 327 Public Overridable Property [Interface] As Object _ 328 Implements XBridgeTest2.Interface 329 Get 330 Return m_xInterface 331 End Get 332 Set (Value As Object) 333 m_xInterface = value 334 End Set 335 End Property 336 337 Public Overridable Property Any As uno.Any _ 338 Implements XBridgeTest2.Any 339 Get 340#if DEBUG 341' Console.WriteLine( "##### " + GetType().FullName + ".Any" ) 342#endif 343 Return m_any 344 End Get 345 Set (Value As Any) 346#if DEBUG 347 'Console.WriteLine( "##### " + GetType().FullName + ".Any:" + value ) 348#endif 349 m_any = value 350 End Set 351 End Property 352 353 Public Overridable Property Sequence As TestElement() _ 354 Implements XBridgeTest2.Sequence 355 Get 356 Return m_testElements 357 End Get 358 Set (Value() As TestElement) 359 m_testElements = value 360 End Set 361 End Property 362 363 Public Overridable Property Struct As TestDataElements _ 364 Implements XBridgeTest2.Struct 365 Get 366 Return m_testDataElements 367 End Get 368 Set (Value As TestDataElements) 369 m_testDataElements = value 370 End Set 371 End Property 372 373 Public Overridable Function transportAny(value As Any) As Any _ 374 Implements XBridgeTest2.transportAny 375 Return value 376 End Function 377 378 Public Overridable Sub [call](nCallId As Integer, nWaitMUSEC As Integer) _ 379 Implements XBridgeTest2.call 380 381 Threading.Thread.Sleep(CType(nWaitMUSEC / 10000, Integer)) 382 If m_bFirstCall = True 383 m_bFirstCall = False 384 Else 385 m_bSequenceOfCallTestPassed = m_bSequenceOfCallTestPassed And (nCallId > m_nLastCallId) 386 End If 387 m_nLastCallId = nCallId 388 End Sub 389 390 Public Overridable Sub callOneway(nCallId As Integer, nWaitMUSEC As Integer) _ 391 Implements XBridgeTest2.callOneway 392 393 Threading.Thread.Sleep(CType(nWaitMUSEC / 10000, Integer)) 394 m_bSequenceOfCallTestPassed = m_bSequenceOfCallTestPassed And (nCallId > m_nLastCallId) 395 m_nLastCallId = nCallId 396 End Sub 397 398 Public Overridable Function sequenceOfCallTestPassed() As Boolean _ 399 Implements XBridgeTest2.sequenceOfCallTestPassed 400 Return m_bSequenceOfCallTestPassed 401 End Function 402 403 Public Overridable Sub callRecursivly(xCall As XRecursiveCall, nToCall As Integer) _ 404 Implements XRecursiveCall.callRecursivly 405 SyncLock (Me) 406 If nToCall <> 0 407 nToCall = nToCall - 1 408 xCall.callRecursivly(Me , nToCall) 409 End If 410 End SyncLock 411 End Sub 412 413 Public Overridable Sub startRecursiveCall(xCall As XRecursiveCall, nToCall As Integer) _ 414 Implements XBridgeTest2.startRecursiveCall 415 SyncLock (Me) 416 If nToCall <> 0 417 nToCall = nToCall - 1 418 xCall.callRecursivly(Me , nToCall ) 419 End If 420 End SyncLock 421 End Sub 422 423 ' XBridgeTest 424 Public Overridable Function raiseException( _ 425 nArgumentPos As Short, rMsg As String, xContext As Object) As TestDataElements _ 426 Implements XBridgeTest2.raiseException 427 Throw New IllegalArgumentException(rMsg, xContext, nArgumentPos) 428 End Function 429 430 Public Overridable Sub raiseRuntimeExceptionOneway(rMsg As String , xContext As Object) _ 431 Implements XBridgeTest2.raiseRuntimeExceptionOneway 432 Throw New RuntimeException(rMsg, xContext) 433 End Sub 434 435 Public Overridable Property RuntimeException As Integer _ 436 Implements XBridgeTest2.RuntimeException 437 Get 438 Throw New RuntimeException(m_string, m_xInterface) 439 End Get 440 Set (Value As Integer) 441 Throw New RuntimeException(m_string, m_xInterface) 442 End Set 443 End Property 444 445 ' XBridgeTest2 446 Public Overridable Function setDim2(val()() As Integer) As Integer()() _ 447 Implements XBridgeTest2.setDim2 448 m_arLong2 = val 449 Return val 450 End Function 451 452 Public Overridable Function setDim3(val()()() As Integer) As Integer()()() _ 453 Implements XBridgeTest2.setDim3 454 m_arLong3 = val 455 Return val 456 End Function 457 458 Public Overridable Function setSequenceAny(val() As Any) As Any() _ 459 Implements XBridgeTest2.setSequenceAny 460 m_arAny = val 461 Return val 462 End Function 463 464 Public Overridable Function setSequenceBool(val() As Boolean) As Boolean() _ 465 Implements XBridgeTest2.setSequenceBool 466 m_arBool = val 467 Return val 468 End Function 469 470 Public Overridable Function setSequenceByte(val() As Byte) As Byte() _ 471 Implements XBridgeTest2.setSequenceByte 472 m_arByte = val 473 Return val 474 End Function 475 476 Public Overridable Function setSequenceChar(val() As Char) As Char() _ 477 Implements XBridgeTest2.setSequenceChar 478 m_arChar = val 479 Return val 480 End Function 481 482 Public Overridable Function setSequenceShort(val() As Short) As Short() _ 483 Implements XBridgeTest2.setSequenceShort 484 m_arShort = val 485 Return val 486 End Function 487 488 Public Overridable Function setSequenceLong(val() As Integer) As Integer() _ 489 Implements XBridgeTest2.setSequenceLong 490 491 m_arLong = val 492 Return val 493 End Function 494 495 Public Overridable Function setSequenceHyper(val() As Long) As Long() _ 496 Implements XBridgeTest2.setSequenceHyper 497 m_arHyper = val 498 Return val 499 End Function 500 501 Public Overridable Function setSequenceFloat(val() As Single) As Single() _ 502 Implements XBridgeTest2.setSequenceFloat 503 m_arFloat = val 504 Return val 505 End Function 506 507 Public Overridable Function setSequenceDouble(val() As Double) As Double() _ 508 Implements XBridgeTest2.setSequenceDouble 509 m_arDouble = val 510 Return val 511 End Function 512 513 Public Overridable Function setSequenceEnum(val() As TestEnum) As TestEnum() _ 514 Implements XBridgeTest2.setSequenceEnum 515 m_arEnum = val 516 Return val 517 End Function 518 519 Public Overridable Function setSequenceUShort(val() As UInt16) As UInt16() _ 520 Implements XBridgeTest2.setSequenceUShort 521 m_arUShort = val 522 Return val 523 End Function 524 525 Public Overridable Function setSequenceULong(val() As UInt32) As UInt32() _ 526 Implements XBridgeTest2.setSequenceULong 527 m_arULong = val 528 Return val 529 End Function 530 531 Public Overridable Function setSequenceUHyper(val() As UInt64) As UInt64() _ 532 Implements XBridgeTest2.setSequenceUHyper 533 m_arUHyper = val 534 Return val 535 End Function 536 537 Public Overridable Function setSequenceXInterface(val() As Object ) As Object() _ 538 Implements XBridgeTest2.setSequenceXInterface 539 m_arObject = val 540 Return val 541 End Function 542 543 Public Overridable Function setSequenceString(val() As String) As String() _ 544 Implements XBridgeTest2.setSequenceString 545 m_arString = val 546 Return val 547 End Function 548 549 Public Overridable Function setSequenceStruct(val() As TestElement) As TestElement() _ 550 Implements XBridgeTest2.setSequenceStruct 551 m_testElements = val 552 Return val 553 End Function 554 555 Public Overridable Sub setSequencesInOut( _ 556 ByRef aSeqBoolean() As Boolean, ByRef aSeqChar() As Char, _ 557 ByRef aSeqByte() As Byte, ByRef aSeqShort() As Short, _ 558 ByRef aSeqUShort() As UInt16, ByRef aSeqLong() As Integer, _ 559 ByRef aSeqULong() As UInt32, ByRef aSeqHyper() As Long, _ 560 ByRef aSeqUHyper() As UInt64, ByRef aSeqFloat() As Single, _ 561 ByRef aSeqDouble() As Double, ByRef aSeqTestEnum() As TestEnum, _ 562 ByRef aSeqString() As String, ByRef aSeqXInterface() As Object, _ 563 ByRef aSeqAny() As Any, ByRef aSeqDim2()() As Integer, _ 564 ByRef aSeqDim3()()() As Integer) _ 565 Implements XBridgeTest2.setSequencesInOut 566 567 m_arBool = aSeqBoolean 568 m_arChar = aSeqChar 569 m_arByte = aSeqByte 570 m_arShort = aSeqShort 571 m_arUShort = aSeqUShort 572 m_arLong = aSeqLong 573 m_arULong = aSeqULong 574 m_arHyper = aSeqHyper 575 m_arUHyper = aSeqUHyper 576 m_arFloat = aSeqFloat 577 m_arDouble = aSeqDouble 578 m_arEnum = aSeqTestEnum 579 m_arString = aSeqString 580 m_arObject = aSeqXInterface 581 m_arAny = aSeqAny 582 m_arLong2 = aSeqDim2 583 m_arLong3 = aSeqDim3 584 End Sub 585 586 Public Overridable Sub setSequencesOut( _ 587 ByRef aSeqBoolean() As Boolean, ByRef aSeqChar() As Char, _ 588 ByRef aSeqByte() As Byte, ByRef aSeqShort() As Short, _ 589 ByRef aSeqUShort() As UInt16, ByRef aSeqLong() As Integer, _ 590 ByRef aSeqULong() As UInt32, ByRef aSeqHyper() As Long, _ 591 ByRef aSeqUHyper() As UInt64, ByRef aSeqFloat() As Single, _ 592 ByRef aSeqDouble() As Double, ByRef aSeqTestEnum() As TestEnum, _ 593 ByRef aSeqString() As String, ByRef aSeqXInterface() As Object, _ 594 ByRef aSeqAny() As Any, ByRef aSeqDim2()() As Integer, _ 595 ByRef aSeqDim3()()() As Integer) _ 596 Implements XBridgeTest2.setSequencesOut 597 598 aSeqBoolean = m_arBool 599 aSeqChar = m_arChar 600 aSeqByte = m_arByte 601 aSeqShort = m_arShort 602 aSeqUShort = m_arUShort 603 aSeqLong = m_arLong 604 aSeqULong = m_arULong 605 aSeqHyper = m_arHyper 606 aSeqUHyper = m_arUHyper 607 aSeqFloat = m_arFloat 608 aSeqDouble = m_arDouble 609 aSeqTestEnum = m_arEnum 610 aSeqString = m_arString 611 aSeqXInterface = m_arObject 612 aSeqAny = m_arAny 613 aSeqDim2 = m_arLong2 614 aSeqDim3 = m_arLong3 615 616 End Sub 617 618End Class 619 620End Namespace 621