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
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.SOfficeFactory
;
28 import com
.sun
.star
.lang
.XMultiServiceFactory
;
29 import com
.sun
.star
.table
.XCellRange
;
30 import com
.sun
.star
.text
.XTextDocument
;
31 import com
.sun
.star
.text
.XTextTable
;
32 import com
.sun
.star
.uno
.UnoRuntime
;
33 import com
.sun
.star
.uno
.XInterface
;
36 * Test for object which is represented by service
37 * <code>com.sun.star.table.CellRange</code>. <p>
38 * Object implements the following interfaces :
40 * <li> <code>com::sun::star::text::CellProperties</code></li>
41 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
43 * This object test <b> is NOT </b> designed to be run in several
44 * threads concurrently.
45 * @see com.sun.star.table.CellRange
46 * @see com.sun.star.text.CellProperties
47 * @see com.sun.star.beans.XPropertySet
48 * @see ifc.text._CellProperties
49 * @see ifc.beans._XPropertySet
51 public class SwXCellRange
extends TestCase
{
53 XTextDocument xTextDoc
;
56 * Creates text document.
59 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
60 SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
61 log
.println( "creating a textdocument" );
62 xTextDoc
= SOF
.createTextDoc( null );
66 * Disposes text document.
69 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
70 log
.println( " disposing xTextDoc " );
71 util
.DesktopTools
.closeDoc(xTextDoc
);
75 * Creating a TestEnvironment for the interfaces to be tested. At first
76 * method creates and initializes the table, then if text document has no
77 * tables, previously created table is inserted to text document. Finally,
78 * custom cell range is gotten from the table created.
79 * Object relations created :
81 * <li> <code>'CellProperties.TextSection'</code> for
82 * {@link ifc.text._CellProperties} : range of complete paragraphs
87 protected TestEnvironment createTestEnvironment
88 (TestParameters tParam
, PrintWriter log
) throws Exception
{
90 XTextTable the_table
= null;
91 XInterface oObj
= null;
92 the_table
= SOfficeFactory
.createTextTable( xTextDoc
);
93 the_table
.initialize(5, 5);
95 if( SOfficeFactory
.getTableCollection( xTextDoc
).getCount() == 0 ) {
96 SOfficeFactory
.insertTextContent(xTextDoc
, the_table
);
98 XCellRange the_Range
= UnoRuntime
.queryInterface(XCellRange
.class, the_table
);
99 oObj
= the_Range
.getCellRangeByPosition(0, 0, 3, 4);
101 log
.println("Creating instance...");
102 TestEnvironment tEnv
= new TestEnvironment( oObj
);
103 log
.println("ImplName: " + util
.utils
.getImplName(oObj
));
105 XMultiServiceFactory oDocMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xTextDoc
);
107 XInterface oTS
= (XInterface
)
108 oDocMSF
.createInstance("com.sun.star.text.TextSection");
109 log
.println(" adding TextSection object");
110 tEnv
.addObjRelation("CellProperties.TextSection", oTS
);
111 } catch (com
.sun
.star
.uno
.Exception e
) {
112 log
.println("Could not get instance of TextSection");
113 e
.printStackTrace(log
);
116 Object
[][] NewData
= new Object
[5][];
117 NewData
[0] = new Double
[]
118 {Double
.valueOf(2.5),Double
.valueOf(5),Double
.valueOf(2.5),Double
.valueOf(5)};
119 NewData
[1] = new Double
[]
120 {Double
.valueOf(4),Double
.valueOf(9),Double
.valueOf(2.5),Double
.valueOf(5)};
121 NewData
[2] = new Double
[]
122 {Double
.valueOf(2.5),Double
.valueOf(5),Double
.valueOf(2.5),Double
.valueOf(5)};
123 NewData
[3] = new Double
[]
124 {Double
.valueOf(2.5),Double
.valueOf(5),Double
.valueOf(2.5),Double
.valueOf(5)};
125 NewData
[4] = new Double
[]
126 {Double
.valueOf(4),Double
.valueOf(9),Double
.valueOf(2.5),Double
.valueOf(5)};
127 tEnv
.addObjRelation("NewData",NewData
);
129 // com::sun::star::chart::XChartDataArray
130 tEnv
.addObjRelation("CRDESC",
131 "Column and RowDescriptions can't be changed for this Object");
136 } // finish class SwXCellRange