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 ifc.sheet; 29 30 import lib.MultiMethodTest; 31 32 import com.sun.star.beans.PropertyValue; 33 import com.sun.star.sheet.ConditionOperator; 34 import com.sun.star.sheet.XSheetConditionalEntries; 35 import com.sun.star.table.CellAddress; 36 37 /** 38 * Testing <code>com.sun.star.sheet.XSheetConditionalEntries</code> 39 * interface methods : 40 * <ul> 41 * <li><code> addNew()</code></li> 42 * <li><code> removeByIndex()</code></li> 43 * <li><code> clear()</code></li> 44 * </ul> <p> 45 * @see com.sun.star.sheet.XSheetConditionalEntries 46 */ 47 public class _XSheetConditionalEntries extends MultiMethodTest { 48 public XSheetConditionalEntries oObj = null; 49 int nNum = 0; 50 51 /** 52 * Test adds a conditional entry to the format. <p> 53 * Has <b> OK </b> status if the method successfully returns. <p> 54 */ 55 public void _addNew() { 56 nNum = oObj.getCount(); 57 oObj.addNew( Conditions(4) ); 58 boolean res = (nNum + 1) == oObj.getCount(); 59 60 tRes.tested("addNew()", res); 61 } 62 63 /** 64 * Test calls the method and checks number of conditional entries in 65 * collection. <p> 66 * Has <b> OK </b> status if number of conditional entries in co0llection 67 * after method call is equal zero. <p> 68 * The following method tests are to be completed successfully before : 69 * <ul> 70 * <li> <code> addNew() </code> : to have one conditional entry in 71 * collection at least </li> 72 * </ul> 73 */ 74 public void _clear() { 75 requiredMethod("removeByIndex()"); 76 oObj.clear(); 77 int anz = oObj.getCount(); 78 tRes.tested("clear()", anz == 0); 79 } 80 81 /** 82 * Test adds a conditional entry, removes entry with index 0 83 * and compares number of entries after adding to number of entries after 84 * removing. <p> 85 * Has <b> OK </b> status if number of entries after adding is greater 86 * than number of entries after removing. <p> 87 * The following method tests are to be completed successfully before : 88 * <ul> 89 * <li> <code> clear() </code> : to be sure that collection hasn't 90 * elements </li> 91 * </ul> 92 */ 93 public void _removeByIndex() { 94 requiredMethod("addNew()"); 95 oObj.removeByIndex(0); 96 int pastNum = oObj.getCount(); 97 tRes.tested("removeByIndex()", pastNum == nNum); 98 } 99 100 /** 101 * Method creates array of property value for conditional entry using 102 * passed parameter <code>nr</code>. 103 * @param nr number of row for conditional entry 104 */ 105 protected PropertyValue[] Conditions(int nr) { 106 PropertyValue[] con = new PropertyValue[5]; 107 CellAddress ca = new CellAddress(); 108 ca.Column = 1; 109 ca.Row = 5; 110 ca.Sheet = 0; 111 con[0] = new PropertyValue(); 112 con[0].Name = "StyleName"; 113 con[0].Value = "Result2"; 114 con[1] = new PropertyValue(); 115 con[1].Name = "Formula1"; 116 con[1].Value = "$Sheet1.$B$"+nr; 117 con[2] = new PropertyValue(); 118 con[2].Name = "Formula2"; 119 con[2].Value = ""; 120 con[3] = new PropertyValue(); 121 con[3].Name = "Operator"; 122 con[3].Value = ConditionOperator.EQUAL; 123 con[4] = new PropertyValue(); 124 con[4].Name = "SourcePosition"; 125 con[4].Value = ca; 126 return con; 127 } 128 129 /** 130 * Forces object environment recreation. 131 */ 132 protected void after() { 133 this.disposeEnvironment(); 134 } 135 } // finish class _XSheetConditionalEntries 136 137 138