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