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.XChartDocument; 40 import com.sun.star.chart.XDiagram; 41 import com.sun.star.lang.XMultiServiceFactory; 42 import com.sun.star.uno.AnyConverter; 43 import com.sun.star.uno.Type; 44 45 /** 46 * Test for object which is represented by service 47 * <code>com.sun.star.chart.ChartLine</code>. <p> 48 * Object implements the following interfaces : 49 * <ul> 50 * <li> <code>com::sun::star::drawing::LineProperties</code></li> 51 * <li> <code>com::sun::star::beans::XPropertySet</code></li> 52 * </ul> 53 * @see com.sun.star.drawing.LineProperties 54 * @see com.sun.star.beans.XPropertySet 55 * @see ifc.drawing._LineProperties 56 * @see ifc.beans._XPropertySet 57 */ 58 public class ChartLine extends TestCase { 59 XChartDocument xChartDoc = null; 60 61 /** 62 * Creates Chart document. 63 */ 64 protected void initialize( TestParameters tParam, PrintWriter log ) { 65 // get a soffice factory object 66 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); 67 68 try { 69 log.println( "creating a chartdocument" ); 70 xChartDoc = SOF.createChartDoc(null);; 71 } catch (com.sun.star.uno.Exception e) { 72 // Some exception occures.FAILED 73 e.printStackTrace( log ); 74 throw new StatusException( "Couldn't create document", e ); 75 } 76 } 77 78 /** 79 * Disposes Chart document. 80 */ 81 protected void cleanup( TestParameters tParam, PrintWriter log ) { 82 if( xChartDoc!=null ) { 83 log.println( " closing xChartDoc" ); 84 util.DesktopTools.closeDoc(xChartDoc); 85 xChartDoc = null; 86 } 87 } 88 89 /** 90 * Creating a Testenvironment for the interfaces to be tested. 91 * Creates a bar diagram and sets the created diagram for the chart document. 92 * Retrieves the property <code>'DataMeanValueProperties'</code> of 93 * the specified data row. The retrieved property is the instance of 94 * the service <code>com.sun.star.chart.ChartLine</code>. 95 * @see com.sun.star.chart.ChartLine 96 */ 97 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 98 99 XPropertySet oObj = null; 100 XDiagram oDiagram = null; 101 SOfficeFactory SOF = null; 102 103 //get LineDiagram 104 SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF()); 105 oDiagram = SOF.createDiagram(xChartDoc, "LineDiagram"); 106 107 log.println( "getting Line-Diagram" ); 108 xChartDoc.setDiagram(oDiagram); 109 110 // get the Line 111 try { 112 log.println( "getting Line" ); 113 XPropertySet RowProps = oDiagram.getDataRowProperties(1); 114 RowProps.setPropertyValue("MeanValue", new Boolean( true )); 115 oObj = (XPropertySet) AnyConverter.toObject( 116 new Type(XPropertySet.class), 117 RowProps.getPropertyValue("DataMeanValueProperties")); 118 } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 119 // Some exception occures.FAILED 120 e.printStackTrace( log ); 121 throw new StatusException( "Couldn't get Line", e ); 122 } catch (com.sun.star.lang.WrappedTargetException e) { 123 // Some exception occures.FAILED 124 e.printStackTrace( log ); 125 throw new StatusException( "Couldn't get Line", e ); 126 } catch (com.sun.star.beans.UnknownPropertyException e) { 127 // Some exception occures.FAILED 128 e.printStackTrace( log ); 129 throw new StatusException( "Couldn't get Line", e ); 130 } catch (com.sun.star.lang.IllegalArgumentException e) { 131 // Some exception occures.FAILED 132 e.printStackTrace( log ); 133 throw new StatusException( "Couldn't get Line", e ); 134 } 135 catch(com.sun.star.beans.PropertyVetoException e) { 136 // Some exception occures.FAILED 137 e.printStackTrace( log ); 138 throw new StatusException( "Couldn't get Line", e ); 139 } 140 141 log.println( "creating a new environment for chartdocument object" ); 142 TestEnvironment tEnv = new TestEnvironment( oObj ); 143 144 145 return tEnv; 146 } // finish method getTestEnvironment 147 148 149 } // finish class ChartLine 150 151