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;
40 protected void before() {
41 oSheet
= (XSpreadsheet
) tEnv
.getObjRelation("SHEET");
44 log
.println("Object relation oSheet is missing");
45 log
.println("Trying to query the needed Interface");
46 oSheet
= UnoRuntime
.queryInterface(
47 XSpreadsheet
.class, tEnv
.getTestObject());
50 throw new StatusException(Status
.failed(
51 "Object relation oSheet is missing"));
57 Boolean myFillAuto
= (Boolean
) tEnv
.getObjRelation("XCELLSERIES_FILLAUTO");
59 if (myFillAuto
!= null) fillAuto
= myFillAuto
.booleanValue();
61 if (tParam
.containsKey("force_fillauto")){
62 fillAuto
= tParam
.getBool("force_fillauto");
63 forceFillAuto
= tParam
.getBool("force_fillauto");
67 public void _fillAuto() {
69 if ((isSpreadSheet
&& !forceFillAuto
) || !fillAuto
) {
70 log
.println("This method consumes to much time for a complete SpreadSheet");
71 log
.println("Please use parameter '-force_fillauto true' to force this test");
72 tRes
.tested("fillAuto()",Status
.skipped(true));
79 oSheet
.getCellByPosition(0, 0).setValue(2);
82 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1)");
83 oObj
.fillAuto(com
.sun
.star
.sheet
.FillDirection
.TO_RIGHT
, 1);
84 oSheet
.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
86 double getting
= oSheet
.getCellByPosition(0, 4).getValue();
87 boolean locres
= (getting
== 14);
90 log
.println("Operation failed");
92 log
.println("Successful");
98 "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1)");
99 oObj
.fillAuto(com
.sun
.star
.sheet
.FillDirection
.TO_BOTTOM
, 1);
100 oSheet
.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
101 getting
= oSheet
.getCellByPosition(4, 0).getValue();
102 locres
= (getting
== 14);
105 log
.println("Operation failed");
107 log
.println("Successful");
111 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
112 log
.println("Couldn't set initial version to cell");
116 tRes
.tested("fillAuto()", res
);
119 public void _fillSeries() {
122 log
.println("This method consumes to much time for a complete SpreadSheet");
123 tRes
.tested("fillSeries()",Status
.skipped(true));
130 oSheet
.getCellByPosition(0, 0).setValue(2);
132 LoggingThread logger
= new LoggingThread((LogWriter
)log
, tParam
);
136 "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)");
137 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_RIGHT
,
138 com
.sun
.star
.sheet
.FillMode
.LINEAR
,
139 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2, 8);
140 oSheet
.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
142 double getting
= oSheet
.getCellByPosition(0, 4).getValue();
143 boolean locres
= (getting
== 20);
148 log
.println("Operation failed");
150 log
.println("Successful");
155 logger
= new LoggingThread((LogWriter
)log
, tParam
);
159 "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)");
160 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_RIGHT
,
161 com
.sun
.star
.sheet
.FillMode
.GROWTH
,
162 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2,
164 oSheet
.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
165 getting
= oSheet
.getCellByPosition(0, 4).getValue();
166 locres
= (getting
== 30);
171 log
.println("Operation failed");
173 log
.println("Successful");
178 logger
= new LoggingThread((LogWriter
)log
, tParam
);
182 "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)");
183 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_BOTTOM
,
184 com
.sun
.star
.sheet
.FillMode
.LINEAR
,
185 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2, 8);
186 oSheet
.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
187 getting
= oSheet
.getCellByPosition(4, 0).getValue();
188 locres
= (getting
== 20);
193 log
.println("Operation failed");
195 log
.println("Successful");
200 logger
= new LoggingThread((LogWriter
)log
, tParam
);
204 "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)");
205 oObj
.fillSeries(com
.sun
.star
.sheet
.FillDirection
.TO_BOTTOM
,
206 com
.sun
.star
.sheet
.FillMode
.GROWTH
,
207 com
.sun
.star
.sheet
.FillDateMode
.FILL_DATE_DAY
, 2,
209 oSheet
.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
210 getting
= oSheet
.getCellByPosition(4, 0).getValue();
211 locres
= (getting
== 30);
216 log
.println("Operation failed");
218 log
.println("Successful");
222 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
223 log
.println("Couldn't set initial version to cell");
227 tRes
.tested("fillSeries()", res
);
231 * Forces environment recreation.
234 public void after() {
235 disposeEnvironment();