Java-WebSocket: upgrade to 1.6.0
[LibreOffice.git] / qadevOOo / tests / java / mod / _xmloff / Impress / XMLImporter.java
blob1331d9130be06d311c5e6547c6dfbc6f537a9321
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.Impress;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.SOfficeFactory;
28 import com.sun.star.container.XNameAccess;
29 import com.sun.star.drawing.XDrawPages;
30 import com.sun.star.drawing.XDrawPagesSupplier;
31 import com.sun.star.lang.XComponent;
32 import com.sun.star.lang.XMultiServiceFactory;
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.uno.XInterface;
36 /**
37 * Test for object which is represented by service
38 * <code>com.sun.star.comp.Impress.XMLImporter</code>. <p>
39 * Object implements the following interfaces :
40 * <ul>
41 * <li><code>com::sun::star::lang::XInitialization</code></li>
42 * <li><code>com::sun::star::document::XImporter</code></li>
43 * <li><code>com::sun::star::document::XFilter</code></li>
44 * <li><code>com::sun::star::document::ImportFilter</code></li>
45 * <li><code>com::sun::star::beans::XPropertySet</code></li>
46 * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li>
47 * </ul>
48 * @see com.sun.star.lang.XInitialization
49 * @see com.sun.star.document.XImporter
50 * @see com.sun.star.document.XFilter
51 * @see com.sun.star.document.ImportFilter
52 * @see com.sun.star.beans.XPropertySet
53 * @see com.sun.star.xml.sax.XDocumentHandler
54 * @see ifc.lang._XInitialization
55 * @see ifc.document._XImporter
56 * @see ifc.document._XFilter
57 * @see ifc.document._XExporter
58 * @see ifc.beans._XPropertySet
59 * @see ifc.xml.sax._XDocumentHandler
61 public class XMLImporter extends TestCase {
62 XComponent xImpressDoc = null;
64 /**
65 * New impress 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 an impress document" );
74 xImpressDoc = SOF.createImpressDoc(null);
77 /**
78 * Impress document destroyed.
80 @Override
81 protected void cleanup( TestParameters tParam, PrintWriter log ) {
82 log.println( " disposing document " );
83 xImpressDoc.dispose();
86 /**
87 * Creating a TestEnvironment for the interfaces to be tested.
88 * Creates an instance of the service
89 * <code>com.sun.star.comp.Impress.XMLImporter</code><p>
91 * The impress document is set as a target document for importer.
92 * Imported tags contain page with the specific name.
93 * After import existence of the page with this specific
94 * name is checked in the target document.
95 * Object relations created :
96 * <ul>
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>
103 * </ul>
105 @Override
106 public TestEnvironment createTestEnvironment
107 (TestParameters tParam, PrintWriter log) throws Exception {
109 XInterface oObj = null;
110 Object oInt = 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.Impress.XMLImporter") ;
121 oObj = (XInterface) oInt ;
123 // create testobject here
124 log.println( "creating a new environment for Paragraph object" );
125 TestEnvironment tEnv = new TestEnvironment( oObj );
127 // adding relation
128 tEnv.addObjRelation("TargetDocument", xImpressDoc) ;
130 final String impName = "XMLImporter";
131 // adding relation for XDocumentHandler
132 String[][] xml = new String[][] {
133 {"start", "office:document",
134 "xmlns:office", "CDATA", "http://openoffice.org/2000/office",
135 "xmlns:draw", "CDATA", "http://openoffice.org/2000/drawing"
137 {"start", "office:body"},
138 {"start", "draw:page",
139 "draw:name", "CDATA", impName },
140 {"end", "draw:page"},
141 {"end", "office:body"},
142 {"end", "office:document"} };
144 tEnv.addObjRelation("XDocumentHandler.XMLData", xml);
146 //get draw pages
147 XDrawPagesSupplier drawPagesSupplier = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc);
148 XDrawPages drawPages = drawPagesSupplier.getDrawPages();
149 final XNameAccess xNamePages = UnoRuntime.queryInterface(XNameAccess.class, drawPages);
151 tEnv.addObjRelation("XDocumentHandler.ImportChecker",
152 new ifc.xml.sax._XDocumentHandler.ImportChecker() {
153 public boolean checkImport() {
154 return xNamePages.hasByName(impName);
156 } );
158 return tEnv;
159 } // finish method getTestEnvironment