1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SwAccessibleTableView.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 import java
.io
.PrintWriter
;
34 import lib
.StatusException
;
36 import lib
.TestEnvironment
;
37 import lib
.TestParameters
;
38 import util
.AccessibilityTools
;
39 import util
.SOfficeFactory
;
40 import util
.WriterTools
;
43 import com
.sun
.star
.accessibility
.AccessibleRole
;
44 import com
.sun
.star
.accessibility
.XAccessible
;
45 import com
.sun
.star
.awt
.XWindow
;
46 import com
.sun
.star
.beans
.XPropertySet
;
47 import com
.sun
.star
.frame
.XController
;
48 import com
.sun
.star
.frame
.XModel
;
49 import com
.sun
.star
.lang
.XMultiServiceFactory
;
50 import com
.sun
.star
.text
.XTextDocument
;
51 import com
.sun
.star
.text
.XTextTable
;
52 import com
.sun
.star
.uno
.UnoRuntime
;
53 import com
.sun
.star
.uno
.XInterface
;
54 import com
.sun
.star
.view
.XViewSettingsSupplier
;
57 * Test of accessible object for the table of a text document.<p>
58 * Object implements the following interfaces :
60 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
62 * @see com.sun.star.accessibility.XAccessible
64 public class SwAccessibleTableView
extends TestCase
{
66 XTextDocument xTextDoc
= null;
69 * Called to create an instance of <code>TestEnvironment</code>
70 * with an object to test and related objects.
71 * Creates a text table and inserts it into the document.
72 * Then obtains accessible object for the table.
74 * @param tParam test parameters
75 * @param log writer to log information while testing
77 * @see TestEnvironment
78 * @see #getTestEnvironment()
80 protected TestEnvironment
createTestEnvironment(
81 TestParameters Param
, PrintWriter log
) {
83 XInterface oObj
= null;
84 XTextTable oTable
= null;
86 SOfficeFactory SOF
= SOfficeFactory
.getFactory((XMultiServiceFactory
)Param
.getMSF());
88 oTable
= SOF
.createTextTable( xTextDoc
);
89 } catch ( com
.sun
.star
.uno
.Exception e
) {
90 e
.printStackTrace( log
);
91 throw new StatusException("Couldn't create TextTable : " +
96 SOF
.insertTextContent(xTextDoc
, oTable
);
97 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
98 e
.printStackTrace( log
);
99 throw new StatusException("Couldn't insert text content :"
100 + e
.getMessage(), e
);
103 XModel aModel
= (XModel
)
104 UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
106 AccessibilityTools at
= new AccessibilityTools();
108 XWindow xWindow
= at
.getCurrentWindow((XMultiServiceFactory
)Param
.getMSF(), aModel
);
109 XAccessible xRoot
= at
.getAccessibleObject(xWindow
);
111 at
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TABLE
);
113 oObj
= at
.SearchedContext
;
115 log
.println("ImplementationName " + utils
.getImplName(oObj
));
116 at
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
118 TestEnvironment tEnv
= new TestEnvironment(oObj
);
120 XController xController
= xTextDoc
.getCurrentController();
121 XViewSettingsSupplier xViewSetSup
= (XViewSettingsSupplier
)
122 UnoRuntime
.queryInterface(XViewSettingsSupplier
.class,
125 final XPropertySet PropSet
= xViewSetSup
.getViewSettings();
127 tEnv
.addObjRelation("EventProducer",
128 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
129 public void fireEvent() {
131 //change zoom value to 15%
132 PropSet
.setPropertyValue("ZoomValue", new Short("15"));
134 PropSet
.setPropertyValue("ZoomValue", new Short("100"));
135 } catch ( com
.sun
.star
.lang
.WrappedTargetException e
) {
137 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
139 } catch ( com
.sun
.star
.beans
.PropertyVetoException e
) {
141 } catch ( com
.sun
.star
.beans
.UnknownPropertyException e
) {
152 * Called while disposing a <code>TestEnvironment</code>.
153 * Disposes text document.
154 * @param tParam test parameters
155 * @param tEnv the environment to cleanup
156 * @param log writer to log information while testing
158 protected void cleanup( TestParameters Param
, PrintWriter log
) {
159 log
.println("dispose text document");
160 util
.DesktopTools
.closeDoc(xTextDoc
);
164 * Called while the <code>TestCase</code> initialization.
165 * Creates a text document.
167 * @param tParam test parameters
168 * @param log writer to log information while testing
170 * @see #initializeTestCase()
172 protected void initialize(TestParameters Param
, PrintWriter log
) {
173 log
.println( "creating a text document" );
174 xTextDoc
= WriterTools
.createTextDoc((XMultiServiceFactory
)Param
.getMSF());