nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scsheetlinkobj.cxx
blob7b248c0a9603a687190ad780d6f9f507db45321a
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/xnamed.hxx>
12 #include <test/sheet/sheetlink.hxx>
13 #include <test/util/xrefreshable.hxx>
15 #include <com/sun/star/beans/XPropertySet.hpp>
16 #include <com/sun/star/container/XIndexAccess.hpp>
17 #include <com/sun/star/container/XNameAccess.hpp>
18 #include <com/sun/star/lang/XComponent.hpp>
19 #include <com/sun/star/sheet/SheetLinkMode.hpp>
20 #include <com/sun/star/sheet/XSheetLinkable.hpp>
21 #include <com/sun/star/sheet/XSpreadsheet.hpp>
22 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
23 #include <com/sun/star/sheet/XSpreadsheets.hpp>
24 #include <com/sun/star/uno/XInterface.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
28 using namespace css;
30 namespace sc_apitest
32 class ScSheetLinkObj : public CalcUnoApiTest,
33 public apitest::SheetLink,
34 public apitest::XNamed,
35 public apitest::XRefreshable
37 public:
38 ScSheetLinkObj();
40 virtual uno::Reference<uno::XInterface> init() override;
42 virtual void setUp() override;
43 virtual void tearDown() override;
45 CPPUNIT_TEST_SUITE(ScSheetLinkObj);
47 // SheetLink
48 CPPUNIT_TEST(testSheetLinkProperties);
50 // XNamed
51 CPPUNIT_TEST(testGetName);
52 CPPUNIT_TEST(testSetNameByScSheetLinkObj);
54 // XRefreshable
55 CPPUNIT_TEST(testRefreshListener);
57 CPPUNIT_TEST_SUITE_END();
59 private:
60 uno::Reference<lang::XComponent> mxComponent;
63 ScSheetLinkObj::ScSheetLinkObj()
64 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
65 , XNamed(m_directories.getURLFromSrc("/sc/qa/extras/testdocuments/ScSheetLinkObj.ods"))
69 uno::Reference<uno::XInterface> ScSheetLinkObj::init()
71 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
73 uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), uno::UNO_SET_THROW);
74 uno::Reference<container::XIndexAccess> xIA(xSheets, uno::UNO_QUERY_THROW);
75 uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), uno::UNO_QUERY_THROW);
77 uno::Reference<sheet::XSheetLinkable> xSL(xSheet, uno::UNO_QUERY_THROW);
78 xSL->link(m_directories.getURLFromSrc("/sc/qa/extras/testdocuments/ScSheetLinkObj.ods"),
79 "Sheet1", "", "", sheet::SheetLinkMode_VALUE);
81 uno::Reference<beans::XPropertySet> xPropSet(xDoc, uno::UNO_QUERY_THROW);
82 uno::Reference<container::XNameAccess> sheetLinks;
83 CPPUNIT_ASSERT(xPropSet->getPropertyValue("SheetLinks") >>= sheetLinks);
84 CPPUNIT_ASSERT(sheetLinks.is());
86 uno::Any aAny = sheetLinks->getByName(sheetLinks->getElementNames()[0]);
87 uno::Reference<beans::XPropertySet> sheetLink;
88 aAny >>= sheetLink;
89 return sheetLink;
92 void ScSheetLinkObj::setUp()
94 CalcUnoApiTest::setUp();
95 // create a calc document
96 mxComponent = loadFromDesktop("private:factory/scalc");
99 void ScSheetLinkObj::tearDown()
101 closeDocument(mxComponent);
102 CalcUnoApiTest::tearDown();
105 CPPUNIT_TEST_SUITE_REGISTRATION(ScSheetLinkObj);
107 } // namespace sc_apitest
109 CPPUNIT_PLUGIN_IMPLEMENT();
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */