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 AccAxis 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 occured.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 XAccessibleContext cont = at.getAccessibleObjectForRole( 76 xRoot, AccessibleRole.SHAPE, "", "AccAxis"); 77 78 79 oObj = cont; 80 81 log.println("ImplementationName " + utils.getImplName(oObj)); 82 log.println("AccessibleName " + cont.getAccessibleName()); 83 84 TestEnvironment tEnv = new TestEnvironment(oObj); 85 86 final XAccessibleComponent acc = (XAccessibleComponent) 87 UnoRuntime.queryInterface( 88 XAccessibleComponent.class,oObj); 89 tEnv.addObjRelation("EventProducer", 90 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { 91 public void fireEvent() { 92 acc.grabFocus(); 93 } 94 }); 95 96 return tEnv; 97 98 } 99 100 /** 101 * Called while disposing a <code>TestEnvironment</code>. 102 * Disposes text document. 103 * @param Param test parameters 104 * @param log writer to log information while testing 105 */ cleanup( TestParameters Param, PrintWriter log)106 protected void cleanup( TestParameters Param, PrintWriter log) { 107 if( xChartDoc!=null ) { 108 log.println( " closing xChartDoc" ); 109 util.DesktopTools.closeDoc(xChartDoc); 110 xChartDoc = null; 111 } 112 } 113 114 } 115