1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.sheet; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import lib.MultiMethodTest; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import com.sun.star.sheet.XAreaLink; 29cdf0e10cSrcweir import com.sun.star.table.CellRangeAddress; 30cdf0e10cSrcweir 31cdf0e10cSrcweir /** 32cdf0e10cSrcweir * Testing <code>com.sun.star.sheet.XAreaLink</code> 33cdf0e10cSrcweir * interface methods : 34cdf0e10cSrcweir * <ul> 35cdf0e10cSrcweir * <li><code> getSourceArea()</code></li> 36cdf0e10cSrcweir * <li><code> setSourceArea()</code></li> 37cdf0e10cSrcweir * <li><code> getDestArea()</code></li> 38cdf0e10cSrcweir * <li><code> setDestArea()</code></li> 39cdf0e10cSrcweir * </ul> <p> 40cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p> 41cdf0e10cSrcweir * @see com.sun.star.sheet.XAreaLink 42cdf0e10cSrcweir */ 43cdf0e10cSrcweir public class _XAreaLink extends MultiMethodTest { 44cdf0e10cSrcweir 45cdf0e10cSrcweir public XAreaLink oObj = null; 46cdf0e10cSrcweir CellRangeAddress oORAdd, oNRAdd, oCRAdd = null; 47cdf0e10cSrcweir 48cdf0e10cSrcweir /** 49cdf0e10cSrcweir * Just calls the method and checks the value returned. 50cdf0e10cSrcweir * (More complicated testing done in <code>setDestArea</code>)<p> 51cdf0e10cSrcweir * Has <b>OK</b> status if not null value returned. 52cdf0e10cSrcweir */ _getDestArea()53cdf0e10cSrcweir public void _getDestArea(){ 54cdf0e10cSrcweir log.println("testing getDestArea()"); 55cdf0e10cSrcweir boolean bResult = false; 56cdf0e10cSrcweir oORAdd = oObj.getDestArea(); 57cdf0e10cSrcweir if (!(oORAdd == null)){ bResult = true; } 58cdf0e10cSrcweir tRes.tested("getDestArea()", bResult) ; 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir /** 62cdf0e10cSrcweir * Just calls the method and checks the value returned. 63cdf0e10cSrcweir * (More complicated testing done in <code>setSourceArea</code>)<p> 64cdf0e10cSrcweir * Has <b>OK</b> status if not null value returned. 65cdf0e10cSrcweir */ _getSourceArea()66cdf0e10cSrcweir public void _getSourceArea(){ 67cdf0e10cSrcweir log.println("testing getSourceArea()"); 68cdf0e10cSrcweir boolean bResult = false; 69cdf0e10cSrcweir String src = null; 70cdf0e10cSrcweir src = oObj.getSourceArea() ; 71cdf0e10cSrcweir if (!(src == null)){ bResult = true; } 72cdf0e10cSrcweir tRes.tested("getSourceArea()", bResult) ; 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir /** 76cdf0e10cSrcweir * Creates a new desination CellRange address and sets it for 77cdf0e10cSrcweir * the link object. <p> 78cdf0e10cSrcweir * After setting the DestArea, the link is refreshed and the area is 79cdf0e10cSrcweir * adjusted to the size of the source data. 80cdf0e10cSrcweir * Therefore EndCol and EndRow will change after setting. <p> 81cdf0e10cSrcweir * Has <b>OK</b> status if Sheet, Starting Column and Row 82cdf0e10cSrcweir * of the destination range is changed correctly. 83cdf0e10cSrcweir */ _setDestArea()84cdf0e10cSrcweir public void _setDestArea(){ 85cdf0e10cSrcweir log.println("testing setDestArea()"); 86cdf0e10cSrcweir boolean bResult = false; 87cdf0e10cSrcweir int newStartCol = 3, newStartRow = 4, newEndCol = 5, newEndRow = 8 ; 88cdf0e10cSrcweir oORAdd = oObj.getDestArea(); 89cdf0e10cSrcweir log.print("Getting: "); 90cdf0e10cSrcweir log.println(getCRA(oORAdd)); 91cdf0e10cSrcweir oNRAdd = new CellRangeAddress ((short) 2, newStartCol, newStartRow, 92cdf0e10cSrcweir newEndCol, newEndRow) ; 93cdf0e10cSrcweir oObj.setDestArea(oNRAdd) ; 94cdf0e10cSrcweir log.print("Setting: "); 95cdf0e10cSrcweir log.println(getCRA(oNRAdd)); 96cdf0e10cSrcweir oCRAdd = oObj.getDestArea(); 97cdf0e10cSrcweir log.print("Getting: "); 98cdf0e10cSrcweir log.println(getCRA(oCRAdd)); 99cdf0e10cSrcweir // After setting the DestArea, the link is refreshed and the area is 100cdf0e10cSrcweir // adjusted to the size of the source data. 101cdf0e10cSrcweir // Therefore EndCol and EndRow will change after setting. 102cdf0e10cSrcweir log.println("After setting the DestArea, the link is refreshed "+ 103cdf0e10cSrcweir "and the area is"); 104cdf0e10cSrcweir log.println("adjusted to the size of the source data."); 105cdf0e10cSrcweir log.println("Therefore only 'Sheet', 'StartCol' and 'StartRow' "+ 106cdf0e10cSrcweir "are compared."); 107cdf0e10cSrcweir if ((oCRAdd.StartColumn == oNRAdd.StartColumn) && 108cdf0e10cSrcweir (oCRAdd.Sheet == oNRAdd.Sheet) && 109cdf0e10cSrcweir (oCRAdd.StartRow == oNRAdd.StartRow)){ 110cdf0e10cSrcweir bResult = true; 111cdf0e10cSrcweir oObj.setDestArea(oORAdd); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir tRes.tested("setDestArea()", bResult) ; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir /** 117cdf0e10cSrcweir * Sets a new source area for the link and then check 118cdf0e10cSrcweir * it using <code>getSourceArea</code> method. <p> 119cdf0e10cSrcweir * Has <b>OK</b> status if areas set and get are equal. 120cdf0e10cSrcweir */ _setSourceArea()121cdf0e10cSrcweir public void _setSourceArea(){ 122cdf0e10cSrcweir log.println("testing setSourceArea()"); 123cdf0e10cSrcweir boolean bResult = false; 124cdf0e10cSrcweir String oSrc = oObj.getSourceArea() ; 125cdf0e10cSrcweir String nSrc = "a1:b2"; 126cdf0e10cSrcweir oObj.setSourceArea(nSrc); 127cdf0e10cSrcweir String cSrc = oObj.getSourceArea(); 128cdf0e10cSrcweir if( nSrc.equals(cSrc)){ 129cdf0e10cSrcweir bResult = true; 130cdf0e10cSrcweir oObj.setSourceArea(oSrc); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir tRes.tested("setSourceArea()", bResult) ; 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir /** 136cdf0e10cSrcweir * Prints cell range structure to LOG 137cdf0e10cSrcweir */ getCRA( CellRangeAddress oCRA )138cdf0e10cSrcweir public String getCRA ( CellRangeAddress oCRA ) { 139cdf0e10cSrcweir String res = "( Sheet: "; 140cdf0e10cSrcweir res += oCRA.Sheet; 141cdf0e10cSrcweir res += ";StartColumn: "; 142cdf0e10cSrcweir res += oCRA.StartColumn; 143cdf0e10cSrcweir res += ";StartRow: "; 144cdf0e10cSrcweir res += oCRA.StartRow; 145cdf0e10cSrcweir res += ";EndColumn: "; 146cdf0e10cSrcweir res += oCRA.EndColumn; 147cdf0e10cSrcweir res += ";EndRow: "; 148cdf0e10cSrcweir res += oCRA.EndRow; 149cdf0e10cSrcweir res += " )"; 150cdf0e10cSrcweir return res; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir } // EOC _XAreaLink 154cdf0e10cSrcweir 155cdf0e10cSrcweir 156