1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package mod._sw;
29 
30 //API Interfaces
31 import java.io.PrintWriter;
32 
33 import lib.StatusException;
34 import lib.TestCase;
35 import lib.TestEnvironment;
36 import lib.TestParameters;
37 import util.SOfficeFactory;
38 
39 import com.sun.star.lang.XMultiServiceFactory;
40 import com.sun.star.text.XTextDocument;
41 import com.sun.star.uno.UnoRuntime;
42 import com.sun.star.uno.XInterface;
43 
44 /**
45  * Test for object which is represented by service
46  * <code>com.sun.star.text.Defaults</code> created by a writer
47  * document's <code>XMultiServiceFactory</code>. <p>
48  *
49  * Object implements the following interfaces :
50  * <ul>
51  *  <li> <code>com::sun::star::style::ParagraphProperties</code></li>
52  *  <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li>
53  *  <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li>
54  *  <li> <code>com::sun::star::text::Defaults</code></li>
55  *  <li> <code>com::sun::star::style::CharacterProperties</code></li>
56  *  <li> <code>com::sun::star::beans::XPropertySet</code></li>
57  *  <li> <code>com::sun::star::style::ParagraphPropertiesComplex</code></li>
58  * </ul> <p>
59  *
60  * @see com.sun.star.style.ParagraphProperties
61  * @see com.sun.star.style.CharacterPropertiesComplex
62  * @see com.sun.star.style.CharacterPropertiesAsian
63  * @see com.sun.star.text.Defaults
64  * @see com.sun.star.style.CharacterProperties
65  * @see com.sun.star.beans.XPropertySet
66  * @see com.sun.star.style.ParagraphPropertiesComplex
67  * @see ifc.style._ParagraphProperties
68  * @see ifc.style._CharacterPropertiesComplex
69  * @see ifc.style._CharacterPropertiesAsian
70  * @see ifc.text._Defaults
71  * @see ifc.style._CharacterProperties
72  * @see ifc.beans._XPropertySet
73  * @see ifc.style._ParagraphPropertiesComplex
74  */
75 public class SwXTextDefaults extends TestCase {
76 
77     XTextDocument xTextDoc;
78 
79     /**
80      * Creates the service <code>com.sun.star.text.Defaults</code>
81      */
82     protected TestEnvironment createTestEnvironment(
83             TestParameters tParam, PrintWriter log) {
84 
85         XInterface oObj = null;
86 
87         XMultiServiceFactory docMSF = (XMultiServiceFactory)
88             UnoRuntime.queryInterface(XMultiServiceFactory.class,xTextDoc);
89 
90         try {
91             oObj = (XInterface)
92                 docMSF.createInstance("com.sun.star.text.Defaults");
93         } catch (com.sun.star.uno.Exception e) {
94             throw new StatusException("Couldn't create Object",e);
95         }
96 
97         TestEnvironment tEnv = new TestEnvironment(oObj);
98 
99         return tEnv;
100     }
101 
102     /**
103     * Creates text document.
104     */
105     protected void initialize( TestParameters tParam, PrintWriter log ) {
106         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
107         try {
108             log.println( "creating a textdocument" );
109             xTextDoc = SOF.createTextDoc( null );
110         } catch ( com.sun.star.uno.Exception e ) {
111             e.printStackTrace( log );
112             throw new StatusException( "Couldn't create document", e );
113         }
114     }
115 
116     /**
117     * Disposes text document.
118     */
119     protected void cleanup( TestParameters tParam, PrintWriter log ) {
120         log.println( "    disposing xTextDoc " );
121         util.DesktopTools.closeDoc(xTextDoc);
122     }
123 }
124