Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / sheet / _XCalculatable.java
blobfb20993d4d6980929175357b51fe90cb741c924a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XCalculatable.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
30 package ifc.sheet;
32 import com.sun.star.sheet.XCalculatable;
33 import com.sun.star.table.XCell;
34 import lib.MultiMethodTest;
35 import lib.Status;
36 import lib.StatusException;
38 /**
41 public class _XCalculatable extends MultiMethodTest {
42 public XCalculatable oObj = null;
43 private boolean bIsAutomaticCalculationEnabled = false;
44 private XCell[] xCells = null;
46 /**
47 * Get object relation: four cells with values and formulas.
48 * @see mod._sc.ScModelObj
50 public void before() {
51 xCells = (XCell[])tEnv.getObjRelation("XCalculatable.Cells");
52 if (xCells == null || xCells.length != 3)
53 throw new StatusException(Status.failed("Couldn't find correct object relation 'XCalculatable.Cells'"));
57 /**
58 * Restore begin setting
60 public void after() {
61 // reset to begin value
62 oObj.enableAutomaticCalculation(bIsAutomaticCalculationEnabled);
66 public void _calculate() {
67 requiredMethod("isAutomaticCalculationEnabled()");
68 boolean result = true;
69 double ergValue1 = xCells[2].getValue();
70 double sourceValue1 = xCells[0].getValue();
71 xCells[0].setValue(sourceValue1 +1);
72 double ergValue2 = xCells[2].getValue();
73 result &= ergValue1 == ergValue2;
74 oObj.calculate();
75 ergValue2 = xCells[2].getValue();
76 result &= ergValue1 != ergValue2;
77 tRes.tested("calculate()", result);
80 public void _calculateAll() {
81 requiredMethod("isAutomaticCalculationEnabled()");
82 boolean result = true;
83 double ergValue1 = xCells[2].getValue();
84 double sourceValue1 = xCells[0].getValue();
85 xCells[0].setValue(sourceValue1 +1);
86 double ergValue2 = xCells[2].getValue();
87 result &= ergValue1 == ergValue2;
88 oObj.calculateAll();
89 ergValue2 = xCells[2].getValue();
90 result &= ergValue1 != ergValue2;
91 oObj.calculateAll();
92 tRes.tested("calculateAll()", result);
95 public void _enableAutomaticCalculation() {
96 bIsAutomaticCalculationEnabled = oObj.isAutomaticCalculationEnabled();
97 oObj.enableAutomaticCalculation(!bIsAutomaticCalculationEnabled);
98 tRes.tested("enableAutomaticCalculation()", true);
101 public void _isAutomaticCalculationEnabled() {
102 requiredMethod("enableAutomaticCalculation()");
103 boolean result = oObj.isAutomaticCalculationEnabled();
104 oObj.enableAutomaticCalculation(false);
105 tRes.tested("isAutomaticCalculationEnabled()", result != bIsAutomaticCalculationEnabled);