xref: /AOO41X/main/qadevOOo/tests/java/mod/_sw/SwXTextTableCursor.java (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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.XTextTable;
41 import com.sun.star.uno.XInterface;
42 
43 /**
44  *
45  * initial description
46  * @see com.sun.star.beans.XPropertySet
47  * @see com.sun.star.text.XTextTableCursor
48  *
49  */
50 public class SwXTextTableCursor extends TestCase {
51     XTextDocument xTextDoc;
52 
53     protected void initialize( TestParameters tParam, PrintWriter log ) {
54         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
55 
56         try {
57             log.println( "creating a textdocument" );
58             xTextDoc = SOF.createTextDoc( null );
59         } catch ( com.sun.star.uno.Exception e ) {
60             // Some exception occures.FAILED
61             e.printStackTrace( log );
62             throw new StatusException( "Couldn't create document", e );
63         }
64     }
65 
66     protected void cleanup( TestParameters tParam, PrintWriter log ) {
67         log.println( "    disposing xTextDoc " );
68         util.DesktopTools.closeDoc(xTextDoc);
69     }
70 
71 
72     /**
73      *    creating a Testenvironment for the interfaces to be tested
74      *
75      *  @param tParam    class which contains additional test parameters
76      *  @param log        class to log the test state and result
77      *
78      *  @return    Status class
79      *
80      *  @see TestParameters
81      *    @see PrintWriter
82      */
83     public synchronized TestEnvironment createTestEnvironment( TestParameters tParam,
84                                                   PrintWriter log )
85                                                     throws StatusException {
86 
87         XInterface oObj = null;
88 
89         // creation of testobject here
90         // first we write what we are intend to do to log file
91         log.println( "creating a test environment" );
92 
93         // get a soffice factory object
94         SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
95 
96         // create testobject here
97 
98         XTextTable oTable = null;
99         try {
100             oTable = SOF.createTextTable( xTextDoc );
101             SOF.insertTextContent(xTextDoc, oTable );
102         }
103         catch( com.sun.star.uno.Exception uE ) {
104             uE.printStackTrace( log );
105             throw new StatusException("Couldn't create TextTable : "
106                     + uE.getMessage(), uE);
107         }
108 
109         oObj = oTable.createCursorByCellName("A1");
110 
111         log.println( "creating a new environment for TextTableCursor object" );
112         TestEnvironment tEnv = new TestEnvironment( oObj );
113 
114         log.println( "adding TextDocument as mod relation to environment" );
115         tEnv.addObjRelation("TEXTDOC", xTextDoc);
116 
117         tEnv.addObjRelation("STYLENAME1", "Table");
118         tEnv.addObjRelation("STYLENAME2", "Text");
119 
120         return tEnv;
121     } // finish method getTestEnvironment
122 
123 }    // finish class SwXTextTableCursor
124 
125