merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _xmloff / Chart / XMLStylesImporter.java
blobcf705e8adfb1a8a4a9b47a602e7252fc8353b83d
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: XMLStylesImporter.java,v $
10 * $Revision: 1.5 $
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._xmloff.Chart;
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;
41 import com.sun.star.chart.XChartDocument;
42 import com.sun.star.lang.XComponent;
43 import com.sun.star.lang.XMultiServiceFactory;
44 import com.sun.star.uno.XInterface;
46 /**
47 * Test for object which is represented by service
48 * <code>com.sun.star.comp.Chart.XMLStylesImporter</code>. <p>
49 * Object implements the following interfaces :
50 * <ul>
51 * <li><code>com::sun::star::lang::XInitialization</code></li>
52 * <li><code>com::sun::star::document::XImporter</code></li>
53 * <li><code>com::sun::star::document::XFilter</code></li>
54 * <li><code>com::sun::star::document::ImportFilter</code></li>
55 * <li><code>com::sun::star::beans::XPropertySet</code></li>
56 * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li>
57 * </ul>
58 * @see com.sun.star.lang.XInitialization
59 * @see com.sun.star.document.XImporter
60 * @see com.sun.star.document.XFilter
61 * @see com.sun.star.document.ImportFilter
62 * @see com.sun.star.beans.XPropertySet
63 * @see com.sun.star.xml.sax.XDocumentHandler
64 * @see ifc.lang._XInitialization
65 * @see ifc.document._XImporter
66 * @see ifc.document._XFilter
67 * @see ifc.document._XExporter
68 * @see ifc.beans._XPropertySet
69 * @see ifc.xml.sax._XDocumentHandler
71 public class XMLStylesImporter extends TestCase {
72 XComponent comp ;
73 XChartDocument xChartDoc = null;
75 /**
76 * New chart document created.
78 protected void initialize( TestParameters tParam, PrintWriter log ) {
79 // get a soffice factory object
80 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF());
82 try {
83 log.println( "creating a chartdocument" );
84 xChartDoc = SOF.createChartDoc(null);
85 } catch ( Exception e ) {
86 // Some exception occures.FAILED
87 e.printStackTrace( log );
88 throw new StatusException( "Couldn't create document", e );
91 comp = xChartDoc;
94 /**
95 * Disposes document.
97 protected void cleanup( TestParameters tParam, PrintWriter log ) {
98 log.println( " disposing document " );
99 comp.dispose();
103 * Creating a Testenvironment for the interfaces to be tested.
104 * Creates an instance of the service
105 * <code>com.sun.star.comp.Chart.XMLStylesImporter</code><p>
107 * The chart document is set as a target document for importer.
108 * Object relations created :
109 * <ul>
110 * <li> <code>'XDocumentHandler.XMLData'</code> for
111 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
112 * <li> <code>'XDocumentHandler.ImportChecker'</code> for
113 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
114 * <li> <code>'TargetDocument'</code> for
115 * {@link ifc.document._XImporter} interface </li>
116 * </ul>
118 public synchronized TestEnvironment createTestEnvironment
119 (TestParameters tParam, PrintWriter log) {
121 XInterface oObj = null;
122 Object oInt = null ;
124 // creation of testobject here
125 // first we write what we are intend to do to log file
126 log.println( "creating a test environment" );
128 XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF() ;
130 try {
131 oInt = xMSF.createInstance
132 ("com.sun.star.comp.Chart.XMLStylesImporter") ;
134 } catch (com.sun.star.uno.Exception e) {
135 e.printStackTrace(log) ;
136 throw new StatusException("Can't create component.", e) ;
139 oObj = (XInterface) oInt ;
141 // create testobject here
142 log.println( "creating a new environment for Paragraph object" );
143 TestEnvironment tEnv = new TestEnvironment( oObj );
145 // adding relation
146 tEnv.addObjRelation("TargetDocument", comp) ;
148 // adding relation for XDocumentHandler
149 String[][] xml = new String[][] {
150 {"start", "office:document-styles",
151 "xmlns:office", "CDATA", "http://openoffice.org/2000/office",
152 "xmlns:text", "CDATA", "http://openoffice.org/2000/text",
153 "xmlns:chart", "CDATA", "http://openoffice.org/2000/chart",
154 "xmlns:style", "CDATA", "http://openoffice.org/2000/style",
155 "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg",
156 "office:class", "CDATA", "chart",
157 "office:version", "CDATA", "1.0"
159 {"start", "office:styles"},
160 {"end", "office:styles"},
161 {"end", "office:document-styles"}} ;
163 tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ;
165 final PrintWriter logF = log ;
167 tEnv.addObjRelation("XDocumentHandler.ImportChecker",
168 new ifc.xml.sax._XDocumentHandler.ImportChecker() {
169 public boolean checkImport() {
170 logF.println("No ways to check styles import were not found.");
171 logF.println(" TRUE returned.");
172 return true ;
173 /* } catch (com.sun.star.uno.Exception e) {
174 logF.println("Exception occured while checking filter :") ;
175 e.printStackTrace(logF) ;
176 return false ;
178 */ }
179 }) ;
182 return tEnv;
183 } // finish method getTestEnvironment