1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 import helper
.LoggingThread
;
30 import lib
.MultiMethodTest
;
32 import lib
.StatusException
;
34 import com
.sun
.star
.sheet
.XCellSeries
;
35 import com
.sun
.star
.sheet
.XSpreadsheet
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
37 import share
.LogWriter
;
40 public class _XCellSeries
extends MultiMethodTest
{
41 public XCellSeries oObj
= null;
42 protected XSpreadsheet oSheet
= null;
43 protected boolean isSpreadSheet
= false;
44 protected boolean fillAuto
= true;
45 protected boolean forceFillAuto
= false;
48 protected void before() {
49 oSheet
= (XSpreadsheet
) tEnv
.getObjRelation("SHEET");
52 log
.println("Object relation oSheet is missing");
53 log
.println("Trying to query the needed Interface");
54 oSheet
= (XSpreadsheet
) UnoRuntime
.queryInterface(
55 XSpreadsheet
.class, tEnv
.getTestObject());
58 throw new StatusException(Status
.failed(
59 "Object relation oSheet is missing"));
65 Boolean myFillAuto
= (Boolean
) tEnv
.getObjRelation("XCELLSERIES_FILLAUTO");
67 if (myFillAuto
!= null) fillAuto
= myFillAuto
.booleanValue();
69 if (tParam
.containsKey("force_fillauto")){
70 fillAuto
= tParam
.getBool("force_fillauto");
71 forceFillAuto
= tParam
.getBool("force_fillauto");
75 public void _fillAuto() {
77 if ((isSpreadSheet
&& !forceFillAuto
) || !fillAuto
) {
78 log
.println("This method consumes to much time for a complete SpreadSheet");
79 log
.println("Please use parameter '-force_fillauto true' to force this test");
80 tRes
.tested("fillAuto()",Status
.skipped(true));
87 oSheet
.getCellByPosition(0, 0).setValue(2);
90 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1)");
91 oObj
.fillAuto(com
.sun
.star
.sheet
.FillDirection
.TO_RIGHT
, 1);
92 oSheet
.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
94 double getting
= oSheet
.getCellByPosition(0, 4).getValue();
95 boolean locres
= (getting
== 14);
98 log
.println("Operation failed");
100 log
.println("Successful");
106 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1)");
107 oObj
.fillAuto(com
.sun
.star
.sheet
.FillDirection
.TO_BOTTOM
, 1);
108 oSheet
.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
109 getting
= oSheet
.getCellByPosition(4, 0).getValue();
110 locres
= (getting
== 14);
113 log
.println("Operation failed");
115 log
.println("Successful");
119 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
120 log
.println("Couldn't set initial version to cell");
124 tRes
.tested("fillAuto()", res
);
127 public void _fillSeries() {
130 log
.println("This method consumes to much time for a complete SpreadSheet");
131 tRes
.tested("fillSeries()",Status
.skipped(true));
138 oSheet
.getCellByPosition(0, 0).setValue(2);
140 LoggingThread logger
= new LoggingThread((LogWriter
)log
, tParam
);
144 "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)");
145 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_RIGHT
,
146 com
.sun
.star
.sheet
.FillMode
.LINEAR
,
147 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2, 8);
148 oSheet
.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
150 double getting
= oSheet
.getCellByPosition(0, 4).getValue();
151 boolean locres
= (getting
== 20);
156 log
.println("Operation failed");
158 log
.println("Successful");
163 logger
= new LoggingThread((LogWriter
)log
, tParam
);
167 "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)");
168 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_RIGHT
,
169 com
.sun
.star
.sheet
.FillMode
.GROWTH
,
170 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2,
172 oSheet
.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
173 getting
= oSheet
.getCellByPosition(0, 4).getValue();
174 locres
= (getting
== 30);
179 log
.println("Operation failed");
181 log
.println("Successful");
186 logger
= new LoggingThread((LogWriter
)log
, tParam
);
190 "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)");
191 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_BOTTOM
,
192 com
.sun
.star
.sheet
.FillMode
.LINEAR
,
193 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2, 8);
194 oSheet
.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
195 getting
= oSheet
.getCellByPosition(4, 0).getValue();
196 locres
= (getting
== 20);
201 log
.println("Operation failed");
203 log
.println("Successful");
208 logger
= new LoggingThread((LogWriter
)log
, tParam
);
212 "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)");
213 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_BOTTOM
,
214 com
.sun
.star
.sheet
.FillMode
.GROWTH
,
215 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2,
217 oSheet
.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
218 getting
= oSheet
.getCellByPosition(4, 0).getValue();
219 locres
= (getting
== 30);
224 log
.println("Operation failed");
226 log
.println("Successful");
230 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
231 log
.println("Couldn't set initial version to cell");
235 tRes
.tested("fillSeries()", res
);
239 * Forces environment recreation.
241 public void after() {
242 disposeEnvironment();