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 
24 package mod._fwk;
25 
26 import com.sun.star.lang.XMultiServiceFactory;
27 import com.sun.star.text.XTextDocument;
28 import com.sun.star.uno.XInterface;
29 import java.io.PrintWriter;
30 import lib.StatusException;
31 import lib.TestCase;
32 import lib.TestEnvironment;
33 import lib.TestParameters;
34 import util.utils;
35 
36 
37 /**
38  */
39 public class ControlMenuController extends TestCase {
40     XInterface oObj = null;
41     XTextDocument xTextDoc;
42 
43     /**
44      * Cleanup: close the created document
45      * @param tParam The test parameters.
46      * @param log The log writer.
47      * @return The test environment.
48      *
49     protected void cleanup(TestParameters tParam, PrintWriter log) {
50         log.println("    disposing xTextDoc ");
51 
52         try {
53             XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
54             XCloseable.class, xTextDoc);
55             closer.close(true);
56         } catch (com.sun.star.util.CloseVetoException e) {
57             log.println("couldn't close document");
58         } catch (com.sun.star.lang.DisposedException e) {
59             log.println("couldn't close document");
60         }
61     }
62 
63     /**
64      * Create test environment.
65      */
createTestEnvironment(TestParameters tParam, PrintWriter log)66     protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
67         TestEnvironment tEnv = null;
68         XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF();
69         try {
70             oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.ControlMenuController");
71         }
72         catch(com.sun.star.uno.Exception e) {
73             e.printStackTrace(log);
74             throw new StatusException("Could not create object 'ControlMenuController'", e);
75         }
76 
77 
78 /*        log.println("Creating instance...");
79 
80         xTextDoc = WriterTools.createTextDoc(xMSF);
81 
82 /*        XText xText = xTextDoc.getText();
83         XTextCursor xTextCursor = xText.createTextCursor();
84 
85         for (int i = 0; i < 11; i++) {
86             xText.insertString(xTextCursor, "A sample text and why not? ", false);
87         }
88 
89         XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class, xTextDoc);
90 
91         // the supplier is available from the model
92         XUIConfigurationManagerSupplier xSupplier =
93                 (XUIConfigurationManagerSupplier)UnoRuntime.queryInterface(
94                 XUIConfigurationManagerSupplier.class, xModel);
95 
96         xManager = xSupplier.getUIConfigurationManager();
97 
98         // just to make sure, it's the right one.
99         log.println("TestObject: " + util.utils.getImplName(xManager));
100         tEnv = new TestEnvironment(xManager); */
101         log.println("TestObject: " + utils.getImplName(oObj));
102         tEnv = new TestEnvironment(oObj);
103         return tEnv;
104     }
105 
106 }
107