bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sch / ChartLine.java
blob6ce09ec0d9d20474ada86b234c6c5325fa164e4d
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package mod._sch;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
29 import com.sun.star.beans.XPropertySet;
30 import com.sun.star.chart.XChartDocument;
31 import com.sun.star.chart.XDiagram;
32 import com.sun.star.lang.XMultiServiceFactory;
33 import com.sun.star.uno.AnyConverter;
34 import com.sun.star.uno.Type;
36 /**
37 * Test for object which is represented by service
38 * <code>com.sun.star.chart.ChartLine</code>. <p>
39 * Object implements the following interfaces :
40 * <ul>
41 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
42 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
43 * </ul>
44 * @see com.sun.star.drawing.LineProperties
45 * @see com.sun.star.beans.XPropertySet
46 * @see ifc.drawing._LineProperties
47 * @see ifc.beans._XPropertySet
49 public class ChartLine extends TestCase {
50 XChartDocument xChartDoc = null;
52 /**
53 * Creates Chart document.
55 protected void initialize( TestParameters tParam, PrintWriter log ) {
56 // get a soffice factory object
57 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
59 try {
60 log.println( "creating a chartdocument" );
61 xChartDoc = SOF.createChartDoc(null);
62 } catch (com.sun.star.uno.Exception e) {
63 // Some exception occurs.FAILED
64 e.printStackTrace( log );
65 throw new StatusException( "Couldn't create document", e );
69 /**
70 * Disposes Chart document.
72 protected void cleanup( TestParameters tParam, PrintWriter log ) {
73 if( xChartDoc!=null ) {
74 log.println( " closing xChartDoc" );
75 util.DesktopTools.closeDoc(xChartDoc);
76 xChartDoc = null;
80 /**
81 * Creating a Testenvironment for the interfaces to be tested.
82 * Creates a bar diagram and sets the created diagram for the chart document.
83 * Retrieves the property <code>'DataMeanValueProperties'</code> of
84 * the specified data row. The retrieved property is the instance of
85 * the service <code>com.sun.star.chart.ChartLine</code>.
86 * @see com.sun.star.chart.ChartLine
88 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
90 XPropertySet oObj = null;
91 XDiagram oDiagram = null;
92 SOfficeFactory SOF = null;
94 //get LineDiagram
95 SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
96 oDiagram = SOF.createDiagram(xChartDoc, "LineDiagram");
98 log.println( "getting Line-Diagram" );
99 xChartDoc.setDiagram(oDiagram);
101 // get the Line
102 try {
103 log.println( "getting Line" );
104 XPropertySet RowProps = oDiagram.getDataRowProperties(1);
105 RowProps.setPropertyValue("MeanValue", new Boolean( true ));
106 oObj = (XPropertySet) AnyConverter.toObject(
107 new Type(XPropertySet.class),
108 RowProps.getPropertyValue("DataMeanValueProperties"));
109 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
110 // Some exception occurs.FAILED
111 e.printStackTrace( log );
112 throw new StatusException( "Couldn't get Line", e );
113 } catch (com.sun.star.lang.WrappedTargetException e) {
114 // Some exception occurs.FAILED
115 e.printStackTrace( log );
116 throw new StatusException( "Couldn't get Line", e );
117 } catch (com.sun.star.beans.UnknownPropertyException e) {
118 // Some exception occurs.FAILED
119 e.printStackTrace( log );
120 throw new StatusException( "Couldn't get Line", e );
121 } catch (com.sun.star.lang.IllegalArgumentException e) {
122 // Some exception occurs.FAILED
123 e.printStackTrace( log );
124 throw new StatusException( "Couldn't get Line", e );
126 catch(com.sun.star.beans.PropertyVetoException e) {
127 // Some exception occurs.FAILED
128 e.printStackTrace( log );
129 throw new StatusException( "Couldn't get Line", e );
132 log.println( "creating a new environment for chartdocument object" );
133 TestEnvironment tEnv = new TestEnvironment( oObj );
136 return tEnv;
137 } // finish method getTestEnvironment
140 } // finish class ChartLine