1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package mod._sch; 24 25 import java.io.PrintWriter; 26 27 import lib.StatusException; 28 import lib.TestCase; 29 import lib.TestEnvironment; 30 import lib.TestParameters; 31 import util.AccessibilityTools; 32 import util.SOfficeFactory; 33 import util.utils; 34 35 import com.sun.star.accessibility.AccessibleRole; 36 import com.sun.star.accessibility.XAccessible; 37 import com.sun.star.accessibility.XAccessibleComponent; 38 import com.sun.star.accessibility.XAccessibleContext; 39 import com.sun.star.awt.XWindow; 40 import com.sun.star.chart.XChartDocument; 41 import com.sun.star.frame.XModel; 42 import com.sun.star.lang.XMultiServiceFactory; 43 import com.sun.star.uno.UnoRuntime; 44 import com.sun.star.uno.XInterface; 45 46 public class AccDiagram extends TestCase { 47 48 XChartDocument xChartDoc = null; 49 createTestEnvironment( TestParameters Param, PrintWriter log)50 protected TestEnvironment createTestEnvironment( 51 TestParameters Param, PrintWriter log) { 52 53 if (xChartDoc != null) cleanup(Param, log); 54 log.println( "creating a chart document" ); 55 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF()); 56 try { 57 log.println( "creating a chartdocument" ); 58 xChartDoc = SOF.createChartDoc(null); 59 } catch (com.sun.star.uno.Exception e) { 60 // Some exception occures.FAILED 61 e.printStackTrace( log ); 62 throw new StatusException( "Couldn't create document", e ); 63 } 64 65 XInterface oObj = null; 66 67 XModel aModel = (XModel) 68 UnoRuntime.queryInterface(XModel.class, xChartDoc); 69 70 AccessibilityTools at = new AccessibilityTools(); 71 72 XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); 73 XAccessible xRoot = at.getAccessibleObject(xWindow); 74 75 at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); 76 77 XAccessibleContext cont = at.getAccessibleObjectForRole( 78 xRoot, AccessibleRole.SHAPE, "", "AccDiagram"); 79 80 oObj = cont; 81 82 log.println("ImplementationName " + utils.getImplName(oObj)); 83 log.println("AccessibleName " + cont.getAccessibleName()); 84 85 TestEnvironment tEnv = new TestEnvironment(oObj); 86 87 final XAccessibleComponent acc = (XAccessibleComponent) 88 UnoRuntime.queryInterface( 89 XAccessibleComponent.class,oObj); 90 tEnv.addObjRelation("EventProducer", 91 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { 92 public void fireEvent() { 93 acc.grabFocus(); 94 } 95 }); 96 97 return tEnv; 98 99 } 100 101 /** 102 * Called while disposing a <code>TestEnvironment</code>. 103 * Disposes text document. 104 * @param Param test parameters 105 * @param log writer to log information while testing 106 */ cleanup( TestParameters Param, PrintWriter log)107 protected void cleanup( TestParameters Param, PrintWriter log) { 108 if( xChartDoc!=null ) { 109 log.println( " closing xChartDoc" ); 110 util.DesktopTools.closeDoc(xChartDoc); 111 xChartDoc = null; 112 } 113 } 114 115 } 116