1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="accessibility_XAccessibleContext" script:language="StarBasic"> 4 5 6'************************************************************************* 7' 8' Licensed to the Apache Software Foundation (ASF) under one 9' or more contributor license agreements. See the NOTICE file 10' distributed with this work for additional information 11' regarding copyright ownership. The ASF licenses this file 12' to you under the Apache License, Version 2.0 (the 13' "License"); you may not use this file except in compliance 14' with the License. You may obtain a copy of the License at 15' 16' http://www.apache.org/licenses/LICENSE-2.0 17' 18' Unless required by applicable law or agreed to in writing, 19' software distributed under the License is distributed on an 20' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21' KIND, either express or implied. See the License for the 22' specific language governing permissions and limitations 23' under the License. 24' 25'************************************************************************* 26 27 28 29 30 31' Be sure that all variables are dimensioned: 32option explicit 33 34 35 36 37Sub RunTest() 38 39'************************************************************************* 40' INTERFACE: 41' com.sun.star.accessibility.XAccessibleContext 42'************************************************************************* 43On Error Goto ErrHndl 44 Dim bOK As Boolean 45 Dim childCount As Long, i As Integer 46 Dim oParent As Object 47 48 Test.StartMethod("getAccessibleChildCount()") 49 bOK = true 50 childCount = oObj.getAccessibleChildCount() 51 bOK = bOK AND (childCount > -1) 52 Test.MethodTested("getAccessibleChildCount()",bOK) 53 54 55 Test.StartMethod("getAccessibleChild()") 56 Dim childContext As Object 57 Dim mCount As Integer 58 bOK = true 59 i = 0 60 if (childCount > 50) then 61 mCount = 50 62 else 63 mCount = childCount 64 End If 65 while (i < mCount) 66 childContext = oObj.getAccessibleChild(i).getAccessibleContext() 67 Out.Log(" Child " + i + ": " + childContext.getAccessibleDescription()) 68 bOK = bOK AND utils.at_equals(childContext.getAccessibleParent(), oObj) 69 i = i + 1 70 wend 71 Test.MethodTested("getAccessibleChild()",bOK) 72 73 74 Test.StartMethod("getAccessibleParent()") 75 bOK = true 76 oParent = oObj.getAccessibleParent() 77 bOK = bOK AND NOT isNull(oParent) 78 Test.MethodTested("getAccessibleParent()",bOK) 79 80 81 Test.StartMethod("getAccessibleIndexInParent()") 82 Dim idx As Integer 83 Dim parentAC As Object 84 bOK = true 85 idx = oObj.getAccessibleIndexInParent() 86 parentAC = oParent.getAccessibleContext() 87 bOK = bOK AND utils.at_equals(parentAC.getAccessibleChild(idx), oObj) 88 Test.MethodTested("getAccessibleIndexInParent()",bOK) 89 90 91 Test.StartMethod("getAccessibleRole()") 92 Dim role As Integer 93 bOK = true 94 role = oObj.getAccessibleRole() 95 Out.Log("The role is " + role) 96 bOK = bOK AND (role > -1) 97 Test.MethodTested("getAccessibleRole()",bOK) 98 99 100 Test.StartMethod("getAccessibleDescription()") 101 Dim descr As String 102 bOK = true 103 descr = oObj.getAccessibleDescription() 104 Out.Log("The description is " + descr) 105 bOK = bOK AND NOT isNull(descr) 106 Test.MethodTested("getAccessibleDescription()",bOK) 107 108 109 Test.StartMethod("getAccessibleName()") 110 Dim oName As String 111 bOK = true 112 oName = oObj.getAccessibleName() 113 Out.Log("The name is " + oName) 114 bOK = bOK AND NOT isNull(oName) 115 Test.MethodTested("getAccessibleName()",bOK) 116 117 118 Test.StartMethod("getAccessibleRelationSet()") 119 Dim oSet As Variant 120 bOK = true 121 oSet = oObj.getAccessibleRelationSet() 122 ' Relationset could be null 123 if not isNull(oSet) then 124 oSet.getRelationCount() 125 end if 126 Test.MethodTested("getAccessibleRelationSet()",bOK) 127 128 129 Test.StartMethod("getAccessibleStateSet()") 130 bOK = true 131 oSet = oObj.getAccessibleStateSet() 132 bOK = bOK AND NOT isNull(oSet) 133 if NOT bOK then Out.Log("This object does not support states") 134 Test.MethodTested("getAccessibleStateSet()",bOK) 135 136 137 Test.StartMethod("getLocale()") 138 Dim oLoc As Variant 139 bOK = true 140 oLoc = oObj.getLocale() 141 Out.Log("The locale is "+oLoc.Language+", "+oLoc.Country) 142 bOK = bOK AND NOT isNull(oLoc) AND (len(oLoc.Language) > 0) AND (len(oLoc.Country) > 0) 143 Test.MethodTested("getLocale()",bOK) 144 145Exit Sub 146ErrHndl: 147 Test.Exception() 148 bOK = false 149 resume next 150End Sub 151</script:module> 152