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.XAreaLink; 29*b1cdbd2cSJim Jagielski import com.sun.star.table.CellRangeAddress; 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielski /** 32*b1cdbd2cSJim Jagielski * Testing <code>com.sun.star.sheet.XAreaLink</code> 33*b1cdbd2cSJim Jagielski * interface methods : 34*b1cdbd2cSJim Jagielski * <ul> 35*b1cdbd2cSJim Jagielski * <li><code> getSourceArea()</code></li> 36*b1cdbd2cSJim Jagielski * <li><code> setSourceArea()</code></li> 37*b1cdbd2cSJim Jagielski * <li><code> getDestArea()</code></li> 38*b1cdbd2cSJim Jagielski * <li><code> setDestArea()</code></li> 39*b1cdbd2cSJim Jagielski * </ul> <p> 40*b1cdbd2cSJim Jagielski * Test is <b> NOT </b> multithread compilant. <p> 41*b1cdbd2cSJim Jagielski * @see com.sun.star.sheet.XAreaLink 42*b1cdbd2cSJim Jagielski */ 43*b1cdbd2cSJim Jagielski public class _XAreaLink extends MultiMethodTest { 44*b1cdbd2cSJim Jagielski 45*b1cdbd2cSJim Jagielski public XAreaLink oObj = null; 46*b1cdbd2cSJim Jagielski CellRangeAddress oORAdd, oNRAdd, oCRAdd = null; 47*b1cdbd2cSJim Jagielski 48*b1cdbd2cSJim Jagielski /** 49*b1cdbd2cSJim Jagielski * Just calls the method and checks the value returned. 50*b1cdbd2cSJim Jagielski * (More complicated testing done in <code>setDestArea</code>)<p> 51*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if not null value returned. 52*b1cdbd2cSJim Jagielski */ _getDestArea()53*b1cdbd2cSJim Jagielski public void _getDestArea(){ 54*b1cdbd2cSJim Jagielski log.println("testing getDestArea()"); 55*b1cdbd2cSJim Jagielski boolean bResult = false; 56*b1cdbd2cSJim Jagielski oORAdd = oObj.getDestArea(); 57*b1cdbd2cSJim Jagielski if (!(oORAdd == null)){ bResult = true; } 58*b1cdbd2cSJim Jagielski tRes.tested("getDestArea()", bResult) ; 59*b1cdbd2cSJim Jagielski } 60*b1cdbd2cSJim Jagielski 61*b1cdbd2cSJim Jagielski /** 62*b1cdbd2cSJim Jagielski * Just calls the method and checks the value returned. 63*b1cdbd2cSJim Jagielski * (More complicated testing done in <code>setSourceArea</code>)<p> 64*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if not null value returned. 65*b1cdbd2cSJim Jagielski */ _getSourceArea()66*b1cdbd2cSJim Jagielski public void _getSourceArea(){ 67*b1cdbd2cSJim Jagielski log.println("testing getSourceArea()"); 68*b1cdbd2cSJim Jagielski boolean bResult = false; 69*b1cdbd2cSJim Jagielski String src = null; 70*b1cdbd2cSJim Jagielski src = oObj.getSourceArea() ; 71*b1cdbd2cSJim Jagielski if (!(src == null)){ bResult = true; } 72*b1cdbd2cSJim Jagielski tRes.tested("getSourceArea()", bResult) ; 73*b1cdbd2cSJim Jagielski } 74*b1cdbd2cSJim Jagielski 75*b1cdbd2cSJim Jagielski /** 76*b1cdbd2cSJim Jagielski * Creates a new desination CellRange address and sets it for 77*b1cdbd2cSJim Jagielski * the link object. <p> 78*b1cdbd2cSJim Jagielski * After setting the DestArea, the link is refreshed and the area is 79*b1cdbd2cSJim Jagielski * adjusted to the size of the source data. 80*b1cdbd2cSJim Jagielski * Therefore EndCol and EndRow will change after setting. <p> 81*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if Sheet, Starting Column and Row 82*b1cdbd2cSJim Jagielski * of the destination range is changed correctly. 83*b1cdbd2cSJim Jagielski */ _setDestArea()84*b1cdbd2cSJim Jagielski public void _setDestArea(){ 85*b1cdbd2cSJim Jagielski log.println("testing setDestArea()"); 86*b1cdbd2cSJim Jagielski boolean bResult = false; 87*b1cdbd2cSJim Jagielski int newStartCol = 3, newStartRow = 4, newEndCol = 5, newEndRow = 8 ; 88*b1cdbd2cSJim Jagielski oORAdd = oObj.getDestArea(); 89*b1cdbd2cSJim Jagielski log.print("Getting: "); 90*b1cdbd2cSJim Jagielski log.println(getCRA(oORAdd)); 91*b1cdbd2cSJim Jagielski oNRAdd = new CellRangeAddress ((short) 2, newStartCol, newStartRow, 92*b1cdbd2cSJim Jagielski newEndCol, newEndRow) ; 93*b1cdbd2cSJim Jagielski oObj.setDestArea(oNRAdd) ; 94*b1cdbd2cSJim Jagielski log.print("Setting: "); 95*b1cdbd2cSJim Jagielski log.println(getCRA(oNRAdd)); 96*b1cdbd2cSJim Jagielski oCRAdd = oObj.getDestArea(); 97*b1cdbd2cSJim Jagielski log.print("Getting: "); 98*b1cdbd2cSJim Jagielski log.println(getCRA(oCRAdd)); 99*b1cdbd2cSJim Jagielski // After setting the DestArea, the link is refreshed and the area is 100*b1cdbd2cSJim Jagielski // adjusted to the size of the source data. 101*b1cdbd2cSJim Jagielski // Therefore EndCol and EndRow will change after setting. 102*b1cdbd2cSJim Jagielski log.println("After setting the DestArea, the link is refreshed "+ 103*b1cdbd2cSJim Jagielski "and the area is"); 104*b1cdbd2cSJim Jagielski log.println("adjusted to the size of the source data."); 105*b1cdbd2cSJim Jagielski log.println("Therefore only 'Sheet', 'StartCol' and 'StartRow' "+ 106*b1cdbd2cSJim Jagielski "are compared."); 107*b1cdbd2cSJim Jagielski if ((oCRAdd.StartColumn == oNRAdd.StartColumn) && 108*b1cdbd2cSJim Jagielski (oCRAdd.Sheet == oNRAdd.Sheet) && 109*b1cdbd2cSJim Jagielski (oCRAdd.StartRow == oNRAdd.StartRow)){ 110*b1cdbd2cSJim Jagielski bResult = true; 111*b1cdbd2cSJim Jagielski oObj.setDestArea(oORAdd); 112*b1cdbd2cSJim Jagielski } 113*b1cdbd2cSJim Jagielski tRes.tested("setDestArea()", bResult) ; 114*b1cdbd2cSJim Jagielski } 115*b1cdbd2cSJim Jagielski 116*b1cdbd2cSJim Jagielski /** 117*b1cdbd2cSJim Jagielski * Sets a new source area for the link and then check 118*b1cdbd2cSJim Jagielski * it using <code>getSourceArea</code> method. <p> 119*b1cdbd2cSJim Jagielski * Has <b>OK</b> status if areas set and get are equal. 120*b1cdbd2cSJim Jagielski */ _setSourceArea()121*b1cdbd2cSJim Jagielski public void _setSourceArea(){ 122*b1cdbd2cSJim Jagielski log.println("testing setSourceArea()"); 123*b1cdbd2cSJim Jagielski boolean bResult = false; 124*b1cdbd2cSJim Jagielski String oSrc = oObj.getSourceArea() ; 125*b1cdbd2cSJim Jagielski String nSrc = "a1:b2"; 126*b1cdbd2cSJim Jagielski oObj.setSourceArea(nSrc); 127*b1cdbd2cSJim Jagielski String cSrc = oObj.getSourceArea(); 128*b1cdbd2cSJim Jagielski if( nSrc.equals(cSrc)){ 129*b1cdbd2cSJim Jagielski bResult = true; 130*b1cdbd2cSJim Jagielski oObj.setSourceArea(oSrc); 131*b1cdbd2cSJim Jagielski } 132*b1cdbd2cSJim Jagielski tRes.tested("setSourceArea()", bResult) ; 133*b1cdbd2cSJim Jagielski } 134*b1cdbd2cSJim Jagielski 135*b1cdbd2cSJim Jagielski /** 136*b1cdbd2cSJim Jagielski * Prints cell range structure to LOG 137*b1cdbd2cSJim Jagielski */ getCRA( CellRangeAddress oCRA )138*b1cdbd2cSJim Jagielski public String getCRA ( CellRangeAddress oCRA ) { 139*b1cdbd2cSJim Jagielski String res = "( Sheet: "; 140*b1cdbd2cSJim Jagielski res += oCRA.Sheet; 141*b1cdbd2cSJim Jagielski res += ";StartColumn: "; 142*b1cdbd2cSJim Jagielski res += oCRA.StartColumn; 143*b1cdbd2cSJim Jagielski res += ";StartRow: "; 144*b1cdbd2cSJim Jagielski res += oCRA.StartRow; 145*b1cdbd2cSJim Jagielski res += ";EndColumn: "; 146*b1cdbd2cSJim Jagielski res += oCRA.EndColumn; 147*b1cdbd2cSJim Jagielski res += ";EndRow: "; 148*b1cdbd2cSJim Jagielski res += oCRA.EndRow; 149*b1cdbd2cSJim Jagielski res += " )"; 150*b1cdbd2cSJim Jagielski return res; 151*b1cdbd2cSJim Jagielski } 152*b1cdbd2cSJim Jagielski 153*b1cdbd2cSJim Jagielski } // EOC _XAreaLink 154*b1cdbd2cSJim Jagielski 155*b1cdbd2cSJim Jagielski 156