merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sw / SwXTextFieldMasters.java
blob0615d870cf3b224e12211b7968d29fee8e902711
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SwXTextFieldMasters.java,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
31 package mod._sw;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.SOfficeFactory;
41 import com.sun.star.lang.XMultiServiceFactory;
42 import com.sun.star.text.XTextDocument;
43 import com.sun.star.text.XTextFieldsSupplier;
44 import com.sun.star.uno.UnoRuntime;
45 import com.sun.star.uno.XInterface;
47 /**
49 * initial description
50 * @see com.sun.star.container.XContainer
51 * @see com.sun.star.container.XElementAccess
52 * @see com.sun.star.container.XNameAccess
53 * @see com.sun.star.container.XNameContainer
54 * @see com.sun.star.container.XNameReplace
57 public class SwXTextFieldMasters extends TestCase {
59 XTextDocument xTextDoc;
61 /**
62 * in general this method creates a testdocument
64 * @param tParam class which contains additional test parameters
65 * @param log class to log the test state and result
68 * @see TestParameters
69 * @see PrintWriter
72 protected void initialize( TestParameters tParam, PrintWriter log ) {
73 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
75 try {
76 log.println( "creating a textdocument" );
77 xTextDoc = SOF.createTextDoc( null );
78 } catch ( com.sun.star.uno.Exception e ) {
79 // Some exception occures.FAILED
80 e.printStackTrace( log );
81 throw new StatusException( "Couldn't create document", e );
85 /**
86 * in general this method disposes the testenvironment and document
88 * @param tParam class which contains additional test parameters
89 * @param log class to log the test state and result
92 * @see TestParameters
93 * @see PrintWriter
96 protected void cleanup( TestParameters tParam, PrintWriter log ) {
97 log.println( " disposing xTextDoc " );
98 util.DesktopTools.closeDoc(xTextDoc);
103 * creating a Testenvironment for the interfaces to be tested
105 * @param tParam class which contains additional test parameters
106 * @param log class to log the test state and result
108 * @return Status class
110 * @see TestParameters
111 * @see PrintWriter
113 public TestEnvironment createTestEnvironment( TestParameters tParam,
114 PrintWriter log )
115 throws StatusException {
117 XInterface oObj = null;
119 // creation of testobject here
120 // first we write what we are intend to do to log file
121 log.println( "creating a test environment" );
124 // create testobject here
125 try {
126 XTextFieldsSupplier oTFS = (XTextFieldsSupplier)
127 UnoRuntime.queryInterface( XTextFieldsSupplier.class, xTextDoc );
129 oObj = oTFS.getTextFieldMasters();
132 catch (Exception ex) {
133 log.println("Couldn't create instance");
134 ex.printStackTrace(log);
137 log.println( "creating a new environment for FieldMasters object" );
138 TestEnvironment tEnv = new TestEnvironment( oObj );
140 return tEnv;
141 } // finish method getTestEnvironment
142 } // finish class SwXTextFieldMasters