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
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.SOfficeFactory
;
28 import com
.sun
.star
.chart
.XChartDocument
;
29 import com
.sun
.star
.lang
.XComponent
;
30 import com
.sun
.star
.lang
.XMultiServiceFactory
;
31 import com
.sun
.star
.uno
.XInterface
;
34 * Test for object which is represented by service
35 * <code>com.sun.star.comp.Chart.XMLStylesImporter</code>. <p>
36 * Object implements the following interfaces :
38 * <li><code>com::sun::star::lang::XInitialization</code></li>
39 * <li><code>com::sun::star::document::XImporter</code></li>
40 * <li><code>com::sun::star::document::XFilter</code></li>
41 * <li><code>com::sun::star::document::ImportFilter</code></li>
42 * <li><code>com::sun::star::beans::XPropertySet</code></li>
43 * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li>
45 * @see com.sun.star.lang.XInitialization
46 * @see com.sun.star.document.XImporter
47 * @see com.sun.star.document.XFilter
48 * @see com.sun.star.document.ImportFilter
49 * @see com.sun.star.beans.XPropertySet
50 * @see com.sun.star.xml.sax.XDocumentHandler
51 * @see ifc.lang._XInitialization
52 * @see ifc.document._XImporter
53 * @see ifc.document._XFilter
54 * @see ifc.document._XExporter
55 * @see ifc.beans._XPropertySet
56 * @see ifc.xml.sax._XDocumentHandler
58 public class XMLStylesImporter
extends TestCase
{
60 XChartDocument xChartDoc
= null;
63 * New chart document created.
66 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
67 // get a soffice factory object
68 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
70 log
.println( "creating a chartdocument" );
71 xChartDoc
= SOF
.createChartDoc();
80 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
81 if( xChartDoc
!=null ) {
82 log
.println( " closing xChartDoc" );
83 util
.DesktopTools
.closeDoc(xChartDoc
);
90 * Creating a TestEnvironment for the interfaces to be tested.
91 * Creates an instance of the service
92 * <code>com.sun.star.comp.Chart.XMLStylesImporter</code><p>
94 * The chart document is set as a target document for importer.
95 * Object relations created :
97 * <li> <code>'XDocumentHandler.XMLData'</code> for
98 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
99 * <li> <code>'XDocumentHandler.ImportChecker'</code> for
100 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
101 * <li> <code>'TargetDocument'</code> for
102 * {@link ifc.document._XImporter} interface </li>
106 public TestEnvironment createTestEnvironment
107 (TestParameters tParam
, PrintWriter log
) throws Exception
{
109 XInterface oObj
= null;
112 // creation of testobject here
113 // first we write what we are intend to do to log file
114 log
.println( "creating a test environment" );
116 XMultiServiceFactory xMSF
= tParam
.getMSF() ;
118 oInt
= xMSF
.createInstance
119 ("com.sun.star.comp.Chart.XMLStylesImporter") ;
121 oObj
= (XInterface
) oInt
;
123 // create testobject here
124 log
.println( "creating a new environment for Paragraph object" );
125 TestEnvironment tEnv
= new TestEnvironment( oObj
);
128 tEnv
.addObjRelation("TargetDocument", comp
) ;
130 // adding relation for XDocumentHandler
131 String
[][] xml
= new String
[][] {
132 {"start", "office:document-styles",
133 "xmlns:office", "CDATA", "http://openoffice.org/2000/office",
134 "xmlns:text", "CDATA", "http://openoffice.org/2000/text",
135 "xmlns:chart", "CDATA", "http://openoffice.org/2000/chart",
136 "xmlns:style", "CDATA", "http://openoffice.org/2000/style",
137 "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg",
138 "office:class", "CDATA", "chart",
139 "office:version", "CDATA", "1.0"
141 {"start", "office:styles"},
142 {"end", "office:styles"},
143 {"end", "office:document-styles"}} ;
145 tEnv
.addObjRelation("XDocumentHandler.XMLData", xml
) ;
147 final PrintWriter logF
= log
;
149 tEnv
.addObjRelation("XDocumentHandler.ImportChecker",
150 new ifc
.xml
.sax
._XDocumentHandler
.ImportChecker() {
151 public boolean checkImport() {
152 logF
.println("No ways to check styles import were not found.");
153 logF
.println(" TRUE returned.");
160 } // finish method getTestEnvironment