2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 import java
.io
.PrintWriter
;
22 import lib
.StatusException
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.AccessibilityTools
;
27 import util
.SOfficeFactory
;
28 import util
.WriterTools
;
31 import com
.sun
.star
.accessibility
.AccessibleRole
;
32 import com
.sun
.star
.accessibility
.XAccessible
;
33 import com
.sun
.star
.awt
.XWindow
;
34 import com
.sun
.star
.beans
.XPropertySet
;
35 import com
.sun
.star
.frame
.XController
;
36 import com
.sun
.star
.frame
.XModel
;
37 import com
.sun
.star
.text
.XTextDocument
;
38 import com
.sun
.star
.text
.XTextTable
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
40 import com
.sun
.star
.uno
.XInterface
;
41 import com
.sun
.star
.view
.XViewSettingsSupplier
;
44 * Test of accessible object for the table of a text document.<p>
45 * Object implements the following interfaces :
47 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
49 * @see com.sun.star.accessibility.XAccessible
51 public class SwAccessibleTableView
extends TestCase
{
53 XTextDocument xTextDoc
= null;
56 * Called to create an instance of <code>TestEnvironment</code>
57 * with an object to test and related objects.
58 * Creates a text table and inserts it into the document.
59 * Then obtains accessible object for the table.
61 * @param Param test parameters
62 * @param log writer to log information while testing
64 * @see TestEnvironment
65 * @see #getTestEnvironment
68 protected TestEnvironment
createTestEnvironment(
69 TestParameters Param
, PrintWriter log
) {
71 XInterface oObj
= null;
72 XTextTable oTable
= null;
74 SOfficeFactory
.getFactory(Param
.getMSF());
75 oTable
= SOfficeFactory
.createTextTable( xTextDoc
);
78 SOfficeFactory
.insertTextContent(xTextDoc
, oTable
);
79 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
80 e
.printStackTrace( log
);
81 throw new StatusException("Couldn't insert text content :"
85 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
87 XWindow xWindow
= AccessibilityTools
.getCurrentWindow(aModel
);
88 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
90 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TABLE
);
92 log
.println("ImplementationName " + utils
.getImplName(oObj
));
93 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
95 TestEnvironment tEnv
= new TestEnvironment(oObj
);
97 XController xController
= xTextDoc
.getCurrentController();
98 XViewSettingsSupplier xViewSetSup
= UnoRuntime
.queryInterface(XViewSettingsSupplier
.class,
101 final XPropertySet PropSet
= xViewSetSup
.getViewSettings();
103 tEnv
.addObjRelation("EventProducer",
104 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
105 public void fireEvent() {
107 //change zoom value to 15%
108 PropSet
.setPropertyValue("ZoomValue", Short
.valueOf("15"));
110 PropSet
.setPropertyValue("ZoomValue", Short
.valueOf("100"));
111 } catch ( com
.sun
.star
.lang
.WrappedTargetException e
) {
113 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
115 } catch ( com
.sun
.star
.beans
.PropertyVetoException e
) {
117 } catch ( com
.sun
.star
.beans
.UnknownPropertyException e
) {
128 * Called while disposing a <code>TestEnvironment</code>.
129 * Disposes text document.
130 * @param Param test parameters
131 * @param log writer to log information while testing
134 protected void cleanup( TestParameters Param
, PrintWriter log
) {
135 log
.println("dispose text document");
136 util
.DesktopTools
.closeDoc(xTextDoc
);
140 * Called while the <code>TestCase</code> initialization.
141 * Creates a text document.
143 * @param Param test parameters
144 * @param log writer to log information while testing
146 * @see #initializeTestCase
149 protected void initialize(TestParameters Param
, PrintWriter log
) {
150 log
.println( "creating a text document" );
151 xTextDoc
= WriterTools
.createTextDoc(Param
.getMSF());