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 com
.sun
.star
.sheet
.XCalculatable
;
21 import com
.sun
.star
.table
.XCell
;
22 import lib
.MultiMethodTest
;
24 import lib
.StatusException
;
29 public class _XCalculatable
extends MultiMethodTest
{
30 public XCalculatable oObj
= null;
31 private boolean bIsAutomaticCalculationEnabled
= false;
32 private XCell
[] xCells
= null;
35 * Get object relation: four cells with values and formulas.
36 * @see mod._sc.ScModelObj
39 public void before() {
40 xCells
= (XCell
[])tEnv
.getObjRelation("XCalculatable.Cells");
41 if (xCells
== null || xCells
.length
!= 3)
42 throw new StatusException(Status
.failed("Couldn't find correct object relation 'XCalculatable.Cells'"));
47 * Restore begin setting
51 // reset to begin value
52 oObj
.enableAutomaticCalculation(bIsAutomaticCalculationEnabled
);
56 public void _calculate() {
57 requiredMethod("isAutomaticCalculationEnabled()");
58 boolean result
= true;
59 double ergValue1
= xCells
[2].getValue();
60 double sourceValue1
= xCells
[0].getValue();
61 xCells
[0].setValue(sourceValue1
+1);
62 double ergValue2
= xCells
[2].getValue();
63 result
&= ergValue1
== ergValue2
;
65 ergValue2
= xCells
[2].getValue();
66 result
&= ergValue1
!= ergValue2
;
67 tRes
.tested("calculate()", result
);
70 public void _calculateAll() {
71 requiredMethod("isAutomaticCalculationEnabled()");
72 boolean result
= true;
73 double ergValue1
= xCells
[2].getValue();
74 double sourceValue1
= xCells
[0].getValue();
75 xCells
[0].setValue(sourceValue1
+1);
76 double ergValue2
= xCells
[2].getValue();
77 result
&= ergValue1
== ergValue2
;
79 ergValue2
= xCells
[2].getValue();
80 result
&= ergValue1
!= ergValue2
;
82 tRes
.tested("calculateAll()", result
);
85 public void _enableAutomaticCalculation() {
86 bIsAutomaticCalculationEnabled
= oObj
.isAutomaticCalculationEnabled();
87 oObj
.enableAutomaticCalculation(!bIsAutomaticCalculationEnabled
);
88 tRes
.tested("enableAutomaticCalculation()", true);
91 public void _isAutomaticCalculationEnabled() {
92 requiredMethod("enableAutomaticCalculation()");
93 boolean result
= oObj
.isAutomaticCalculationEnabled();
94 oObj
.enableAutomaticCalculation(false);
95 tRes
.tested("isAutomaticCalculationEnabled()", result
!= bIsAutomaticCalculationEnabled
);