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