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.beans.XPropertySet; 41 import com.sun.star.chart.XChartDocument; 42 import com.sun.star.frame.XModel; 43 import com.sun.star.lang.XMultiServiceFactory; 44 import com.sun.star.uno.UnoRuntime; 45 import com.sun.star.uno.XInterface; 46 47 public class AccFloor extends TestCase { 48 49 XChartDocument xChartDoc = null; 50 createTestEnvironment( TestParameters Param, PrintWriter log)51 protected TestEnvironment createTestEnvironment( 52 TestParameters Param, PrintWriter log) { 53 54 if (xChartDoc != null) cleanup(Param, log); 55 log.println( "creating a chart document" ); 56 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF()); 57 try { 58 log.println( "creating a chartdocument" ); 59 xChartDoc = SOF.createChartDoc(null); 60 } catch (com.sun.star.uno.Exception e) { 61 // Some exception occures.FAILED 62 e.printStackTrace( log ); 63 throw new StatusException( "Couldn't create document", e ); 64 } 65 66 log.println("Change Diagram to 3D"); 67 XPropertySet ChartProps = (XPropertySet) 68 UnoRuntime.queryInterface( XPropertySet.class, xChartDoc.getDiagram() ); 69 try { 70 ChartProps.setPropertyValue("Dim3D", new Boolean(true)); 71 } catch(com.sun.star.lang.WrappedTargetException e) { 72 log.println("Couldn't change Diagram to 3D"); 73 e.printStackTrace(log); 74 throw new StatusException("Couldn't change Diagram to 3D", e); 75 } catch(com.sun.star.lang.IllegalArgumentException e) { 76 log.println("Couldn't change Diagram to 3D"); 77 e.printStackTrace(log); 78 throw new StatusException("Couldn't change Diagram to 3D", e); 79 } catch(com.sun.star.beans.PropertyVetoException e) { 80 log.println("Couldn't change Diagram to 3D"); 81 e.printStackTrace(log); 82 throw new StatusException("Couldn't change Diagram to 3D", e); 83 } catch(com.sun.star.beans.UnknownPropertyException e) { 84 log.println("Couldn't change Diagram to 3D"); 85 e.printStackTrace(log); 86 throw new StatusException("Couldn't change Diagram to 3D", e); 87 } 88 89 XInterface oObj = null; 90 91 XModel aModel = (XModel) 92 UnoRuntime.queryInterface(XModel.class, xChartDoc); 93 94 AccessibilityTools at = new AccessibilityTools(); 95 96 XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel); 97 XAccessible xRoot = at.getAccessibleObject(xWindow); 98 99 at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); 100 101 XAccessibleContext cont = at.getAccessibleObjectForRole( 102 xRoot, AccessibleRole.SHAPE, "", "AccFloor"); 103 104 105 oObj = cont; 106 107 log.println("ImplementationName " + utils.getImplName(oObj)); 108 log.println("AccessibleName " + cont.getAccessibleName()); 109 110 TestEnvironment tEnv = new TestEnvironment(oObj); 111 112 final XAccessibleComponent acc = (XAccessibleComponent) 113 UnoRuntime.queryInterface( 114 XAccessibleComponent.class,oObj); 115 tEnv.addObjRelation("EventProducer", 116 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { 117 public void fireEvent() { 118 acc.grabFocus(); 119 } 120 }); 121 122 return tEnv; 123 124 } 125 126 /** 127 * Called while disposing a <code>TestEnvironment</code>. 128 * Disposes text document. 129 * @param Param test parameters 130 * @param log writer to log information while testing 131 */ cleanup( TestParameters Param, PrintWriter log)132 protected void cleanup( TestParameters Param, PrintWriter log) { 133 if( xChartDoc!=null ) { 134 log.println( " closing xChartDoc" ); 135 util.DesktopTools.closeDoc(xChartDoc); 136 xChartDoc = null; 137 } 138 } 139 140 } 141