1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package mod._sch;
25 
26 import java.io.PrintWriter;
27 
28 import lib.StatusException;
29 import lib.TestCase;
30 import lib.TestEnvironment;
31 import lib.TestParameters;
32 import util.SOfficeFactory;
33 
34 import com.sun.star.beans.XPropertySet;
35 import com.sun.star.chart.XAxisYSupplier;
36 import com.sun.star.chart.XChartDocument;
37 import com.sun.star.chart.XDiagram;
38 import com.sun.star.drawing.XShape;
39 import com.sun.star.lang.XMultiServiceFactory;
40 import com.sun.star.uno.UnoRuntime;
41 
42 /**
43 * Test for object which is represented by service
44 * <code>com.sun.star.chart.ChartAxis</code>. <p>
45 * Object implements the following interfaces :
46 * <ul>
47 *  <li> <code>com::sun::star::drawing::LineProperties</code></li>
48 *  <li> <code>com::sun::star::style::CharacterProperties</code></li>
49 *  <li> <code>com::sun::star::beans::XPropertySet</code></li>
50 *  <li> <code>com::sun::star::chart::ChartAxis</code></li>
51 * </ul>
52 * @see com.sun.star.drawing.LineProperties
53 * @see com.sun.star.style.CharacterProperties
54 * @see com.sun.star.beans.XPropertySet
55 * @see com.sun.star.chart.ChartAxis
56 * @see ifc.drawing._LineProperties
57 * @see ifc.style._CharacterProperties
58 * @see ifc.beans._XPropertySet
59 * @see ifc.chart._ChartAxis
60 */
61 public class ChXChartAxis extends TestCase {
62     XChartDocument xChartDoc = null;
63 
64     /**
65     * Creates Chart document.
66     */
initialize( TestParameters tParam, PrintWriter log )67     protected void initialize( TestParameters tParam, PrintWriter log ) {
68         // get a soffice factory object
69         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
70 
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 );
78         }
79     }
80 
81     /**
82     * Disposes Chart document.
83     */
cleanup( TestParameters tParam, PrintWriter log )84     protected void cleanup( TestParameters tParam, PrintWriter log ) {
85         if( xChartDoc!=null ) {
86             log.println( "    closing xChartDoc" );
87             util.DesktopTools.closeDoc(xChartDoc);
88             xChartDoc = null;
89         }
90     }
91 
92     /**
93     * Creating a Testenvironment for the interfaces to be tested.
94     * Retrieves the diagram of the chart document. Then obtains the properties
95     * of the y-axis of the diagram using the interface
96     * <code>XAxisYSupplier</code>. The obatined property is the instance
97     * of the service <code>com.sun.star.chart.ChartAxis</code>.
98     * @see com.sun.star.chart.XAxisYSupplier
99     * @see com.sun.star.chart.ChartAxis
100     */
createTestEnvironment(TestParameters Param, PrintWriter log)101     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
102 
103         XPropertySet oObj = null;
104         XShape oDiagram = null;
105 
106         // create testobject here
107         // get the Diagram
108         log.println( "getting Diagram" );
109         oDiagram = (XDiagram) xChartDoc.getDiagram();
110 
111         // get the Axis
112         log.println( "getting ChartAxis" );
113         XAxisYSupplier oAxisSup = (XAxisYSupplier)
114             UnoRuntime.queryInterface(XAxisYSupplier.class,oDiagram);
115         oObj = (XPropertySet) oAxisSup.getYAxis();
116 
117         log.println( "creating a new environment for chartdocument object" );
118         TestEnvironment tEnv = new TestEnvironment( oObj );
119 
120         return tEnv;
121     } // finish method getTestEnvironment
122 
123 
124 
125 }    // finish class ChXChartAxis
126 
127