1*15ab5183SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*15ab5183SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*15ab5183SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*15ab5183SAndrew Rist * distributed with this work for additional information 6*15ab5183SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*15ab5183SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*15ab5183SAndrew Rist * "License"); you may not use this file except in compliance 9*15ab5183SAndrew Rist * with the License. You may obtain a copy of the License at 10*15ab5183SAndrew Rist * 11*15ab5183SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*15ab5183SAndrew Rist * 13*15ab5183SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*15ab5183SAndrew Rist * software distributed under the License is distributed on an 15*15ab5183SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*15ab5183SAndrew Rist * KIND, either express or implied. See the License for the 17*15ab5183SAndrew Rist * specific language governing permissions and limitations 18*15ab5183SAndrew Rist * under the License. 19*15ab5183SAndrew Rist * 20*15ab5183SAndrew Rist *************************************************************/ 21*15ab5183SAndrew Rist 22*15ab5183SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package complex.dataPilot; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import com.sun.star.sheet.XDataPilotTable; 27cdf0e10cSrcweir import com.sun.star.table.CellAddress; 28cdf0e10cSrcweir import com.sun.star.table.CellRangeAddress; 29cdf0e10cSrcweir import com.sun.star.table.XCell; 30cdf0e10cSrcweir // import lib.Status; 31cdf0e10cSrcweir //import lib.StatusException; 32cdf0e10cSrcweir import lib.TestParameters; 33cdf0e10cSrcweir // import share.LogWriter; 34cdf0e10cSrcweir 35cdf0e10cSrcweir /** 36cdf0e10cSrcweir * Testing <code>com.sun.star.sheet.XDataPilotTable</code> 37cdf0e10cSrcweir * interface methods : 38cdf0e10cSrcweir * <ul> 39cdf0e10cSrcweir * <li><code> getOutputRange()</code></li> 40cdf0e10cSrcweir * <li><code> refresh()</code></li> 41cdf0e10cSrcweir * </ul> <p> 42cdf0e10cSrcweir * This test needs the following object relations : 43cdf0e10cSrcweir * <ul> 44cdf0e10cSrcweir * <li> <code>'OUTPUTRANGE'</code> (of type <code>CellAddress</code>): 45cdf0e10cSrcweir * to check value returned by method <code>getOutputRange()</code> </li> 46cdf0e10cSrcweir * <li> <code>'CELLFORCHANGE'</code> (of type <code>XCell</code>): 47cdf0e10cSrcweir * to check the method refresh(value of this cell will be changed)</li> 48cdf0e10cSrcweir * <li> <code>'CELLFORCHECK'</code> (of type <code>XCell</code>): 49cdf0e10cSrcweir * to check the method refresh (value of this cell must be changed after refresh 50cdf0e10cSrcweir * call) </li><ul> <p> 51cdf0e10cSrcweir * @see com.sun.star.sheet.XDataPilotTable 52cdf0e10cSrcweir * @see com.sun.star.table.CellAddress 53cdf0e10cSrcweir */ 54cdf0e10cSrcweir public class _XDataPilotTable { 55cdf0e10cSrcweir 56cdf0e10cSrcweir public XDataPilotTable oObj = null; 57cdf0e10cSrcweir XCell xCellForChange = null; 58cdf0e10cSrcweir XCell xCellForCheck = null; 59cdf0e10cSrcweir CellAddress OutputRange = null; 60cdf0e10cSrcweir int changeValue = 0; 61cdf0e10cSrcweir 62cdf0e10cSrcweir /** 63cdf0e10cSrcweir * The test parameters 64cdf0e10cSrcweir */ 65cdf0e10cSrcweir private TestParameters param = null; 66cdf0e10cSrcweir 67cdf0e10cSrcweir /** 68cdf0e10cSrcweir * The log writer 69cdf0e10cSrcweir */ 70cdf0e10cSrcweir // private LogWriter log = null; 71cdf0e10cSrcweir 72cdf0e10cSrcweir /** 73cdf0e10cSrcweir * Constructor: gets the object to test, a logger and the test parameters 74cdf0e10cSrcweir * @param xObj The test object 75cdf0e10cSrcweir 76cdf0e10cSrcweir * @param param The test parameters 77cdf0e10cSrcweir */ _XDataPilotTable(XDataPilotTable xObj , TestParameters param)78cdf0e10cSrcweir public _XDataPilotTable(XDataPilotTable xObj/*, 79cdf0e10cSrcweir LogWriter log*/, TestParameters param) { 80cdf0e10cSrcweir oObj = xObj; 81cdf0e10cSrcweir // this.log = log; 82cdf0e10cSrcweir this.param = param; 83cdf0e10cSrcweir } 84cdf0e10cSrcweir before()85cdf0e10cSrcweir public boolean before() { 86cdf0e10cSrcweir xCellForChange = (XCell)param.get("CELLFORCHANGE"); 87cdf0e10cSrcweir xCellForCheck = (XCell)param.get("CELLFORCHECK"); 88cdf0e10cSrcweir OutputRange = (CellAddress)param.get("OUTPUTRANGE"); 89cdf0e10cSrcweir changeValue = ((Integer)param.get("CHANGEVALUE")).intValue(); 90cdf0e10cSrcweir 91cdf0e10cSrcweir if (xCellForChange == null || OutputRange == null || 92cdf0e10cSrcweir xCellForCheck == null) { 93cdf0e10cSrcweir System.out.println("Relation not found"); 94cdf0e10cSrcweir return false; 95cdf0e10cSrcweir } 96cdf0e10cSrcweir return true; 97cdf0e10cSrcweir } 98cdf0e10cSrcweir /** 99cdf0e10cSrcweir * Test calls the method and checks returned value using value obtained by 100cdf0e10cSrcweir * object relation <code>'OUTPUTRANGE'</code>. <p> 101cdf0e10cSrcweir * Has <b> OK </b> status if values are equal. <p> 102cdf0e10cSrcweir * @return 103cdf0e10cSrcweir */ _getOutputRange()104cdf0e10cSrcweir public boolean _getOutputRange(){ 105cdf0e10cSrcweir boolean bResult = true; 106cdf0e10cSrcweir CellRangeAddress objRange = oObj.getOutputRange(); 107cdf0e10cSrcweir bResult &= OutputRange.Sheet == objRange.Sheet; 108cdf0e10cSrcweir bResult &= OutputRange.Row == objRange.StartRow; 109cdf0e10cSrcweir bResult &= OutputRange.Column == objRange.StartColumn; 110cdf0e10cSrcweir return bResult; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir /** 114cdf0e10cSrcweir * Test sets new value of the cell obtained by object relation 115cdf0e10cSrcweir * 'CELLFORCHANGE', and checks value of the cell obtained by object 116cdf0e10cSrcweir * relation 'CELLFORCHECK'.<p> 117cdf0e10cSrcweir * Has <b>OK</b> status if value of the cell obtained by object relation 118cdf0e10cSrcweir * 'CELLFORCHECK' is changed. <p> 119cdf0e10cSrcweir * @return 120cdf0e10cSrcweir */ _refresh()121cdf0e10cSrcweir public boolean _refresh(){ 122cdf0e10cSrcweir xCellForChange.setValue(changeValue); 123cdf0e10cSrcweir double oldData = xCellForCheck.getValue(); 124cdf0e10cSrcweir oObj.refresh(); 125cdf0e10cSrcweir double newData = xCellForCheck.getValue(); 126cdf0e10cSrcweir System.out.println("Old data:" + oldData + "; new data:" + newData); 127cdf0e10cSrcweir 128cdf0e10cSrcweir return oldData != newData; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132