bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _xmloff / Chart / XMLStylesImporter.java
blob6f474395b1e00ef3951423202f396e7df04434e0
1 /*
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;
24 import lib.TestCase;
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;
34 /**
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 :
38 * <ul>
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>
45 * </ul>
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 {
60 XComponent comp ;
61 XChartDocument xChartDoc = null;
63 /**
64 * New chart document created.
66 @Override
67 protected void initialize( TestParameters tParam, PrintWriter log ) {
68 // get a soffice factory object
69 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
71 try {
72 log.println( "creating a chartdocument" );
73 xChartDoc = SOF.createChartDoc();
74 } catch ( Exception e ) {
75 // Some exception occurs.FAILED
76 e.printStackTrace( log );
77 throw new StatusException( "Couldn't create document", e );
80 comp = xChartDoc;
83 /**
84 * Close document
86 @Override
87 protected void cleanup( TestParameters tParam, PrintWriter log ) {
88 if( xChartDoc!=null ) {
89 log.println( " closing xChartDoc" );
90 util.DesktopTools.closeDoc(xChartDoc);
91 xChartDoc = null;
92 comp = null;
96 /**
97 * Creating a Testenvironment for the interfaces to be tested.
98 * Creates an instance of the service
99 * <code>com.sun.star.comp.Chart.XMLStylesImporter</code><p>
101 * The chart document is set as a target document for importer.
102 * Object relations created :
103 * <ul>
104 * <li> <code>'XDocumentHandler.XMLData'</code> for
105 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
106 * <li> <code>'XDocumentHandler.ImportChecker'</code> for
107 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
108 * <li> <code>'TargetDocument'</code> for
109 * {@link ifc.document._XImporter} interface </li>
110 * </ul>
112 @Override
113 public synchronized TestEnvironment createTestEnvironment
114 (TestParameters tParam, PrintWriter log) {
116 XInterface oObj = null;
117 Object oInt = null ;
119 // creation of testobject here
120 // first we write what we are intend to do to log file
121 log.println( "creating a test environment" );
123 XMultiServiceFactory xMSF = tParam.getMSF() ;
125 try {
126 oInt = xMSF.createInstance
127 ("com.sun.star.comp.Chart.XMLStylesImporter") ;
129 } catch (com.sun.star.uno.Exception e) {
130 e.printStackTrace(log) ;
131 throw new StatusException("Can't create component.", e) ;
134 oObj = (XInterface) oInt ;
136 // create testobject here
137 log.println( "creating a new environment for Paragraph object" );
138 TestEnvironment tEnv = new TestEnvironment( oObj );
140 // adding relation
141 tEnv.addObjRelation("TargetDocument", comp) ;
143 // adding relation for XDocumentHandler
144 String[][] xml = new String[][] {
145 {"start", "office:document-styles",
146 "xmlns:office", "CDATA", "http://openoffice.org/2000/office",
147 "xmlns:text", "CDATA", "http://openoffice.org/2000/text",
148 "xmlns:chart", "CDATA", "http://openoffice.org/2000/chart",
149 "xmlns:style", "CDATA", "http://openoffice.org/2000/style",
150 "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg",
151 "office:class", "CDATA", "chart",
152 "office:version", "CDATA", "1.0"
154 {"start", "office:styles"},
155 {"end", "office:styles"},
156 {"end", "office:document-styles"}} ;
158 tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ;
160 final PrintWriter logF = log ;
162 tEnv.addObjRelation("XDocumentHandler.ImportChecker",
163 new ifc.xml.sax._XDocumentHandler.ImportChecker() {
164 public boolean checkImport() {
165 logF.println("No ways to check styles import were not found.");
166 logF.println(" TRUE returned.");
167 return true ;
169 }) ;
172 return tEnv;
173 } // finish method getTestEnvironment