1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package ifc.sheet; 24 25 import helper.LoggingThread; 26 import lib.MultiMethodTest; 27 import lib.Status; 28 import lib.StatusException; 29 30 import com.sun.star.sheet.XCellSeries; 31 import com.sun.star.sheet.XSpreadsheet; 32 import com.sun.star.uno.UnoRuntime; 33 import share.LogWriter; 34 35 36 public class _XCellSeries extends MultiMethodTest { 37 public XCellSeries oObj = null; 38 protected XSpreadsheet oSheet = null; 39 protected boolean isSpreadSheet = false; 40 protected boolean fillAuto = true; 41 protected boolean forceFillAuto = false; 42 43 before()44 protected void before() { 45 oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET"); 46 47 if (oSheet == null) { 48 log.println("Object relation oSheet is missing"); 49 log.println("Trying to query the needed Interface"); 50 oSheet = (XSpreadsheet) UnoRuntime.queryInterface( 51 XSpreadsheet.class, tEnv.getTestObject()); 52 53 if (oSheet == null) { 54 throw new StatusException(Status.failed( 55 "Object relation oSheet is missing")); 56 } else { 57 isSpreadSheet = true; 58 } 59 } 60 61 Boolean myFillAuto = (Boolean) tEnv.getObjRelation("XCELLSERIES_FILLAUTO"); 62 63 if (myFillAuto != null) fillAuto = myFillAuto.booleanValue(); 64 65 if (tParam.containsKey("force_fillauto")){ 66 fillAuto = tParam.getBool("force_fillauto"); 67 forceFillAuto = tParam.getBool("force_fillauto"); 68 } 69 } 70 _fillAuto()71 public void _fillAuto() { 72 73 if ((isSpreadSheet && !forceFillAuto) || !fillAuto) { 74 log.println("This method consumes to much time for a complete SpreadSheet"); 75 log.println("Please use parameter '-force_fillauto true' to force this test"); 76 tRes.tested("fillAuto()",Status.skipped(true)); 77 return; 78 } 79 80 boolean res = true; 81 82 try { 83 oSheet.getCellByPosition(0, 0).setValue(2); 84 85 log.println( 86 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1)"); 87 oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1); 88 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)"); 89 90 double getting = oSheet.getCellByPosition(0, 4).getValue(); 91 boolean locres = (getting == 14); 92 93 if (!locres) { 94 log.println("Operation failed"); 95 } else { 96 log.println("Successful"); 97 } 98 99 res &= locres; 100 101 log.println( 102 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1)"); 103 oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1); 104 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)"); 105 getting = oSheet.getCellByPosition(4, 0).getValue(); 106 locres = (getting == 14); 107 108 if (!locres) { 109 log.println("Operation failed"); 110 } else { 111 log.println("Successful"); 112 } 113 114 res &= locres; 115 } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 116 log.println("Couldn't set initial version to cell"); 117 res = false; 118 } 119 120 tRes.tested("fillAuto()", res); 121 } 122 _fillSeries()123 public void _fillSeries() { 124 125 if (isSpreadSheet) { 126 log.println("This method consumes to much time for a complete SpreadSheet"); 127 tRes.tested("fillSeries()",Status.skipped(true)); 128 return; 129 } 130 131 boolean res = true; 132 133 try { 134 oSheet.getCellByPosition(0, 0).setValue(2); 135 136 LoggingThread logger = new LoggingThread((LogWriter)log, tParam); 137 logger.start(); 138 139 log.println( 140 "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.LINEAR, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8)"); 141 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, 142 com.sun.star.sheet.FillMode.LINEAR, 143 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8); 144 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)"); 145 146 double getting = oSheet.getCellByPosition(0, 4).getValue(); 147 boolean locres = (getting == 20); 148 149 logger.finish(); 150 151 if (!locres) { 152 log.println("Operation failed"); 153 } else { 154 log.println("Successful"); 155 } 156 157 res &= locres; 158 159 logger = new LoggingThread((LogWriter)log, tParam); 160 logger.start(); 161 162 log.println( 163 "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.GROWTH, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 16)"); 164 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, 165 com.sun.star.sheet.FillMode.GROWTH, 166 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 167 16); 168 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)"); 169 getting = oSheet.getCellByPosition(0, 4).getValue(); 170 locres = (getting == 30); 171 172 logger.finish(); 173 174 if (!locres) { 175 log.println("Operation failed"); 176 } else { 177 log.println("Successful"); 178 } 179 180 res &= locres; 181 182 logger = new LoggingThread((LogWriter)log, tParam); 183 logger.start(); 184 185 log.println( 186 "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, com.sun.star.sheet.FillMode.LINEAR, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8)"); 187 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, 188 com.sun.star.sheet.FillMode.LINEAR, 189 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8); 190 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)"); 191 getting = oSheet.getCellByPosition(4, 0).getValue(); 192 locres = (getting == 20); 193 194 logger.finish(); 195 196 if (!locres) { 197 log.println("Operation failed"); 198 } else { 199 log.println("Successful"); 200 } 201 202 res &= locres; 203 204 logger = new LoggingThread((LogWriter)log, tParam); 205 logger.start(); 206 207 log.println( 208 "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, com.sun.star.sheet.FillMode.GROWTH, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 16)"); 209 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, 210 com.sun.star.sheet.FillMode.GROWTH, 211 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 212 16); 213 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)"); 214 getting = oSheet.getCellByPosition(4, 0).getValue(); 215 locres = (getting == 30); 216 217 logger.finish(); 218 219 if (!locres) { 220 log.println("Operation failed"); 221 } else { 222 log.println("Successful"); 223 } 224 225 res &= locres; 226 } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 227 log.println("Couldn't set initial version to cell"); 228 res = false; 229 } 230 231 tRes.tested("fillSeries()", res); 232 } 233 234 /** 235 * Forces environment recreation. 236 */ after()237 public void after() { 238 disposeEnvironment(); 239 } 240 }