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