merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / table / _XCellRange.java
blobad70f96e888401542c92fee85f39a68c8dfb78a0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XCellRange.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.table;
33 import lib.MultiMethodTest;
35 import com.sun.star.table.XCell;
36 import com.sun.star.table.XCellRange;
38 /**
39 * Testing <code>com.sun.star.table.XCellRange</code>
40 * interface methods :
41 * <ul>
42 * <li><code> getCellByPosition()</code></li>
43 * <li><code> getCellRangeByPosition()</code></li>
44 * <li><code> getCellRangeByName()</code></li>
45 * </ul> <p>
46 * This test needs the following object relations :
47 * <ul>
48 * <li> <code>'ValidRange'</code> (of type <code>String</code>):
49 * cell range that can be defined by the object test instead of
50 * definition at this test ("<code>A1:A1</code>")</li>
51 * </ul> <p>
52 * Test is <b> NOT </b> multithread compilant. <p>
53 * @see com.sun.star.table.XCellRange
55 public class _XCellRange extends MultiMethodTest {
56 public XCellRange oObj = null;
58 /**
59 * First a cell get from valid position, second - from invalid. <p>
60 * Has <b> OK </b> status if in the first case not null value is
61 * returned and no exceptions are thrown, and in the second
62 * case <code>IndexOutOfBoundsException</code> is thrown. <p>
64 public void _getCellByPosition() {
66 boolean result = false;
68 try {
69 XCell cell = oObj.getCellByPosition(0,0);
70 result = cell != null ;
71 log.println("Getting cell by position with a valid position ... OK");
72 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
73 log.println("Exception occurred while getting cell by position with a valid position");
74 e.printStackTrace(log);
75 result = false;
78 try {
79 oObj.getCellByPosition(-1,1);
80 log.println("No Exception occurred while getting cell by position with invalid position");
81 result &= false;
82 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
83 log.println("Getting cell by position with a invalid position ... OK");
84 result &= true;
87 tRes.tested( "getCellByPosition()", result );
89 } // end getCellByPosition()
91 /**
92 * A range is tried to obtain with valid name. <p>
93 * Has <b> OK </b> status if not null range is
94 * returned. <p>
96 public void _getCellRangeByName() {
98 boolean result = false;
100 String valid = (String) tEnv.getObjRelation("ValidRange");
101 if (valid == null ) valid = "A1:A1";
102 XCellRange range = oObj.getCellRangeByName(valid);
103 result = range != null ;
104 log.println("Getting cellrange by name with a valid name ... OK");
106 tRes.tested( "getCellRangeByName()", result );
109 } // end getCellRangeByName()
112 * First a range is tried to obtain with valid bounds,
113 * second - with invalid. <p>
114 * Has <b> OK </b> status if in the first case not null range is
115 * returned and no exceptions are thrown, and in the second
116 * case <code>IndexOutOfBoundsException</code> is thrown. <p>
118 public void _getCellRangeByPosition() {
120 boolean result = false;
122 try {
123 XCellRange range = oObj.getCellRangeByPosition(0,0,0,0);
124 result = range != null;
125 log.println("Getting cellrange by Position with a valid position ... OK");
126 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
127 log.println("Exception occurred while getting cellrange by position with a valid position");
128 e.printStackTrace(log);
129 result = false;
132 try {
133 oObj.getCellRangeByPosition(-1,0,-1,1);
134 log.println("No Exception occurred while getting cellrange by position with invalid position");
135 result &= false;
136 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
137 log.println("Getting cellrange by position with a invalid position ... OK");
138 result &= true;
141 tRes.tested( "getCellRangeByPosition()", result );
144 } // end getCellRangeByPosition()
147 * Forces environment recreation.
149 protected void after() {
150 disposeEnvironment();
153 } // finish class _XCellRange