merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sw / SwXTextViewCursor.java
blobca052884f155a8d64f9032480ec332a11027b697
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: SwXTextViewCursor.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.XTextViewCursorSupplier;
44 import com.sun.star.uno.UnoRuntime;
45 import com.sun.star.uno.XInterface;
46 /**
48 * initial description
49 * @see com.sun.star.beans.XPropertySet
50 * @see com.sun.star.beans.XPropertyState
51 * @see com.sun.star.document.XDocumentInsertable
52 * @see com.sun.star.style.CharacterProperties
53 * @see com.sun.star.style.ParagraphProperties
54 * @see com.sun.star.text.XPageCursor
55 * @see com.sun.star.text.XParagraphCursor
56 * @see com.sun.star.text.XSentenceCursor
57 * @see com.sun.star.text.XTextCursor
58 * @see com.sun.star.text.XTextRange
59 * @see com.sun.star.text.XWordCursor
60 * @see com.sun.star.util.XSortable
61 * @see com.sun.star.view.XScreenCursor
64 public class SwXTextViewCursor extends TestCase {
65 XTextDocument xTextDoc;
67 protected void initialize( TestParameters tParam, PrintWriter log ) {
68 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
70 try {
71 log.println( "creating a textdocument" );
72 xTextDoc = SOF.createTextDoc( null );
73 } catch ( com.sun.star.uno.Exception e ) {
74 // Some exception occures.FAILED
75 e.printStackTrace( log );
76 throw new StatusException( "Couldn't create document", e );
80 protected void cleanup( TestParameters tParam, PrintWriter log ) {
81 log.println( " disposing xTextDoc " );
82 util.DesktopTools.closeDoc(xTextDoc);
86 /**
87 * creating a Testenvironment for the interfaces to be tested
89 * @param tParam class which contains additional test parameters
90 * @param log class to log the test state and result
92 * @return Status class
94 * @see TestParameters
95 * @see PrintWriter
97 public synchronized TestEnvironment createTestEnvironment
98 (TestParameters tParam, PrintWriter log) {
100 XInterface oObj = null;
102 // creation of testobject here
103 // first we write what we are intend to do to log file
104 log.println( "creating a test environment" );
106 // create testobject here
107 oObj = xTextDoc.getCurrentController();
109 XTextViewCursorSupplier oTVCSupp = (XTextViewCursorSupplier)
110 UnoRuntime.queryInterface(XTextViewCursorSupplier.class, oObj);
112 oObj = oTVCSupp.getViewCursor();
114 log.println( "creating a new environment for TextViewCursor object" );
115 TestEnvironment tEnv = new TestEnvironment( oObj );
117 log.println( "adding TextDocument as mod relation to environment" );
118 tEnv.addObjRelation("TEXTDOC", xTextDoc);
119 tEnv.addObjRelation("XTEXT", xTextDoc.getText());
121 return tEnv;
122 } // finish method getTestEnvironment
125 } // finish class SwXTextViewCursor