/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
package ifc.text;
import lib.MultiMethodTest;
import com.sun.star.table.XCell;
import com.sun.star.text.XTextTableCursor;
/**
* Testing com.sun.star.text.XTextTableCursor
* interface methods :
*
getRangeName()
gotoCellByName()
goLeft()
goRight()
goUp()
goDown()
gotoStart()
gotoEnd()
mergeRange()
splitRange()
* * Prerequisites : the table must have a size * 2x2 and current cursor position must be in the upper * left cell.
* * Test is NOT multithread compilant.
* * 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.
* * Has OK 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.
*
* Has OK status if the method returns
* true
.
*/
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.
*
* Has OK status if the method returns
* true
.
*/
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.
*
* Has OK status if the method returns
* true
.
*/
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.
*
* Has OK status if the method returns
* true
.
*/
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.
* Has OK 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.
* * Has OK 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.
* * Has OK 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.
* * Has OK status if the end cell has a name * 'A1'. * * The following method tests are to be executed before : *
getRangeName(), gotoStart(), gotoEnd()
* goLeft(), goRight(), goUp(), goDown(), gotoCellByName()
* : these methods must be completed before all cells of the
* table are merged into one cell * * Has OK 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.
* * The following method tests are to be completed successfully before : *
mergeRange()
: to have one cell in a table
* which this test splits.