nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scindexenumeration_namedrangesenumeration.cxx
blob2a1b2a8c4ee29a6066109d238290b83df3ac5ab2
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/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/XNamedRanges.hpp>
17 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
18 #include <com/sun/star/table/CellAddress.hpp>
19 #include <com/sun/star/table/CellRangeAddress.hpp>
20 #include <com/sun/star/uno/XInterface.hpp>
22 #include <com/sun/star/uno/Any.hxx>
23 #include <com/sun/star/uno/Reference.hxx>
25 using namespace css;
26 using namespace css::uno;
28 namespace sc_apitest
30 class ScIndexEnumeration_NamedRangesEnumeration : public CalcUnoApiTest,
31 public apitest::XEnumeration
33 public:
34 ScIndexEnumeration_NamedRangesEnumeration();
36 virtual uno::Reference<uno::XInterface> init() override;
37 virtual void setUp() override;
38 virtual void tearDown() override;
40 CPPUNIT_TEST_SUITE(ScIndexEnumeration_NamedRangesEnumeration);
42 // XEnumeration
43 CPPUNIT_TEST(testHasMoreElements);
44 CPPUNIT_TEST(testNextElement);
46 CPPUNIT_TEST_SUITE_END();
48 private:
49 uno::Reference<lang::XComponent> m_xComponent;
52 ScIndexEnumeration_NamedRangesEnumeration::ScIndexEnumeration_NamedRangesEnumeration()
53 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
57 uno::Reference<uno::XInterface> ScIndexEnumeration_NamedRangesEnumeration::init()
59 uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xComponent, uno::UNO_QUERY_THROW);
60 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
62 uno::Reference<beans::XPropertySet> xPropertySet(xDoc, uno::UNO_QUERY_THROW);
63 uno::Reference<sheet::XNamedRanges> xNR;
64 CPPUNIT_ASSERT(xPropertySet->getPropertyValue("NamedRanges") >>= xNR);
66 table::CellRangeAddress aCellRangeAddr(0, 0, 0, 2, 2);
67 table::CellAddress aBaseAddr(aCellRangeAddr.Sheet, aCellRangeAddr.StartColumn,
68 aCellRangeAddr.StartRow);
69 xNR->addNewByName("ANamedRange", "A1:B2", aBaseAddr, 0);
70 xNR->outputList(table::CellAddress(0, 1, 1));
72 uno::Reference<container::XEnumerationAccess> xEA(xNR, uno::UNO_QUERY_THROW);
74 return xEA->createEnumeration();
77 void ScIndexEnumeration_NamedRangesEnumeration::setUp()
79 CalcUnoApiTest::setUp();
80 m_xComponent = loadFromDesktop("private:factory/scalc");
81 CPPUNIT_ASSERT_MESSAGE("no component", m_xComponent.is());
84 void ScIndexEnumeration_NamedRangesEnumeration::tearDown()
86 closeDocument(m_xComponent);
87 CalcUnoApiTest::tearDown();
90 CPPUNIT_TEST_SUITE_REGISTRATION(ScIndexEnumeration_NamedRangesEnumeration);
92 } // namespace sc_apitest
94 CPPUNIT_PLUGIN_IMPLEMENT();
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */