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