nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scsubtotalfieldobj.cxx
blob991ee7bed43660a7e6b3faf7f53c9a64208aa871
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;
54 ScSubTotalFieldObj::ScSubTotalFieldObj()
55 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
59 uno::Reference<uno::XInterface> ScSubTotalFieldObj::init()
61 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
63 uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
64 uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
66 uno::Reference<sheet::XSubTotalCalculatable> xSubTotalCalc(xSheet, uno::UNO_QUERY_THROW);
67 uno::Reference<sheet::XSubTotalDescriptor> xSubTotalDesc
68 = 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");
89 void ScSubTotalFieldObj::tearDown()
91 closeDocument(mxComponent);
92 CalcUnoApiTest::tearDown();
95 CPPUNIT_TEST_SUITE_REGISTRATION(ScSubTotalFieldObj);
97 } // end namespace
99 CPPUNIT_PLUGIN_IMPLEMENT();
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */