tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / sc / qa / extras / scsubtotalfieldobj.cxx
blob15e907cc7b6fbd470135e6716cc650c01f05b826
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/unoapi_test.hxx>
11 #include <test/sheet/xsubtotalfield.hxx>
13 #include <com/sun/star/container/XIndexAccess.hpp>
14 #include <com/sun/star/sheet/GeneralFunction.hpp>
15 #include <com/sun/star/sheet/SubTotalColumn.hpp>
16 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
17 #include <com/sun/star/sheet/XSpreadsheet.hpp>
18 #include <com/sun/star/sheet/XSubTotalCalculatable.hpp>
19 #include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
20 #include <com/sun/star/sheet/XSubTotalField.hpp>
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <com/sun/star/uno/XInterface.hpp>
26 using namespace css;
27 using namespace css::uno;
28 using namespace com::sun::star;
30 namespace sc_apitest
32 class ScSubTotalFieldObj : public UnoApiTest, public apitest::XSubTotalField
34 public:
35 ScSubTotalFieldObj();
37 virtual uno::Reference<uno::XInterface> init() override;
38 virtual void setUp() override;
40 CPPUNIT_TEST_SUITE(ScSubTotalFieldObj);
42 // XSubTotalField
43 CPPUNIT_TEST(testGetSetGroupColumn);
44 CPPUNIT_TEST(testGetSetTotalColumns);
46 CPPUNIT_TEST_SUITE_END();
49 ScSubTotalFieldObj::ScSubTotalFieldObj()
50 : UnoApiTest(u"/sc/qa/extras/testdocuments"_ustr)
54 uno::Reference<uno::XInterface> ScSubTotalFieldObj::init()
56 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
58 uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
59 uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
61 uno::Reference<sheet::XSubTotalCalculatable> xSubTotalCalc(xSheet, uno::UNO_QUERY_THROW);
62 uno::Reference<sheet::XSubTotalDescriptor> xSubTotalDesc
63 = xSubTotalCalc->createSubTotalDescriptor(true);
65 uno::Sequence<sheet::SubTotalColumn> xCols{ { /* Column */ 5,
66 /* Function */ sheet::GeneralFunction_SUM } };
67 xSubTotalDesc->addNew(xCols, 1);
69 uno::Reference<container::XIndexAccess> xDescIndex(xSubTotalDesc, uno::UNO_QUERY_THROW);
70 uno::Reference<sheet::XSubTotalField> xSTF(xDescIndex->getByIndex(0), uno::UNO_QUERY_THROW);
72 return xSTF;
75 void ScSubTotalFieldObj::setUp()
77 UnoApiTest::setUp();
78 // create a calc document
79 loadFromURL(u"private:factory/scalc"_ustr);
82 CPPUNIT_TEST_SUITE_REGISTRATION(ScSubTotalFieldObj);
84 } // end namespace
86 CPPUNIT_PLUGIN_IMPLEMENT();
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */