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 import util.utils;
34 
35 import com.sun.star.beans.XPropertySet;
36 import com.sun.star.chart.XChartDocument;
37 import com.sun.star.lang.XComponent;
38 import com.sun.star.lang.XMultiServiceFactory;
39 import com.sun.star.uno.UnoRuntime;
40 
41 /**
42 * Test for object which is represented by service
43 * <code>com.sun.star.chart.ChartArea</code>. <p>
44 * Object implements the following interfaces :
45 * <ul>
46 *  <li> <code>com::sun::star::drawing::FillProperties</code></li>
47 *  <li> <code>com::sun::star::drawing::LineProperties</code></li>
48 *  <li> <code>com::sun::star::beans::XPropertySet</code></li>
49 * </ul>
50 * The following files used by this test :
51 * <ul>
52 *  <li><b> TransparencyChart.sxs </b> : to load predefined chart
53 *       document where two 'automatic' transparency styles exists :
54 *       'Transparency 1' and 'Transparency 2'.</li>
55 * </ul> <p>
56 * @see com.sun.star.chart.ChartArea
57 * @see com.sun.star.drawing.FillProperties
58 * @see com.sun.star.drawing.LineProperties
59 * @see com.sun.star.beans.XPropertySet
60 * @see ifc.drawing._FillProperties
61 * @see ifc.drawing._LineProperties
62 * @see ifc.beans._XPropertySet
63 */
64 public class ChartArea extends TestCase {
65     XChartDocument xChartDoc = null;
66 
67     /**
68     * Creates Chart document.
69     */
initialize( TestParameters tParam, PrintWriter log )70     protected void initialize( TestParameters tParam, PrintWriter log ) {
71         // get a soffice factory object
72         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
73 
74         try {
75             log.println( "creating a chartdocument" );
76             XComponent xComp = SOF.loadDocument(
77                              utils.getFullTestURL("TransparencyChart.sxs"));
78             xChartDoc = (XChartDocument)
79                 UnoRuntime.queryInterface(XChartDocument.class,xComp);
80         } catch (com.sun.star.uno.Exception e) {
81             // Some exception occured.FAILED
82             e.printStackTrace( log );
83             throw new StatusException( "Couldn't create document", e );
84         }
85     }
86 
87     /**
88     * Disposes Chart document.
89     */
cleanup( TestParameters tParam, PrintWriter log )90     protected void cleanup( TestParameters tParam, PrintWriter log ) {
91         if( xChartDoc!=null ) {
92             log.println( "    closing xChartDoc" );
93             util.DesktopTools.closeDoc(xChartDoc);
94             xChartDoc = null;
95         }
96     }
97 
98     /**
99     * Creating a Testenvironment for the interfaces to be tested.
100     * Retrieved the instance of the service <code>com.sun.star.chart.ChartArea</code>
101     * using the interface <code>XChartDocument</code>.
102     * @see com.sun.star.chart.XChartDocument
103     * @see com.sun.star.chart.ChartArea
104     */
createTestEnvironment(TestParameters Param, PrintWriter log)105     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
106 
107         // get the Area
108         log.println( "getting Area" );
109         XPropertySet oObj = (XPropertySet) xChartDoc.getArea();
110 
111         log.println( "creating a new environment for chartdocument object" );
112         TestEnvironment tEnv = new TestEnvironment( oObj );
113 
114         return tEnv;
115     } // finish method getTestEnvironment
116 
117 }    // finish class ChartArea
118 
119