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 AccWall extends TestCase { 48 49 XChartDocument xChartDoc = null; 50 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, "", "AccWall"); 103 104 oObj = cont; 105 106 log.println("ImplementationName " + utils.getImplName(oObj)); 107 log.println("AccessibleName " + cont.getAccessibleName()); 108 109 TestEnvironment tEnv = new TestEnvironment(oObj); 110 111 final XAccessibleComponent acc = (XAccessibleComponent) 112 UnoRuntime.queryInterface( 113 XAccessibleComponent.class,oObj); 114 tEnv.addObjRelation("EventProducer", 115 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { 116 public void fireEvent() { 117 acc.grabFocus(); 118 } 119 }); 120 121 return tEnv; 122 123 } 124 125 /** 126 * Called while disposing a <code>TestEnvironment</code>. 127 * Disposes text document. 128 * @param tParam test parameters 129 * @param tEnv the environment to cleanup 130 * @param log writer to log information while testing 131 */ 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