1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package complex.dataPilot; 29 30 import com.sun.star.sheet.XDataPilotTable; 31 import com.sun.star.table.CellAddress; 32 import com.sun.star.table.CellRangeAddress; 33 import com.sun.star.table.XCell; 34 // import lib.Status; 35 //import lib.StatusException; 36 import lib.TestParameters; 37 // import share.LogWriter; 38 39 /** 40 * Testing <code>com.sun.star.sheet.XDataPilotTable</code> 41 * interface methods : 42 * <ul> 43 * <li><code> getOutputRange()</code></li> 44 * <li><code> refresh()</code></li> 45 * </ul> <p> 46 * This test needs the following object relations : 47 * <ul> 48 * <li> <code>'OUTPUTRANGE'</code> (of type <code>CellAddress</code>): 49 * to check value returned by method <code>getOutputRange()</code> </li> 50 * <li> <code>'CELLFORCHANGE'</code> (of type <code>XCell</code>): 51 * to check the method refresh(value of this cell will be changed)</li> 52 * <li> <code>'CELLFORCHECK'</code> (of type <code>XCell</code>): 53 * to check the method refresh (value of this cell must be changed after refresh 54 * call) </li><ul> <p> 55 * @see com.sun.star.sheet.XDataPilotTable 56 * @see com.sun.star.table.CellAddress 57 */ 58 public class _XDataPilotTable { 59 60 public XDataPilotTable oObj = null; 61 XCell xCellForChange = null; 62 XCell xCellForCheck = null; 63 CellAddress OutputRange = null; 64 int changeValue = 0; 65 66 /** 67 * The test parameters 68 */ 69 private TestParameters param = null; 70 71 /** 72 * The log writer 73 */ 74 // private LogWriter log = null; 75 76 /** 77 * Constructor: gets the object to test, a logger and the test parameters 78 * @param xObj The test object 79 80 * @param param The test parameters 81 */ 82 public _XDataPilotTable(XDataPilotTable xObj/*, 83 LogWriter log*/, TestParameters param) { 84 oObj = xObj; 85 // this.log = log; 86 this.param = param; 87 } 88 89 public boolean before() { 90 xCellForChange = (XCell)param.get("CELLFORCHANGE"); 91 xCellForCheck = (XCell)param.get("CELLFORCHECK"); 92 OutputRange = (CellAddress)param.get("OUTPUTRANGE"); 93 changeValue = ((Integer)param.get("CHANGEVALUE")).intValue(); 94 95 if (xCellForChange == null || OutputRange == null || 96 xCellForCheck == null) { 97 System.out.println("Relation not found"); 98 return false; 99 } 100 return true; 101 } 102 /** 103 * Test calls the method and checks returned value using value obtained by 104 * object relation <code>'OUTPUTRANGE'</code>. <p> 105 * Has <b> OK </b> status if values are equal. <p> 106 * @return 107 */ 108 public boolean _getOutputRange(){ 109 boolean bResult = true; 110 CellRangeAddress objRange = oObj.getOutputRange(); 111 bResult &= OutputRange.Sheet == objRange.Sheet; 112 bResult &= OutputRange.Row == objRange.StartRow; 113 bResult &= OutputRange.Column == objRange.StartColumn; 114 return bResult; 115 } 116 117 /** 118 * Test sets new value of the cell obtained by object relation 119 * 'CELLFORCHANGE', and checks value of the cell obtained by object 120 * relation 'CELLFORCHECK'.<p> 121 * Has <b>OK</b> status if value of the cell obtained by object relation 122 * 'CELLFORCHECK' is changed. <p> 123 * @return 124 */ 125 public boolean _refresh(){ 126 xCellForChange.setValue(changeValue); 127 double oldData = xCellForCheck.getValue(); 128 oObj.refresh(); 129 double newData = xCellForCheck.getValue(); 130 System.out.println("Old data:" + oldData + "; new data:" + newData); 131 132 return oldData != newData; 133 } 134 } 135 136