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="sd_AccessibleOutlineView" script:language="StarBasic"> 4 5 6'************************************************************************* 7' 8' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9' 10' Copyright 2000, 2010 Oracle and/or its affiliates. 11' 12' OpenOffice.org - a multi-platform office productivity suite 13' 14' This file is part of OpenOffice.org. 15' 16' OpenOffice.org is free software: you can redistribute it and/or modify 17' it under the terms of the GNU Lesser General Public License version 3 18' only, as published by the Free Software Foundation. 19' 20' OpenOffice.org is distributed in the hope that it will be useful, 21' but WITHOUT ANY WARRANTY; without even the implied warranty of 22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23' GNU Lesser General Public License version 3 for more details 24' (a copy is included in the LICENSE file that accompanied this code). 25' 26' You should have received a copy of the GNU Lesser General Public License 27' version 3 along with OpenOffice.org. If not, see 28' <http://www.openoffice.org/license.html> 29' for a copy of the LGPLv3 License. 30' 31'************************************************************************* 32***** 33'************************************************************************* 34 35 36 37' Be sure that all variables are dimensioned: 38option explicit 39 40 41' REQUIRED VARIABLES for interface/service tests: 42Global oDPn As Variant 43Global fireCount as Integer 44 45 46Sub CreateObj() 47 48'************************************************************************* 49' COMPONENT: 50' sd.AccessibleOutlineView 51'************************************************************************* 52On Error Goto ErrHndl 53 Dim aSlotID As String 54 Dim urls As Variant 55 Dim url as new com.sun.star.util.URL 56 Dim UrlTransformer As Object, xDispatcher As Object 57 Dim oCntr As Object, oWin As Object, xRoot As Object 58 Dim oSearchedContext As Object 59 60 oDoc = utils.createImpressDocument(cObjectName) 61 oCntr = oDoc.getCurrentController() 62 63 Out.log("Switching to outline view...") 64 switchOutlineView(oDoc) 65 66 oWin = utils.at_getCurrentWindow(oDoc) 67 xRoot = utils.at_getAccessibleObject(oWin) 68 oSearchedContext = utils.at_getAccessibleObjectForRole(xRoot, com.sun.star.accessibility.AccessibleRole.DOCUMENT) 69 oObj = oSearchedContext 70 oDPn = oDoc.getDrawPages() 71 fireCount = 0 72 73Exit Sub 74ErrHndl: 75 Test.Exception() 76End Sub 77 78Sub DisposeObj() 79 utils.closeObject(oDoc) 80End Sub 81 82 83' This method is used for XAccessibleEventBroadcaster interface 84Sub fireEvent() 85 fireCount = fireCount + 1 86 Out.log("fire event...") 87 Dim oDP as Object 88 oDP = oDPn.getByIndex(0) 89 addShape(oDP, fireCount * 500, fireCount * 500) 90 91 92 wait(500) 93End Sub 94 95Sub AddShape(oPage as Object, nPosX as Integer, nPosY as Integer) 96 Dim aPoint As New com.sun.star.awt.Point 97 Dim aSize As New com.sun.star.awt.Size 98 Dim oRectangleShape As Object 99 100 aPoint.x = nPosX 101 aPoint.y = nPosY 102 aSize.Width = 10000 103 aSize.Height = 10000 104 oRectangleShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape") 105 oRectangleShape.Size = aSize 106 oRectangleShape.Position = aPoint 107 oRectangleShape.FillColor = RGB(255, 0, 0) 108 oPage.add(oRectangleShape) 109End Sub 110 111Sub switchOutlineView(xDoc as Object) 112On Error Goto ErrHndl 113 114 Dim Contrl as Variant, disp as Variant, transf as Object 115 Dim URL as new com.sun.star.util.URL 116 Dim noProps() 117 Dim res as Boolean 118 119 Contrl = xDoc.getCurrentController() 120 URL.Complete = "slot:27010" 121 transf = createUnoService("com.sun.star.util.URLTransformer") 122 res = transf.parseStrict(URL) 123 124 out.log("URL parsed :" + res) 125 126 disp = Contrl.queryDispatch(URL, "", 0) 127 128 out.log("disp get.") 129 130 disp.dispatch(URL, noProps()) 131Exit Sub 132ErrHndl: 133 Test.Exception() 134End Sub 135 136 137</script:module> 138