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
.lang
.XMultiServiceFactory
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
40 import com
.sun
.star
.uno
.XInterface
;
45 * Object implements the following interfaces :
47 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
48 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
49 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
50 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
51 * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li>
54 * @see com.sun.star.accessibility.XAccessible
55 * @see com.sun.star.accessibility.XAccessibleComponent
56 * @see com.sun.star.accessibility.XAccessibleContext
57 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
58 * @see com.sun.star.accessibility.XAccessibleText
59 * @see ifc.accessibility._XAccessible
60 * @see ifc.accessibility._XAccessibleComponent
61 * @see ifc.accessibility._XAccessibleContext
62 * @see ifc.accessibility._XAccessibleEventBroadcaster
63 * @see ifc.accessibility._XAccessibleText
65 public class SmGraphicAccessible
extends TestCase
{
69 * Creates a <code>StarMath</code> document and obtains an accessibility
70 * component with the role <code>AccessibleRole.PANEL</code>.
72 protected synchronized TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
74 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
) 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 AccessibilityTools at
= new AccessibilityTools();
115 XWindow xWindow
= AccessibilityTools
.getCurrentWindow( (XMultiServiceFactory
) Param
.getMSF(), aModel
);
116 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
118 oObj
= AccessibilityTools
.getAccessibleObjectForRole
119 (xRoot
, AccessibleRole
.DOCUMENT
, "Formula");
121 log
.println("ImplementationName " + utils
.getImplName(oObj
));
123 final XAccessibleComponent xAC
= UnoRuntime
.queryInterface(XAccessibleComponent
.class, oObj
);
125 TestEnvironment tEnv
= new TestEnvironment(oObj
);
127 tEnv
.addObjRelation("EditOnly",
128 "This method isn't supported in this dialog");
131 tEnv
.addObjRelation("EventProducer",
132 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer(){
133 public void fireEvent() {
136 xPS
.setPropertyValue("Formula", "sum hat x");
138 xPS
.setPropertyValue("Formula", expFormula
);
140 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
141 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
142 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
143 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
151 * Disposes the document created in <code>createTestEnvironment</code>
154 protected void cleanup( TestParameters Param
, PrintWriter log
) {
156 log
.println( " disposing xMathDoc " );
161 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
164 private void shortWait() {
167 } catch (InterruptedException e
) {
168 log
.println("While waiting :" + e
) ;
171 } // finish class SmModel