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.beans.XPropertySet; 36 import com.sun.star.chart.XChartDocument; 37 import com.sun.star.chart.XDiagram; 38 import com.sun.star.lang.XComponent; 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.ChartDataPointProperties</code>. <p> 45 * Object implements the following interfaces 46 * <ul> 47 * <li> <code>com::sun::star::chart::ChartDataPointProperties</code></li> 48 * <li> <code>com::sun::star::drawing::FillProperties</code></li> 49 * <li> <code>com::sun::star::drawing::LineProperties</code></li> 50 * <li> <code>com::sun::star::style::CharacterProperties</code></li> 51 * <li> <code>com::sun::star::beans::XPropertySet</code></li> 52 * <li> <code>com::sun::star::chart::Chart3DBarProperties</code></li> 53 * </ul> 54 * The following files used by this test : 55 * <ul> 56 * <li><b> TransparencyChart.sxs </b> : to load predefined chart 57 * document where two 'automatic' transparency styles exists : 58 * 'Transparency 1' and 'Transparency 2'.</li> 59 * </ul> <p> 60 * @see com.sun.star.chart.ChartDataPointProperties 61 * @see com.sun.star.drawing.FillProperties 62 * @see com.sun.star.drawing.LineProperties 63 * @see com.sun.star.style.CharacterProperties 64 * @see com.sun.star.beans.XPropertySet 65 * @see com.sun.star.chart.Chart3DBarProperties 66 * @see ifc.chart._ChartDataPointProperties 67 * @see ifc.drawing._FillProperties 68 * @see ifc.drawing._LineProperties 69 * @see ifc.style._CharacterProperties 70 * @see ifc.beans._XPropertySet 71 * @see ifc.chart._Chart3DBarProperties 72 */ 73 public class ChXDataPoint extends TestCase { 74 XChartDocument xChartDoc = null; 75 76 /** 77 * Creates Chart document. 78 */ initialize( TestParameters tParam, PrintWriter log )79 protected void initialize( TestParameters tParam, PrintWriter log ) { 80 // get a soffice factory object 81 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 82 83 try { 84 log.println( "creating a chartdocument" ); 85 XComponent xComp = SOF.loadDocument( 86 utils.getFullTestURL("TransparencyChart.sxs")); 87 xChartDoc = (XChartDocument) 88 UnoRuntime.queryInterface(XChartDocument.class,xComp); 89 } catch (com.sun.star.uno.Exception e) { 90 // Some exception occures.FAILED 91 e.printStackTrace( log ); 92 throw new StatusException( "Couldn't create document", e ); 93 } 94 } 95 96 /** 97 * Disposes Chart document. 98 */ cleanup( TestParameters tParam, PrintWriter log )99 protected void cleanup( TestParameters tParam, PrintWriter log ) { 100 if( xChartDoc!=null ) { 101 log.println( " closing xChartDoc" ); 102 util.DesktopTools.closeDoc(xChartDoc); 103 xChartDoc = null; 104 } 105 } 106 107 /** 108 * Creating a Testenvironment for the interfaces to be tested. 109 * Retrieves the diagram of the chart document. Obtains the properties of 110 * the specified data point. The obtained properties is the instance of 111 * the service <code>com.sun.star.chart.ChartDataPointProperties</code>. 112 * Creates a XY-diagram and bar-diagram also. 113 * Object relations created : 114 * <ul> 115 * <li> <code>'LINE'</code> for 116 * {@link ifc.chart._ChartDataPointProperties}(the created XY-diagram)</li> 117 * <li> <code>'CHARTDOC'</code> for 118 * {@link ifc.chart._ChartDataPointProperties}, 119 * {@link ifc.chart._Chart3DBarProperties}(the chart document)</li> 120 * <li> <code>'BAR'</code> for 121 * {@link ifc.chart._Chart3DBarProperties}(the created bar-diagram)</li> 122 * </ul> 123 */ createTestEnvironment(TestParameters Param, PrintWriter log)124 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 125 126 XPropertySet oObj = null; 127 XDiagram oDiagram = null; 128 129 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF()); 130 131 // get the DataRowPoint_Point 132 try { 133 log.println( "getting ChXDataRowPoint_Point" ); 134 oDiagram = (XDiagram) xChartDoc.getDiagram(); 135 oObj = (XPropertySet) oDiagram.getDataPointProperties(1,1); 136 } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 137 // Some exception occures.FAILED 138 e.printStackTrace( log ); 139 throw new StatusException( "Couldn't get ChXDataRowPoint_Point", e ); 140 } 141 142 log.println( "creating a new environment for chartdocument object" ); 143 TestEnvironment tEnv = new TestEnvironment( oObj ); 144 145 Object line = SOF.createDiagram(xChartDoc,"XYDiagram"); 146 tEnv.addObjRelation("LINE",line); 147 148 Object bar = SOF.createDiagram(xChartDoc,"BarDiagram"); 149 tEnv.addObjRelation("BAR",bar); 150 151 log.println( "adding ChartDocument as mod relation to environment" ); 152 tEnv.addObjRelation("CHARTDOC", xChartDoc); 153 154 return tEnv; 155 } // finish method getTestEnvironment 156 157 } // finish class ChXDataPoint 158 159