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 import java.io.PrintWriter;
30 
31 import lib.StatusException;
32 import lib.TestCase;
33 import lib.TestEnvironment;
34 import lib.TestParameters;
35 import util.SOfficeFactory;
36 
37 import com.sun.star.chart.XChartData;
38 import com.sun.star.chart.XChartDocument;
39 import com.sun.star.lang.XMultiServiceFactory;
40 
41 /**
42 * Test for object which is represented by service
43 * <code>com.sun.star.chart.ChartDataArray</code>. <p>
44 * Object implements the following interfaces :
45 * <ul>
46 *  <li> <code>com::sun::star::chart::XChartData</code></li>
47 *  <li> <code>com::sun::star::chart::XChartDataArray</code></li>
48 * </ul>
49 * @see com.sun.star.chart.ChartDataArray
50 * @see com.sun.star.chart.XChartData
51 * @see com.sun.star.chart.XChartDataArray
52 * @see ifc.chart._XChartData
53 * @see ifc.chart._XChartDataArray
54 */
55 public class ChXChartDataArray extends TestCase {
56     XChartDocument xChartDoc = null;
57 
58     /**
59     * Creates Chart document.
60     */
61     protected void initialize( TestParameters tParam, PrintWriter log ) {
62         // get a soffice factory object
63         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
64 
65         try {
66             log.println( "creating a chartdocument" );
67             xChartDoc = SOF.createChartDoc(null);;
68         } catch (com.sun.star.uno.Exception e) {
69             // Some exception occures.FAILED
70             e.printStackTrace( log );
71             throw new StatusException( "Couldn't create document", e );
72         }
73     }
74 
75     /**
76     * Disposes Chart document.
77     */
78     protected void cleanup( TestParameters tParam, PrintWriter log ) {
79         if( xChartDoc!=null ) {
80             log.println( "    closing xChartDoc" );
81             util.DesktopTools.closeDoc(xChartDoc);
82             xChartDoc = null;
83         }
84     }
85 
86     /**
87     * Creating a Testenvironment for the interfaces to be tested.
88     * Retrieves the data source of the chart. This data source is the instance
89     * of the service <code>com.sun.star.chart.ChartDataArray</code>.
90     * <code>com.sun.star.chart.ChartDataArray</code>.
91     * @see com.sun.star.chart.ChartDataArray
92     */
93     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
94 
95         // get the Data
96         log.println( "getting Data" );
97         XChartData oObj = (XChartData) xChartDoc.getData();
98 
99         log.println( "creating a new environment for chartdocument object" );
100         TestEnvironment tEnv = new TestEnvironment( oObj );
101 
102         return tEnv;
103     } // finish method getTestEnvironment
104 
105 }    // finish class ChXChartDataArray
106 
107