nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scindexenumeration_sheetlinksenumeration.cxx
blobb68f540c2d489c7893da91ee92336315b4714eef
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/container/XIndexAccess.hpp>
16 #include <com/sun/star/container/XNameAccess.hpp>
17 #include <com/sun/star/lang/XComponent.hpp>
18 #include <com/sun/star/sheet/SheetLinkMode.hpp>
19 #include <com/sun/star/sheet/XSheetLinkable.hpp>
20 #include <com/sun/star/sheet/XSpreadsheet.hpp>
21 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
22 #include <com/sun/star/sheet/XSpreadsheets.hpp>
23 #include <com/sun/star/uno/XInterface.hpp>
25 #include <com/sun/star/uno/Any.hxx>
26 #include <com/sun/star/uno/Reference.hxx>
28 using namespace css;
29 using namespace css::uno;
31 namespace sc_apitest
33 class ScIndexEnumeration_SheetLinksEnumeration : public CalcUnoApiTest, public apitest::XEnumeration
35 public:
36 ScIndexEnumeration_SheetLinksEnumeration();
38 virtual uno::Reference<uno::XInterface> init() override;
39 virtual void setUp() override;
40 virtual void tearDown() override;
42 CPPUNIT_TEST_SUITE(ScIndexEnumeration_SheetLinksEnumeration);
44 // XEnumeration
45 CPPUNIT_TEST(testHasMoreElements);
46 CPPUNIT_TEST(testNextElement);
48 CPPUNIT_TEST_SUITE_END();
50 private:
51 uno::Reference<lang::XComponent> m_xComponent;
54 ScIndexEnumeration_SheetLinksEnumeration::ScIndexEnumeration_SheetLinksEnumeration()
55 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
59 uno::Reference<uno::XInterface> ScIndexEnumeration_SheetLinksEnumeration::init()
61 uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xComponent, uno::UNO_QUERY_THROW);
62 CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
64 uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), uno::UNO_SET_THROW);
65 uno::Reference<container::XIndexAccess> xIA(xSheets, uno::UNO_QUERY_THROW);
66 uno::Reference<sheet::XSpreadsheet> xSheet0(xIA->getByIndex(0), uno::UNO_QUERY_THROW);
68 uno::Reference<sheet::XSheetLinkable> xSL(xSheet0, uno::UNO_QUERY_THROW);
69 xSL->link("ScIndexEnumeration_SheetLinksEnumeration.ods", "Sheet1", "", "",
70 sheet::SheetLinkMode_VALUE);
72 uno::Reference<beans::XPropertySet> xPropertySet(xDoc, uno::UNO_QUERY_THROW);
73 uno::Reference<container::XNameAccess> xSheetLinks;
74 CPPUNIT_ASSERT(xPropertySet->getPropertyValue("SheetLinks") >>= xSheetLinks);
76 uno::Reference<container::XEnumerationAccess> xEA(xSheetLinks, uno::UNO_QUERY_THROW);
78 return xEA->createEnumeration();
81 void ScIndexEnumeration_SheetLinksEnumeration::setUp()
83 CalcUnoApiTest::setUp();
84 m_xComponent = loadFromDesktop("private:factory/scalc");
85 CPPUNIT_ASSERT_MESSAGE("no component", m_xComponent.is());
88 void ScIndexEnumeration_SheetLinksEnumeration::tearDown()
90 closeDocument(m_xComponent);
91 CalcUnoApiTest::tearDown();
94 CPPUNIT_TEST_SUITE_REGISTRATION(ScIndexEnumeration_SheetLinksEnumeration);
96 } // namespace sc_apitest
98 CPPUNIT_PLUGIN_IMPLEMENT();
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */