tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXTextTableRow.java
bloba8f4144f2047a8edcb242ea5874958a3b84918e5
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.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.SOfficeFactory;
28 import com.sun.star.beans.XPropertySet;
29 import com.sun.star.container.XIndexAccess;
30 import com.sun.star.table.XTableRows;
31 import com.sun.star.text.XText;
32 import com.sun.star.text.XTextCursor;
33 import com.sun.star.text.XTextDocument;
34 import com.sun.star.text.XTextTable;
35 import com.sun.star.uno.AnyConverter;
36 import com.sun.star.uno.Type;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
41 public class SwXTextTableRow extends TestCase {
42 XTextDocument xTextDoc;
44 @Override
45 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
46 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
48 log.println( "creating a textdocument" );
49 xTextDoc = SOF.createTextDoc( null );
52 @Override
53 protected void cleanup( TestParameters tParam, PrintWriter log ) {
54 log.println( " disposing xTextDoc " );
55 util.DesktopTools.closeDoc(xTextDoc);
58 @Override
59 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
61 XInterface oObj = null;
62 XTextTable oTable = null;
66 // creation of testobject here
67 // first we write what we are intend to do to log file
68 log.println( "Creating a test environment" );
70 // get a soffice factory object
71 SOfficeFactory.getFactory( Param.getMSF() );
73 try {
74 log.println("creating a texttable");
75 oTable = SOfficeFactory.createTextTable(xTextDoc,5,5);
76 } catch( Exception e ) {
77 e.printStackTrace(log);
80 XText oText = xTextDoc.getText();
82 XTextCursor oCursor = oText.createTextCursor();
84 try {
85 log.println("inserting texttable");
86 oText.insertTextContent(oCursor, oTable, false);
87 } catch (Exception e) {
88 log.println("Exception!");
91 try {
92 log.println("getting table row");
93 XTableRows oTRn = oTable.getRows();
94 XIndexAccess oIA = UnoRuntime.queryInterface
95 (XIndexAccess.class,oTRn);
96 oObj = (XPropertySet) AnyConverter.toObject(
97 new Type(XPropertySet.class),oIA.getByIndex(1));
98 } catch( Exception e ) {
99 e.printStackTrace(log);
102 log.println( "creating a new environment for TextTableRow object" );
103 TestEnvironment tEnv = new TestEnvironment( oObj );
105 log.println( "adding TextDocument as mod relation to environment" );
106 tEnv.addObjRelation("TEXTDOC", xTextDoc);
109 return tEnv;
110 } // finish method getTestEnvironment
112 } // finish class SwXTextTableRow