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.drawing.XControlShape;
26 import com.sun.star.lang.XMultiServiceFactory;
27 import com.sun.star.text.XTextDocument;
28 import com.sun.star.uno.XInterface;
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 util.FormTools;
38 import util.WriterTools;
39 import util.utils;
40 
41 
42 public class TabControllerModel extends TestCase {
43     private static XTextDocument xTextDoc;
44 
initialize(TestParameters param, PrintWriter log)45     protected void initialize(TestParameters param, PrintWriter log) {
46         try {
47             log.println("creating a textdocument");
48             xTextDoc = WriterTools.createTextDoc(
49                                (XMultiServiceFactory) param.getMSF());
50         } catch (Exception e) {
51             e.printStackTrace(log);
52             throw new StatusException("Couldn't create document", e);
53         }
54     }
55 
cleanup(TestParameters param, PrintWriter log)56     protected void cleanup(TestParameters param, PrintWriter log) {
57         log.println("disposing xTextDoc");
58         util.DesktopTools.closeDoc(xTextDoc);
59     }
60 
createTestEnvironment(TestParameters param, PrintWriter log)61     public TestEnvironment createTestEnvironment(TestParameters param,
62                                                  PrintWriter log) {
63         XInterface oObj = null;
64 
65         log.println("inserting some ControlShapes");
66 
67         XControlShape shape1 = FormTools.createControlShape(xTextDoc, 3000,
68                                                             4500, 15000, 1000,
69                                                             "CommandButton");
70         XControlShape shape2 = FormTools.createControlShape(xTextDoc, 5000,
71                                                             3500, 7500, 5000,
72                                                             "TextField");
73 
74         try {
75             oObj = (XInterface) ((XMultiServiceFactory) param.getMSF()).createInstance(
76                            "com.sun.star.awt.TabControllerModel");
77         } catch (Exception e) {
78             e.printStackTrace(log);
79             throw new StatusException("Couldn't create " +
80                                       "TabControllerModel", e);
81         }
82 
83         log.println("creating a new environment for TabControllerModel");
84 
85         TestEnvironment tEnv = new TestEnvironment(oObj);
86 
87         tEnv.addObjRelation("OBJNAME",
88                             "stardiv.vcl.controlmodel.TabController");
89         tEnv.addObjRelation("Model1", shape1.getControl());
90         tEnv.addObjRelation("Model2", shape2.getControl());
91 
92 
93         //Object Relation for XPersistObject
94         tEnv.addObjRelation("noPS", new Boolean(true));
95 
96         System.out.println("ImplementationName: " + utils.getImplName(oObj));
97 
98         return tEnv;
99     } // finish method getTestEnvironment
100 } // finish class TabControllerModel
101