1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLStylesImporter.java,v $
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
;
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
;
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 :
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>
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
{
73 XChartDocument xChartDoc
= null;
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());
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
);
97 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
98 log
.println( " disposing document " );
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 :
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>
118 public synchronized TestEnvironment createTestEnvironment
119 (TestParameters tParam
, PrintWriter log
) {
121 XInterface oObj
= 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() ;
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
);
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.");
173 /* } catch (com.sun.star.uno.Exception e) {
174 logF.println("Exception occured while checking filter :") ;
175 e.printStackTrace(logF) ;
183 } // finish method getTestEnvironment