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: UIElementFactoryManager.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
;
43 import util
.WriterTools
;
47 public class UIElementFactoryManager
extends TestCase
{
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();
87 log
.println("Creating instance...");
88 xTextDoc
= WriterTools
.createTextDoc(xMSF
);
90 oObj
= xMSF
.createInstance("com.sun.star.ui.UIElementFactoryManager");
92 catch(com
.sun
.star
.uno
.Exception e
) {
93 throw new StatusException("Cannot create test object.", e
);
95 log
.println("TestObject: " + util
.utils
.getImplName(oObj
));
97 tEnv
= new TestEnvironment((XInterface
)oObj
);