nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / sccellsenumeration.cxx
blob1ea47e6f208e18e6f3cef014bba3884a1a72c15a
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/calc_unoapi_test.hxx>
11 #include <test/container/xenumeration.hxx>
13 #include <com/sun/star/container/XEnumerationAccess.hpp>
14 #include <com/sun/star/container/XIndexAccess.hpp>
15 #include <com/sun/star/lang/XComponent.hpp>
16 #include <com/sun/star/sheet/XCellRangesQuery.hpp>
17 #include <com/sun/star/sheet/XSheetCellRanges.hpp>
18 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
19 #include <com/sun/star/sheet/XSpreadsheets.hpp>
20 #include <com/sun/star/table/XCell.hpp>
21 #include <com/sun/star/table/XCellRange.hpp>
22 #include <com/sun/star/text/XTextRange.hpp>
23 #include <com/sun/star/uno/XInterface.hpp>
25 #include <com/sun/star/uno/Reference.hxx>
27 using namespace css;
28 using namespace css::uno;
30 namespace sc_apitest
32 class ScCellsEnumeration : public CalcUnoApiTest, public apitest::XEnumeration
34 public:
35 ScCellsEnumeration();
37 virtual uno::Reference<uno::XInterface> init() override;
38 virtual void setUp() override;
39 virtual void tearDown() override;
41 CPPUNIT_TEST_SUITE(ScCellsEnumeration);
43 // XEnumeration
44 CPPUNIT_TEST(testHasMoreElements);
45 CPPUNIT_TEST(testNextElement);
47 CPPUNIT_TEST_SUITE_END();
49 private:
50 uno::Reference<lang::XComponent> m_xComponent;
53 ScCellsEnumeration::ScCellsEnumeration()
54 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
58 uno::Reference<uno::XInterface> ScCellsEnumeration::init()
60 uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xComponent, uno::UNO_QUERY_THROW);
61 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
63 uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), uno::UNO_SET_THROW);
64 uno::Reference<container::XIndexAccess> xIA(xSheets, uno::UNO_QUERY_THROW);
66 uno::Reference<table::XCellRange> xCellRange(xIA->getByIndex(0), uno::UNO_QUERY_THROW);
67 uno::Reference<table::XCell> xCell0(xCellRange->getCellByPosition(0, 0), uno::UNO_SET_THROW);
68 uno::Reference<text::XTextRange> xTextRange0(xCell0, uno::UNO_QUERY_THROW);
69 xTextRange0->setString("Test string 1");
71 uno::Reference<table::XCell> xCell1(xCellRange->getCellByPosition(5, 1), uno::UNO_SET_THROW);
72 xCell1->setValue(15);
74 uno::Reference<table::XCell> xCell2(xCellRange->getCellByPosition(3, 9), uno::UNO_SET_THROW);
75 uno::Reference<text::XTextRange> xTextRange1(xCell2, uno::UNO_QUERY_THROW);
76 xTextRange1->setString("Test string 2");
78 uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(xCellRange, uno::UNO_QUERY_THROW);
79 uno::Reference<sheet::XSheetCellRanges> xSCR(xCellRangesQuery->queryVisibleCells(),
80 uno::UNO_SET_THROW);
82 return xSCR->getCells()->createEnumeration();
85 void ScCellsEnumeration::setUp()
87 CalcUnoApiTest::setUp();
88 m_xComponent = loadFromDesktop("private:factory/scalc");
89 CPPUNIT_ASSERT_MESSAGE("no component", m_xComponent.is());
92 void ScCellsEnumeration::tearDown()
94 closeDocument(m_xComponent);
95 CalcUnoApiTest::tearDown();
98 CPPUNIT_TEST_SUITE_REGISTRATION(ScCellsEnumeration);
100 } // namespace sc_apitest
102 CPPUNIT_PLUGIN_IMPLEMENT();
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */