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._sw; 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.lang.XMultiServiceFactory; 39 import com.sun.star.text.XTextDocument; 40 import com.sun.star.text.XTextFieldsSupplier; 41 import com.sun.star.uno.UnoRuntime; 42 import com.sun.star.uno.XInterface; 43 44 /** 45 * 46 * initial description 47 * @see com.sun.star.container.XContainer 48 * @see com.sun.star.container.XElementAccess 49 * @see com.sun.star.container.XNameAccess 50 * @see com.sun.star.container.XNameContainer 51 * @see com.sun.star.container.XNameReplace 52 * 53 */ 54 public class SwXTextFieldMasters extends TestCase { 55 56 XTextDocument xTextDoc; 57 58 /** 59 * in general this method creates a testdocument 60 * 61 * @param tParam class which contains additional test parameters 62 * @param log class to log the test state and result 63 * 64 * 65 * @see TestParameters 66 * @see PrintWriter 67 * 68 */ 69 protected void initialize( TestParameters tParam, PrintWriter log ) { 70 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); 71 72 try { 73 log.println( "creating a textdocument" ); 74 xTextDoc = SOF.createTextDoc( null ); 75 } catch ( com.sun.star.uno.Exception e ) { 76 // Some exception occures.FAILED 77 e.printStackTrace( log ); 78 throw new StatusException( "Couldn't create document", e ); 79 } 80 } 81 82 /** 83 * in general this method disposes the testenvironment and document 84 * 85 * @param tParam class which contains additional test parameters 86 * @param log class to log the test state and result 87 * 88 * 89 * @see TestParameters 90 * @see PrintWriter 91 * 92 */ 93 protected void cleanup( TestParameters tParam, PrintWriter log ) { 94 log.println( " disposing xTextDoc " ); 95 util.DesktopTools.closeDoc(xTextDoc); 96 } 97 98 99 /** 100 * creating a Testenvironment for the interfaces to be tested 101 * 102 * @param tParam class which contains additional test parameters 103 * @param log class to log the test state and result 104 * 105 * @return Status class 106 * 107 * @see TestParameters 108 * @see PrintWriter 109 */ 110 public TestEnvironment createTestEnvironment( TestParameters tParam, 111 PrintWriter log ) 112 throws StatusException { 113 114 XInterface oObj = null; 115 116 // creation of testobject here 117 // first we write what we are intend to do to log file 118 log.println( "creating a test environment" ); 119 120 121 // create testobject here 122 try { 123 XTextFieldsSupplier oTFS = (XTextFieldsSupplier) 124 UnoRuntime.queryInterface( XTextFieldsSupplier.class, xTextDoc ); 125 126 oObj = oTFS.getTextFieldMasters(); 127 128 } 129 catch (Exception ex) { 130 log.println("Couldn't create instance"); 131 ex.printStackTrace(log); 132 } 133 134 log.println( "creating a new environment for FieldMasters object" ); 135 TestEnvironment tEnv = new TestEnvironment( oObj ); 136 137 return tEnv; 138 } // finish method getTestEnvironment 139 } // finish class SwXTextFieldMasters 140 141