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._sfx;
29 
30 import java.io.PrintWriter;
31 
32 import lib.StatusException;
33 import lib.TestCase;
34 import lib.TestEnvironment;
35 import lib.TestParameters;
36 
37 import com.sun.star.frame.XStorable;
38 import com.sun.star.lang.XMultiServiceFactory;
39 import com.sun.star.text.XTextDocument;
40 import com.sun.star.uno.UnoRuntime;
41 import com.sun.star.uno.XInterface;
42 
43 /**
44  * Test for object which is represented by service
45  * <code>com.sun.star.frame.DocumentTemplates</code>. <p>
46  *
47  * Object implements the following interfaces :
48  * <ul>
49  *  <li> <code>com::sun::star::frame::XDocumentTemplates</code></li>
50  * </ul> <p>
51  *
52  */
53 public class DocumentTemplates extends TestCase {
54 
55     XTextDocument xTextDoc;
56 
57     protected void initialize( TestParameters tParam, PrintWriter log ) {
58         String aURL=util.utils.getFullTestURL("report2.stw");
59         xTextDoc = util.WriterTools.loadTextDoc((XMultiServiceFactory)tParam.getMSF(),aURL);
60     }
61 
62     protected void cleanup( TestParameters tParam, PrintWriter log ) {
63         log.println( "    disposing xTextDoc " );
64         xTextDoc.dispose();
65     }
66 
67     /**
68      * Creating a Testenvironment for the interfaces to be tested.
69      * Creates an instance of the service
70      * <code>com.sun.star.frame.DocumentTemplates</code>.
71     */
72     protected TestEnvironment createTestEnvironment
73             (TestParameters tParam, PrintWriter log) {
74 
75         XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF();
76         XInterface oObj = null;
77         XStorable store = null;
78 
79         try {
80             oObj = (XInterface)xMSF.createInstance
81                 ("com.sun.star.frame.DocumentTemplates");
82             store = (XStorable) UnoRuntime.queryInterface
83                 (XStorable.class,xTextDoc);
84         } catch (com.sun.star.uno.Exception e) {
85             e.printStackTrace(log);
86             throw new StatusException("Unexpected exception", e);
87         }
88 
89         String Iname = util.utils.getImplName(oObj);
90         log.println("Implementation Name: "+Iname);
91         TestEnvironment tEnv = new TestEnvironment(oObj);
92         tEnv.addObjRelation("Store",store);
93         return tEnv;
94     }
95 
96 }    // finish class TestCase
97 
98