merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sch / ChXChartDocument.java
blobb160ac542ede1d3be2a97c4287a3376bddfe96b7
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: ChXChartDocument.java,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
30 package mod._sch;
32 import com.sun.star.chart.XChartData;
33 import com.sun.star.chart.XChartDocument;
34 import com.sun.star.frame.XController;
35 import com.sun.star.lang.XMultiServiceFactory;
36 import com.sun.star.uno.UnoRuntime;
37 import com.sun.star.uno.XInterface;
38 import com.sun.star.view.XSelectionSupplier;
40 import java.io.PrintWriter;
42 import lib.StatusException;
43 import lib.TestCase;
44 import lib.TestEnvironment;
45 import lib.TestParameters;
47 import util.SOfficeFactory;
50 /**
51 * Test for object which is represented by service
52 * <code>com.sun.star.chart.ChartDocument</code>. <p>
53 * Object implements the following interfaces :
54 * <ul>
55 * <li> <code>com::sun::star::lang::XComponent</code></li>
56 * <li> <code>com::sun::star::frame::XModel</code></li>
57 * <li> <code>com::sun::star::chart::XChartDocument</code></li>
58 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
59 * <li> <code>com::sun::star::chart::ChartTableAddressSupplier</code></li>
60 * <li> <code>com::sun::star::chart::ChartDocument</code></li>
61 * </ul>
62 * @see com.sun.star.lang.XComponent
63 * @see com.sun.star.frame.XModel
64 * @see com.sun.star.chart.XChartDocument
65 * @see com.sun.star.beans.XPropertySet
66 * @see com.sun.star.chart.ChartTableAddressSupplier
67 * @see com.sun.star.chart.ChartDocument
68 * @see ifc.lang._XComponent
69 * @see ifc.frame._XModel
70 * @see ifc.chart._XChartDocument
71 * @see ifc.beans._XPropertySet
72 * @see ifc.chart._ChartTableAddressSupplier
73 * @see ifc.chart._ChartDocument
75 public class ChXChartDocument extends TestCase {
76 XChartDocument xChartDoc = null;
77 XChartDocument doc2 = null;
79 /**
80 * Disposes Chart documents.
82 protected void cleanup(TestParameters Param, PrintWriter log) {
83 log.println( " closing xChartDoc " );
84 util.DesktopTools.closeDoc(xChartDoc);
85 log.println( " closing xChartDoc2 " );
86 util.DesktopTools.closeDoc(doc2);
89 /**
90 * Creating a Testenvironment for the interfaces to be tested.
91 * Creates two chart documents and retrieves current controllers from them
92 * using the interface <code>XChartDocument</code>. The created documents
93 * is the instances of the service <code>com.sun.star.chart.ChartDocument</code>.
94 * Obtains the data source of the second created chart and creates
95 * a pie diagram.
96 * Object relations created :
97 * <ul>
98 * <li> <code>'SELSUPP'</code> for
99 * {@link ifc.frame._XModel}(the controller of the first created chart
100 * document)</li>
101 * <li> <code>'TOSELECT'</code> for
102 * {@link ifc.frame._XModel}(the shape of the main title of
103 * the first created chart document)</li>
104 * <li> <code>'CONT2'</code> for
105 * {@link ifc.frame._XModel}(the second created chart document)</li>
106 * <li> <code>'DIAGRAM'</code> for
107 * {@link ifc.chart._XChartDocument}(the created pie diagram)</li>
108 * <li> <code>'CHARTDATA'</code> for
109 * {@link ifc.chart._XChartDocument}(the data source of the second
110 * created chart)</li>
111 * </ul>
112 * @see com.sun.star.chart.XChartData
113 * @see com.sun.star.chart.ChartDocument
115 protected synchronized TestEnvironment createTestEnvironment(TestParameters tParam,
116 PrintWriter log) {
117 // get a soffice factory object
118 SOfficeFactory SOF = SOfficeFactory.getFactory(
119 (XMultiServiceFactory) tParam.getMSF());
121 try {
122 log.println("creating a chartdocument");
123 xChartDoc = SOF.createChartDoc(null);
124 log.println("Waiting before opening second document");
125 doc2 = SOF.createChartDoc(null);
126 } catch (com.sun.star.uno.Exception e) {
127 // Some exception occures.FAILED
128 e.printStackTrace(log);
129 throw new StatusException("Couldn't create document", e);
133 // get the chartdocument
134 log.println("getting ChartDocument");
136 XInterface oObj = (XChartDocument) xChartDoc;
138 XController cont1 = xChartDoc.getCurrentController();
139 XController cont2 = doc2.getCurrentController();
141 cont1.getFrame().setName("cont1");
142 cont2.getFrame().setName("cont2");
144 XSelectionSupplier sel = (XSelectionSupplier) UnoRuntime.queryInterface(
145 XSelectionSupplier.class, cont1);
147 log.println("creating a new environment for chartdocument object");
149 TestEnvironment tEnv = new TestEnvironment(oObj);
151 log.println("Adding SelectionSupplier and Shape to select for XModel");
152 tEnv.addObjRelation("SELSUPP", sel);
153 tEnv.addObjRelation("TOSELECT", xChartDoc.getTitle());
155 log.println("adding Controller as ObjRelation for XModel");
156 tEnv.addObjRelation("CONT2", cont2);
158 log.println("adding another Diagram as mod relation to environment");
159 tEnv.addObjRelation("DIAGRAM",
160 SOF.createDiagram(xChartDoc, "PieDiagram"));
162 log.println("adding another ChartData as mod relation to environment");
164 XChartData ChartData = doc2.getData();
165 tEnv.addObjRelation("CHARTDATA", ChartData);
167 return tEnv;
168 } // finish method getTestEnvironment
169 } // finish class ChXChartDocument