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/lang/XComponent.hpp>
19 #include <com/sun/star/sheet/XSpreadsheet.hpp>
20 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
21 #include <com/sun/star/sheet/XSpreadsheets.hpp>
22 #include <com/sun/star/table/XCellRange.hpp>
23 #include <com/sun/star/table/XColumnRowRange.hpp>
24 #include <com/sun/star/table/XTableRows.hpp>
25 #include <com/sun/star/uno/XInterface.hpp>
27 #include <com/sun/star/uno/Reference.hxx>
29 #include <cppu/unotype.hxx>
31 #include <sheetlimits.hxx>
34 using namespace css::uno
;
38 class ScTableRowsObj
: public UnoApiTest
,
39 public apitest::XElementAccess
,
40 public apitest::XEnumerationAccess
,
41 public apitest::XIndexAccess
,
42 public apitest::XServiceInfo
,
43 public apitest::XTableRows
48 virtual uno::Reference
<uno::XInterface
> init() override
;
49 virtual uno::Reference
<uno::XInterface
> getXCellRange() override
;
50 virtual void setUp() override
;
52 CPPUNIT_TEST_SUITE(ScTableRowsObj
);
55 CPPUNIT_TEST(testGetElementType
);
56 CPPUNIT_TEST(testHasElements
);
59 CPPUNIT_TEST(testCreateEnumeration
);
62 CPPUNIT_TEST(testGetByIndex
);
63 CPPUNIT_TEST(testGetCount
);
66 CPPUNIT_TEST(testGetImplementationName
);
67 CPPUNIT_TEST(testGetSupportedServiceNames
);
68 CPPUNIT_TEST(testSupportsService
);
71 CPPUNIT_TEST(testInsertByIndex
);
72 CPPUNIT_TEST(testRemoveByIndex
);
74 CPPUNIT_TEST_SUITE_END();
77 ScTableRowsObj::ScTableRowsObj()
78 : UnoApiTest("/sc/qa/extras/testdocuments")
79 , XElementAccess(cppu::UnoType
<table::XCellRange
>::get())
80 , XIndexAccess(ScSheetLimits::CreateDefault().GetMaxRowCount())
81 , XServiceInfo("ScTableRowsObj", "com.sun.star.table.TableRows")
85 uno::Reference
<uno::XInterface
> ScTableRowsObj::init()
87 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
88 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc
.is());
90 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), uno::UNO_SET_THROW
);
91 uno::Reference
<container::XNameAccess
> xNA(xSheets
, uno::UNO_QUERY_THROW
);
92 uno::Reference
<sheet::XSpreadsheet
> xSheet0(xSheets
->getByName(xNA
->getElementNames()[0]),
93 uno::UNO_QUERY_THROW
);
95 uno::Reference
<table::XColumnRowRange
> xCRR(xSheet0
, uno::UNO_QUERY_THROW
);
96 uno::Reference
<table::XTableRows
> xTR(xCRR
->getRows(), uno::UNO_SET_THROW
);
101 uno::Reference
<uno::XInterface
> ScTableRowsObj::getXCellRange()
103 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
104 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc
.is());
106 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), uno::UNO_SET_THROW
);
107 uno::Reference
<container::XNameAccess
> xNA(xSheets
, uno::UNO_QUERY_THROW
);
108 uno::Reference
<sheet::XSpreadsheet
> xSheet0(xSheets
->getByName(xNA
->getElementNames()[0]),
109 uno::UNO_QUERY_THROW
);
111 uno::Reference
<table::XCellRange
> xCR(xSheet0
, uno::UNO_QUERY_THROW
);
115 void ScTableRowsObj::setUp()
118 mxComponent
= loadFromDesktop("private:factory/scalc");
121 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableRowsObj
);
122 } // namespace sc_apitest
124 CPPUNIT_PLUGIN_IMPLEMENT();
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */