1*b1cdbd2cSJim Jagielski<?xml version="1.0" encoding="UTF-8"?> 2*b1cdbd2cSJim Jagielski<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*b1cdbd2cSJim Jagielski<script:module xmlns:script="http://openoffice.org/2000/script" script:name="accessibility_XAccessibleTable" script:language="StarBasic"> 4*b1cdbd2cSJim Jagielski 5*b1cdbd2cSJim Jagielski 6*b1cdbd2cSJim Jagielski'************************************************************************* 7*b1cdbd2cSJim Jagielski' 8*b1cdbd2cSJim Jagielski' Licensed to the Apache Software Foundation (ASF) under one 9*b1cdbd2cSJim Jagielski' or more contributor license agreements. See the NOTICE file 10*b1cdbd2cSJim Jagielski' distributed with this work for additional information 11*b1cdbd2cSJim Jagielski' regarding copyright ownership. The ASF licenses this file 12*b1cdbd2cSJim Jagielski' to you under the Apache License, Version 2.0 (the 13*b1cdbd2cSJim Jagielski' "License"); you may not use this file except in compliance 14*b1cdbd2cSJim Jagielski' with the License. You may obtain a copy of the License at 15*b1cdbd2cSJim Jagielski' 16*b1cdbd2cSJim Jagielski' http://www.apache.org/licenses/LICENSE-2.0 17*b1cdbd2cSJim Jagielski' 18*b1cdbd2cSJim Jagielski' Unless required by applicable law or agreed to in writing, 19*b1cdbd2cSJim Jagielski' software distributed under the License is distributed on an 20*b1cdbd2cSJim Jagielski' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21*b1cdbd2cSJim Jagielski' KIND, either express or implied. See the License for the 22*b1cdbd2cSJim Jagielski' specific language governing permissions and limitations 23*b1cdbd2cSJim Jagielski' under the License. 24*b1cdbd2cSJim Jagielski' 25*b1cdbd2cSJim Jagielski'************************************************************************* 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielski' Be sure that all variables are dimensioned: 32*b1cdbd2cSJim Jagielskioption explicit 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski 35*b1cdbd2cSJim Jagielski 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim JagielskiSub RunTest() 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski'************************************************************************* 40*b1cdbd2cSJim Jagielski' INTERFACE: 41*b1cdbd2cSJim Jagielski' com.sun.star.accessibility.XAccessibleTable 42*b1cdbd2cSJim Jagielski'************************************************************************* 43*b1cdbd2cSJim JagielskiOn Error Goto ErrHndl 44*b1cdbd2cSJim Jagielski Dim bOK As Boolean 45*b1cdbd2cSJim Jagielski Dim implSel As Boolean 46*b1cdbd2cSJim Jagielski 47*b1cdbd2cSJim Jagielski implSel = hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleSelection") 48*b1cdbd2cSJim Jagielski if (NOT implSel) then 49*b1cdbd2cSJim Jagielski Out.Log("!!! The component doesn't implement the interface XAccessibleSelection.") 50*b1cdbd2cSJim Jagielski Out.Log("!!! This interface is required for more detailed tests.") 51*b1cdbd2cSJim Jagielski End If 52*b1cdbd2cSJim Jagielski 53*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleRowCount()") 54*b1cdbd2cSJim Jagielski Dim rowCount As Long 55*b1cdbd2cSJim Jagielski bOK = true 56*b1cdbd2cSJim Jagielski rowCount = oObj.getAccessibleRowCount() 57*b1cdbd2cSJim Jagielski Out.Log("Accessible row count: "+rowCount) 58*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleRowCount()",bOK) 59*b1cdbd2cSJim Jagielski 60*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleColumnCount()") 61*b1cdbd2cSJim Jagielski Dim colCount As Long 62*b1cdbd2cSJim Jagielski bOK = true 63*b1cdbd2cSJim Jagielski colCount = oObj.getAccessibleColumnCount() 64*b1cdbd2cSJim Jagielski Out.Log("Accessible column count: "+colCount) 65*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleColumnCount()",bOK) 66*b1cdbd2cSJim Jagielski 67*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleRowDescription()") 68*b1cdbd2cSJim Jagielski Dim rowDescr As String 69*b1cdbd2cSJim Jagielski bOK = true 70*b1cdbd2cSJim Jagielski if (rowCount > 0) then 71*b1cdbd2cSJim Jagielski rowDescr = oObj.getAccessibleRowDescription(rowCount - 1) 72*b1cdbd2cSJim Jagielski Out.Log("Row "+(rowCount-1)+" description: "+rowDescr) 73*b1cdbd2cSJim Jagielski bOK = bOK AND NOT isNull(rowDescr) 74*b1cdbd2cSJim Jagielski else 75*b1cdbd2cSJim Jagielski Out.Log("!!! RowCount is 0. Could not test this method.") 76*b1cdbd2cSJim Jagielski End If 77*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleRowDescription()",bOK) 78*b1cdbd2cSJim Jagielski 79*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleColumnDescription()") 80*b1cdbd2cSJim Jagielski Dim colDescr As String 81*b1cdbd2cSJim Jagielski bOK = true 82*b1cdbd2cSJim Jagielski if (colCount > 0) then 83*b1cdbd2cSJim Jagielski colDescr = oObj.getAccessibleRowDescription(colCount - 1) 84*b1cdbd2cSJim Jagielski Out.Log("Column "+(colCount-1)+" description: "+colDescr) 85*b1cdbd2cSJim Jagielski bOK = bOK AND NOT isNull(colDescr) 86*b1cdbd2cSJim Jagielski else 87*b1cdbd2cSJim Jagielski Out.Log("!!! ColumnCount is 0. Could not test this method.") 88*b1cdbd2cSJim Jagielski End If 89*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleColumnDescription()",bOK) 90*b1cdbd2cSJim Jagielski 91*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleRowExtentAt()") 92*b1cdbd2cSJim Jagielski Dim ext As Long 93*b1cdbd2cSJim Jagielski bOK = true 94*b1cdbd2cSJim Jagielski ext = oObj.getAccessibleRowExtentAt(rowCount - 1, colCount - 1) 95*b1cdbd2cSJim Jagielski Out.Log(ext) 96*b1cdbd2cSJim Jagielski bOK = bOK AND (ext >= 1) 97*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleRowExtentAt()",bOK) 98*b1cdbd2cSJim Jagielski 99*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleColumnExtentAt()") 100*b1cdbd2cSJim Jagielski bOK = true 101*b1cdbd2cSJim Jagielski ext = oObj.getAccessibleColumnExtentAt(rowCount - 1, colCount - 1) 102*b1cdbd2cSJim Jagielski Out.Log(ext) 103*b1cdbd2cSJim Jagielski bOK = bOK AND (ext >= 1) 104*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleColumnExtentAt()",bOK) 105*b1cdbd2cSJim Jagielski 106*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleRowHeaders()") 107*b1cdbd2cSJim Jagielski Dim rowHeaders As Object 108*b1cdbd2cSJim Jagielski bOK = true 109*b1cdbd2cSJim Jagielski rowHeaders = oObj.getAccessibleRowHeaders() 110*b1cdbd2cSJim Jagielski bOK = bOK AND NOT isNull(rowHeaders) 111*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleRowHeaders()",bOK) 112*b1cdbd2cSJim Jagielski 113*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleColumnHeaders()") 114*b1cdbd2cSJim Jagielski Dim colHeaders As Object 115*b1cdbd2cSJim Jagielski bOK = true 116*b1cdbd2cSJim Jagielski colHeaders = oObj.getAccessibleColumnHeaders() 117*b1cdbd2cSJim Jagielski bOK = bOK AND NOT isNull(colHeaders) 118*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleColumnHeaders()",bOK) 119*b1cdbd2cSJim Jagielski 120*b1cdbd2cSJim Jagielski Test.StartMethod("getSelectedAccessibleRows()") 121*b1cdbd2cSJim Jagielski Dim selRows As Variant 122*b1cdbd2cSJim Jagielski Dim elCount As Long, i As Integer 123*b1cdbd2cSJim Jagielski Dim locRes As Boolean 124*b1cdbd2cSJim Jagielski bOK = true 125*b1cdbd2cSJim Jagielski if implSel then 126*b1cdbd2cSJim Jagielski oObj.selectAllAccessible() 127*b1cdbd2cSJim Jagielski End If 128*b1cdbd2cSJim Jagielski selRows = oObj.getSelectedAccessibleRows() 129*b1cdbd2cSJim Jagielski elCount = ubound(selRows) - 1 130*b1cdbd2cSJim Jagielski Out.Log("Returned sequence has "+elCount+" elements") 131*b1cdbd2cSJim Jagielski if implSel then 132*b1cdbd2cSJim Jagielski bOK = bOK AND (elCount = rowCount) 133*b1cdbd2cSJim Jagielski else 134*b1cdbd2cSJim Jagielski bOK = bOK AND (elCount = 0) 135*b1cdbd2cSJim Jagielski End If 136*b1cdbd2cSJim Jagielski if (elCount > 0) then 137*b1cdbd2cSJim Jagielski Out.Log("Checking that returned sequence is in ascending order") 138*b1cdbd2cSJim Jagielski End If 139*b1cdbd2cSJim Jagielski i = 1 140*b1cdbd2cSJim Jagielski while (i < elCount) 141*b1cdbd2cSJim Jagielski locRes = (selRows(i) >= selRows(i-1)) 142*b1cdbd2cSJim Jagielski bOK = bOK AND locRes 143*b1cdbd2cSJim Jagielski if NOT locRes then 144*b1cdbd2cSJim Jagielski Out.Log("Element "+i+" : Returned sequence is not in accending order.") 145*b1cdbd2cSJim Jagielski break 146*b1cdbd2cSJim Jagielski End If 147*b1cdbd2cSJim Jagielski wend 148*b1cdbd2cSJim Jagielski Test.MethodTested("getSelectedAccessibleRows()",bOK) 149*b1cdbd2cSJim Jagielski 150*b1cdbd2cSJim Jagielski Test.StartMethod("getSelectedAccessibleColumns()") 151*b1cdbd2cSJim Jagielski Dim selCols As Variant 152*b1cdbd2cSJim Jagielski bOK = true 153*b1cdbd2cSJim Jagielski selCols = oObj.getSelectedAccessibleRows() 154*b1cdbd2cSJim Jagielski elCount = ubound(selCols) - 1 155*b1cdbd2cSJim Jagielski Out.Log("Returned sequence has "+elCount+" elements") 156*b1cdbd2cSJim Jagielski if implSel then 157*b1cdbd2cSJim Jagielski bOK = bOK AND (elCount = colCount) 158*b1cdbd2cSJim Jagielski else 159*b1cdbd2cSJim Jagielski bOK = bOK AND (elCount = 0) 160*b1cdbd2cSJim Jagielski End If 161*b1cdbd2cSJim Jagielski if (elCount > 0) then 162*b1cdbd2cSJim Jagielski Out.Log("Checking that returned sequence is in ascending order") 163*b1cdbd2cSJim Jagielski End If 164*b1cdbd2cSJim Jagielski i = 1 165*b1cdbd2cSJim Jagielski while (i < elCount) 166*b1cdbd2cSJim Jagielski locRes = (selCols(i) >= selCols(i-1)) 167*b1cdbd2cSJim Jagielski bOK = bOK AND locRes 168*b1cdbd2cSJim Jagielski if NOT locRes then 169*b1cdbd2cSJim Jagielski Out.Log("Element "+i+" : Returned sequence is not in accending order.") 170*b1cdbd2cSJim Jagielski break 171*b1cdbd2cSJim Jagielski End If 172*b1cdbd2cSJim Jagielski wend 173*b1cdbd2cSJim Jagielski Test.MethodTested("getSelectedAccessibleColumns()",bOK) 174*b1cdbd2cSJim Jagielski 175*b1cdbd2cSJim Jagielski Test.StartMethod("isAccessibleRowSelected()") 176*b1cdbd2cSJim Jagielski Dim mCount As Integer 177*b1cdbd2cSJim Jagielski bOK = true 178*b1cdbd2cSJim Jagielski locRes = true 179*b1cdbd2cSJim Jagielski if (rowCount > 299) then 180*b1cdbd2cSJim Jagielski mCount = 299 181*b1cdbd2cSJim Jagielski else 182*b1cdbd2cSJim Jagielski mCount = rowCount - 1 183*b1cdbd2cSJim Jagielski End If 184*b1cdbd2cSJim Jagielski for i=0 to mCount 185*b1cdbd2cSJim Jagielski locRes = oObj.isAccessibleRowSelected(i) 186*b1cdbd2cSJim Jagielski if implSel then 187*b1cdbd2cSJim Jagielski bOK = bOK AND locRes 188*b1cdbd2cSJim Jagielski else 189*b1cdbd2cSJim Jagielski bOK = bOK AND NOT locRes 190*b1cdbd2cSJim Jagielski End If 191*b1cdbd2cSJim Jagielski next i 192*b1cdbd2cSJim Jagielski Out.Log("Checked "+i+" of "+rowCount+" rows.") 193*b1cdbd2cSJim Jagielski Test.MethodTested("isAccessibleRowSelected()",bOK) 194*b1cdbd2cSJim Jagielski 195*b1cdbd2cSJim Jagielski Test.StartMethod("isAccessibleColumnSelected()") 196*b1cdbd2cSJim Jagielski bOK = true 197*b1cdbd2cSJim Jagielski locRes = true 198*b1cdbd2cSJim Jagielski if (colCount > 299) then 199*b1cdbd2cSJim Jagielski mCount = 299 200*b1cdbd2cSJim Jagielski else 201*b1cdbd2cSJim Jagielski mCount = colCount - 1 202*b1cdbd2cSJim Jagielski End If 203*b1cdbd2cSJim Jagielski for i=0 to mCount 204*b1cdbd2cSJim Jagielski locRes = oObj.isAccessibleColumnSelected(i) 205*b1cdbd2cSJim Jagielski if implSel then 206*b1cdbd2cSJim Jagielski bOK = bOK AND locRes 207*b1cdbd2cSJim Jagielski else 208*b1cdbd2cSJim Jagielski bOK = bOK AND NOT locRes 209*b1cdbd2cSJim Jagielski End If 210*b1cdbd2cSJim Jagielski next i 211*b1cdbd2cSJim Jagielski Out.Log("Checked "+i+" of "+colCount+" columns.") 212*b1cdbd2cSJim Jagielski Test.MethodTested("isAccessibleColumnSelected()",bOK) 213*b1cdbd2cSJim Jagielski 214*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleCellAt()") 215*b1cdbd2cSJim Jagielski Dim xAccCell As Object 216*b1cdbd2cSJim Jagielski bOK = true 217*b1cdbd2cSJim Jagielski xAccCell = oObj.getAccessibleCellAt(rowCount - 1, colCount - 1) 218*b1cdbd2cSJim Jagielski bOK = bOK AND NOT isNull(xAccCell) 219*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleCellAt()",bOK) 220*b1cdbd2cSJim Jagielski 221*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleCaption()") 222*b1cdbd2cSJim Jagielski Dim caption As Object 223*b1cdbd2cSJim Jagielski bOK = true 224*b1cdbd2cSJim Jagielski caption = oObj.getAccessibleCaption() 225*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleCaption()",bOK) 226*b1cdbd2cSJim Jagielski 227*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleSummary()") 228*b1cdbd2cSJim Jagielski Dim summary As Object 229*b1cdbd2cSJim Jagielski bOK = true 230*b1cdbd2cSJim Jagielski summary = oObj.getAccessibleSummary() 231*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleSummary()",bOK) 232*b1cdbd2cSJim Jagielski 233*b1cdbd2cSJim Jagielski Test.StartMethod("isAccessibleSelected()") 234*b1cdbd2cSJim Jagielski bOK = true 235*b1cdbd2cSJim Jagielski locRes = oObj.isAccessibleSelected(rowCount - 1, colCount - 1) 236*b1cdbd2cSJim Jagielski if implSel then 237*b1cdbd2cSJim Jagielski bOK = bOK AND locRes 238*b1cdbd2cSJim Jagielski else 239*b1cdbd2cSJim Jagielski bOK = bOK AND NOT locRes 240*b1cdbd2cSJim Jagielski End If 241*b1cdbd2cSJim Jagielski Test.MethodTested("isAccessibleSelected()",bOK) 242*b1cdbd2cSJim Jagielski 243*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleIndex()") 244*b1cdbd2cSJim Jagielski Dim ind As Long, expIndex As Long 245*b1cdbd2cSJim Jagielski bOK = true 246*b1cdbd2cSJim Jagielski ind = oObj.getAccessibleIndex(rowCount - 1, colCount - 1) 247*b1cdbd2cSJim Jagielski Out.Log("AccessibleIndex is: "+ind) 248*b1cdbd2cSJim Jagielski if NOT isNull(xAccCell) then 249*b1cdbd2cSJim Jagielski expIndex = xAccCell.getAccessibleContext().getAccessibleIndexInParent() 250*b1cdbd2cSJim Jagielski Out.Log("Expected index is: "+expIndex) 251*b1cdbd2cSJim Jagielski bOK = bOK AND (ind = expIndex) 252*b1cdbd2cSJim Jagielski End If 253*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleIndex()",bOK) 254*b1cdbd2cSJim Jagielski 255*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleRow()") 256*b1cdbd2cSJim Jagielski Dim rowIndex As Long 257*b1cdbd2cSJim Jagielski Dim chCount As Long 258*b1cdbd2cSJim Jagielski bOK = true 259*b1cdbd2cSJim Jagielski if hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleContext") then 260*b1cdbd2cSJim Jagielski chCount = oObj.getAccessibleChildCount() 261*b1cdbd2cSJim Jagielski rowIndex = oObj.getAccessibleRow(chCount - 1) 262*b1cdbd2cSJim Jagielski bOK = bOK AND (rowIndex >= 0) AND (rowIndex <= rowCount) 263*b1cdbd2cSJim Jagielski End If 264*b1cdbd2cSJim Jagielski rowIndex = oObj.getAccessibleRow(0) 265*b1cdbd2cSJim Jagielski bOK = bOK AND (rowIndex >= 0) AND (rowIndex <= rowCount) 266*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleRow()",bOK) 267*b1cdbd2cSJim Jagielski 268*b1cdbd2cSJim Jagielski Test.StartMethod("getAccessibleColumn()") 269*b1cdbd2cSJim Jagielski Dim colIndex As Long 270*b1cdbd2cSJim Jagielski bOK = true 271*b1cdbd2cSJim Jagielski if hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleContext") then 272*b1cdbd2cSJim Jagielski chCount = oObj.getAccessibleChildCount() 273*b1cdbd2cSJim Jagielski colIndex = oObj.getAccessibleColumn(chCount - 1) 274*b1cdbd2cSJim Jagielski bOK = bOK AND (colIndex >= 0) AND (colIndex <= colCount) 275*b1cdbd2cSJim Jagielski End If 276*b1cdbd2cSJim Jagielski colIndex = oObj.getAccessibleColumn(0) 277*b1cdbd2cSJim Jagielski bOK = bOK AND (colIndex >= 0) AND (colIndex <= colCount) 278*b1cdbd2cSJim Jagielski Test.MethodTested("getAccessibleColumn()",bOK) 279*b1cdbd2cSJim Jagielski 280*b1cdbd2cSJim JagielskiExit Sub 281*b1cdbd2cSJim JagielskiErrHndl: 282*b1cdbd2cSJim Jagielski Test.Exception() 283*b1cdbd2cSJim Jagielski bOK = false 284*b1cdbd2cSJim Jagielski resume next 285*b1cdbd2cSJim JagielskiEnd Sub 286*b1cdbd2cSJim Jagielski</script:module> 287