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 package mod._toolkit;
24 
25 import com.sun.star.lang.XMultiServiceFactory;
26 import com.sun.star.text.XTextDocument;
27 import com.sun.star.uno.XInterface;
28 
29 import java.io.PrintWriter;
30 
31 import lib.StatusException;
32 import lib.TestCase;
33 import lib.TestEnvironment;
34 import lib.TestParameters;
35 
36 import util.WriterTools;
37 import util.utils;
38 
39 
40 public class UnoControlButtonModel extends TestCase {
41     private static XTextDocument xTextDoc;
42 
43     /**
44     * Creates StarOffice Writer document.
45     */
initialize(TestParameters tParam, PrintWriter log)46     protected void initialize(TestParameters tParam, PrintWriter log) {
47         log.println("creating a textdocument");
48         xTextDoc = WriterTools.createTextDoc(
49                            (XMultiServiceFactory) tParam.getMSF());
50     }
51 
52     /**
53     * Disposes StarOffice Writer document.
54     */
cleanup(TestParameters tParam, PrintWriter log)55     protected void cleanup(TestParameters tParam, PrintWriter log) {
56         log.println("    disposing xTextDoc ");
57 
58         util.DesktopTools.closeDoc(xTextDoc);
59     }
60 
createTestEnvironment(TestParameters Param, PrintWriter log)61     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param,
62                                                                  PrintWriter log) {
63         XInterface oObj = null;
64 
65         try {
66             oObj = (XInterface) ((XMultiServiceFactory) Param.getMSF()).createInstance(
67                            "com.sun.star.awt.UnoControlButtonModel");
68         } catch (Exception e) {
69             e.printStackTrace(log);
70             throw new StatusException("Couldn't create object", e);
71         }
72 
73         log.println(
74                 "creating a new environment for UnoControlButtonModel object");
75 
76         TestEnvironment tEnv = new TestEnvironment(oObj);
77 
78         tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.Button");
79         System.out.println("ImplementationName: " + utils.getImplName(oObj));
80 
81         return tEnv;
82     } // finish method getTestEnvironment
83 } // finish class UnoControlButtonModel
84