12#include <com/sun/star/sheet/XCalculatable.hpp>
13#include <com/sun/star/table/XCell.hpp>
15#include <com/sun/star/uno/Reference.hxx>
16#include <com/sun/star/uno/Sequence.hxx>
18#include <cppunit/TestAssert.h>
27 uno::Reference<sheet::XCalculatable> xCalculatable(
init(), UNO_QUERY_THROW);
29 bool bIsAutomaticCalculationEnabled = xCalculatable->isAutomaticCalculationEnabled();
30 xCalculatable->enableAutomaticCalculation(!bIsAutomaticCalculationEnabled);
31 bool bIsAutomaticCalculationEnabledNew = xCalculatable->isAutomaticCalculationEnabled();
32 CPPUNIT_ASSERT_MESSAGE(
"Unable to set enableAutomaticCalculation()",
33 bIsAutomaticCalculationEnabled != bIsAutomaticCalculationEnabledNew);
38 uno::Reference<sheet::XCalculatable> xCalculatable(
init(), UNO_QUERY_THROW);
39 xCalculatable->enableAutomaticCalculation(
false);
41 uno::Sequence<uno::Reference<table::XCell>> xCells =
getXCells();
43 double dProduct = xCells[2]->getValue();
44 double dFactor1 = xCells[0]->getValue();
45 xCells[0]->setValue(dFactor1 + 1.0);
46 double dProduct2 = xCells[2]->getValue();
47 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
"Calculated products are equal", dProduct, dProduct2, 0.5);
49 xCalculatable->calculate();
50 dProduct2 = xCells[2]->getValue();
51 CPPUNIT_ASSERT_MESSAGE(
"Calculated products are not equal", dProduct != dProduct2);
56 uno::Reference<sheet::XCalculatable> xCalculatable(
init(), UNO_QUERY_THROW);
57 xCalculatable->enableAutomaticCalculation(
false);
59 uno::Sequence<uno::Reference<table::XCell>> xCells =
getXCells();
61 double dProduct = xCells[2]->getValue();
62 double dFactor1 = xCells[0]->getValue();
63 xCells[0]->setValue(dFactor1 + 1.0);
64 double dProduct2 = xCells[2]->getValue();
65 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
"Calculated products are equal", dProduct, dProduct2, 0.5);
67 xCalculatable->calculateAll();
68 dProduct2 = xCells[2]->getValue();
69 CPPUNIT_ASSERT_MESSAGE(
"Calculated products are not equal", dProduct != dProduct2);
70 xCalculatable->calculateAll();
virtual css::uno::Reference< css::uno::XInterface > init()=0
void testEnableAutomaticCalculation()
virtual css::uno::Sequence< css::uno::Reference< css::table::XCell > > getXCells()=0