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/unoapi_test.hxx>
11 #include <test/container/xelementaccess.hxx>
12 #include <test/container/xenumerationaccess.hxx>
13 #include <test/container/xindexaccess.hxx>
14 #include <test/lang/xserviceinfo.hxx>
15 #include <test/table/xtablerows.hxx>
17 #include <com/sun/star/container/XNameAccess.hpp>
18 #include <com/sun/star/sheet/XSpreadsheet.hpp>
19 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
20 #include <com/sun/star/sheet/XSpreadsheets.hpp>
21 #include <com/sun/star/table/XCellRange.hpp>
22 #include <com/sun/star/table/XColumnRowRange.hpp>
23 #include <com/sun/star/table/XTableRows.hpp>
24 #include <com/sun/star/uno/XInterface.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
28 #include <cppu/unotype.hxx>
30 #include <sheetlimits.hxx>
33 using namespace css::uno
;
37 class ScTableRowsObj
: public UnoApiTest
,
38 public apitest::XElementAccess
,
39 public apitest::XEnumerationAccess
,
40 public apitest::XIndexAccess
,
41 public apitest::XServiceInfo
,
42 public apitest::XTableRows
47 virtual uno::Reference
<uno::XInterface
> init() override
;
48 virtual uno::Reference
<uno::XInterface
> getXCellRange() override
;
49 virtual void setUp() override
;
51 CPPUNIT_TEST_SUITE(ScTableRowsObj
);
54 CPPUNIT_TEST(testGetElementType
);
55 CPPUNIT_TEST(testHasElements
);
58 CPPUNIT_TEST(testCreateEnumeration
);
61 CPPUNIT_TEST(testGetByIndex
);
62 CPPUNIT_TEST(testGetCount
);
65 CPPUNIT_TEST(testGetImplementationName
);
66 CPPUNIT_TEST(testGetSupportedServiceNames
);
67 CPPUNIT_TEST(testSupportsService
);
70 CPPUNIT_TEST(testInsertByIndex
);
71 CPPUNIT_TEST(testRemoveByIndex
);
73 CPPUNIT_TEST_SUITE_END();
76 ScTableRowsObj::ScTableRowsObj()
77 : UnoApiTest(u
"/sc/qa/extras/testdocuments"_ustr
)
78 , XElementAccess(cppu::UnoType
<table::XCellRange
>::get())
79 , XIndexAccess(ScSheetLimits::CreateDefault().GetMaxRowCount())
80 , XServiceInfo(u
"ScTableRowsObj"_ustr
, u
"com.sun.star.table.TableRows"_ustr
)
84 uno::Reference
<uno::XInterface
> ScTableRowsObj::init()
86 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
87 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc
.is());
89 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), uno::UNO_SET_THROW
);
90 uno::Reference
<container::XNameAccess
> xNA(xSheets
, uno::UNO_QUERY_THROW
);
91 uno::Reference
<sheet::XSpreadsheet
> xSheet0(xSheets
->getByName(xNA
->getElementNames()[0]),
92 uno::UNO_QUERY_THROW
);
94 uno::Reference
<table::XColumnRowRange
> xCRR(xSheet0
, uno::UNO_QUERY_THROW
);
95 uno::Reference
<table::XTableRows
> xTR(xCRR
->getRows(), uno::UNO_SET_THROW
);
100 uno::Reference
<uno::XInterface
> ScTableRowsObj::getXCellRange()
102 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
103 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc
.is());
105 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), uno::UNO_SET_THROW
);
106 uno::Reference
<container::XNameAccess
> xNA(xSheets
, uno::UNO_QUERY_THROW
);
107 uno::Reference
<sheet::XSpreadsheet
> xSheet0(xSheets
->getByName(xNA
->getElementNames()[0]),
108 uno::UNO_QUERY_THROW
);
110 uno::Reference
<table::XCellRange
> xCR(xSheet0
, uno::UNO_QUERY_THROW
);
114 void ScTableRowsObj::setUp()
117 loadFromURL(u
"private:factory/scalc"_ustr
);
120 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableRowsObj
);
121 } // namespace sc_apitest
123 CPPUNIT_PLUGIN_IMPLEMENT();
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */