Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / table / _XCellCursor.java
blob9f3aea9b43540fc4bd59fbaf8ca56d514670e2a1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc.table;
30 import lib.MultiMethodTest;
32 import com.sun.star.sheet.XCellRangeAddressable;
33 import com.sun.star.sheet.XSheetCellCursor;
34 import com.sun.star.sheet.XSheetCellRange;
35 import com.sun.star.sheet.XSpreadsheet;
36 import com.sun.star.table.CellRangeAddress;
37 import com.sun.star.table.XCellCursor;
38 import com.sun.star.table.XCellRange;
39 import com.sun.star.uno.UnoRuntime;
41 /**
42 * Testing <code>com.sun.star.table.XCellCursor</code>
43 * interface methods :
44 * <ul>
45 * <li><code> gotoStart()</code></li>
46 * <li><code> gotoEnd()</code></li>
47 * <li><code> gotoNext()</code></li>
48 * <li><code> gotoPrevious()</code></li>
49 * <li><code> gotoOffset()</code></li>
50 * </ul> <p>
51 * This test needs the following object relations :
52 * <ul>
53 * <li> <code>'SHEET'</code> (of type <code>XSpreadsheet</code>):
54 * is used for creating a new cell range.</li>
55 * <ul> <p>
57 * The component tested <b>must implement</b>
58 * <code>XCellRangeAddressable</code> interface. <p>
60 * Test is <b> NOT </b> multithread compilant. <p>
61 * After test completion object environment has to be recreated.
62 * @see com.sun.star.table.XCellCursor
64 public class _XCellCursor extends MultiMethodTest {
66 public static XCellCursor oObj = null;
67 public static XSpreadsheet oSheet = null;
69 /**
70 * <code>XCellRangeAddressable</code> interface is queried
71 * first for getting current position of cursor. The cursor
72 * is moved to next cell. Address of cursor obtained before
73 * and after moving. <p>
74 * Has <b> OK </b> status if cursor column is changed after
75 * movement. <p>
77 public void _gotoNext(){
78 boolean bResult = false;
79 int startCol, endCol, startRow, endRow = 0;
80 int startCol2, endCol2, startRow2, endRow2 = 0;
82 XCellRangeAddressable oRange = (XCellRangeAddressable)
83 UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj);
84 CellRangeAddress oAddr = oRange.getRangeAddress();
85 startRow = oAddr.StartRow;
86 startCol = oAddr.StartColumn;
87 endRow = oAddr.EndRow;
88 endCol = oAddr.EndColumn;
90 oObj.gotoNext();
92 oAddr = oRange.getRangeAddress();
93 startRow2 = oAddr.StartRow;
94 startCol2 = oAddr.StartColumn;
95 endRow2 = oAddr.EndRow;
96 endCol2 = oAddr.EndColumn;
98 if (!(startCol == startCol2)){
99 bResult = true;
101 tRes.tested( "gotoNext()", bResult );
105 * <code>XCellRangeAddressable</code> interface is queried
106 * first for getting current position of cursor. The cursor
107 * is moved then. Address of cursor obtained before
108 * and after moving. <p>
109 * Has <b> OK </b> status if starting column and row of
110 * cursor is changed after movement. <p>
112 public void _gotoOffset(){
113 boolean bResult = false;
114 int startCol, endCol, startRow, endRow = 0;
115 int startCol2, endCol2, startRow2, endRow2 = 0;
117 XCellRangeAddressable oRange = (XCellRangeAddressable)
118 UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj);
119 CellRangeAddress oAddr = oRange.getRangeAddress();
120 startRow = oAddr.StartRow;
121 startCol = oAddr.StartColumn;
122 endRow = oAddr.EndRow;
123 endCol = oAddr.EndColumn;
125 oObj.gotoOffset(4,4);
127 oAddr = oRange.getRangeAddress();
128 startRow2 = oAddr.StartRow;
129 startCol2 = oAddr.StartColumn;
130 endRow2 = oAddr.EndRow;
131 endCol2 = oAddr.EndColumn;
132 if (!(startCol == startCol2) || (startRow == startRow2)){
133 bResult = true;
135 tRes.tested( "gotoOffset()", bResult );
139 * <code>XCellRangeAddressable</code> interface is queried
140 * first for getting current position of cursor. The cursor
141 * is moved to previous cell. Address of cursor obtained before
142 * and after moving. <p>
143 * Has <b> OK </b> status if cursor column is changed after
144 * movement. <p>
146 public void _gotoPrevious(){
147 boolean bResult = false;
148 int startCol, endCol, startRow, endRow = 0;
149 int startCol2, endCol2, startRow2, endRow2 = 0;
151 XCellRangeAddressable oRange = (XCellRangeAddressable)
152 UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj);
153 CellRangeAddress oAddr = oRange.getRangeAddress();
154 startRow = oAddr.StartRow;
155 startCol = oAddr.StartColumn;
156 endRow = oAddr.EndRow;
157 endCol = oAddr.EndColumn;
159 oObj.gotoPrevious();
161 oAddr = oRange.getRangeAddress();
162 startRow2 = oAddr.StartRow;
163 startCol2 = oAddr.StartColumn;
164 endRow2 = oAddr.EndRow;
165 endCol2 = oAddr.EndColumn;
167 if (!(startCol == startCol2)){
168 bResult = true;
170 tRes.tested( "gotoPrevious()", bResult );
174 * <code>XCellRangeAddressable</code> interface is queried
175 * first for getting current position of cursor. The cursor
176 * is moved to the start of its range .
177 * Address of cursor obtained before and after moving. <p>
178 * Has <b> OK </b> status if cursor was collapsed to a single
179 * cell (i.e. start column is the same as end column) after
180 * movement. <p>
182 public void _gotoStart(){
183 boolean bResult = false;
184 int startCol, endCol, startRow, endRow = 0;
186 XCellRangeAddressable oRange = (XCellRangeAddressable)
187 UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj);
188 oObj.gotoStart();
189 CellRangeAddress oAddr = oRange.getRangeAddress();
190 startRow = oAddr.StartRow;
191 startCol = oAddr.StartColumn;
192 endRow = oAddr.EndRow;
193 endCol = oAddr.EndColumn;
194 if ((startCol == endCol) && (endRow == startRow)){
195 bResult = true;
198 tRes.tested( "gotoStart()", bResult );
202 * A new cell range is created using spreadsheet passed by relation.
203 * The method is tested on that range. <code>gotoEnd</code> is
204 * called and range address is checked.<p>
205 * Has <b> OK </b> status if cursor was collapsed to a single
206 * cell (i.e. start column is the same as end column) after
207 * movement. <p>
209 public void _gotoEnd(){
210 //gotoEnd gets it's own cursor to see a change
211 oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET");
212 XCellRange testRange = oSheet.getCellRangeByName("$A$1:$g$7") ;
213 XSheetCellRange testSheetRange = (XSheetCellRange)
214 UnoRuntime.queryInterface(XSheetCellRange.class,testRange);
215 XSheetCellCursor oCellCursor = oSheet.createCursorByRange
216 (testSheetRange);
217 XCellCursor oCursor = (XCellCursor)
218 UnoRuntime.queryInterface(XCellCursor.class,oCellCursor);
220 boolean bResult = false;
221 int startCol, endCol, startRow, endRow = 0;
223 XCellRangeAddressable oRange = (XCellRangeAddressable)
224 UnoRuntime.queryInterface(XCellRangeAddressable.class, oCursor);
225 oCursor.gotoEnd();
226 CellRangeAddress oAddr = oRange.getRangeAddress();
227 startRow = oAddr.StartRow;
228 startCol = oAddr.StartColumn;
229 endRow = oAddr.EndRow;
230 endCol = oAddr.EndColumn;
231 if ((startCol == endCol) && (endRow == startRow)){
232 bResult = true;
235 tRes.tested( "gotoEnd()", bResult );
239 * Forces object environment recreation.
241 protected void after() {
242 disposeEnvironment();
246 } //EOC _XCellCursor