tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXTableCellText.java
blob336aba189eead6b4fede65d7e598512e48ca9ce0
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.InstCreator;
28 import util.ParagraphDsc;
29 import util.SOfficeFactory;
30 import util.TextSectionDsc;
32 import com.sun.star.table.XCell;
33 import com.sun.star.text.XSimpleText;
34 import com.sun.star.text.XTextDocument;
35 import com.sun.star.text.XTextTable;
36 import com.sun.star.uno.UnoRuntime;
37 import com.sun.star.uno.XInterface;
39 /**
40 * Test for object which is represented by cell text of the text table.<p>
41 * Object implements the following interfaces :
42 * <ul>
43 * <li> <code>com::sun::star::text::XTextRangeMover</code></li>
44 * <li> <code>com::sun::star::text::XSimpleText</code></li>
45 * <li> <code>com::sun::star::text::XTextRange</code></li>
46 * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li>
47 * <li> <code>com::sun::star::text::XTextRangeCompare</code></li>
48 * <li> <code>com::sun::star::container::XElementAccess</code></li>
49 * <li> <code>com::sun::star::container::XEnumerationAccess</code></li>
50 * <li> <code>com::sun::star::text::XText</code></li>
51 * </ul> <p>
52 * This object test <b> is NOT </b> designed to be run in several
53 * threads concurrently.
54 * @see com.sun.star.text.XTextRangeMover
55 * @see com.sun.star.text.XSimpleText
56 * @see com.sun.star.text.XTextRange
57 * @see com.sun.star.text.XRelativeTextContentInsert
58 * @see com.sun.star.text.XTextRangeCompare
59 * @see com.sun.star.container.XElementAccess
60 * @see com.sun.star.container.XEnumerationAccess
61 * @see com.sun.star.text.XText
62 * @see ifc.text._XTextRangeMover
63 * @see ifc.text._XSimpleText
64 * @see ifc.text._XTextRange
65 * @see ifc.text._XRelativeTextContentInsert
66 * @see ifc.text._XTextRangeCompare
67 * @see ifc.container._XElementAccess
68 * @see ifc.container._XEnumerationAccess
69 * @see ifc.text._XText
71 public class SwXTableCellText extends TestCase {
72 XTextDocument xTextDoc;
73 SOfficeFactory SOF;
75 /**
76 * Creates text document.
78 @Override
79 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
80 SOF = SOfficeFactory.getFactory( tParam.getMSF() );
81 log.println( "creating a textdocument" );
82 xTextDoc = SOF.createTextDoc( null );
85 /**
86 * Disposes text document.
88 @Override
89 protected void cleanup( TestParameters tParam, PrintWriter log ) {
90 log.println( " disposing xTextDoc " );
91 util.DesktopTools.closeDoc(xTextDoc);
94 /**
95 * Creating a TestEnvironment for the interfaces to be tested. After creation
96 * of text table, it is inserted to a text document. Then cell named 'A1' is
97 * obtained from table, string 'SwXTableCellText' is set to this cell, then
98 * cell text is gotten from cell obtained before and returned as a test
99 * component.
100 * Object relations created :
101 * <ul>
102 * <li> <code>'TEXT'</code> for
103 * {@link ifc.text._XTextRangeCompare} : table cell text</li>
104 * <li> <code>'PARA'</code> for
105 * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li>
106 * <li> <code>'XTEXTINFO'</code> for
107 * {@link ifc.text._XRelativeTextContentInsert},
108 * {@link ifc.text._XText} : creates text sections</li>
109 * </ul>
111 @Override
112 public TestEnvironment createTestEnvironment(
113 TestParameters Param, PrintWriter log ) throws StatusException {
114 XInterface oObj = null;
115 XTextTable oTable = null;
117 log.println( "Creating a test environment" );
118 oTable = SOfficeFactory.createTextTable( xTextDoc );
120 SOfficeFactory.insertTextContent(xTextDoc, oTable );
122 XCell oCell = oTable.getCellByName("A1");
123 XSimpleText oCellText = UnoRuntime.queryInterface(XSimpleText.class, oCell);
124 oCellText.setString("SwXTableCellText");
125 oObj = oCellText.getText();
127 log.println( "creating a new environment for Cell object" );
128 TestEnvironment tEnv = new TestEnvironment( oObj );
130 log.println( "adding TextDocument as mod relation to environment" );
131 tEnv.addObjRelation("TEXT", oObj);
133 log.println( " adding InstCreator object" );
134 TextSectionDsc tDsc = new TextSectionDsc();
135 tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) );
137 log.println( " adding Paragraph" );
138 ParagraphDsc pDsc = new ParagraphDsc();
139 tEnv.addObjRelation( "PARA", new InstCreator( xTextDoc, pDsc ) );
141 return tEnv;
142 } // finish method getTestEnvironment
145 } // finish class SwXTableCellText