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