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/xenumeration.hxx>
13 #include <com/sun/star/container/XEnumerationAccess.hpp>
14 #include <com/sun/star/container/XNameAccess.hpp>
15 #include <com/sun/star/sheet/XSpreadsheet.hpp>
16 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
17 #include <com/sun/star/sheet/XSpreadsheets.hpp>
18 #include <com/sun/star/table/XCellRange.hpp>
19 #include <com/sun/star/table/XColumnRowRange.hpp>
20 #include <com/sun/star/table/XTableRows.hpp>
21 #include <com/sun/star/uno/XInterface.hpp>
23 #include <com/sun/star/uno/Reference.hxx>
26 using namespace css::uno
;
30 class ScIndexEnumeration_TableRowsEnumeration
: public UnoApiTest
, public apitest::XEnumeration
33 ScIndexEnumeration_TableRowsEnumeration();
35 virtual uno::Reference
<uno::XInterface
> init() override
;
36 virtual void setUp() override
;
38 CPPUNIT_TEST_SUITE(ScIndexEnumeration_TableRowsEnumeration
);
41 CPPUNIT_TEST(testHasMoreElements
);
42 CPPUNIT_TEST(testNextElement
);
44 CPPUNIT_TEST_SUITE_END();
47 ScIndexEnumeration_TableRowsEnumeration::ScIndexEnumeration_TableRowsEnumeration()
48 : UnoApiTest(u
"/sc/qa/extras/testdocuments"_ustr
)
52 uno::Reference
<uno::XInterface
> ScIndexEnumeration_TableRowsEnumeration::init()
54 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
55 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc
.is());
57 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), uno::UNO_SET_THROW
);
58 uno::Reference
<container::XNameAccess
> xNA(xSheets
, uno::UNO_QUERY_THROW
);
59 uno::Reference
<sheet::XSpreadsheet
> xSheet0(xNA
->getByName(xNA
->getElementNames()[0]),
60 uno::UNO_QUERY_THROW
);
62 // limit the range the XEnumeration has to walk over (see fdo#45337).
63 uno::Reference
<table::XCellRange
> xCR(xSheet0
->getCellRangeByName(u
"A1:A4"_ustr
),
66 uno::Reference
<table::XColumnRowRange
> xColRowRange(xCR
, uno::UNO_QUERY_THROW
);
67 uno::Reference
<table::XTableRows
> xTableRows(xColRowRange
->getRows(), uno::UNO_SET_THROW
);
68 uno::Reference
<container::XEnumerationAccess
> xEA(xTableRows
, uno::UNO_QUERY_THROW
);
70 return xEA
->createEnumeration();
73 void ScIndexEnumeration_TableRowsEnumeration::setUp()
76 loadFromURL(u
"private:factory/scalc"_ustr
);
79 CPPUNIT_TEST_SUITE_REGISTRATION(ScIndexEnumeration_TableRowsEnumeration
);
81 } // namespace sc_apitest
83 CPPUNIT_PLUGIN_IMPLEMENT();
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */