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="sc_ScAccessibleDocumentPagePreview" 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 win As Object
37
38
39Sub CreateObj()
40
41'*************************************************************************
42' COMPONENT:
43' sc.ScAccessibleDocumentPagePreview
44'*************************************************************************
45On Error Goto ErrHndl
46    Dim xRoot As Object, xDispatcher As Object
47    Dim xController As Object, xCell As Object
48    Dim url As New com.sun.star.util.URL
49    Dim urlTransformer As Object, oWin As Object
50    Dim noProps()
51
52    oDoc = utils.createDocument("scalc",cObjectName)
53    xCell = oDoc.getSheets().getByIndex(1).getCellByPosition(0,0)
54    xCell.setFormula("ScAccessibleDocumentPagePreview - Page 2")
55    xCell = oDoc.getSheets().getByIndex(2).getCellByPosition(0,0)
56    xCell.setFormula("ScAccessibleDocumentPagePreview - Page 3")
57    xCell = oDoc.getSheets().getByIndex(0).getCellByPosition(0,0)
58    xCell.setFormula("ScAccessibleDocumentPagePreview - Page 1")
59    xController = oDoc.getCurrentController()
60    urlTransformer = createUNOService("com.sun.star.util.URLTransformer")
61    url.Complete = ".uno:PrintPreview"
62    urlTransformer.parseStrict(url)
63    xDispatcher = xController.queryDispatch(url,"",0)
64
65    if (NOT isNull(xDispatcher)) then
66        xDispatcher.dispatch(url, noProps())
67        oWin = utils.at_getCurrentWindow(oDoc)
68        xRoot = utils.at_getAccessibleObject(oWin)
69        oObj = utils.at_getAccessibleObjectForRole(xRoot, com.sun.star.accessibility.AccessibleRole.DOCUMENT)
70        win = oDoc.getCurrentController().getFrame().getComponentWindow()
71    else
72        Out.Log("QueryDispatch FAILED. Cannot switch to Preview mode...")
73    End If
74
75Exit Sub
76ErrHndl:
77    Test.Exception()
78End Sub
79
80Sub fireEvent()
81    Dim oRect As New com.sun.star.awt.Rectangle
82    oRect = win.getPosSize()
83    win.setPosSize(oRect.X,oRect.Y,oRect.Height-1,oRect.Width-1,15)
84    win.setPosSize(oRect.X,oRect.Y,oRect.Height,oRect.Width,15)
85End Sub
86</script:module>
87