svx: prefix members of SdrUnoObj
[LibreOffice.git] / qadevOOo / tests / java / mod / _xmloff / Chart / XMLStylesExporter.java
blob66f46ba5216603560f82a7537fa3f85c04c154b8
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.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.SOfficeFactory;
27 import util.XMLTools;
29 import com.sun.star.chart.XChartDocument;
30 import com.sun.star.document.XExporter;
31 import com.sun.star.lang.XMultiServiceFactory;
32 import com.sun.star.uno.Any;
33 import com.sun.star.uno.Exception;
34 import com.sun.star.uno.Type;
35 import com.sun.star.uno.UnoRuntime;
36 import com.sun.star.uno.XInterface;
37 import com.sun.star.xml.sax.XDocumentHandler;
39 /**
40 * Test for object which is represented by service
41 * <code>com.sun.star.comp.Chart.XMLStylesExporter</code>. <p>
42 * Object implements the following interfaces :
43 * <ul>
44 * <li><code>com::sun::star::lang::XInitialization</code></li>
45 * <li><code>com::sun::star::document::ExportFilter</code></li>
46 * <li><code>com::sun::star::document::XFilter</code></li>
47 * <li><code>com::sun::star::document::XExporter</code></li>
48 * <li><code>com::sun::star::beans::XPropertySet</code></li>
49 * </ul>
50 * @see com.sun.star.lang.XInitialization
51 * @see com.sun.star.document.ExportFilter
52 * @see com.sun.star.document.XFilter
53 * @see com.sun.star.document.XExporter
54 * @see com.sun.star.beans.XPropertySet
55 * @see ifc.lang._XInitialization
56 * @see ifc.document._ExportFilter
57 * @see ifc.document._XFilter
58 * @see ifc.document._XExporter
59 * @see ifc.beans._XPropertySet
61 public class XMLStylesExporter extends TestCase {
62 XChartDocument xChartDoc = null;
64 /**
65 * New text document created.
67 @Override
68 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
70 // get a soffice factory object
71 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
73 log.println( "creating a chartdocument" );
74 xChartDoc = SOF.createChartDoc();
77 /**
78 * Close document
80 @Override
81 protected void cleanup( TestParameters tParam, PrintWriter log ) {
82 if( xChartDoc!=null ) {
83 log.println( " closing xChartDoc" );
84 util.DesktopTools.closeDoc(xChartDoc);
85 xChartDoc = null;
89 /**
90 * Creating a TestEnvironment for the interfaces to be tested.
91 * Creates an instance of the service
92 * <code>com.sun.star.comp.Chart.XMLStylesExporter</code> with
93 * argument which is an implementation of <code>XDocumentHandler</code>
94 * and which can check if required tags and character data is
95 * exported. <p>
96 * Existing of some tags checked in XML data exported.
97 * Object relations created :
98 * <ul>
99 * <li> <code>'MediaDescriptor'</code> for
100 * {@link ifc.document._XFilter} interface </li>
101 * <li> <code>'XFilter.Checker'</code> for
102 * {@link ifc.document._XFilter} interface </li>
103 * <li> <code>'SourceDocument'</code> for
104 * {@link ifc.document._XExporter} interface </li>
105 * </ul>
107 @Override
108 public TestEnvironment createTestEnvironment
109 (TestParameters tParam, PrintWriter log) throws Exception {
111 XMultiServiceFactory xMSF = tParam.getMSF() ;
112 XInterface oObj = null;
114 FilterChecker filter = new FilterChecker(log);
115 Any arg = new Any(new Type(XDocumentHandler.class),filter);
117 oObj = (XInterface) xMSF.createInstanceWithArguments(
118 "com.sun.star.comp.Chart.XMLStylesExporter",
119 new Object[] {arg});
120 XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj);
121 xEx.setSourceDocument(xChartDoc);
124 filter.addTag(new XMLTools.Tag("office:document-styles")) ;
125 filter.addTagEnclosed(new XMLTools.Tag("office:styles"),
126 new XMLTools.Tag("office:document-styles"));
128 // create testobject here
129 log.println( "creating a new environment" );
130 TestEnvironment tEnv = new TestEnvironment( oObj );
132 tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor(
133 new String[] {"FilterName"},
134 new Object[] {"schart: StarOffice XML (Chart)"}));
135 tEnv.addObjRelation("SourceDocument",xChartDoc);
136 tEnv.addObjRelation("XFilter.Checker", filter) ;
137 log.println("Implementation Name: "+util.utils.getImplName(oObj));
139 return tEnv;
144 * This class checks the XML for tags and data required and returns
145 * checking result to <code>XFilter</code> interface test. All
146 * the information about errors occurred in XML data is written
147 * to log specified.
148 * @see ifc.document._XFilter
150 private class FilterChecker extends XMLTools.XMLChecker
151 implements ifc.document._XFilter.FilterChecker {
154 * Creates a class which will write information
155 * into log specified.
157 private FilterChecker(PrintWriter log) {
158 super(log, true) ;
161 * <code>_XFilter.FilterChecker</code> interface method
162 * which returns the result of XML checking.
163 * @return <code>true</code> if the XML data exported was
164 * valid (i.e. all necessary tags and character data exists),
165 * <code>false</code> if some errors occurred.
167 public boolean checkFilter() {
168 return check() ;