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/calc_unoapi_test.hxx>
11 #include <test/container/xenumeration.hxx>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 #include <com/sun/star/container/XEnumerationAccess.hpp>
15 #include <com/sun/star/lang/XComponent.hpp>
16 #include <com/sun/star/sheet/XLabelRanges.hpp>
17 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
18 #include <com/sun/star/table/CellRangeAddress.hpp>
19 #include <com/sun/star/uno/XInterface.hpp>
21 #include <com/sun/star/uno/Any.hxx>
22 #include <com/sun/star/uno/Reference.hxx>
25 using namespace css::uno
;
29 class ScIndexEnumeration_LabelRangesEnumeration
: public CalcUnoApiTest
,
30 public apitest::XEnumeration
33 ScIndexEnumeration_LabelRangesEnumeration();
35 virtual uno::Reference
<uno::XInterface
> init() override
;
36 virtual void setUp() override
;
37 virtual void tearDown() override
;
39 CPPUNIT_TEST_SUITE(ScIndexEnumeration_LabelRangesEnumeration
);
42 CPPUNIT_TEST(testHasMoreElements
);
43 CPPUNIT_TEST(testNextElement
);
45 CPPUNIT_TEST_SUITE_END();
48 uno::Reference
<lang::XComponent
> m_xComponent
;
51 ScIndexEnumeration_LabelRangesEnumeration::ScIndexEnumeration_LabelRangesEnumeration()
52 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
56 uno::Reference
<uno::XInterface
> ScIndexEnumeration_LabelRangesEnumeration::init()
58 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(m_xComponent
, uno::UNO_QUERY_THROW
);
59 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc
.is());
61 uno::Reference
<beans::XPropertySet
> xPropertySet(xDoc
, uno::UNO_QUERY_THROW
);
62 uno::Reference
<sheet::XLabelRanges
> xLR
;
63 CPPUNIT_ASSERT(xPropertySet
->getPropertyValue("ColumnLabelRanges") >>= xLR
);
65 xLR
->addNew(table::CellRangeAddress(0, 0, 1, 0, 6), table::CellRangeAddress(0, 0, 0, 0, 1));
67 uno::Reference
<container::XEnumerationAccess
> xEA(xLR
, uno::UNO_QUERY_THROW
);
69 return xEA
->createEnumeration();
72 void ScIndexEnumeration_LabelRangesEnumeration::setUp()
74 CalcUnoApiTest::setUp();
75 m_xComponent
= loadFromDesktop("private:factory/scalc");
76 CPPUNIT_ASSERT_MESSAGE("no component", m_xComponent
.is());
79 void ScIndexEnumeration_LabelRangesEnumeration::tearDown()
81 closeDocument(m_xComponent
);
82 CalcUnoApiTest::tearDown();
85 CPPUNIT_TEST_SUITE_REGISTRATION(ScIndexEnumeration_LabelRangesEnumeration
);
87 } // namespace sc_apitest
89 CPPUNIT_PLUGIN_IMPLEMENT();
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */