bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXTextTableCursor.java
blob980765be4fc2fdb10e7c6dee9023b1e961e92db2
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package mod._sw;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
29 import com.sun.star.lang.XMultiServiceFactory;
30 import com.sun.star.text.XTextDocument;
31 import com.sun.star.text.XTextTable;
32 import com.sun.star.uno.XInterface;
34 /**
36 * initial description
37 * @see com.sun.star.beans.XPropertySet
38 * @see com.sun.star.text.XTextTableCursor
41 public class SwXTextTableCursor extends TestCase {
42 XTextDocument xTextDoc;
44 protected void initialize( TestParameters tParam, PrintWriter log ) {
45 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
47 try {
48 log.println( "creating a textdocument" );
49 xTextDoc = SOF.createTextDoc( null );
50 } catch ( com.sun.star.uno.Exception e ) {
51 // Some exception occurs.FAILED
52 e.printStackTrace( log );
53 throw new StatusException( "Couldn't create document", e );
57 protected void cleanup( TestParameters tParam, PrintWriter log ) {
58 log.println( " disposing xTextDoc " );
59 util.DesktopTools.closeDoc(xTextDoc);
63 /**
64 * creating a Testenvironment for the interfaces to be tested
66 * @param tParam class which contains additional test parameters
67 * @param log class to log the test state and result
69 * @return Status class
71 * @see TestParameters
72 * @see PrintWriter
74 public synchronized TestEnvironment createTestEnvironment( TestParameters tParam,
75 PrintWriter log )
76 throws StatusException {
78 XInterface oObj = null;
80 // creation of testobject here
81 // first we write what we are intend to do to log file
82 log.println( "creating a test environment" );
84 // get a soffice factory object
85 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
87 // create testobject here
89 XTextTable oTable = null;
90 try {
91 oTable = SOfficeFactory.createTextTable( xTextDoc );
92 SOfficeFactory.insertTextContent(xTextDoc, oTable );
94 catch( com.sun.star.uno.Exception uE ) {
95 uE.printStackTrace( log );
96 throw new StatusException("Couldn't create TextTable : "
97 + uE.getMessage(), uE);
100 oObj = oTable.createCursorByCellName("A1");
102 log.println( "creating a new environment for TextTableCursor object" );
103 TestEnvironment tEnv = new TestEnvironment( oObj );
105 log.println( "adding TextDocument as mod relation to environment" );
106 tEnv.addObjRelation("TEXTDOC", xTextDoc);
108 tEnv.addObjRelation("STYLENAME1", "Table");
109 tEnv.addObjRelation("STYLENAME2", "Text");
111 return tEnv;
112 } // finish method getTestEnvironment
114 } // finish class SwXTextTableCursor