1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package mod._sch; 29 30 import java.io.PrintWriter; 31 32 import lib.StatusException; 33 import lib.TestCase; 34 import lib.TestEnvironment; 35 import lib.TestParameters; 36 import util.SOfficeFactory; 37 38 import com.sun.star.beans.XPropertySet; 39 import com.sun.star.chart.XAxisYSupplier; 40 import com.sun.star.chart.XChartDocument; 41 import com.sun.star.chart.XDiagram; 42 import com.sun.star.drawing.XShape; 43 import com.sun.star.lang.XMultiServiceFactory; 44 import com.sun.star.uno.UnoRuntime; 45 46 /** 47 * Test for object which is represented by service 48 * <code>com.sun.star.chart.ChartAxis</code>. <p> 49 * Object implements the following interfaces : 50 * <ul> 51 * <li> <code>com::sun::star::drawing::LineProperties</code></li> 52 * <li> <code>com::sun::star::style::CharacterProperties</code></li> 53 * <li> <code>com::sun::star::beans::XPropertySet</code></li> 54 * <li> <code>com::sun::star::chart::ChartAxis</code></li> 55 * </ul> 56 * @see com.sun.star.drawing.LineProperties 57 * @see com.sun.star.style.CharacterProperties 58 * @see com.sun.star.beans.XPropertySet 59 * @see com.sun.star.chart.ChartAxis 60 * @see ifc.drawing._LineProperties 61 * @see ifc.style._CharacterProperties 62 * @see ifc.beans._XPropertySet 63 * @see ifc.chart._ChartAxis 64 */ 65 public class ChXChartAxis extends TestCase { 66 XChartDocument xChartDoc = null; 67 68 /** 69 * Creates Chart document. 70 */ 71 protected void initialize( TestParameters tParam, PrintWriter log ) { 72 // get a soffice factory object 73 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 74 75 try { 76 log.println( "creating a chartdocument" ); 77 xChartDoc = SOF.createChartDoc(null);; 78 } catch (com.sun.star.uno.Exception e) { 79 // Some exception occures.FAILED 80 e.printStackTrace( log ); 81 throw new StatusException( "Couldn't create document", e ); 82 } 83 } 84 85 /** 86 * Disposes Chart document. 87 */ 88 protected void cleanup( TestParameters tParam, PrintWriter log ) { 89 if( xChartDoc!=null ) { 90 log.println( " closing xChartDoc" ); 91 util.DesktopTools.closeDoc(xChartDoc); 92 xChartDoc = null; 93 } 94 } 95 96 /** 97 * Creating a Testenvironment for the interfaces to be tested. 98 * Retrieves the diagram of the chart document. Then obtains the properties 99 * of the y-axis of the diagram using the interface 100 * <code>XAxisYSupplier</code>. The obatined property is the instance 101 * of the service <code>com.sun.star.chart.ChartAxis</code>. 102 * @see com.sun.star.chart.XAxisYSupplier 103 * @see com.sun.star.chart.ChartAxis 104 */ 105 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 106 107 XPropertySet oObj = null; 108 XShape oDiagram = null; 109 110 // create testobject here 111 // get the Diagram 112 log.println( "getting Diagram" ); 113 oDiagram = (XDiagram) xChartDoc.getDiagram(); 114 115 // get the Axis 116 log.println( "getting ChartAxis" ); 117 XAxisYSupplier oAxisSup = (XAxisYSupplier) 118 UnoRuntime.queryInterface(XAxisYSupplier.class,oDiagram); 119 oObj = (XPropertySet) oAxisSup.getYAxis(); 120 121 log.println( "creating a new environment for chartdocument object" ); 122 TestEnvironment tEnv = new TestEnvironment( oObj ); 123 124 return tEnv; 125 } // finish method getTestEnvironment 126 127 128 129 } // finish class ChXChartAxis 130 131