1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XCellSeries.java,v $
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 ************************************************************************/
32 import helper
.LoggingThread
;
33 import lib
.MultiMethodTest
;
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");
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());
61 throw new StatusException(Status
.failed(
62 "Object relation oSheet is missing"));
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));
90 oSheet
.getCellByPosition(0, 0).setValue(2);
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);
101 log
.println("Operation failed");
103 log
.println("Successful");
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);
116 log
.println("Operation failed");
118 log
.println("Successful");
122 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
123 log
.println("Couldn't set initial version to cell");
127 tRes
.tested("fillAuto()", res
);
130 public void _fillSeries() {
133 log
.println("This method consumes to much time for a complete SpreadSheet");
134 tRes
.tested("fillSeries()",Status
.skipped(true));
141 oSheet
.getCellByPosition(0, 0).setValue(2);
143 LoggingThread logger
= new LoggingThread((LogWriter
)log
, tParam
);
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);
159 log
.println("Operation failed");
161 log
.println("Successful");
166 logger
= new LoggingThread((LogWriter
)log
, tParam
);
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,
175 oSheet
.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
176 getting
= oSheet
.getCellByPosition(0, 4).getValue();
177 locres
= (getting
== 30);
182 log
.println("Operation failed");
184 log
.println("Successful");
189 logger
= new LoggingThread((LogWriter
)log
, tParam
);
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);
204 log
.println("Operation failed");
206 log
.println("Successful");
211 logger
= new LoggingThread((LogWriter
)log
, tParam
);
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,
220 oSheet
.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
221 getting
= oSheet
.getCellByPosition(4, 0).getValue();
222 locres
= (getting
== 30);
227 log
.println("Operation failed");
229 log
.println("Successful");
233 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
234 log
.println("Couldn't set initial version to cell");
238 tRes
.tested("fillSeries()", res
);
242 * Forces environment recreation.
244 public void after() {
245 disposeEnvironment();