Set that a non-modal Popover don't auto-grab focus on popup
[LibreOffice.git] / qadevOOo / tests / java / mod / _xmloff / Draw / XMLSettingsImporter.java
blobec6d5625d794f559aa2fcfbc150db68da0297d5f
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.Draw;
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.beans.XPropertySet;
29 import com.sun.star.frame.XController;
30 import com.sun.star.frame.XModel;
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.Draw.XMLSettingsImporter</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 XMLSettingsImporter extends TestCase {
62 XComponent xDrawDoc = null;
64 /**
65 * New draw 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 drawdocument" );
74 xDrawDoc = SOF.createDrawDoc(null);
77 /**
78 * Text draw destroyed.
80 @Override
81 protected void cleanup( TestParameters tParam, PrintWriter log ) {
82 log.println( " disposing document " );
83 xDrawDoc.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.Draw.XMLSettingsImporter</code><p>
91 * The draw document is set as a target document for importer.
92 * Imported XML-data contains only settings tags including
93 * tag with property 'IsLayerMode'.
94 * After import property 'IsLayerMode' getting from target
95 * document is checked.
96 * Object relations created :
97 * <ul>
98 * <li> <code>'XDocumentHandler.XMLData'</code> for
99 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
100 * <li> <code>'XDocumentHandler.ImportChecker'</code> for
101 * {@link ifc.xml.sax._XDocumentHandler} interface </li>
102 * <li> <code>'TargetDocument'</code> for
103 * {@link ifc.document._XImporter} interface </li>
104 * </ul>
106 @Override
107 public TestEnvironment createTestEnvironment
108 (TestParameters tParam, PrintWriter log) throws Exception {
110 XInterface oObj = null;
111 Object oInt = null ;
113 // creation of testobject here
114 // first we write what we are intend to do to log file
115 log.println( "creating a test environment" );
117 XMultiServiceFactory xMSF = tParam.getMSF() ;
119 oInt = xMSF.createInstance
120 ("com.sun.star.comp.Draw.XMLSettingsImporter") ;
122 oObj = (XInterface) oInt ;
124 // create testobject here
125 log.println( "creating a new environment for Paragraph object" );
126 TestEnvironment tEnv = new TestEnvironment( oObj );
128 // adding relation
129 tEnv.addObjRelation("TargetDocument", xDrawDoc) ;
131 // adding relation for XDocumentHandler
132 String[][] xml = new String[][] {
133 {"start", "office:document-settings",
134 "xmlns:office", "CDATA", "http://openoffice.org/2000/office",
135 "xmlns:config", "CDATA", "http://openoffice.org/2001/config"},
136 {"start", "office:settings"},
137 {"start", "config:config-item-set",
138 "config:name", "CDATA", "view-settings"},
139 {"start", "config:config-item-map-indexed",
140 "config:name", "CDATA", "Views"},
141 {"start", "config:config-item-map-entry"},
142 {"start", "config:config-item",
143 "config:name", "CDATA", "IsLayerMode",
144 "config:type", "CDATA", "boolean"},
145 {"chars", "true"},
146 {"end", "config:config-item"},
147 {"end", "config:config-item-map-entry"},
148 {"end", "config:config-item-map-indexed"},
149 {"end", "config:config-item-set"},
150 {"end", "office:settings"},
151 {"end", "office:document-settings"} };
153 tEnv.addObjRelation("XDocumentHandler.XMLData", xml);
154 final PrintWriter logF = log;
155 XModel xDrawModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc);
156 XController xController = xDrawModel.getCurrentController();
157 final XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController);
159 tEnv.addObjRelation("XDocumentHandler.ImportChecker",
160 new ifc.xml.sax._XDocumentHandler.ImportChecker() {
161 public boolean checkImport() {
162 try {
163 Boolean value = (Boolean)
164 xPropSet.getPropertyValue("IsLayerMode");
165 logF.println("'IsLayerMode' property value is '"
166 + value + "'");
167 return value.booleanValue();
168 } catch (com.sun.star.uno.Exception e) {
169 logF.println("Exception while checking import :") ;
170 e.printStackTrace(logF) ;
171 return false ;
174 }) ;
176 return tEnv;
177 } // finish method getTestEnvironment