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_XAccessibleEditableText" 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 hasChangeableAttrs as boolean 39cdf0e10cSrcweir 40cdf0e10cSrcweir'************************************************************************* 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir 46cdf0e10cSrcweir 47cdf0e10cSrcweirSub RunTest() 48cdf0e10cSrcweir 49cdf0e10cSrcweir'************************************************************************* 50cdf0e10cSrcweir' INTERFACE: 51cdf0e10cSrcweir' com.sun.star.accessibility.XAccessibleEditableText 52cdf0e10cSrcweir'************************************************************************* 53cdf0e10cSrcweirOn Error Goto ErrHndl 54cdf0e10cSrcweir Dim bOK As Boolean, locRes As Boolean 55cdf0e10cSrcweir Dim oldText As String, curText As String 56cdf0e10cSrcweir Dim length As Integer, initialText As String 57cdf0e10cSrcweir 58cdf0e10cSrcweir oldText = oObj.getText() 59cdf0e10cSrcweir initialText = oldText 60cdf0e10cSrcweir length = oObj.getCharacterCount() 61cdf0e10cSrcweir Out.Log("Text: "+oldText) 62cdf0e10cSrcweir Out.Log("Length: "+length) 63cdf0e10cSrcweir 64cdf0e10cSrcweir 65cdf0e10cSrcweir Test.StartMethod("cutText()") 66cdf0e10cSrcweir bOK = true 67cdf0e10cSrcweir locRes = oObj.cutText(0,length) 68cdf0e10cSrcweir curText = oObj.getText() 69cdf0e10cSrcweir bOK = bOK AND (len(curText) = 0) AND locRes 70cdf0e10cSrcweir Test.MethodTested("cutText()",bOK) 71cdf0e10cSrcweir 72cdf0e10cSrcweir 73cdf0e10cSrcweir Test.StartMethod("pasteText()") 74cdf0e10cSrcweir bOK = true 75cdf0e10cSrcweir locRes = oObj.pasteText(0) 76cdf0e10cSrcweir curText = oObj.getText() 77cdf0e10cSrcweir bOK = bOK AND (len(curText) = length) AND locRes 78cdf0e10cSrcweir Test.MethodTested("pasteText()",bOK) 79cdf0e10cSrcweir 80cdf0e10cSrcweir 81cdf0e10cSrcweir Test.StartMethod("insertText()") 82cdf0e10cSrcweir Dim insString As String 83cdf0e10cSrcweir bOK = true 84cdf0e10cSrcweir insString = "Inserted String" 85cdf0e10cSrcweir locRes = oObj.insertText(insString,length) 86cdf0e10cSrcweir curText = oObj.getText() 87cdf0e10cSrcweir bOK = bOK AND (curText = oldText + insString) AND locRes 88cdf0e10cSrcweir Test.MethodTested("insertText()",bOK) 89cdf0e10cSrcweir 90cdf0e10cSrcweir 91cdf0e10cSrcweir Test.StartMethod("deleteText()") 92cdf0e10cSrcweir bOK = true 93cdf0e10cSrcweir locRes = oObj.deleteText(len(curText) - len(insString),len(curText)) 94cdf0e10cSrcweir curText = oObj.getText() 95cdf0e10cSrcweir bOK = bOK AND (curText = oldText) AND locRes 96cdf0e10cSrcweir Test.MethodTested("deleteText()",bOK) 97cdf0e10cSrcweir 98cdf0e10cSrcweir 99cdf0e10cSrcweir Test.StartMethod("replaceText()") 100cdf0e10cSrcweir Dim replacement As String 101cdf0e10cSrcweir Dim endIndex As Integer 102cdf0e10cSrcweir bOK = true 103cdf0e10cSrcweir oObj.setText(oldText+"(part of string to replace)") 104cdf0e10cSrcweir endIndex = len(oObj.getText) 105cdf0e10cSrcweir replacement = "Replacement string" 106cdf0e10cSrcweir locRes = oObj.replaceText(len(oldText),endIndex,replacement) 107cdf0e10cSrcweir curText = oObj.getText() 108cdf0e10cSrcweir bOK = bOK AND (curText = oldText + replacement) AND locRes 109cdf0e10cSrcweir Test.MethodTested("replaceText()",bOK) 110cdf0e10cSrcweir 111cdf0e10cSrcweir 112cdf0e10cSrcweir Test.StartMethod("setAttributes()") 113cdf0e10cSrcweir if hasChangeableAttrs then 114cdf0e10cSrcweir Dim attrs As Variant, newAttrs As Variant 115cdf0e10cSrcweir Dim i As Integer 116cdf0e10cSrcweir bOK = true 117cdf0e10cSrcweir length = oObj.getCharacterCount() 118cdf0e10cSrcweir attrs = oObj.getCharacterAttributes(0) 119cdf0e10cSrcweir for i=0 to ubound(attrs()) 120cdf0e10cSrcweir if attrs(i).Name = "CharBackColor" then attrs(i).Value = RGB(120,205,40) 121cdf0e10cSrcweir if attrs(i).Name = "CharHeight" then attrs(i).Value = 30 122cdf0e10cSrcweir if attrs(i).Name = "CharColor" then attrs(i).Value = RGB(255,255,255) 123cdf0e10cSrcweir next i 124cdf0e10cSrcweir locRes = oObj.setAttributes(0,length,attrs) 125cdf0e10cSrcweir bOK = bOK AND locRes 126cdf0e10cSrcweir newAttrs = oObj.getCharacterAttributes(0) 127cdf0e10cSrcweir bOK = bOK AND PropertyTester.equals(attrs,newAttrs) 128cdf0e10cSrcweir else 129cdf0e10cSrcweir Out.Log("Object has no changeable attributes.") 130cdf0e10cSrcweir bOK = true 131cdf0e10cSrcweir End If 132cdf0e10cSrcweir Test.MethodTested("setAttributes()",bOK) 133cdf0e10cSrcweir 134cdf0e10cSrcweir 135cdf0e10cSrcweir Test.StartMethod("setText()") 136cdf0e10cSrcweir Dim newText As String 137cdf0e10cSrcweir bOK = true 138cdf0e10cSrcweir oldText = oObj.getText() 139cdf0e10cSrcweir newText = "New string" 140cdf0e10cSrcweir locRes = oObj.setText(newText) 141cdf0e10cSrcweir curText = oObj.getText() 142cdf0e10cSrcweir bOK = bOK AND (curText = newText) AND locRes 143cdf0e10cSrcweir if locRes then 144cdf0e10cSrcweir Out.Log("Test 1 passed OK.") 145cdf0e10cSrcweir else 146cdf0e10cSrcweir Out.Log("Test 1 failed.") 147cdf0e10cSrcweir End If 148cdf0e10cSrcweir newText = "" 149cdf0e10cSrcweir locRes = oObj.setText(newText) 150cdf0e10cSrcweir curText = oObj.getText() 151cdf0e10cSrcweir bOK = bOK AND (newText = curText) AND locRes 152cdf0e10cSrcweir if locRes then 153cdf0e10cSrcweir Out.Log("Test 2 passed OK.") 154cdf0e10cSrcweir else 155cdf0e10cSrcweir Out.Log("Test 2 failed.") 156cdf0e10cSrcweir End If 157cdf0e10cSrcweir locRes = oObj.setText(oldText) 158cdf0e10cSrcweir curText = oObj.getText() 159cdf0e10cSrcweir bOK = bOK AND (curText = oldText) AND locRes 160cdf0e10cSrcweir if locRes then 161cdf0e10cSrcweir Out.Log("Test 3 passed OK.") 162cdf0e10cSrcweir else 163cdf0e10cSrcweir Out.Log("Test 3 failed.") 164cdf0e10cSrcweir End If 165cdf0e10cSrcweir Test.MethodTested("setText()",bOK) 166cdf0e10cSrcweir 167cdf0e10cSrcweir out.dbg("Setting initial text: " + initialText ) 168cdf0e10cSrcweir oObj.setText(initialText) 169cdf0e10cSrcweir 170cdf0e10cSrcweirExit Sub 171cdf0e10cSrcweirErrHndl: 172cdf0e10cSrcweir Test.Exception() 173cdf0e10cSrcweir bOK = false 174cdf0e10cSrcweir resume next 175cdf0e10cSrcweirEnd Sub 176cdf0e10cSrcweir</script:module> 177