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