1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package mod._sw; 25 26 import java.io.PrintWriter; 27 28 import lib.StatusException; 29 import lib.TestCase; 30 import lib.TestEnvironment; 31 import lib.TestParameters; 32 import util.SOfficeFactory; 33 34 import com.sun.star.lang.XMultiServiceFactory; 35 import com.sun.star.text.XTextDocument; 36 import com.sun.star.text.XTextFieldsSupplier; 37 import com.sun.star.uno.UnoRuntime; 38 import com.sun.star.uno.XInterface; 39 40 /** 41 * 42 * initial description 43 * @see com.sun.star.container.XContainer 44 * @see com.sun.star.container.XElementAccess 45 * @see com.sun.star.container.XNameAccess 46 * @see com.sun.star.container.XNameContainer 47 * @see com.sun.star.container.XNameReplace 48 * 49 */ 50 public class SwXTextFieldMasters extends TestCase { 51 52 XTextDocument xTextDoc; 53 54 /** 55 * in general this method creates a testdocument 56 * 57 * @param tParam class which contains additional test parameters 58 * @param log class to log the test state and result 59 * 60 * 61 * @see TestParameters 62 * @see PrintWriter 63 * 64 */ initialize( TestParameters tParam, PrintWriter log )65 protected void initialize( TestParameters tParam, PrintWriter log ) { 66 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() ); 67 68 try { 69 log.println( "creating a textdocument" ); 70 xTextDoc = SOF.createTextDoc( null ); 71 } catch ( com.sun.star.uno.Exception e ) { 72 // Some exception occures.FAILED 73 e.printStackTrace( log ); 74 throw new StatusException( "Couldn't create document", e ); 75 } 76 } 77 78 /** 79 * in general this method disposes the testenvironment and document 80 * 81 * @param tParam class which contains additional test parameters 82 * @param log class to log the test state and result 83 * 84 * 85 * @see TestParameters 86 * @see PrintWriter 87 * 88 */ cleanup( TestParameters tParam, PrintWriter log )89 protected void cleanup( TestParameters tParam, PrintWriter log ) { 90 log.println( " disposing xTextDoc " ); 91 util.DesktopTools.closeDoc(xTextDoc); 92 } 93 94 95 /** 96 * creating a Testenvironment for the interfaces to be tested 97 * 98 * @param tParam class which contains additional test parameters 99 * @param log class to log the test state and result 100 * 101 * @return Status class 102 * 103 * @see TestParameters 104 * @see PrintWriter 105 */ createTestEnvironment( TestParameters tParam, PrintWriter log )106 public TestEnvironment createTestEnvironment( TestParameters tParam, 107 PrintWriter log ) 108 throws StatusException { 109 110 XInterface oObj = null; 111 112 // creation of testobject here 113 // first we write what we are intend to do to log file 114 log.println( "creating a test environment" ); 115 116 117 // create testobject here 118 try { 119 XTextFieldsSupplier oTFS = (XTextFieldsSupplier) 120 UnoRuntime.queryInterface( XTextFieldsSupplier.class, xTextDoc ); 121 122 oObj = oTFS.getTextFieldMasters(); 123 124 } 125 catch (Exception ex) { 126 log.println("Couldn't create instance"); 127 ex.printStackTrace(log); 128 } 129 130 log.println( "creating a new environment for FieldMasters object" ); 131 TestEnvironment tEnv = new TestEnvironment( oObj ); 132 133 return tEnv; 134 } // finish method getTestEnvironment 135 } // finish class SwXTextFieldMasters 136 137