1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package mod._sw;
25 
26 //API Interfaces
27 import java.io.PrintWriter;
28 
29 import lib.StatusException;
30 import lib.TestCase;
31 import lib.TestEnvironment;
32 import lib.TestParameters;
33 import util.SOfficeFactory;
34 
35 import com.sun.star.lang.XMultiServiceFactory;
36 import com.sun.star.text.XTextDocument;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
39 
40 /**
41  * Test for object which is represented by service
42  * <code>com.sun.star.text.Defaults</code> created by a writer
43  * document's <code>XMultiServiceFactory</code>. <p>
44  *
45  * Object implements the following interfaces :
46  * <ul>
47  *  <li> <code>com::sun::star::style::ParagraphProperties</code></li>
48  *  <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li>
49  *  <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li>
50  *  <li> <code>com::sun::star::text::Defaults</code></li>
51  *  <li> <code>com::sun::star::style::CharacterProperties</code></li>
52  *  <li> <code>com::sun::star::beans::XPropertySet</code></li>
53  *  <li> <code>com::sun::star::style::ParagraphPropertiesComplex</code></li>
54  * </ul> <p>
55  *
56  * @see com.sun.star.style.ParagraphProperties
57  * @see com.sun.star.style.CharacterPropertiesComplex
58  * @see com.sun.star.style.CharacterPropertiesAsian
59  * @see com.sun.star.text.Defaults
60  * @see com.sun.star.style.CharacterProperties
61  * @see com.sun.star.beans.XPropertySet
62  * @see com.sun.star.style.ParagraphPropertiesComplex
63  * @see ifc.style._ParagraphProperties
64  * @see ifc.style._CharacterPropertiesComplex
65  * @see ifc.style._CharacterPropertiesAsian
66  * @see ifc.text._Defaults
67  * @see ifc.style._CharacterProperties
68  * @see ifc.beans._XPropertySet
69  * @see ifc.style._ParagraphPropertiesComplex
70  */
71 public class SwXTextDefaults extends TestCase {
72 
73     XTextDocument xTextDoc;
74 
75     /**
76      * Creates the service <code>com.sun.star.text.Defaults</code>
77      */
createTestEnvironment( TestParameters tParam, PrintWriter log)78     protected TestEnvironment createTestEnvironment(
79             TestParameters tParam, PrintWriter log) {
80 
81         XInterface oObj = null;
82 
83         XMultiServiceFactory docMSF = (XMultiServiceFactory)
84             UnoRuntime.queryInterface(XMultiServiceFactory.class,xTextDoc);
85 
86         try {
87             oObj = (XInterface)
88                 docMSF.createInstance("com.sun.star.text.Defaults");
89         } catch (com.sun.star.uno.Exception e) {
90             throw new StatusException("Couldn't create Object",e);
91         }
92 
93         TestEnvironment tEnv = new TestEnvironment(oObj);
94 
95         return tEnv;
96     }
97 
98     /**
99     * Creates text document.
100     */
initialize( TestParameters tParam, PrintWriter log )101     protected void initialize( TestParameters tParam, PrintWriter log ) {
102         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
103         try {
104             log.println( "creating a textdocument" );
105             xTextDoc = SOF.createTextDoc( null );
106         } catch ( com.sun.star.uno.Exception e ) {
107             e.printStackTrace( log );
108             throw new StatusException( "Couldn't create document", e );
109         }
110     }
111 
112     /**
113     * Disposes text document.
114     */
cleanup( TestParameters tParam, PrintWriter log )115     protected void cleanup( TestParameters tParam, PrintWriter log ) {
116         log.println( "    disposing xTextDoc " );
117         util.DesktopTools.closeDoc(xTextDoc);
118     }
119 }
120