1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ObjectMenuController.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import com
.sun
.star
.lang
.XMultiServiceFactory
;
34 import com
.sun
.star
.uno
.UnoRuntime
;
35 import com
.sun
.star
.uno
.XInterface
;
36 import java
.io
.PrintWriter
;
37 import com
.sun
.star
.text
.XTextDocument
;
38 import com
.sun
.star
.util
.XCloseable
;
39 import lib
.StatusException
;
41 import lib
.TestEnvironment
;
42 import lib
.TestParameters
;
47 public class ObjectMenuController
extends TestCase
{
48 XInterface oObj
= null;
49 XTextDocument xTextDoc
;
52 * Cleanup: close the created document
53 * @param tParam The test parameters.
54 * @param The log writer.
55 * @return The test environment.
57 protected void cleanup(TestParameters tParam
, PrintWriter log
) {
58 log
.println(" disposing xTextDoc ");
61 XCloseable closer
= (XCloseable
) UnoRuntime
.queryInterface(
62 XCloseable
.class, xTextDoc
);
64 } catch (com
.sun
.star
.util
.CloseVetoException e
) {
65 log
.println("couldn't close document");
66 } catch (com
.sun
.star
.lang
.DisposedException e
) {
67 log
.println("couldn't close document");
72 * Create test environment:
74 * <li>create a text doc</li>
75 * <li>get the model from the text doc</li>
76 * <li>query model for XUIConfigurationManagerSupplier interface</li>
77 * <li>get the manager from the supplier</li>
79 * @param tParam The test parameters.
80 * @param The log writer.
81 * @return The test environment.
83 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) {
84 TestEnvironment tEnv
= null;
85 XMultiServiceFactory xMSF
= (XMultiServiceFactory
)tParam
.getMSF();
88 oObj
= (XInterface
)xMSF
.createInstance("com.sun.star.comp.framework.ObjectMenuController");
90 catch(com
.sun
.star
.uno
.Exception e
) {
91 e
.printStackTrace(log
);
92 throw new StatusException("Could not create object 'ControlMenuController'", e
);
94 log
.println("TestObject: " + utils
.getImplName(oObj
));
95 tEnv
= new TestEnvironment(oObj
);