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 java.io.PrintWriter; 31 32 import lib.StatusException; 33 import lib.TestCase; 34 import lib.TestEnvironment; 35 import lib.TestParameters; 36 import util.SOfficeFactory; 37 38 import com.sun.star.frame.XFrame; 39 import com.sun.star.lang.XMultiServiceFactory; 40 import com.sun.star.text.XTextDocument; 41 import com.sun.star.uno.UnoRuntime; 42 import com.sun.star.uno.XInterface; 43 import com.sun.star.util.XCloseable; 44 45 /** 46 * Test for object that implements the following interfaces : 47 * <ul> 48 * <li><code>com::sun::star::frame::XDispatchProvider</code></li> 49 * <li><code>com::sun::star::frame::XFrame</code></li> 50 * <li><code>com::sun::star::frame::XFramesSupplier</code></li> 51 * <li><code>com::sun::star::task::XStatusIndicatorFactory</code></li> 52 * <li><code>com::sun::star::lang::XComponent</code></li> 53 * </ul><p> 54 * @see com.sun.star.frame.XDispatchProvider 55 * @see com.sun.star.frame.XFrame 56 * @see com.sun.star.frame.XFramesSupplier 57 * @see com.sun.star.task.XStatusIndicatorFactory 58 * @see com.sun.star.lang.XComponent 59 * @see ifc.frame._XDispatchProvider 60 * @see ifc.frame._XFrame 61 * @see ifc.frame._XFramesSupplier 62 * @see ifc.task._XStatusIndicatorFactory 63 * @see ifc.lang._XComponent 64 */ 65 public class Frame extends TestCase { 66 67 XTextDocument xTextDoc; 68 XFrame frame = null; 69 70 71 /** 72 * Creates a text document and obtains a frame of current controller. 73 */ 74 public TestEnvironment createTestEnvironment( TestParameters Param, 75 PrintWriter log ) throws StatusException { 76 77 XInterface oObj = null; 78 79 log.println( "creating a test environment" ); 80 81 // get a soffice factory object 82 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF()); 83 84 try { 85 log.println( "creating a text document" ); 86 xTextDoc = SOF.createTextDoc(null); 87 } catch ( com.sun.star.uno.Exception e ) { 88 // Some exception occures.FAILED 89 e.printStackTrace( log ); 90 throw new StatusException( "Couldn't create document", e ); 91 } 92 93 frame = xTextDoc.getCurrentController().getFrame(); 94 oObj = (XInterface)UnoRuntime.queryInterface(XInterface.class, frame); 95 96 log.println(util.utils.getImplName(oObj)); 97 98 TestEnvironment tEnv = new TestEnvironment( oObj ); 99 100 tEnv.addObjRelation("XDispatchProvider.URL", 101 ".uno:SwitchControlDesignMode"); 102 103 return tEnv; 104 } // finish method getTestEnvironment 105 106 107 /** 108 * Disposes the document created and finally disposes 109 * the frame containing the document (for case when the frame 110 * contains no model after some interafce manipulations). 111 */ 112 protected void cleanup( TestParameters Param, PrintWriter log) { 113 try { 114 XCloseable xTextClose = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, xTextDoc); 115 xTextClose.close(true); 116 } catch(Exception e){} 117 118 } 119 } 120