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
;
23 import lib
.TestEnvironment
;
24 import lib
.TestParameters
;
25 import util
.AccessibilityTools
;
26 import util
.SOfficeFactory
;
27 import util
.WriterTools
;
30 import com
.sun
.star
.accessibility
.AccessibleRole
;
31 import com
.sun
.star
.accessibility
.XAccessible
;
32 import com
.sun
.star
.awt
.XWindow
;
33 import com
.sun
.star
.beans
.XPropertySet
;
34 import com
.sun
.star
.frame
.XController
;
35 import com
.sun
.star
.frame
.XModel
;
36 import com
.sun
.star
.text
.XTextDocument
;
37 import com
.sun
.star
.text
.XTextTable
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
40 import com
.sun
.star
.view
.XViewSettingsSupplier
;
43 * Test of accessible object for the table of a text document.<p>
44 * Object implements the following interfaces :
46 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
48 * @see com.sun.star.accessibility.XAccessible
50 public class SwAccessibleTableView
extends TestCase
{
52 XTextDocument xTextDoc
= null;
55 * Called to create an instance of <code>TestEnvironment</code>
56 * with an object to test and related objects.
57 * Creates a text table and inserts it into the document.
58 * Then obtains accessible object for the table.
60 * @param Param test parameters
61 * @param log writer to log information while testing
63 * @see TestEnvironment
64 * @see #getTestEnvironment
67 protected TestEnvironment
createTestEnvironment(
68 TestParameters Param
, PrintWriter log
) {
70 XInterface oObj
= null;
71 XTextTable oTable
= null;
73 SOfficeFactory
.getFactory(Param
.getMSF());
74 oTable
= SOfficeFactory
.createTextTable( xTextDoc
);
76 SOfficeFactory
.insertTextContent(xTextDoc
, oTable
);
78 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
80 XWindow xWindow
= AccessibilityTools
.getCurrentWindow(aModel
);
81 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
83 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TABLE
);
85 log
.println("ImplementationName " + utils
.getImplName(oObj
));
86 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
88 TestEnvironment tEnv
= new TestEnvironment(oObj
);
90 XController xController
= xTextDoc
.getCurrentController();
91 XViewSettingsSupplier xViewSetSup
= UnoRuntime
.queryInterface(XViewSettingsSupplier
.class,
94 final XPropertySet PropSet
= xViewSetSup
.getViewSettings();
96 tEnv
.addObjRelation("EventProducer",
97 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
98 public void fireEvent() {
100 //change zoom value to 15%
101 PropSet
.setPropertyValue("ZoomValue", Short
.valueOf("15"));
103 PropSet
.setPropertyValue("ZoomValue", Short
.valueOf("100"));
104 } catch ( com
.sun
.star
.lang
.WrappedTargetException e
) {
106 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
108 } catch ( com
.sun
.star
.beans
.PropertyVetoException e
) {
110 } catch ( com
.sun
.star
.beans
.UnknownPropertyException e
) {
121 * Called while disposing a <code>TestEnvironment</code>.
122 * Disposes text document.
123 * @param Param test parameters
124 * @param log writer to log information while testing
127 protected void cleanup( TestParameters Param
, PrintWriter log
) {
128 log
.println("dispose text document");
129 util
.DesktopTools
.closeDoc(xTextDoc
);
133 * Called while the <code>TestCase</code> initialization.
134 * Creates a text document.
136 * @param Param test parameters
137 * @param log writer to log information while testing
139 * @see #initializeTestCase
142 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
143 log
.println( "creating a text document" );
144 xTextDoc
= WriterTools
.createTextDoc(Param
.getMSF());