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
.lang
.XMultiServiceFactory
;
38 import com
.sun
.star
.text
.XText
;
39 import com
.sun
.star
.text
.XTextContent
;
40 import com
.sun
.star
.text
.XTextCursor
;
41 import com
.sun
.star
.text
.XTextDocument
;
42 import com
.sun
.star
.uno
.UnoRuntime
;
43 import com
.sun
.star
.uno
.XInterface
;
44 import com
.sun
.star
.view
.XViewSettingsSupplier
;
47 * Test of accessible object for the graphic object of a text document.<p>
48 * Object implements the following interfaces :
50 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
52 * @see com.sun.star.accessibility.XAccessible
54 public class SwAccessibleTextGraphicObject
extends TestCase
{
56 XTextDocument xTextDoc
= null;
59 * Called to create an instance of <code>TestEnvironment</code>
60 * with an object to test and related objects.
61 * Creates a graphic object and inserts it into the document.
62 * Obtains accessible object for graphic object.
64 * @param Param test parameters
65 * @param log writer to log information while testing
67 * @see TestEnvironment
68 * @see #getTestEnvironment
70 protected TestEnvironment
createTestEnvironment(
71 TestParameters Param
, PrintWriter log
) {
73 XInterface oObj
= null;
75 SOfficeFactory SOF
= SOfficeFactory
.getFactory((XMultiServiceFactory
)Param
.getMSF());
76 Object oGraphObj
= SOF
.createInstance(
77 xTextDoc
, "com.sun.star.text.GraphicObject");
79 XText the_text
= xTextDoc
.getText();
80 XTextCursor the_cursor
= the_text
.createTextCursor();
81 XTextContent the_content
= UnoRuntime
.queryInterface(XTextContent
.class, oGraphObj
);
83 log
.println( "inserting graphic" );
85 the_text
.insertTextContent(the_cursor
, the_content
, true);
86 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
88 throw new StatusException("Couldn't insert Content", e
);
91 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
93 AccessibilityTools at
= new AccessibilityTools();
95 XWindow xWindow
= AccessibilityTools
.getCurrentWindow((XMultiServiceFactory
)Param
.getMSF(), aModel
);
96 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
98 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.GRAPHIC
);
100 log
.println("ImplementationName " + utils
.getImplName(oObj
));
101 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
103 TestEnvironment tEnv
= new TestEnvironment(oObj
);
105 XController xController
= xTextDoc
.getCurrentController();
106 XViewSettingsSupplier xViewSetSup
= UnoRuntime
.queryInterface(XViewSettingsSupplier
.class,
109 final XPropertySet PropSet
= xViewSetSup
.getViewSettings();
111 tEnv
.addObjRelation("EventProducer",
112 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
113 public void fireEvent() {
115 //change zoom value to 15%
116 PropSet
.setPropertyValue("ZoomValue", new Short("15"));
118 PropSet
.setPropertyValue("ZoomValue", new Short("100"));
119 } catch ( com
.sun
.star
.lang
.WrappedTargetException e
) {
121 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
123 } catch ( com
.sun
.star
.beans
.PropertyVetoException e
) {
125 } catch ( com
.sun
.star
.beans
.UnknownPropertyException e
) {
138 * Called while disposing a <code>TestEnvironment</code>.
139 * Disposes text document.
140 * @param Param test parameters
141 * @param log writer to log information while testing
143 protected void cleanup( TestParameters Param
, PrintWriter log
) {
144 log
.println("dispose text document");
145 util
.DesktopTools
.closeDoc(xTextDoc
);
149 * Called while the <code>TestCase</code> initialization.
150 * Creates a text document.
152 * @param Param test parameters
153 * @param log writer to log information while testing
155 * @see #initializeTestCase
157 protected void initialize(TestParameters Param
, PrintWriter log
) {
158 log
.println( "creating a text document" );
159 xTextDoc
= WriterTools
.createTextDoc((XMultiServiceFactory
)Param
.getMSF());