1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <test/calc_unoapi_test.hxx>
11 #include <test/sheet/xsubtotalfield.hxx>
13 #include <com/sun/star/container/XIndexAccess.hpp>
14 #include <com/sun/star/lang/XComponent.hpp>
15 #include <com/sun/star/sheet/GeneralFunction.hpp>
16 #include <com/sun/star/sheet/SubTotalColumn.hpp>
17 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
18 #include <com/sun/star/sheet/XSpreadsheet.hpp>
19 #include <com/sun/star/sheet/XSubTotalCalculatable.hpp>
20 #include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
21 #include <com/sun/star/sheet/XSubTotalField.hpp>
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/uno/Sequence.hxx>
25 #include <com/sun/star/uno/XInterface.hpp>
28 using namespace css::uno
;
29 using namespace com::sun::star
;
31 namespace sc_apitest
{
33 class ScSubTotalFieldObj
: public CalcUnoApiTest
, public apitest::XSubTotalField
38 virtual uno::Reference
< uno::XInterface
> init() override
;
39 virtual void setUp() override
;
40 virtual void tearDown() override
;
42 CPPUNIT_TEST_SUITE(ScSubTotalFieldObj
);
45 CPPUNIT_TEST(testGetSetGroupColumn
);
46 CPPUNIT_TEST(testGetSetTotalColumns
);
48 CPPUNIT_TEST_SUITE_END();
51 uno::Reference
< lang::XComponent
> mxComponent
;
55 ScSubTotalFieldObj::ScSubTotalFieldObj()
56 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
60 uno::Reference
< uno::XInterface
> ScSubTotalFieldObj::init()
62 uno::Reference
< sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
64 uno::Reference
< container::XIndexAccess
> xIndex(xDoc
->getSheets(), uno::UNO_QUERY_THROW
);
65 uno::Reference
< sheet::XSpreadsheet
> xSheet(xIndex
->getByIndex(0), uno::UNO_QUERY_THROW
);
67 uno::Reference
< sheet::XSubTotalCalculatable
> xSubTotalCalc(xSheet
, uno::UNO_QUERY_THROW
);
68 uno::Reference
< sheet::XSubTotalDescriptor
> xSubTotalDesc
= xSubTotalCalc
->createSubTotalDescriptor(true);
70 uno::Sequence
< sheet::SubTotalColumn
> xCols
;
73 xCols
[0].Function
= sheet::GeneralFunction_SUM
;
74 xSubTotalDesc
->addNew(xCols
, 1);
76 uno::Reference
< container::XIndexAccess
> xDescIndex(xSubTotalDesc
, uno::UNO_QUERY_THROW
);
77 uno::Reference
< sheet::XSubTotalField
> xSTF(xDescIndex
->getByIndex(0), uno::UNO_QUERY_THROW
);
82 void ScSubTotalFieldObj::setUp()
84 CalcUnoApiTest::setUp();
85 // create a calc document
86 mxComponent
= loadFromDesktop("private:factory/scalc");
90 void ScSubTotalFieldObj::tearDown()
92 closeDocument(mxComponent
);
93 CalcUnoApiTest::tearDown();
96 CPPUNIT_TEST_SUITE_REGISTRATION(ScSubTotalFieldObj
);
100 CPPUNIT_PLUGIN_IMPLEMENT();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */