2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package mod
._xmloff
.Chart
;
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.SOfficeFactory
;
29 import com
.sun
.star
.chart
.XChartDocument
;
30 import com
.sun
.star
.lang
.XComponent
;
31 import com
.sun
.star
.lang
.XMultiServiceFactory
;
32 import com
.sun
.star
.uno
.XInterface
;
35 * Test for object which is represented by service
36 * <code>com.sun.star.comp.Chart.XMLStylesImporter</code>. <p>
37 * Object implements the following interfaces :
39 * <li><code>com::sun::star::lang::XInitialization</code></li>
40 * <li><code>com::sun::star::document::XImporter</code></li>
41 * <li><code>com::sun::star::document::XFilter</code></li>
42 * <li><code>com::sun::star::document::ImportFilter</code></li>
43 * <li><code>com::sun::star::beans::XPropertySet</code></li>
44 * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li>
46 * @see com.sun.star.lang.XInitialization
47 * @see com.sun.star.document.XImporter
48 * @see com.sun.star.document.XFilter
49 * @see com.sun.star.document.ImportFilter
50 * @see com.sun.star.beans.XPropertySet
51 * @see com.sun.star.xml.sax.XDocumentHandler
52 * @see ifc.lang._XInitialization
53 * @see ifc.document._XImporter
54 * @see ifc.document._XFilter
55 * @see ifc.document._XExporter
56 * @see ifc.beans._XPropertySet
57 * @see ifc.xml.sax._XDocumentHandler
59 public class XMLStylesImporter
extends TestCase
{
61 XChartDocument xChartDoc
= null;
64 * New chart document created.
66 protected void initialize( TestParameters tParam
, PrintWriter log
) {
67 // get a soffice factory object
68 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
71 log
.println( "creating a chartdocument" );
72 xChartDoc
= SOF
.createChartDoc(null);
73 } catch ( Exception e
) {
74 // Some exception occurs.FAILED
75 e
.printStackTrace( log
);
76 throw new StatusException( "Couldn't create document", e
);
85 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
86 if( xChartDoc
!=null ) {
87 log
.println( " closing xChartDoc" );
88 util
.DesktopTools
.closeDoc(xChartDoc
);
95 * Creating a Testenvironment for the interfaces to be tested.
96 * Creates an instance of the service
97 * <code>com.sun.star.comp.Chart.XMLStylesImporter</code><p>
99 * The chart document is set as a target document for importer.
100 * Object relations created :
102 * <li> <code>'XDocumentHandler.XMLData'</code> for
103 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
104 * <li> <code>'XDocumentHandler.ImportChecker'</code> for
105 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
106 * <li> <code>'TargetDocument'</code> for
107 * {@link ifc.document._XImporter} interface </li>
110 public synchronized TestEnvironment createTestEnvironment
111 (TestParameters tParam
, PrintWriter log
) {
113 XInterface oObj
= null;
116 // creation of testobject here
117 // first we write what we are intend to do to log file
118 log
.println( "creating a test environment" );
120 XMultiServiceFactory xMSF
= (XMultiServiceFactory
)tParam
.getMSF() ;
123 oInt
= xMSF
.createInstance
124 ("com.sun.star.comp.Chart.XMLStylesImporter") ;
126 } catch (com
.sun
.star
.uno
.Exception e
) {
127 e
.printStackTrace(log
) ;
128 throw new StatusException("Can't create component.", e
) ;
131 oObj
= (XInterface
) oInt
;
133 // create testobject here
134 log
.println( "creating a new environment for Paragraph object" );
135 TestEnvironment tEnv
= new TestEnvironment( oObj
);
138 tEnv
.addObjRelation("TargetDocument", comp
) ;
140 // adding relation for XDocumentHandler
141 String
[][] xml
= new String
[][] {
142 {"start", "office:document-styles",
143 "xmlns:office", "CDATA", "http://openoffice.org/2000/office",
144 "xmlns:text", "CDATA", "http://openoffice.org/2000/text",
145 "xmlns:chart", "CDATA", "http://openoffice.org/2000/chart",
146 "xmlns:style", "CDATA", "http://openoffice.org/2000/style",
147 "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg",
148 "office:class", "CDATA", "chart",
149 "office:version", "CDATA", "1.0"
151 {"start", "office:styles"},
152 {"end", "office:styles"},
153 {"end", "office:document-styles"}} ;
155 tEnv
.addObjRelation("XDocumentHandler.XMLData", xml
) ;
157 final PrintWriter logF
= log
;
159 tEnv
.addObjRelation("XDocumentHandler.ImportChecker",
160 new ifc
.xml
.sax
._XDocumentHandler
.ImportChecker() {
161 public boolean checkImport() {
162 logF
.println("No ways to check styles import were not found.");
163 logF
.println(" TRUE returned.");
165 /* } catch (com.sun.star.uno.Exception e) {
166 logF.println("Exception occurred while checking filter :") ;
167 e.printStackTrace(logF) ;
175 } // finish method getTestEnvironment