1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package mod._fwk; 29 30 import com.sun.star.lang.XMultiServiceFactory; 31 import com.sun.star.text.XTextDocument; 32 import com.sun.star.uno.XInterface; 33 import java.io.PrintWriter; 34 import lib.StatusException; 35 import lib.TestCase; 36 import lib.TestEnvironment; 37 import lib.TestParameters; 38 import util.utils; 39 40 41 /** 42 */ 43 public class ControlMenuController extends TestCase { 44 XInterface oObj = null; 45 XTextDocument xTextDoc; 46 47 /** 48 * Cleanup: close the created document 49 * @param tParam The test parameters. 50 * @param The log writer. 51 * @return The test environment. 52 * 53 protected void cleanup(TestParameters tParam, PrintWriter log) { 54 log.println(" disposing xTextDoc "); 55 56 try { 57 XCloseable closer = (XCloseable) UnoRuntime.queryInterface( 58 XCloseable.class, xTextDoc); 59 closer.close(true); 60 } catch (com.sun.star.util.CloseVetoException e) { 61 log.println("couldn't close document"); 62 } catch (com.sun.star.lang.DisposedException e) { 63 log.println("couldn't close document"); 64 } 65 } 66 67 /** 68 * Create test environment. 69 */ 70 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { 71 TestEnvironment tEnv = null; 72 XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF(); 73 try { 74 oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.ControlMenuController"); 75 } 76 catch(com.sun.star.uno.Exception e) { 77 e.printStackTrace(log); 78 throw new StatusException("Could not create object 'ControlMenuController'", e); 79 } 80 81 82 /* log.println("Creating instance..."); 83 84 xTextDoc = WriterTools.createTextDoc(xMSF); 85 86 /* XText xText = xTextDoc.getText(); 87 XTextCursor xTextCursor = xText.createTextCursor(); 88 89 for (int i = 0; i < 11; i++) { 90 xText.insertString(xTextCursor, "A sample text and why not? ", false); 91 } 92 93 XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class, xTextDoc); 94 95 // the supplier is available from the model 96 XUIConfigurationManagerSupplier xSupplier = 97 (XUIConfigurationManagerSupplier)UnoRuntime.queryInterface( 98 XUIConfigurationManagerSupplier.class, xModel); 99 100 xManager = xSupplier.getUIConfigurationManager(); 101 102 // just to make sure, it's the right one. 103 log.println("TestObject: " + util.utils.getImplName(xManager)); 104 tEnv = new TestEnvironment(xManager); */ 105 log.println("TestObject: " + utils.getImplName(oObj)); 106 tEnv = new TestEnvironment(oObj); 107 return tEnv; 108 } 109 110 } 111