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 lib
.MultiMethodTest
;
23 import com
.sun
.star
.table
.XCell
;
24 import com
.sun
.star
.table
.XCellRange
;
27 * Testing <code>com.sun.star.table.XCellRange</code>
30 * <li><code> getCellByPosition()</code></li>
31 * <li><code> getCellRangeByPosition()</code></li>
32 * <li><code> getCellRangeByName()</code></li>
34 * This test needs the following object relations :
36 * <li> <code>'ValidRange'</code> (of type <code>String</code>):
37 * cell range that can be defined by the object test instead of
38 * definition at this test ("<code>A1:A1</code>")</li>
40 * Test is <b> NOT </b> multithread compliant. <p>
41 * @see com.sun.star.table.XCellRange
43 public class _XCellRange
extends MultiMethodTest
{
44 public XCellRange oObj
= null;
47 * First a cell get from valid position, second - from invalid. <p>
48 * Has <b> OK </b> status if in the first case not null value is
49 * returned and no exceptions are thrown, and in the second
50 * case <code>IndexOutOfBoundsException</code> is thrown. <p>
52 public void _getCellByPosition() {
54 boolean result
= false;
57 XCell cell
= oObj
.getCellByPosition(0,0);
58 result
= cell
!= null ;
59 log
.println("Getting cell by position with a valid position ... OK");
60 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
61 log
.println("Exception occurred while getting cell by position with a valid position");
62 e
.printStackTrace(log
);
67 oObj
.getCellByPosition(-1,1);
68 log
.println("No Exception occurred while getting cell by position with invalid position");
70 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
71 log
.println("Getting cell by position with an invalid position ... OK");
75 tRes
.tested( "getCellByPosition()", result
);
77 } // end getCellByPosition()
80 * A range is tried to obtain with valid name. <p>
81 * Has <b> OK </b> status if not null range is
84 public void _getCellRangeByName() {
86 boolean result
= false;
88 String valid
= (String
) tEnv
.getObjRelation("ValidRange");
89 if (valid
== null ) valid
= "A1:A1";
90 XCellRange range
= oObj
.getCellRangeByName(valid
);
91 result
= range
!= null ;
92 log
.println("Getting cellrange by name with a valid name ... OK");
94 tRes
.tested( "getCellRangeByName()", result
);
97 } // end getCellRangeByName()
100 * First a range is tried to obtain with valid bounds,
101 * second - with invalid. <p>
102 * Has <b> OK </b> status if in the first case not null range is
103 * returned and no exceptions are thrown, and in the second
104 * case <code>IndexOutOfBoundsException</code> is thrown. <p>
106 public void _getCellRangeByPosition() {
108 boolean result
= false;
111 XCellRange range
= oObj
.getCellRangeByPosition(0,0,0,0);
112 result
= range
!= null;
113 log
.println("Getting cellrange by Position with a valid position ... OK");
114 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
115 log
.println("Exception occurred while getting cellrange by position with a valid position");
116 e
.printStackTrace(log
);
121 oObj
.getCellRangeByPosition(-1,0,-1,1);
122 log
.println("No Exception occurred while getting cellrange by position with invalid position");
124 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
125 log
.println("Getting cellrange by position with an invalid position ... OK");
129 tRes
.tested( "getCellRangeByPosition()", result
);
132 } // end getCellRangeByPosition()
135 * Forces environment recreation.
138 protected void after() {
139 disposeEnvironment();
142 } // finish class _XCellRange