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.XAxisXSupplier;
40 import com.sun.star.chart.XChartDocument;
41 import com.sun.star.chart.XDiagram;
42 import com.sun.star.drawing.XShape;
43 import com.sun.star.lang.XMultiServiceFactory;
44 import com.sun.star.uno.UnoRuntime;
45 
46 /**
47 * Test for object which is represented by service
48 * <code>com.sun.star.chart.ChartGrid</code>. <p>
49 * Object implements the following interfaces :
50 * <ul>
51 *  <li> <code>com::sun::star::drawing::LineProperties</code></li>
52 *  <li> <code>com::sun::star::beans::XPropertySet</code></li>
53 * </ul>
54 * @see com.sun.star.chart.ChartGrid
55 * @see com.sun.star.drawing.LineProperties
56 * @see com.sun.star.beans.XPropertySet
57 * @see ifc.drawing._LineProperties
58 * @see ifc.beans._XPropertySet
59 */
60 public class ChartGrid extends TestCase {
61     XChartDocument xChartDoc = null;
62 
63     /**
64     * Creates Chart document.
65     */
66     protected void initialize( TestParameters tParam, PrintWriter log ) {
67         // get a soffice factory object
68         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
69 
70         try {
71             log.println( "creating a chartdocument" );
72             xChartDoc = SOF.createChartDoc(null);;
73         } catch (com.sun.star.uno.Exception e) {
74             // Some exception occures.FAILED
75             e.printStackTrace( log );
76             throw new StatusException( "Couldn't create document", e );
77         }
78     }
79 
80     /**
81     * Disposes Chart document.
82     */
83     protected void cleanup( TestParameters tParam, PrintWriter log ) {
84         if( xChartDoc!=null ) {
85             log.println( "    closing xChartDoc" );
86             util.DesktopTools.closeDoc(xChartDoc);
87             xChartDoc = null;
88         }
89     }
90 
91     /**
92     * Creating a Testenvironment for the interfaces to be tested.
93     * Retrieves the diagram of the chart document. Then obtains
94     * the properties of the main grid of the x-axis of the diagram
95     * using the interface <code>XAxisXSupplier</code>. This properties is
96     * the instance of the service <code>com.sun.star.chart.ChartGrid</code>.
97     * @see com.sun.star.chart.XAxisXSupplier
98     * @see com.sun.star.chart.ChartGrid
99     */
100     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
101         XPropertySet oObj = null;
102         XShape oDiagram = null;
103 
104         // get the Diagram
105         log.println( "getting Diagram" );
106         oDiagram = (XDiagram) xChartDoc.getDiagram();
107 
108         // get the Grid
109         log.println( "getting ChartGrid" );
110         XAxisXSupplier oAxisSup = (XAxisXSupplier)
111             UnoRuntime.queryInterface(XAxisXSupplier.class,oDiagram);
112         oObj = (XPropertySet) oAxisSup.getXMainGrid();
113 
114         log.println( "creating a new environment for chartdocument object" );
115         TestEnvironment tEnv = new TestEnvironment( oObj );
116 
117         return tEnv;
118     } // finish method getTestEnvironment
119 
120 
121 }    // finish class ChartGrid
122 
123