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 import util.utils; 34 35 import com.sun.star.chart.XChartDocument; 36 import com.sun.star.drawing.XShape; 37 import com.sun.star.lang.XComponent; 38 import com.sun.star.lang.XMultiServiceFactory; 39 import com.sun.star.uno.UnoRuntime; 40 41 /** 42 * Test for object which is represented by service 43 * <code>com.sun.star.chart.ChartLegend</code>. <p> 44 * Object implements the following interfaces : 45 * <ul> 46 * <li> <code>com::sun::star::drawing::FillProperties</code></li> 47 * <li> <code>com::sun::star::drawing::XShape</code></li> 48 * <li> <code>com::sun::star::drawing::Shape</code></li> 49 * <li> <code>com::sun::star::chart::ChartLegend</code></li> 50 * <li> <code>com::sun::star::drawing::LineProperties</code></li> 51 * <li> <code>com::sun::star::beans::XPropertySet</code></li> 52 * <li> <code>com::sun::star::style::CharacterProperties</code></li> 53 * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> 54 * <li> <code>com::sun::star::lang::XComponent</code></li> 55 * </ul> 56 * The following files used by this test : 57 * <ul> 58 * <li><b> TransparencyChart.sxs </b> : to load predefined chart 59 * document where two 'automatic' transparency styles exists : 60 * 'Transparency 1' and 'Transparency 2'.</li> 61 * </ul> <p> 62 * @see com.sun.star.drawing.FillProperties 63 * @see com.sun.star.drawing.XShape 64 * @see com.sun.star.drawing.Shape 65 * @see com.sun.star.chart.ChartLegend 66 * @see com.sun.star.drawing.LineProperties 67 * @see com.sun.star.beans.XPropertySet 68 * @see com.sun.star.style.CharacterProperties 69 * @see com.sun.star.drawing.XShapeDescriptor 70 * @see com.sun.star.lang.XComponent 71 * @see ifc.drawing._FillProperties 72 * @see ifc.drawing._XShape 73 * @see ifc.drawing._Shape 74 * @see ifc.chart._ChartLegend 75 * @see ifc.drawing._LineProperties 76 * @see ifc.beans._XPropertySet 77 * @see ifc.style._CharacterProperties 78 * @see ifc.drawing._XShapeDescriptor 79 * @see ifc.lang._XComponent 80 */ 81 public class ChartLegend extends TestCase { 82 XChartDocument xChartDoc = null; 83 84 /** 85 * Creates Chart document. 86 */ initialize( TestParameters tParam, PrintWriter log )87 protected void initialize( TestParameters tParam, PrintWriter log ) { 88 // get a soffice factory object 89 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 90 91 try { 92 log.println( "creating a chartdocument" ); 93 XComponent xComp = SOF.loadDocument( 94 utils.getFullTestURL("TransparencyChart.sxs")); 95 xChartDoc = (XChartDocument) 96 UnoRuntime.queryInterface(XChartDocument.class,xComp); 97 } catch (com.sun.star.uno.Exception e) { 98 // Some exception occures.FAILED 99 e.printStackTrace( log ); 100 throw new StatusException( "Couldn't create document", e ); 101 } 102 } 103 104 /** 105 * Disposes Chart document. 106 */ cleanup( TestParameters tParam, PrintWriter log )107 protected void cleanup( TestParameters tParam, PrintWriter log ) { 108 if( xChartDoc!=null ) { 109 log.println( " closing xChartDoc" ); 110 util.DesktopTools.closeDoc(xChartDoc); 111 xChartDoc = null; 112 } 113 } 114 115 /** 116 * Creating a Testenvironment for the interfaces to be tested. 117 * Retrieves the diagram of the chart document. The retrieved 118 * diagram is the instance of the service 119 * <code>com.sun.star.chart.ChartLegend</code>. 120 */ createTestEnvironment(TestParameters Param, PrintWriter log)121 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 122 123 XShape oObj = null; 124 125 // get the Legend 126 log.println( "getting Legend" ); 127 oObj = (XShape) xChartDoc.getLegend(); 128 129 log.println( "creating a new environment for chartdocument object" ); 130 TestEnvironment tEnv = new TestEnvironment( oObj ); 131 132 tEnv.addObjRelation("NoSetSize", "sch.ChartLegend"); 133 return tEnv; 134 } // finish method getTestEnvironment 135 136 137 } // finish class ChartLegend 138 139