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 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.SOfficeFactory
;
29 import com
.sun
.star
.beans
.XPropertySet
;
30 import com
.sun
.star
.container
.XIndexAccess
;
31 import com
.sun
.star
.lang
.XMultiServiceFactory
;
32 import com
.sun
.star
.table
.XTableRows
;
33 import com
.sun
.star
.text
.XText
;
34 import com
.sun
.star
.text
.XTextCursor
;
35 import com
.sun
.star
.text
.XTextDocument
;
36 import com
.sun
.star
.text
.XTextTable
;
37 import com
.sun
.star
.uno
.AnyConverter
;
38 import com
.sun
.star
.uno
.Type
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
40 import com
.sun
.star
.uno
.XInterface
;
43 public class SwXTextTableRow
extends TestCase
{
44 XTextDocument xTextDoc
;
46 protected void initialize( TestParameters tParam
, PrintWriter log
) {
47 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
50 log
.println( "creating a textdocument" );
51 xTextDoc
= SOF
.createTextDoc( null );
52 } catch ( com
.sun
.star
.uno
.Exception e
) {
53 // Some exception occurs.FAILED
54 e
.printStackTrace( log
);
55 throw new StatusException( "Couldn't create document", e
);
59 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
60 log
.println( " disposing xTextDoc " );
61 util
.DesktopTools
.closeDoc(xTextDoc
);
64 protected synchronized TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
66 XInterface oObj
= null;
67 XTextTable oTable
= null;
71 // creation of testobject here
72 // first we write what we are intend to do to log file
73 log
.println( "Creating a test environment" );
75 // get a soffice factory object
76 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF() );
79 log
.println("creating a texttable");
80 oTable
= SOfficeFactory
.createTextTable(xTextDoc
,5,5);
81 } catch( Exception e
) {
82 e
.printStackTrace(log
);
85 XText oText
= xTextDoc
.getText();
87 XTextCursor oCursor
= oText
.createTextCursor();
90 log
.println("inserting texttable");
91 oText
.insertTextContent(oCursor
, oTable
, false);
92 } catch (Exception e
) {
93 log
.println("Exception!");
97 log
.println("getting table row");
98 XTableRows oTRn
= oTable
.getRows();
99 XIndexAccess oIA
= UnoRuntime
.queryInterface
100 (XIndexAccess
.class,oTRn
);
101 oObj
= (XPropertySet
) AnyConverter
.toObject(
102 new Type(XPropertySet
.class),oIA
.getByIndex(1));
103 } catch( Exception e
) {
104 e
.printStackTrace(log
);
107 log
.println( "creating a new environment for TextTableRow object" );
108 TestEnvironment tEnv
= new TestEnvironment( oObj
);
110 log
.println( "adding TextDocument as mod relation to environment" );
111 tEnv
.addObjRelation("TEXTDOC", xTextDoc
);
115 } // finish method getTestEnvironment
117 } // finish class SwXTextTableRow