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="sw_SwAccessiblePageView" 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' REQUIRED VARIABLES for interface/service tests: 36Global prevButton As Object 37Global nextButton As Object 38 39 40Sub CreateObj() 41 42'************************************************************************* 43' COMPONENT: 44' sw.SwAccessiblePageView 45'************************************************************************* 46On Error Goto ErrHndl 47 Dim xRoot As Object, xDispatcher As Object 48 Dim xController As Object, oWin As Object 49 Dim url As New com.sun.star.util.URL 50 Dim urlTransformer As Object 51 Dim oText As Object, cursor As Object 52 Dim i As Integer 53 54 oDoc = utils.createDocument("swriter",cObjectName) 55 oText = oDoc.getText() 56 cursor = oText.createTextCursor() 57 58 'inserting some lines 59 for i = 0 to 30 60 oText.insertString(cursor, "Paragraph Number: " + i, false) 61 oText.insertString(cursor,_ 62 " The quick brown fox jumps over the lazy Dog: SwAccessibleDocumentPageView",_ 63 false) 64 oText.insertControlCharacter(cursor,_ 65 com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false) 66 oText.insertString(cursor,_ 67 "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwAccessibleDocumentPageView",_ 68 false) 69 oText.insertControlCharacter(cursor,_ 70 com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false) 71 oText.insertControlCharacter(cursor,_ 72 com.sun.star.text.ControlCharacter.LINE_BREAK, false) 73 next i 74 wait(1000) 75 76 xController = oDoc.getCurrentController() 77 78 'switch to PreviewMode 79 urlTransformer = createUNOService("com.sun.star.util.URLTransformer") 80 url.Complete = ".uno:PrintPreview" 81 urlTransformer.parseStrict(url) 82 wait(500) 83 xDispatcher = xController.queryDispatch(url,"",0) 84 if (NOT isNull(xDispatcher)) then 85 xDispatcher.dispatch(url, DimArray()) 86 wait(1000) 87 oWin = utils.at_getCurrentWindow(oDoc) 88 xRoot = utils.at_getAccessibleObject(oWin) 89 'utils.at_printAccessibleTree(xRoot) 90 oObj = utils.at_getAccessibleObjectForRole(xRoot, com.sun.star.accessibility.AccessibleRole.PANEL,"Page") 91 Out.Log("Implementation Name: "+oObj.getImplementationName()) 92 prevButton = utils.at_getAccessibleObjectForRole(xRoot, com.sun.star.accessibility.AccessibleRole.PUSH_BUTTON,"Previous Page") 93 nextButton = utils.at_getAccessibleObjectForRole(xRoot, com.sun.star.accessibility.AccessibleRole.PUSH_BUTTON,"Next Page") 94 else 95 Out.Log("QueryDispatch FAILED. Cannot switch to Preview mode...") 96 End If 97 98Exit Sub 99ErrHndl: 100 Test.Exception() 101End Sub 102 103Sub fireEvent() 104 prevButton.doAccessibleAction(0) 105 wait(500) 106 nextButton.doAccessibleAction(0) 107 wait(500) 108End Sub 109</script:module> 110