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 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.AccessibilityTools
;
28 import util
.SOfficeFactory
;
31 import com
.sun
.star
.accessibility
.AccessibleRole
;
32 import com
.sun
.star
.accessibility
.XAccessible
;
33 import com
.sun
.star
.accessibility
.XAccessibleComponent
;
34 import com
.sun
.star
.awt
.XWindow
;
35 import com
.sun
.star
.beans
.XPropertySet
;
36 import com
.sun
.star
.frame
.XModel
;
37 import com
.sun
.star
.lang
.XComponent
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
44 * Object implements the following interfaces :
46 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
47 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
48 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
49 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
50 * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li>
53 * @see com.sun.star.accessibility.XAccessible
54 * @see com.sun.star.accessibility.XAccessibleComponent
55 * @see com.sun.star.accessibility.XAccessibleContext
56 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
57 * @see com.sun.star.accessibility.XAccessibleText
58 * @see ifc.accessibility._XAccessible
59 * @see ifc.accessibility._XAccessibleComponent
60 * @see ifc.accessibility._XAccessibleContext
61 * @see ifc.accessibility._XAccessibleEventBroadcaster
62 * @see ifc.accessibility._XAccessibleText
64 public class SmGraphicAccessible
extends TestCase
{
68 * Creates a <code>StarMath</code> document and obtains an accessibility
69 * component with the role <code>AccessibleRole.PANEL</code>.
72 protected synchronized TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
74 SOfficeFactory SOF
= SOfficeFactory
.getFactory( Param
.getMSF() );
76 xMathDoc
= SOF
.openDoc("smath","_blank");
77 } catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
78 ex
.printStackTrace( log
);
79 throw new StatusException( "Couldn't create document", ex
);
80 } catch (com
.sun
.star
.io
.IOException ex
) {
81 ex
.printStackTrace( log
);
82 throw new StatusException( "Couldn't create document", ex
);
83 } catch (com
.sun
.star
.uno
.Exception ex
) {
84 ex
.printStackTrace( log
);
85 throw new StatusException( "Couldn't create document", ex
);
88 // setting a formula in document
89 final String expFormula
= "sum a cdot b";
90 final XPropertySet xPS
= UnoRuntime
.queryInterface
91 (XPropertySet
.class, xMathDoc
);
93 xPS
.setPropertyValue("Formula", expFormula
);
94 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
95 log
.println("Couldn't set property value");
96 e
.printStackTrace(log
);
97 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
98 log
.println("Couldn't set property value");
99 e
.printStackTrace(log
);
100 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
101 log
.println("Couldn't set property value");
102 e
.printStackTrace(log
);
103 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
104 log
.println("Couldn't set property value");
105 e
.printStackTrace(log
);
108 XInterface oObj
= null;
110 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xMathDoc
);
113 XWindow xWindow
= AccessibilityTools
.getCurrentWindow(aModel
);
114 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
116 oObj
= AccessibilityTools
.getAccessibleObjectForRole
117 (xRoot
, AccessibleRole
.DOCUMENT
, "Formula");
119 log
.println("ImplementationName " + utils
.getImplName(oObj
));
121 final XAccessibleComponent xAC
= UnoRuntime
.queryInterface(XAccessibleComponent
.class, oObj
);
123 TestEnvironment tEnv
= new TestEnvironment(oObj
);
125 tEnv
.addObjRelation("EditOnly",
126 "This method isn't supported in this dialog");
129 tEnv
.addObjRelation("EventProducer",
130 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer(){
131 public void fireEvent() {
134 xPS
.setPropertyValue("Formula", "sum hat x");
135 util
.utils
.pause(1000);
136 xPS
.setPropertyValue("Formula", expFormula
);
137 util
.utils
.pause(1000);
138 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
139 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
140 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
141 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
149 * Disposes the document created in <code>createTestEnvironment</code>
153 protected void cleanup( TestParameters Param
, PrintWriter log
) {
155 log
.println( " disposing xMathDoc " );
158 } // finish class SmModel