merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sch / ChartLine.java
blobbb162b37ba5952f1c4bf0e0a8ed2ee2f0f2ff203
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChartLine.java,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package mod._sch;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.SOfficeFactory;
41 import com.sun.star.beans.XPropertySet;
42 import com.sun.star.chart.XChartDocument;
43 import com.sun.star.chart.XDiagram;
44 import com.sun.star.lang.XMultiServiceFactory;
45 import com.sun.star.uno.AnyConverter;
46 import com.sun.star.uno.Type;
48 /**
49 * Test for object which is represented by service
50 * <code>com.sun.star.chart.ChartLine</code>. <p>
51 * Object implements the following interfaces :
52 * <ul>
53 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
54 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
55 * </ul>
56 * @see com.sun.star.drawing.LineProperties
57 * @see com.sun.star.beans.XPropertySet
58 * @see ifc.drawing._LineProperties
59 * @see ifc.beans._XPropertySet
61 public class ChartLine extends TestCase {
62 XChartDocument xChartDoc = null;
64 /**
65 * Creates Chart document.
67 protected void initialize( TestParameters tParam, PrintWriter log ) {
68 // get a soffice factory object
69 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
71 try {
72 log.println( "creating a chartdocument" );
73 xChartDoc = SOF.createChartDoc(null);;
74 } catch (com.sun.star.uno.Exception e) {
75 // Some exception occures.FAILED
76 e.printStackTrace( log );
77 throw new StatusException( "Couldn't create document", e );
81 /**
82 * Disposes Chart document.
84 protected void cleanup( TestParameters tParam, PrintWriter log ) {
85 log.println( " closing xChartDoc " );
86 util.DesktopTools.closeDoc(xChartDoc);
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
97 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
99 XPropertySet oObj = null;
100 XDiagram oDiagram = null;
101 SOfficeFactory SOF = null;
103 //get LineDiagram
104 SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
105 oDiagram = SOF.createDiagram(xChartDoc, "LineDiagram");
107 log.println( "getting Line-Diagram" );
108 xChartDoc.setDiagram(oDiagram);
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 );
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 );
141 log.println( "creating a new environment for chartdocument object" );
142 TestEnvironment tEnv = new TestEnvironment( oObj );
145 return tEnv;
146 } // finish method getTestEnvironment
149 } // finish class ChartLine