1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="accessibility_XAccessibleText" script:language="StarBasic"> 4cdf0e10cSrcweir 5cdf0e10cSrcweir 6cdf0e10cSrcweir'************************************************************************* 7cdf0e10cSrcweir' 8*2f3df0e5SAndrew Rist' Licensed to the Apache Software Foundation (ASF) under one 9*2f3df0e5SAndrew Rist' or more contributor license agreements. See the NOTICE file 10*2f3df0e5SAndrew Rist' distributed with this work for additional information 11*2f3df0e5SAndrew Rist' regarding copyright ownership. The ASF licenses this file 12*2f3df0e5SAndrew Rist' to you under the Apache License, Version 2.0 (the 13*2f3df0e5SAndrew Rist' "License"); you may not use this file except in compliance 14*2f3df0e5SAndrew Rist' with the License. You may obtain a copy of the License at 15*2f3df0e5SAndrew Rist' 16*2f3df0e5SAndrew Rist' http://www.apache.org/licenses/LICENSE-2.0 17*2f3df0e5SAndrew Rist' 18*2f3df0e5SAndrew Rist' Unless required by applicable law or agreed to in writing, 19*2f3df0e5SAndrew Rist' software distributed under the License is distributed on an 20*2f3df0e5SAndrew Rist' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21*2f3df0e5SAndrew Rist' KIND, either express or implied. See the License for the 22*2f3df0e5SAndrew Rist' specific language governing permissions and limitations 23*2f3df0e5SAndrew Rist' under the License. 24cdf0e10cSrcweir' 25cdf0e10cSrcweir'************************************************************************* 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29*2f3df0e5SAndrew Rist 30*2f3df0e5SAndrew Rist 31cdf0e10cSrcweir' Be sure that all variables are dimensioned: 32cdf0e10cSrcweiroption explicit 33cdf0e10cSrcweir 34cdf0e10cSrcweir'************************************************************************* 35cdf0e10cSrcweir' This Interface/Service test depends on the following GLOBAL variables, 36cdf0e10cSrcweir' which must be specified in the object creation: 37cdf0e10cSrcweir 38cdf0e10cSrcweir' Global accText as String 39cdf0e10cSrcweir' Global readOnly as Boolean 40cdf0e10cSrcweir 41cdf0e10cSrcweir'************************************************************************* 42cdf0e10cSrcweir 43cdf0e10cSrcweirSub RunTest() 44cdf0e10cSrcweir 45cdf0e10cSrcweir'************************************************************************* 46cdf0e10cSrcweir' INTERFACE: 47cdf0e10cSrcweir' com.sun.star.accessibility.XAccessibleText 48cdf0e10cSrcweir'************************************************************************* 49cdf0e10cSrcweirOn Error Goto ErrHndl 50cdf0e10cSrcweir Dim bOK As Boolean 51cdf0e10cSrcweir Dim chCount As Integer 52cdf0e10cSrcweir Dim accTextSegment as new com.sun.star.accessibility.TextSegment 53cdf0e10cSrcweir 54cdf0e10cSrcweir Test.StartMethod("getCharacterCount()") 55cdf0e10cSrcweir bOK = true 56cdf0e10cSrcweir chCount = oObj.getCharacterCount() 57cdf0e10cSrcweir Out.Log("Character count: "+chCount) 58cdf0e10cSrcweir bOK = bOK AND (len(accText) = chCount) 59cdf0e10cSrcweir Test.MethodTested("getCharacterCount()",bOK) 60cdf0e10cSrcweir 61cdf0e10cSrcweir Test.StartMethod("getCaretPosition()") 62cdf0e10cSrcweir Test.StartMethod("setCaretPosition()") 63cdf0e10cSrcweir bOK = true 64cdf0e10cSrcweir Dim carPos As Integer 65cdf0e10cSrcweir oObj.setCaretPosition(chCount - 1) 66cdf0e10cSrcweir carPos = oObj.getCaretPosition() 67cdf0e10cSrcweir if not readOnly then 68cdf0e10cSrcweir Out.Log("getCaretPosition: " + carPos) 69cdf0e10cSrcweir bOK = bOK AND (carPos = chCount - 1) 70cdf0e10cSrcweir else 71cdf0e10cSrcweir Out.Log("Object is read only and Caret position couldn't be set") 72cdf0e10cSrcweir end if 73cdf0e10cSrcweir Test.MethodTested("getCaretPosition()",bOK) 74cdf0e10cSrcweir Test.MethodTested("setCaretPosition()",bOK) 75cdf0e10cSrcweir 76cdf0e10cSrcweir Test.StartMethod("getCharacter()") 77cdf0e10cSrcweir Dim i As Integer 78cdf0e10cSrcweir bOK = true 79cdf0e10cSrcweir for i = 0 to chCount-1 80cdf0e10cSrcweir bOK = bOK AND (chr(oObj.getCharacter(i)) = _ 81cdf0e10cSrcweir utils.getCharacter(i+1,accText)) 82cdf0e10cSrcweir next i 83cdf0e10cSrcweir Test.MethodTested("getCharacter()",bOK) 84cdf0e10cSrcweir 85cdf0e10cSrcweir Test.StartMethod("getCharacterAttributes()") 86cdf0e10cSrcweir Dim attrs() As Variant 87cdf0e10cSrcweir Dim ReqAttrs(0) as String 88cdf0e10cSrcweir bOK = true 89cdf0e10cSrcweir attrs = oObj.getCharacterAttributes(chCount - 1, ReqAttrs()) 90cdf0e10cSrcweir bOK = bOK AND NOT isNull(attrs) 91cdf0e10cSrcweir Out.Log("Properties ubound: "+ubound(attrs)) 92cdf0e10cSrcweir Test.MethodTested("getCharacterAttributes()",bOK) 93cdf0e10cSrcweir 94cdf0e10cSrcweir Test.StartMethod("getCharacterBounds()") 95cdf0e10cSrcweir Dim chBounds As new com.sun.star.awt.Rectangle 96cdf0e10cSrcweir bOK = true 97cdf0e10cSrcweir chBounds = oObj.getCharacterBounds(chCount - 1) 98cdf0e10cSrcweir Out.Log("Character boundbox: "+chBounds.X+", "+chBounds.Y+", "+ _ 99cdf0e10cSrcweir chBounds.Width+", "+chBounds.Height) 100cdf0e10cSrcweir bOK = bOK AND NOT isNull(chBounds) 101cdf0e10cSrcweir Test.MethodTested("getCharacterBounds()",bOK) 102cdf0e10cSrcweir 103cdf0e10cSrcweir Test.StartMethod("getIndexAtPoint()") 104cdf0e10cSrcweir Dim index As Integer 105cdf0e10cSrcweir Dim point As new com.sun.star.awt.Point 106cdf0e10cSrcweir bOK = true 107cdf0e10cSrcweir point.X = chBounds.X + 1 108cdf0e10cSrcweir point.Y = chBounds.Y + 1 109cdf0e10cSrcweir index = oObj.getIndexAtPoint(point) 110cdf0e10cSrcweir bOK = bOK AND (index = chCount -1) 111cdf0e10cSrcweir Test.MethodTested("getIndexAtPoint()",bOK) 112cdf0e10cSrcweir 113cdf0e10cSrcweir Test.StartMethod("getSelectedText()") 114cdf0e10cSrcweir bOK = true 115cdf0e10cSrcweir oObj.setSelection(0, chCount) 116cdf0e10cSrcweir if not readOnly then 117cdf0e10cSrcweir bOK = bOK AND (accText = oObj.getSelectedText()) 118cdf0e10cSrcweir else 119cdf0e10cSrcweir Out.Log("Object is unselectable") 120cdf0e10cSrcweir end if 121cdf0e10cSrcweir Test.MethodTested("getSelectedText()",bOK) 122cdf0e10cSrcweir 123cdf0e10cSrcweir Test.StartMethod("getSelectionStart()") 124cdf0e10cSrcweir bOK = true 125cdf0e10cSrcweir oObj.setSelection(chCount-1,chCount) 126cdf0e10cSrcweir if not readOnly then 127cdf0e10cSrcweir bOK = bOK AND (oObj.getSelectionStart() = chCount -1) 128cdf0e10cSrcweir else 129cdf0e10cSrcweir Out.Log("Object is unselectable") 130cdf0e10cSrcweir end if 131cdf0e10cSrcweir Test.MethodTested("getSelectionStart()",bOK) 132cdf0e10cSrcweir 133cdf0e10cSrcweir Test.StartMethod("getSelectionEnd()") 134cdf0e10cSrcweir bOK = true 135cdf0e10cSrcweir oObj.setSelection(0,chCount - 1) 136cdf0e10cSrcweir if not readOnly then 137cdf0e10cSrcweir bOK = bOK AND (oObj.getSelectionEnd() = chCount - 1) 138cdf0e10cSrcweir else 139cdf0e10cSrcweir Out.Log("Object is unselectable") 140cdf0e10cSrcweir end if 141cdf0e10cSrcweir Test.MethodTested("getSelectionEnd()",bOK) 142cdf0e10cSrcweir 143cdf0e10cSrcweir Test.StartMethod("setSelection()") 144cdf0e10cSrcweir bOK = true 145cdf0e10cSrcweir if not readOnly then 146cdf0e10cSrcweir bOK = bOK AND oObj.setSelection(0,chCount) 147cdf0e10cSrcweir else 148cdf0e10cSrcweir Out.Log("Object is unselectable") 149cdf0e10cSrcweir end if 150cdf0e10cSrcweir Test.MethodTested("setSelection()",bOK) 151cdf0e10cSrcweir 152cdf0e10cSrcweir Test.StartMethod("getText()") 153cdf0e10cSrcweir bOK = true 154cdf0e10cSrcweir bOK = bOK AND (accText = oObj.getText()) 155cdf0e10cSrcweir Test.MethodTested("getText()",bOK) 156cdf0e10cSrcweir 157cdf0e10cSrcweir Test.StartMethod("getTextRange()") 158cdf0e10cSrcweir bOK = true 159cdf0e10cSrcweir bOK = bOK AND (accText = oObj.getTextRange(0,chCount)) 160cdf0e10cSrcweir Test.MethodTested("getTextRange()",bOK) 161cdf0e10cSrcweir 162cdf0e10cSrcweir Test.StartMethod("getTextAtIndex()") 163cdf0e10cSrcweir bOK = true 164cdf0e10cSrcweir accTextSegment = oObj.getTextAtIndex(chCount - 1, 4) 165cdf0e10cSrcweir bOK = bOK AND (accText = accTextSegment.SegmentText) 166cdf0e10cSrcweir Test.MethodTested("getTextAtIndex()",bOK) 167cdf0e10cSrcweir 168cdf0e10cSrcweir Test.StartMethod("getTextBeforeIndex()") 169cdf0e10cSrcweir bOK = true 170cdf0e10cSrcweir accTextSegment = oObj.getTextBeforeIndex(1, 1) 171cdf0e10cSrcweir bOK = bOK AND (accTextSegment.SegmentText = utils.getCharacter(1,accText)) 172cdf0e10cSrcweir Test.MethodTested("getTextBeforeIndex()",bOK) 173cdf0e10cSrcweir 174cdf0e10cSrcweir Test.StartMethod("getTextBehindIndex()") 175cdf0e10cSrcweir bOK = true 176cdf0e10cSrcweir accTextSegment = oObj.getTextBehindIndex(chCount-2,1) 177cdf0e10cSrcweir bOK = bOK AND (accTextSegment.SegmentText = utils.getCharacter(chCount,accText)) 178cdf0e10cSrcweir Test.MethodTested("getTextBehindIndex()",bOK) 179cdf0e10cSrcweir 180cdf0e10cSrcweir Test.StartMethod("copyText()") 181cdf0e10cSrcweir bOK = true 182cdf0e10cSrcweir bOK = bOK AND oObj.copyText(0,chCount) 183cdf0e10cSrcweir if readOnly then bOK = true 184cdf0e10cSrcweir Test.MethodTested("copyText()",bOK) 185cdf0e10cSrcweir 186cdf0e10cSrcweirExit Sub 187cdf0e10cSrcweirErrHndl: 188cdf0e10cSrcweir Test.Exception() 189cdf0e10cSrcweir bOK = false 190cdf0e10cSrcweir resume next 191cdf0e10cSrcweirEnd Sub 192cdf0e10cSrcweir</script:module> 193