1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski package ifc.sheet; 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim Jagielski import lib.MultiMethodTest; 27*b1cdbd2cSJim Jagielski 28*b1cdbd2cSJim Jagielski import com.sun.star.sheet.XCellRangeAddressable; 29*b1cdbd2cSJim Jagielski import com.sun.star.sheet.XSheetCellCursor; 30*b1cdbd2cSJim Jagielski import com.sun.star.sheet.XUsedAreaCursor; 31*b1cdbd2cSJim Jagielski import com.sun.star.table.CellRangeAddress; 32*b1cdbd2cSJim Jagielski import com.sun.star.uno.UnoRuntime; 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski /** 35*b1cdbd2cSJim Jagielski * Testing <code>com.sun.star.sheet.XUsedAreaCursor</code> 36*b1cdbd2cSJim Jagielski * interface methods : 37*b1cdbd2cSJim Jagielski * <ul> 38*b1cdbd2cSJim Jagielski * <li><code> gotoStartOfUsedArea()</code></li> 39*b1cdbd2cSJim Jagielski * <li><code> gotoEndOfUsedArea()</code></li> 40*b1cdbd2cSJim Jagielski * </ul> <p> 41*b1cdbd2cSJim Jagielski * Component must also implement the following interfaces : 42*b1cdbd2cSJim Jagielski * <ul> 43*b1cdbd2cSJim Jagielski * <li> <code> com.sun.star.XCellRangeAddressable </code> : to check the current 44*b1cdbd2cSJim Jagielski * position of the cursor </li> 45*b1cdbd2cSJim Jagielski * <ul> <p> 46*b1cdbd2cSJim Jagielski * @see com.sun.star.sheet.XUsedAreaCursor 47*b1cdbd2cSJim Jagielski */ 48*b1cdbd2cSJim Jagielski public class _XUsedAreaCursor extends MultiMethodTest { 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski public XUsedAreaCursor oObj = null; 51*b1cdbd2cSJim Jagielski public XSheetCellCursor oC = null; 52*b1cdbd2cSJim Jagielski CellRangeAddress sAddr = null; 53*b1cdbd2cSJim Jagielski 54*b1cdbd2cSJim Jagielski /** 55*b1cdbd2cSJim Jagielski * Test points the cursor to the start of used area, expands cursor to the 56*b1cdbd2cSJim Jagielski * end of the used area, gets and checks current range address, then 57*b1cdbd2cSJim Jagielski * points the cursor to the end of the used area, gets and checks current 58*b1cdbd2cSJim Jagielski * range address again. <p> 59*b1cdbd2cSJim Jagielski * Has <b> OK </b> status if the range address expands at all used area 60*b1cdbd2cSJim Jagielski * in first case and if the range address just points to the cell at the end 61*b1cdbd2cSJim Jagielski * of the used area in second case. <p> 62*b1cdbd2cSJim Jagielski */ _gotoEndOfUsedArea()63*b1cdbd2cSJim Jagielski public void _gotoEndOfUsedArea() { 64*b1cdbd2cSJim Jagielski boolean result = true ; 65*b1cdbd2cSJim Jagielski 66*b1cdbd2cSJim Jagielski XCellRangeAddressable oAddr = (XCellRangeAddressable) 67*b1cdbd2cSJim Jagielski UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ; 68*b1cdbd2cSJim Jagielski 69*b1cdbd2cSJim Jagielski // first with true argument 70*b1cdbd2cSJim Jagielski oObj.gotoStartOfUsedArea(false); 71*b1cdbd2cSJim Jagielski oObj.gotoEndOfUsedArea(true); 72*b1cdbd2cSJim Jagielski sAddr = oAddr.getRangeAddress(); 73*b1cdbd2cSJim Jagielski 74*b1cdbd2cSJim Jagielski result &= (sAddr.StartColumn == 1); 75*b1cdbd2cSJim Jagielski result &= (sAddr.StartRow == 1); 76*b1cdbd2cSJim Jagielski result &= (sAddr.EndColumn == 4); 77*b1cdbd2cSJim Jagielski result &= (sAddr.EndRow == 5); 78*b1cdbd2cSJim Jagielski 79*b1cdbd2cSJim Jagielski oObj.gotoEndOfUsedArea(false); 80*b1cdbd2cSJim Jagielski sAddr = oAddr.getRangeAddress(); 81*b1cdbd2cSJim Jagielski 82*b1cdbd2cSJim Jagielski result &= (sAddr.StartColumn == 4); 83*b1cdbd2cSJim Jagielski result &= (sAddr.StartRow == 5); 84*b1cdbd2cSJim Jagielski result &= (sAddr.EndColumn == 4); 85*b1cdbd2cSJim Jagielski result &= (sAddr.EndRow == 5); 86*b1cdbd2cSJim Jagielski 87*b1cdbd2cSJim Jagielski tRes.tested("gotoEndOfUsedArea()", result) ; 88*b1cdbd2cSJim Jagielski } 89*b1cdbd2cSJim Jagielski 90*b1cdbd2cSJim Jagielski /** 91*b1cdbd2cSJim Jagielski * Test points the cursor to the end of used area, expands cursor to the 92*b1cdbd2cSJim Jagielski * start of the used area, gets and checks current range address, then 93*b1cdbd2cSJim Jagielski * points the cursor to the start of the used area, gets and checks current 94*b1cdbd2cSJim Jagielski * range address again. <p> 95*b1cdbd2cSJim Jagielski * Has <b> OK </b> status if the range address expands at all used area 96*b1cdbd2cSJim Jagielski * in first case and if the range address just points to the cell at the 97*b1cdbd2cSJim Jagielski * start of the used area in second case. <p> 98*b1cdbd2cSJim Jagielski */ _gotoStartOfUsedArea()99*b1cdbd2cSJim Jagielski public void _gotoStartOfUsedArea() { 100*b1cdbd2cSJim Jagielski XCellRangeAddressable oAddr = (XCellRangeAddressable) 101*b1cdbd2cSJim Jagielski UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ; 102*b1cdbd2cSJim Jagielski 103*b1cdbd2cSJim Jagielski boolean result = true ; 104*b1cdbd2cSJim Jagielski 105*b1cdbd2cSJim Jagielski // with true parameter first 106*b1cdbd2cSJim Jagielski oObj.gotoEndOfUsedArea(false); 107*b1cdbd2cSJim Jagielski oObj.gotoStartOfUsedArea(true); 108*b1cdbd2cSJim Jagielski sAddr = oAddr.getRangeAddress(); 109*b1cdbd2cSJim Jagielski 110*b1cdbd2cSJim Jagielski result &= (sAddr.StartColumn == 1); 111*b1cdbd2cSJim Jagielski result &= (sAddr.StartRow == 1); 112*b1cdbd2cSJim Jagielski result &= (sAddr.EndColumn == 4); 113*b1cdbd2cSJim Jagielski result &= (sAddr.EndRow == 5); 114*b1cdbd2cSJim Jagielski 115*b1cdbd2cSJim Jagielski // now testing with false parameter 116*b1cdbd2cSJim Jagielski oObj.gotoStartOfUsedArea(false); 117*b1cdbd2cSJim Jagielski sAddr = oAddr.getRangeAddress(); 118*b1cdbd2cSJim Jagielski 119*b1cdbd2cSJim Jagielski result &= (sAddr.StartColumn == 1); 120*b1cdbd2cSJim Jagielski result &= (sAddr.StartRow == 1); 121*b1cdbd2cSJim Jagielski result &= (sAddr.EndColumn == 1); 122*b1cdbd2cSJim Jagielski result &= (sAddr.EndRow == 1); 123*b1cdbd2cSJim Jagielski 124*b1cdbd2cSJim Jagielski tRes.tested("gotoStartOfUsedArea()", result) ; 125*b1cdbd2cSJim Jagielski } // finished gotoStartOfUsedArea 126*b1cdbd2cSJim Jagielski 127*b1cdbd2cSJim Jagielski /** 128*b1cdbd2cSJim Jagielski * Forces object environment recreation. 129*b1cdbd2cSJim Jagielski */ after()130*b1cdbd2cSJim Jagielski protected void after() { 131*b1cdbd2cSJim Jagielski this.disposeEnvironment(); 132*b1cdbd2cSJim Jagielski } 133*b1cdbd2cSJim Jagielski } // finished class _XUsedAreaCursor 134*b1cdbd2cSJim Jagielski 135