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