tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / sc / qa / extras / sctablerowsobj.cxx
blobffc9766f7ae034079c9cc726d6ea4480a2718421
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/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>
32 using namespace css;
33 using namespace css::uno;
35 namespace sc_apitest
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
44 public:
45 ScTableRowsObj();
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);
53 // XElementAccess
54 CPPUNIT_TEST(testGetElementType);
55 CPPUNIT_TEST(testHasElements);
57 // XEnumerationAccess
58 CPPUNIT_TEST(testCreateEnumeration);
60 // XIndexAccess
61 CPPUNIT_TEST(testGetByIndex);
62 CPPUNIT_TEST(testGetCount);
64 // XServiceInfo
65 CPPUNIT_TEST(testGetImplementationName);
66 CPPUNIT_TEST(testGetSupportedServiceNames);
67 CPPUNIT_TEST(testSupportsService);
69 // XTableRows
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);
97 return xTR;
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);
111 return xCR;
114 void ScTableRowsObj::setUp()
116 UnoApiTest::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: */