2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 import helper
.LoggingThread
;
21 import lib
.MultiMethodTest
;
23 import lib
.StatusException
;
25 import com
.sun
.star
.sheet
.XCellSeries
;
26 import com
.sun
.star
.sheet
.XSpreadsheet
;
27 import com
.sun
.star
.uno
.UnoRuntime
;
28 import share
.LogWriter
;
31 public class _XCellSeries
extends MultiMethodTest
{
32 public XCellSeries oObj
= null;
33 protected XSpreadsheet oSheet
= null;
34 protected boolean isSpreadSheet
= false;
35 protected boolean fillAuto
= true;
36 protected boolean forceFillAuto
= false;
39 protected void before() {
40 oSheet
= (XSpreadsheet
) tEnv
.getObjRelation("SHEET");
43 log
.println("Object relation oSheet is missing");
44 log
.println("Trying to query the needed Interface");
45 oSheet
= UnoRuntime
.queryInterface(
46 XSpreadsheet
.class, tEnv
.getTestObject());
49 throw new StatusException(Status
.failed(
50 "Object relation oSheet is missing"));
56 Boolean myFillAuto
= (Boolean
) tEnv
.getObjRelation("XCELLSERIES_FILLAUTO");
58 if (myFillAuto
!= null) fillAuto
= myFillAuto
.booleanValue();
60 if (tParam
.containsKey("force_fillauto")){
61 fillAuto
= tParam
.getBool("force_fillauto");
62 forceFillAuto
= tParam
.getBool("force_fillauto");
66 public void _fillAuto() {
68 if ((isSpreadSheet
&& !forceFillAuto
) || !fillAuto
) {
69 log
.println("This method consumes to much time for a complete SpreadSheet");
70 log
.println("Please use parameter '-force_fillauto true' to force this test");
71 tRes
.tested("fillAuto()",Status
.skipped(true));
78 oSheet
.getCellByPosition(0, 0).setValue(2);
81 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1)");
82 oObj
.fillAuto(com
.sun
.star
.sheet
.FillDirection
.TO_RIGHT
, 1);
83 oSheet
.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
85 double getting
= oSheet
.getCellByPosition(0, 4).getValue();
86 boolean locres
= (getting
== 14);
89 log
.println("Operation failed");
91 log
.println("Successful");
97 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1)");
98 oObj
.fillAuto(com
.sun
.star
.sheet
.FillDirection
.TO_BOTTOM
, 1);
99 oSheet
.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
100 getting
= oSheet
.getCellByPosition(4, 0).getValue();
101 locres
= (getting
== 14);
104 log
.println("Operation failed");
106 log
.println("Successful");
110 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
111 log
.println("Couldn't set initial version to cell");
115 tRes
.tested("fillAuto()", res
);
118 public void _fillSeries() {
121 log
.println("This method consumes to much time for a complete SpreadSheet");
122 tRes
.tested("fillSeries()",Status
.skipped(true));
129 oSheet
.getCellByPosition(0, 0).setValue(2);
131 LoggingThread logger
= new LoggingThread((LogWriter
)log
, tParam
);
135 "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)");
136 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_RIGHT
,
137 com
.sun
.star
.sheet
.FillMode
.LINEAR
,
138 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2, 8);
139 oSheet
.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
141 double getting
= oSheet
.getCellByPosition(0, 4).getValue();
142 boolean locres
= (getting
== 20);
147 log
.println("Operation failed");
149 log
.println("Successful");
154 logger
= new LoggingThread((LogWriter
)log
, tParam
);
158 "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)");
159 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_RIGHT
,
160 com
.sun
.star
.sheet
.FillMode
.GROWTH
,
161 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2,
163 oSheet
.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
164 getting
= oSheet
.getCellByPosition(0, 4).getValue();
165 locres
= (getting
== 30);
170 log
.println("Operation failed");
172 log
.println("Successful");
177 logger
= new LoggingThread((LogWriter
)log
, tParam
);
181 "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)");
182 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_BOTTOM
,
183 com
.sun
.star
.sheet
.FillMode
.LINEAR
,
184 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2, 8);
185 oSheet
.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
186 getting
= oSheet
.getCellByPosition(4, 0).getValue();
187 locres
= (getting
== 20);
192 log
.println("Operation failed");
194 log
.println("Successful");
199 logger
= new LoggingThread((LogWriter
)log
, tParam
);
203 "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)");
204 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_BOTTOM
,
205 com
.sun
.star
.sheet
.FillMode
.GROWTH
,
206 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2,
208 oSheet
.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
209 getting
= oSheet
.getCellByPosition(4, 0).getValue();
210 locres
= (getting
== 30);
215 log
.println("Operation failed");
217 log
.println("Successful");
221 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
222 log
.println("Couldn't set initial version to cell");
226 tRes
.tested("fillSeries()", res
);
230 * Forces environment recreation.
232 public void after() {
233 disposeEnvironment();