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
.XAccessibleContext
;
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
;
43 * Object implements the following interfaces :
45 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
46 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
47 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
48 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
49 * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li>
52 * @see com.sun.star.accessibility.XAccessible
53 * @see com.sun.star.accessibility.XAccessibleComponent
54 * @see com.sun.star.accessibility.XAccessibleContext
55 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
56 * @see com.sun.star.accessibility.XAccessibleText
57 * @see ifc.accessibility._XAccessible
58 * @see ifc.accessibility._XAccessibleComponent
59 * @see ifc.accessibility._XAccessibleContext
60 * @see ifc.accessibility._XAccessibleEventBroadcaster
61 * @see ifc.accessibility._XAccessibleText
63 public class SmEditAccessible
extends TestCase
{
67 * Creates a <code>StarMath</code> document and obtains an accessibility
68 * component with the role <code>AccessibleRole.PANEL</code>.
70 protected synchronized TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
72 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF() );
74 xMathDoc
= SOF
.openDoc("smath","_blank");
75 } catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
76 ex
.printStackTrace( log
);
77 throw new StatusException( "Couldn't create document", ex
);
78 } catch (com
.sun
.star
.io
.IOException ex
) {
79 ex
.printStackTrace( log
);
80 throw new StatusException( "Couldn't create document", ex
);
81 } catch (com
.sun
.star
.uno
.Exception ex
) {
82 ex
.printStackTrace( log
);
83 throw new StatusException( "Couldn't create document", ex
);
86 // setting a formula in document
87 final String expFormula
= "sum hat a";
88 final XPropertySet xPS
= UnoRuntime
.queryInterface
89 (XPropertySet
.class, xMathDoc
);
91 xPS
.setPropertyValue("Formula", expFormula
);
92 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
93 log
.println("Couldn't set property value");
94 e
.printStackTrace(log
);
95 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
96 log
.println("Couldn't set property value");
97 e
.printStackTrace(log
);
98 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
99 log
.println("Couldn't set property value");
100 e
.printStackTrace(log
);
101 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
102 log
.println("Couldn't set property value");
103 e
.printStackTrace(log
);
106 XInterface oObj
= null;
108 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xMathDoc
);
111 AccessibilityTools at
= new AccessibilityTools();
113 XWindow xWindow
= AccessibilityTools
.getCurrentWindow((XMultiServiceFactory
)Param
.getMSF(), aModel
);
114 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
116 oObj
= AccessibilityTools
.getAccessibleObjectForRole
117 (xRoot
, AccessibleRole
.PANEL
, "", "SmEditAccessible");
119 log
.println("ImplementationName " + utils
.getImplName(oObj
));
120 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
121 TestEnvironment tEnv
= new TestEnvironment(oObj
);
123 tEnv
.addObjRelation("Destroy", new Boolean(true));
125 final XAccessibleContext con
= UnoRuntime
.queryInterface(XAccessibleContext
.class, oObj
);
126 tEnv
.addObjRelation("EventProducer",
127 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer(){
128 public void fireEvent() {
130 System
.out
.println("Children "+con
.getAccessibleChildCount());
131 xPS
.setPropertyValue("Formula", "sum hat x \n int a \n sum b");
133 System
.out
.println("Children "+con
.getAccessibleChildCount());
134 xPS
.setPropertyValue("Formula", expFormula
);
136 } catch(com
.sun
.star
.lang
.WrappedTargetException e
) {
137 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
138 } catch(com
.sun
.star
.beans
.PropertyVetoException e
) {
139 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
148 * Disposes the document created in <code>createTestEnvironment</code>
151 protected void cleanup( TestParameters Param
, PrintWriter log
) {
153 log
.println( " disposing xMathDoc " );
158 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
161 private void shortWait() {
164 } catch (InterruptedException e
) {
165 log
.println("While waiting :" + e
) ;
168 } // finish class SmModel