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 24 package mod._sch; 25 26 import java.io.PrintWriter; 27 28 import lib.StatusException; 29 import lib.TestCase; 30 import lib.TestEnvironment; 31 import lib.TestParameters; 32 import util.SOfficeFactory; 33 34 import com.sun.star.beans.XPropertySet; 35 import com.sun.star.chart.XAxisXSupplier; 36 import com.sun.star.chart.XChartDocument; 37 import com.sun.star.chart.XDiagram; 38 import com.sun.star.drawing.XShape; 39 import com.sun.star.lang.XMultiServiceFactory; 40 import com.sun.star.uno.UnoRuntime; 41 42 /** 43 * Test for object which is represented by service 44 * <code>com.sun.star.chart.ChartGrid</code>. <p> 45 * Object implements the following interfaces : 46 * <ul> 47 * <li> <code>com::sun::star::drawing::LineProperties</code></li> 48 * <li> <code>com::sun::star::beans::XPropertySet</code></li> 49 * </ul> 50 * @see com.sun.star.chart.ChartGrid 51 * @see com.sun.star.drawing.LineProperties 52 * @see com.sun.star.beans.XPropertySet 53 * @see ifc.drawing._LineProperties 54 * @see ifc.beans._XPropertySet 55 */ 56 public class ChartGrid extends TestCase { 57 XChartDocument xChartDoc = null; 58 59 /** 60 * Creates Chart document. 61 */ initialize( TestParameters tParam, PrintWriter log )62 protected void initialize( TestParameters tParam, PrintWriter log ) { 63 // get a soffice factory object 64 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 65 66 try { 67 log.println( "creating a chartdocument" ); 68 xChartDoc = SOF.createChartDoc(null); 69 } catch (com.sun.star.uno.Exception e) { 70 // Some exception occures.FAILED 71 e.printStackTrace( log ); 72 throw new StatusException( "Couldn't create document", e ); 73 } 74 } 75 76 /** 77 * Disposes Chart document. 78 */ cleanup( TestParameters tParam, PrintWriter log )79 protected void cleanup( TestParameters tParam, PrintWriter log ) { 80 if( xChartDoc!=null ) { 81 log.println( " closing xChartDoc" ); 82 util.DesktopTools.closeDoc(xChartDoc); 83 xChartDoc = null; 84 } 85 } 86 87 /** 88 * Creating a Testenvironment for the interfaces to be tested. 89 * Retrieves the diagram of the chart document. Then obtains 90 * the properties of the main grid of the x-axis of the diagram 91 * using the interface <code>XAxisXSupplier</code>. This properties is 92 * the instance of the service <code>com.sun.star.chart.ChartGrid</code>. 93 * @see com.sun.star.chart.XAxisXSupplier 94 * @see com.sun.star.chart.ChartGrid 95 */ createTestEnvironment(TestParameters Param, PrintWriter log)96 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 97 XPropertySet oObj = null; 98 XShape oDiagram = null; 99 100 // get the Diagram 101 log.println( "getting Diagram" ); 102 oDiagram = (XDiagram) xChartDoc.getDiagram(); 103 104 // get the Grid 105 log.println( "getting ChartGrid" ); 106 XAxisXSupplier oAxisSup = (XAxisXSupplier) 107 UnoRuntime.queryInterface(XAxisXSupplier.class,oDiagram); 108 oObj = (XPropertySet) oAxisSup.getXMainGrid(); 109 110 log.println( "creating a new environment for chartdocument object" ); 111 TestEnvironment tEnv = new TestEnvironment( oObj ); 112 113 return tEnv; 114 } // finish method getTestEnvironment 115 116 117 } // finish class ChartGrid 118 119