12#include <com/sun/star/sheet/GeneralFunction.hpp>
13#include <com/sun/star/sheet/SubTotalColumn.hpp>
14#include <com/sun/star/sheet/XSpreadsheet.hpp>
15#include <com/sun/star/sheet/XSubTotalCalculatable.hpp>
16#include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
18#include <com/sun/star/uno/Reference.hxx>
19#include <com/sun/star/uno/Sequence.hxx>
21#include <cppunit/TestAssert.h>
30 uno::Reference< sheet::XSubTotalCalculatable > xSTC(
init(), uno::UNO_QUERY_THROW);
31 uno::Reference< sheet::XSubTotalDescriptor > xSTD = xSTC->createSubTotalDescriptor(
true);
33 uno::Sequence< sheet::SubTotalColumn > xCols{ { 5,
34 sheet::GeneralFunction_SUM } };
36 CPPUNIT_ASSERT_NO_THROW_MESSAGE(
"Unable to create XSubTotalDescriptor", xSTD->addNew(xCols, 1));
41 uno::Reference< sheet::XSpreadsheet > xSheet(
getXSpreadsheet(), UNO_QUERY_THROW);
42 uno::Reference< sheet::XSubTotalCalculatable > xSTC(xSheet, UNO_QUERY_THROW);
44 uno::Reference< sheet::XSubTotalDescriptor > xSTD = xSTC->createSubTotalDescriptor(
true);
45 uno::Sequence< sheet::SubTotalColumn > xCols{ { 0,
46 sheet::GeneralFunction_SUM } };
47 xSTD->addNew(xCols, 1);
49 xSheet->getCellByPosition(0, 0)->setFormula(
"first");
50 xSheet->getCellByPosition(1, 0)->setFormula(
"second");
51 xSheet->getCellByPosition(0, 3)->setFormula(
"");
52 xSheet->getCellByPosition(0, 1)->setValue(5);
53 xSheet->getCellByPosition(0, 2)->setValue(5);
54 xSheet->getCellByPosition(1, 1)->setValue(17);
55 xSheet->getCellByPosition(1, 2)->setValue(17);
57 xSTC->applySubTotals(xSTD,
true);
58 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to apply SubTotals",
59 OUString(
"=SUBTOTAL(9;$A$2:$A$3)"),
60 xSheet->getCellByPosition(0, 3)->getFormula());
62 xSTC->removeSubTotals();
63 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to remove SubTotals",
65 xSheet->getCellByPosition(0, 3)->getFormula());
void testApplyRemoveSubTotals()
void testCreateSubTotalDescriptor()
virtual css::uno::Reference< css::uno::XInterface > getXSpreadsheet()=0
virtual css::uno::Reference< css::uno::XInterface > init()=0