merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sch / ChXDataPoint.java
blob187a6608819207207d6c1bbdbec60b83d97adbfb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChXDataPoint.java,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package mod._sch;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.SOfficeFactory;
40 import util.utils;
42 import com.sun.star.beans.XPropertySet;
43 import com.sun.star.chart.XChartDocument;
44 import com.sun.star.chart.XDiagram;
45 import com.sun.star.lang.XComponent;
46 import com.sun.star.lang.XMultiServiceFactory;
47 import com.sun.star.uno.UnoRuntime;
49 /**
50 * Test for object which is represented by service
51 * <code>com.sun.star.chart.ChartDataPointProperties</code>. <p>
52 * Object implements the following interfaces
53 * <ul>
54 * <li> <code>com::sun::star::chart::ChartDataPointProperties</code></li>
55 * <li> <code>com::sun::star::drawing::FillProperties</code></li>
56 * <li> <code>com::sun::star::drawing::LineProperties</code></li>
57 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
58 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
59 * <li> <code>com::sun::star::chart::Chart3DBarProperties</code></li>
60 * </ul>
61 * The following files used by this test :
62 * <ul>
63 * <li><b> TransparencyChart.sxs </b> : to load predefined chart
64 * document where two 'automatic' transparency styles exists :
65 * 'Transparency 1' and 'Transparency 2'.</li>
66 * </ul> <p>
67 * @see com.sun.star.chart.ChartDataPointProperties
68 * @see com.sun.star.drawing.FillProperties
69 * @see com.sun.star.drawing.LineProperties
70 * @see com.sun.star.style.CharacterProperties
71 * @see com.sun.star.beans.XPropertySet
72 * @see com.sun.star.chart.Chart3DBarProperties
73 * @see ifc.chart._ChartDataPointProperties
74 * @see ifc.drawing._FillProperties
75 * @see ifc.drawing._LineProperties
76 * @see ifc.style._CharacterProperties
77 * @see ifc.beans._XPropertySet
78 * @see ifc.chart._Chart3DBarProperties
80 public class ChXDataPoint extends TestCase {
81 XChartDocument xChartDoc = null;
83 /**
84 * Creates Chart document.
86 protected void initialize( TestParameters tParam, PrintWriter log ) {
87 // get a soffice factory object
88 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
90 try {
91 log.println( "creating a chartdocument" );
92 XComponent xComp = SOF.loadDocument(
93 utils.getFullTestURL("TransparencyChart.sxs"));
94 xChartDoc = (XChartDocument)
95 UnoRuntime.queryInterface(XChartDocument.class,xComp);
96 } catch (com.sun.star.uno.Exception e) {
97 // Some exception occures.FAILED
98 e.printStackTrace( log );
99 throw new StatusException( "Couldn't create document", e );
104 * Disposes Chart document.
106 protected void cleanup( TestParameters tParam, PrintWriter log ) {
107 log.println( " closing xChartDoc " );
108 util.DesktopTools.closeDoc(xChartDoc);
112 * Creating a Testenvironment for the interfaces to be tested.
113 * Retrieves the diagram of the chart document. Obtains the properties of
114 * the specified data point. The obtained properties is the instance of
115 * the service <code>com.sun.star.chart.ChartDataPointProperties</code>.
116 * Creates a XY-diagram and bar-diagram also.
117 * Object relations created :
118 * <ul>
119 * <li> <code>'LINE'</code> for
120 * {@link ifc.chart._ChartDataPointProperties}(the created XY-diagram)</li>
121 * <li> <code>'CHARTDOC'</code> for
122 * {@link ifc.chart._ChartDataPointProperties},
123 * {@link ifc.chart._Chart3DBarProperties}(the chart document)</li>
124 * <li> <code>'BAR'</code> for
125 * {@link ifc.chart._Chart3DBarProperties}(the created bar-diagram)</li>
126 * </ul>
128 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
130 XPropertySet oObj = null;
131 XDiagram oDiagram = null;
133 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
135 // get the DataRowPoint_Point
136 try {
137 log.println( "getting ChXDataRowPoint_Point" );
138 oDiagram = (XDiagram) xChartDoc.getDiagram();
139 oObj = (XPropertySet) oDiagram.getDataPointProperties(1,1);
140 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
141 // Some exception occures.FAILED
142 e.printStackTrace( log );
143 throw new StatusException( "Couldn't get ChXDataRowPoint_Point", e );
146 log.println( "creating a new environment for chartdocument object" );
147 TestEnvironment tEnv = new TestEnvironment( oObj );
149 Object line = SOF.createDiagram(xChartDoc,"XYDiagram");
150 tEnv.addObjRelation("LINE",line);
152 Object bar = SOF.createDiagram(xChartDoc,"BarDiagram");
153 tEnv.addObjRelation("BAR",bar);
155 log.println( "adding ChartDocument as mod relation to environment" );
156 tEnv.addObjRelation("CHARTDOC", xChartDoc);
158 return tEnv;
159 } // finish method getTestEnvironment
161 } // finish class ChXDataPoint