1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
package ifc.text;
import lib.MultiMethodTest;
import com.sun.star.table.XCell;
import com.sun.star.text.XTextTableCursor;
/**
* Testing <code>com.sun.star.text.XTextTableCursor</code>
* interface methods :
* <ul>
* <li><code> getRangeName()</code></li>
* <li><code> gotoCellByName()</code></li>
* <li><code> goLeft()</code></li>
* <li><code> goRight()</code></li>
* <li><code> goUp()</code></li>
* <li><code> goDown()</code></li>
* <li><code> gotoStart()</code></li>
* <li><code> gotoEnd()</code></li>
* <li><code> mergeRange()</code></li>
* <li><code> splitRange()</code></li>
* </ul> <p>
*
* <b>Prerequisites : </b> the table must have a size
* 2x2 and current cursor position must be in the upper
* left cell. <p>
*
* Test is <b> NOT </b> multithread compilant. <p>
*
* After test completion object environment has to be recreated
* because after merging and splitting cells their names
* differ from initial.
*
* @see com.sun.star.text.XTextTableCursor
*/
public class _XTextTableCursor extends MultiMethodTest {
public XTextTableCursor oObj = null; // oObj filled by MultiMethodTest
XCell oCell = null;
/**
* Moves the cursor to upper-left cell and checks
* its range name. <p>
*
* Has <b>OK</b> status if the name returned is 'A1'.
*/
public void _getRangeName(){
log.println( "test for getRangeName()" );
oObj.gotoStart(false);
String oCellName = oObj.getRangeName();
log.println( "CellName = " + oCellName );
tRes.tested("getRangeName()", oCellName.equals("A1") );
}
/**
* Calls the method which moves the cursor down by 1 cell,
* after that returns cursor to the old position. <p>
*
* Has <b>OK</b> status if the method returns
* <code>true</code>.
*/
public void _goDown(){
boolean bDown = false;
log.println( "test for goDown()" );
short i = 1;
bDown = oObj.goDown(i,false);
tRes.tested("goDown()", bDown );
oObj.goUp(i,false);
}
/**
* Calls the method which moves the cursor to the right by 1 cell,
* after that returns cursor to the old position. <p>
*
* Has <b>OK</b> status if the method returns
* <code>true</code>.
*/
public void _goRight(){
boolean bRight = false;
log.println( "test for goRight()" );
short i = 1;
bRight = oObj.goRight(i,false);
tRes.tested("goRight()", bRight );
oObj.goLeft(i,false);
}
/**
* Calls the method which moves the cursor to the left by 1 cell,
* after that returns cursor to the old position. <p>
*
* Has <b>OK</b> status if the method returns
* <code>true</code>.
*/
public void _goLeft(){
boolean bLeft = false;
log.println( "test for goLeft()" );
short i = 1;
oObj.goRight(i,false);
bLeft = oObj.goLeft(i,false);
tRes.tested("goLeft()", bLeft );
}
/**
* Calls the method which moves the cursor up by 1 cell,
* after that returns cursor to the old position. <p>
*
* Has <b>OK</b> status if the method returns
* <code>true</code>.
*/
public void _goUp(){
boolean bUp = false;
log.println( "test for goUp()" );
short i = 1;
oObj.gotoEnd(true);
bUp = oObj.goUp(i,false);
tRes.tested("goUp()", bUp );
}
/**
* Moves the cursor to the cell with name 'B1', then
* checks the current range name. <p>
* Has <b>OK</b> status if the returned range name is
* 'B1'.
*/
public void _gotoCellByName(){
log.println( "test for gotoCellByName()" );
oObj.gotoCellByName("B1",false);
String oCellName = oObj.getRangeName();
tRes.tested("gotoCellByName()", oCellName.equals("B1") );
}
/**
* Moves cursor to the start (upper-left cell). Then
* checks the current range name. <p>
*
* Has <b>OK</b> status if current range name is 'A1'.
*/
public void _gotoStart(){
log.println( "test for gotoStart()" );
oObj.gotoStart(false);
String oCellName = oObj.getRangeName();
tRes.tested("gotoStart()", oCellName.equals("A1") );
}
/**
* Moves cursor to the end (lower-right cell). Then
* checks the current range name. <p>
*
* Has <b>OK</b> status if current range name is 'B2'
* (the table is assumed to be of size 2x2).
*/
public void _gotoEnd(){
log.println( "test for gotoEnd()" );
oObj.gotoEnd(false);
String oCellName = oObj.getRangeName();
tRes.tested("gotoEnd()", oCellName.equals("B2") );
}
/**
* Selects all cells in the table and merges them.
* Finally move the cursor to the end and checks
* current range name.<p>
*
* Has <b>OK</b> status if the end cell has a name
* 'A1'.
*
* The following method tests are to be executed before :
* <ul>
* <li> <code> getRangeName(), gotoStart(), gotoEnd()
* goLeft(), goRight(), goUp(), goDown(), gotoCellByName()</code>
* : these methods must be completed before all cells of the
* table are merged into one cell </li>
* </ul>
*/
public void _mergeRange(){
executeMethod("getRangeName()") ;
executeMethod("gotoStart()") ;
executeMethod("gotoEnd()") ;
executeMethod("goLeft()") ;
executeMethod("goRight()") ;
executeMethod("goUp()") ;
executeMethod("goDown()") ;
executeMethod("gotoCellByName()") ;
boolean bMerge = false;
log.println( "test for mergeRange()" );
oObj.gotoStart(false);
oObj.gotoEnd(true);
bMerge = oObj.mergeRange();
oObj.gotoEnd(false);
String curName = oObj.getRangeName() ;
bMerge &= "A1".equals(curName) ;
tRes.tested("mergeRange()", bMerge );
}
/**
* First splits the cell horyzontally. Then the end cell
* name is checked. Second split all cells vertically and
* again the end cell name is checked<p>
*
* Has <b> OK </b> status if in the first case the end cell name
* is not 'A1', and in the second case the end cell name is not
* equal to the name gotten in the first case. <p>
*
* The following method tests are to be completed successfully before :
* <ul>
* <li> <code> mergeRange() </code> : to have one cell in a table
* which this test splits. </li>
* </ul>
*/
public void _splitRange(){
requiredMethod("mergeRange()") ;
boolean bSplit = true ;
log.println( "test for splitRange" ) ;
short i = 1 ;
bSplit &= oObj.splitRange(i, true) ;
oObj.gotoEnd(false);
String horName = oObj.getRangeName() ;
log.println("The end cell after horiz. split : " + horName) ;
bSplit &= !"A1".equals(horName) ;
oObj.gotoStart(false);
oObj.gotoEnd(true);
bSplit &= oObj.splitRange(i, false) ;
oObj.gotoEnd(false);
String vertName = oObj.getRangeName() ;
log.println("The end cell after vert. split : " + vertName) ;
bSplit &= !horName.equals(vertName) ;
tRes.tested("splitRange()", bSplit ) ;
}
/**
* Forces object environment recreation.
*/
public void after() {
disposeEnvironment() ;
}
} // finish class _XTextTableCursor
|