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' Be sure that all variables are dimensioned:
37option explicit
38
39
40' REQUIRED VARIABLES for interface/service tests:
41Global oDPn As Variant
42Global fireCount as Integer
43
44
45Sub CreateObj()
46
47'*************************************************************************
48' COMPONENT:
49' sd.AccessibleOutlineView
50'*************************************************************************
51On Error Goto ErrHndl
52    Dim aSlotID As String
53    Dim urls As Variant
54    Dim url as new com.sun.star.util.URL
55    Dim UrlTransformer As Object, xDispatcher As Object
56    Dim oCntr As Object, oWin As Object, xRoot As Object
57    Dim oSearchedContext As Object
58
59    oDoc = utils.createImpressDocument(cObjectName)
60    oCntr = oDoc.getCurrentController()
61
62    Out.log("Switching to outline view...")
63    switchOutlineView(oDoc)
64
65    oWin = utils.at_getCurrentWindow(oDoc)
66    xRoot = utils.at_getAccessibleObject(oWin)
67    oSearchedContext = utils.at_getAccessibleObjectForRole(xRoot, com.sun.star.accessibility.AccessibleRole.DOCUMENT)
68    oObj = oSearchedContext
69    oDPn = oDoc.getDrawPages()
70    fireCount = 0
71
72Exit Sub
73ErrHndl:
74    Test.Exception()
75End Sub
76
77Sub DisposeObj()
78    utils.closeObject(oDoc)
79End Sub
80
81
82' This method is used for XAccessibleEventBroadcaster interface
83Sub fireEvent()
84    fireCount = fireCount + 1
85    Out.log("fire event...")
86    Dim oDP as Object
87	oDP = oDPn.getByIndex(0)
88    addShape(oDP, fireCount * 500, fireCount * 500)
89
90
91    wait(500)
92End Sub
93
94Sub AddShape(oPage as Object, nPosX as Integer, nPosY as Integer)
95    Dim aPoint As New com.sun.star.awt.Point
96    Dim aSize As New com.sun.star.awt.Size
97    Dim oRectangleShape As Object
98
99    aPoint.x = nPosX
100    aPoint.y = nPosY
101    aSize.Width = 10000
102    aSize.Height = 10000
103    oRectangleShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape")
104    oRectangleShape.Size = aSize
105    oRectangleShape.Position = aPoint
106    oRectangleShape.FillColor = RGB(255, 0, 0)
107    oPage.add(oRectangleShape)
108End Sub
109
110Sub switchOutlineView(xDoc as Object)
111On Error Goto ErrHndl
112
113        Dim Contrl as Variant, disp as Variant, transf as Object
114        Dim URL as new com.sun.star.util.URL
115        Dim noProps()
116        Dim res as Boolean
117
118        Contrl = xDoc.getCurrentController()
119        URL.Complete = "slot:27010"
120        transf = createUnoService("com.sun.star.util.URLTransformer")
121        res = transf.parseStrict(URL)
122
123        out.log("URL parsed :" + res)
124
125        disp = Contrl.queryDispatch(URL, "", 0)
126
127        out.log("disp get.")
128
129        disp.dispatch(URL, noProps())
130Exit Sub
131ErrHndl:
132    Test.Exception()
133End Sub
134
135
136</script:module>
137