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
.text
.XTextTableCursor
;
27 * Testing <code>com.sun.star.text.XTextTableCursor</code>
30 * <li><code> getRangeName()</code></li>
31 * <li><code> gotoCellByName()</code></li>
32 * <li><code> goLeft()</code></li>
33 * <li><code> goRight()</code></li>
34 * <li><code> goUp()</code></li>
35 * <li><code> goDown()</code></li>
36 * <li><code> gotoStart()</code></li>
37 * <li><code> gotoEnd()</code></li>
38 * <li><code> mergeRange()</code></li>
39 * <li><code> splitRange()</code></li>
42 * <b>Prerequisites : </b> the table must have a size
43 * 2x2 and current cursor position must be in the upper
46 * Test is <b> NOT </b> multithread compliant. <p>
48 * After test completion object environment has to be recreated
49 * because after merging and splitting cells their names
50 * differ from initial.
52 * @see com.sun.star.text.XTextTableCursor
54 public class _XTextTableCursor
extends MultiMethodTest
{
56 public XTextTableCursor oObj
= null; // oObj filled by MultiMethodTest
59 * Moves the cursor to upper-left cell and checks
62 * Has <b>OK</b> status if the name returned is 'A1'.
64 public void _getRangeName(){
65 log
.println( "test for getRangeName()" );
66 oObj
.gotoStart(false);
67 String oCellName
= oObj
.getRangeName();
68 log
.println( "CellName = " + oCellName
);
70 tRes
.tested("getRangeName()", oCellName
.equals("A1") );
74 * Calls the method which moves the cursor down by 1 cell,
75 * after that returns cursor to the old position. <p>
77 * Has <b>OK</b> status if the method returns
80 public void _goDown(){
81 boolean bDown
= false;
82 log
.println( "test for goDown()" );
85 bDown
= oObj
.goDown(i
,false);
87 tRes
.tested("goDown()", bDown
);
92 * Calls the method which moves the cursor to the right by 1 cell,
93 * after that returns cursor to the old position. <p>
95 * Has <b>OK</b> status if the method returns
98 public void _goRight(){
99 boolean bRight
= false;
100 log
.println( "test for goRight()" );
103 bRight
= oObj
.goRight(i
,false);
105 tRes
.tested("goRight()", bRight
);
106 oObj
.goLeft(i
,false);
110 * Calls the method which moves the cursor to the left by 1 cell,
111 * after that returns cursor to the old position. <p>
113 * Has <b>OK</b> status if the method returns
116 public void _goLeft(){
117 boolean bLeft
= false;
118 log
.println( "test for goLeft()" );
121 oObj
.goRight(i
,false);
122 bLeft
= oObj
.goLeft(i
,false);
124 tRes
.tested("goLeft()", bLeft
);
128 * Calls the method which moves the cursor up by 1 cell,
129 * after that returns cursor to the old position. <p>
131 * Has <b>OK</b> status if the method returns
136 log
.println( "test for goUp()" );
141 bUp
= oObj
.goUp(i
,false);
142 tRes
.tested("goUp()", bUp
);
146 * Moves the cursor to the cell with name 'B1', then
147 * checks the current range name. <p>
148 * Has <b>OK</b> status if the returned range name is
151 public void _gotoCellByName(){
152 log
.println( "test for gotoCellByName()" );
154 oObj
.gotoCellByName("B1",false);
155 String oCellName
= oObj
.getRangeName();
157 tRes
.tested("gotoCellByName()", oCellName
.equals("B1") );
161 * Moves cursor to the start (upper-left cell). Then
162 * checks the current range name. <p>
164 * Has <b>OK</b> status if current range name is 'A1'.
166 public void _gotoStart(){
167 log
.println( "test for gotoStart()" );
169 oObj
.gotoStart(false);
170 String oCellName
= oObj
.getRangeName();
172 tRes
.tested("gotoStart()", oCellName
.equals("A1") );
176 * Moves cursor to the end (lower-right cell). Then
177 * checks the current range name. <p>
179 * Has <b>OK</b> status if current range name is 'B2'
180 * (the table is assumed to be of size 2x2).
182 public void _gotoEnd(){
183 log
.println( "test for gotoEnd()" );
186 String oCellName
= oObj
.getRangeName();
188 tRes
.tested("gotoEnd()", oCellName
.equals("B2") );
192 * Selects all cells in the table and merges them.
193 * Finally move the cursor to the end and checks
194 * current range name.<p>
196 * Has <b>OK</b> status if the end cell has a name
199 * The following method tests are to be executed before :
201 * <li> <code> getRangeName(), gotoStart(), gotoEnd()
202 * goLeft(), goRight(), goUp(), goDown(), gotoCellByName()</code>
203 * : these methods must be completed before all cells of the
204 * table are merged into one cell </li>
207 public void _mergeRange(){
208 executeMethod("getRangeName()") ;
209 executeMethod("gotoStart()") ;
210 executeMethod("gotoEnd()") ;
211 executeMethod("goLeft()") ;
212 executeMethod("goRight()") ;
213 executeMethod("goUp()") ;
214 executeMethod("goDown()") ;
215 executeMethod("gotoCellByName()") ;
217 boolean bMerge
= false;
218 log
.println( "test for mergeRange()" );
220 oObj
.gotoStart(false);
222 bMerge
= oObj
.mergeRange();
226 String curName
= oObj
.getRangeName() ;
227 bMerge
&= "A1".equals(curName
) ;
229 tRes
.tested("mergeRange()", bMerge
);
233 * First splits the cell horizontally. Then the end cell
234 * name is checked. Second split all cells vertically and
235 * again the end cell name is checked<p>
237 * Has <b> OK </b> status if in the first case the end cell name
238 * is not 'A1', and in the second case the end cell name is not
239 * equal to the name gotten in the first case. <p>
241 * The following method tests are to be completed successfully before :
243 * <li> <code> mergeRange() </code> : to have one cell in a table
244 * which this test splits. </li>
247 public void _splitRange(){
248 requiredMethod("mergeRange()") ;
250 boolean bSplit
= true ;
251 log
.println( "test for splitRange" ) ;
254 bSplit
&= oObj
.splitRange(i
, true) ;
257 String horName
= oObj
.getRangeName() ;
258 log
.println("The end cell after horiz. split : " + horName
) ;
259 bSplit
&= !"A1".equals(horName
) ;
261 oObj
.gotoStart(false);
263 bSplit
&= oObj
.splitRange(i
, false) ;
266 String vertName
= oObj
.getRangeName() ;
267 log
.println("The end cell after vert. split : " + vertName
) ;
268 bSplit
&= !horName
.equals(vertName
) ;
270 tRes
.tested("splitRange()", bSplit
) ;
274 * Forces object environment recreation.
277 public void after() {
278 disposeEnvironment() ;
281 } // finish class _XTextTableCursor