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