Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / sheet / _XCellSeries.java
blobcd7379e2d520fb7f4ae44faa56cf17b5ed73400b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XCellSeries.java,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package ifc.sheet;
32 import helper.LoggingThread;
33 import lib.MultiMethodTest;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.sheet.XCellSeries;
38 import com.sun.star.sheet.XSpreadsheet;
39 import com.sun.star.uno.UnoRuntime;
40 import share.LogWriter;
43 public class _XCellSeries extends MultiMethodTest {
44 public XCellSeries oObj = null;
45 protected XSpreadsheet oSheet = null;
46 protected boolean isSpreadSheet = false;
47 protected boolean fillAuto = true;
48 protected boolean forceFillAuto = false;
51 protected void before() {
52 oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET");
54 if (oSheet == null) {
55 log.println("Object relation oSheet is missing");
56 log.println("Trying to query the needed Interface");
57 oSheet = (XSpreadsheet) UnoRuntime.queryInterface(
58 XSpreadsheet.class, tEnv.getTestObject());
60 if (oSheet == null) {
61 throw new StatusException(Status.failed(
62 "Object relation oSheet is missing"));
63 } else {
64 isSpreadSheet = true;
68 Boolean myFillAuto = (Boolean) tEnv.getObjRelation("XCELLSERIES_FILLAUTO");
70 if (myFillAuto != null) fillAuto = myFillAuto.booleanValue();
72 if (tParam.containsKey("force_fillauto")){
73 fillAuto = tParam.getBool("force_fillauto");
74 forceFillAuto = tParam.getBool("force_fillauto");
78 public void _fillAuto() {
80 if ((isSpreadSheet && !forceFillAuto) || !fillAuto) {
81 log.println("This method consumes to much time for a complete SpreadSheet");
82 log.println("Please use parameter '-force_fillauto true' to force this test");
83 tRes.tested("fillAuto()",Status.skipped(true));
84 return;
87 boolean res = true;
89 try {
90 oSheet.getCellByPosition(0, 0).setValue(2);
92 log.println(
93 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1)");
94 oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1);
95 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
97 double getting = oSheet.getCellByPosition(0, 4).getValue();
98 boolean locres = (getting == 14);
100 if (!locres) {
101 log.println("Operation failed");
102 } else {
103 log.println("Successful");
106 res &= locres;
108 log.println(
109 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1)");
110 oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1);
111 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
112 getting = oSheet.getCellByPosition(4, 0).getValue();
113 locres = (getting == 14);
115 if (!locres) {
116 log.println("Operation failed");
117 } else {
118 log.println("Successful");
121 res &= locres;
122 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
123 log.println("Couldn't set initial version to cell");
124 res = false;
127 tRes.tested("fillAuto()", res);
130 public void _fillSeries() {
132 if (isSpreadSheet) {
133 log.println("This method consumes to much time for a complete SpreadSheet");
134 tRes.tested("fillSeries()",Status.skipped(true));
135 return;
138 boolean res = true;
140 try {
141 oSheet.getCellByPosition(0, 0).setValue(2);
143 LoggingThread logger = new LoggingThread((LogWriter)log, tParam);
144 logger.start();
146 log.println(
147 "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)");
148 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT,
149 com.sun.star.sheet.FillMode.LINEAR,
150 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8);
151 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
153 double getting = oSheet.getCellByPosition(0, 4).getValue();
154 boolean locres = (getting == 20);
156 logger.finish();
158 if (!locres) {
159 log.println("Operation failed");
160 } else {
161 log.println("Successful");
164 res &= locres;
166 logger = new LoggingThread((LogWriter)log, tParam);
167 logger.start();
169 log.println(
170 "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)");
171 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT,
172 com.sun.star.sheet.FillMode.GROWTH,
173 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2,
174 16);
175 oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
176 getting = oSheet.getCellByPosition(0, 4).getValue();
177 locres = (getting == 30);
179 logger.finish();
181 if (!locres) {
182 log.println("Operation failed");
183 } else {
184 log.println("Successful");
187 res &= locres;
189 logger = new LoggingThread((LogWriter)log, tParam);
190 logger.start();
192 log.println(
193 "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)");
194 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM,
195 com.sun.star.sheet.FillMode.LINEAR,
196 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8);
197 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
198 getting = oSheet.getCellByPosition(4, 0).getValue();
199 locres = (getting == 20);
201 logger.finish();
203 if (!locres) {
204 log.println("Operation failed");
205 } else {
206 log.println("Successful");
209 res &= locres;
211 logger = new LoggingThread((LogWriter)log, tParam);
212 logger.start();
214 log.println(
215 "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)");
216 oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM,
217 com.sun.star.sheet.FillMode.GROWTH,
218 com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2,
219 16);
220 oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
221 getting = oSheet.getCellByPosition(4, 0).getValue();
222 locres = (getting == 30);
224 logger.finish();
226 if (!locres) {
227 log.println("Operation failed");
228 } else {
229 log.println("Successful");
232 res &= locres;
233 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
234 log.println("Couldn't set initial version to cell");
235 res = false;
238 tRes.tested("fillSeries()", res);
242 * Forces environment recreation.
244 public void after() {
245 disposeEnvironment();