Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / qa / extras / scsubtotalfieldobj.cxx
blob2667f28a40984ffba4337dacc103dbc9cbda6b75
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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/.
8 */
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>
27 using namespace css;
28 using namespace css::uno;
29 using namespace com::sun::star;
31 namespace sc_apitest {
33 class ScSubTotalFieldObj : public CalcUnoApiTest, public apitest::XSubTotalField
35 public:
36 ScSubTotalFieldObj();
38 virtual uno::Reference< uno::XInterface > init() override;
39 virtual void setUp() override;
40 virtual void tearDown() override;
42 CPPUNIT_TEST_SUITE(ScSubTotalFieldObj);
44 // XSubTotalField
45 CPPUNIT_TEST(testGetSetGroupColumn);
46 CPPUNIT_TEST(testGetSetTotalColumns);
48 CPPUNIT_TEST_SUITE_END();
50 private:
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;
71 xCols.realloc(1);
72 xCols[0].Column = 5;
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);
79 return xSTF;
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);
98 } // end namespace
100 CPPUNIT_PLUGIN_IMPLEMENT();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */