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/xelementaccess.hxx>
12 #include <test/container/xenumerationaccess.hxx>
13 #include <test/container/xindexaccess.hxx>
14 #include <test/container/xnameaccess.hxx>
15 #include <test/lang/xserviceinfo.hxx>
17 #include <cppu/unotype.hxx>
19 #include <com/sun/star/beans/XPropertySet.hpp>
20 #include <com/sun/star/container/XIndexAccess.hpp>
21 #include <com/sun/star/lang/XComponent.hpp>
22 #include <com/sun/star/sheet/SheetLinkMode.hpp>
23 #include <com/sun/star/sheet/XSheetLinkable.hpp>
24 #include <com/sun/star/sheet/XSpreadsheet.hpp>
25 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
26 #include <com/sun/star/sheet/XSpreadsheets.hpp>
27 #include <com/sun/star/uno/XInterface.hpp>
29 #include <com/sun/star/uno/Reference.hxx>
35 class ScSheetLinksObj
: public CalcUnoApiTest
,
36 public apitest::XElementAccess
,
37 public apitest::XEnumerationAccess
,
38 public apitest::XIndexAccess
,
39 public apitest::XNameAccess
,
40 public apitest::XServiceInfo
45 virtual uno::Reference
<uno::XInterface
> init() override
;
46 virtual void setUp() override
;
47 virtual void tearDown() override
;
49 CPPUNIT_TEST_SUITE(ScSheetLinksObj
);
52 CPPUNIT_TEST(testGetElementType
);
53 CPPUNIT_TEST(testHasElements
);
56 CPPUNIT_TEST(testCreateEnumeration
);
59 CPPUNIT_TEST(testGetByIndex
);
60 CPPUNIT_TEST(testGetCount
);
63 CPPUNIT_TEST(testGetByName
);
64 CPPUNIT_TEST(testGetElementNames
);
65 CPPUNIT_TEST(testHasByName
);
68 CPPUNIT_TEST(testGetImplementationName
);
69 CPPUNIT_TEST(testGetSupportedServiceNames
);
70 CPPUNIT_TEST(testSupportsService
);
72 CPPUNIT_TEST_SUITE_END();
75 uno::Reference
<lang::XComponent
> m_xComponent
;
78 ScSheetLinksObj::ScSheetLinksObj()
79 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
80 , XElementAccess(cppu::UnoType
<beans::XPropertySet
>::get())
82 , XNameAccess(m_directories
.getURLFromSrc("/sc/qa/extras/testdocuments/ScSheetLinksObj.ods"))
83 , XServiceInfo("ScSheetLinksObj", "com.sun.star.sheet.SheetLinks")
87 uno::Reference
<uno::XInterface
> ScSheetLinksObj::init()
89 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(m_xComponent
, uno::UNO_QUERY_THROW
);
90 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), uno::UNO_SET_THROW
);
91 uno::Reference
<container::XIndexAccess
> xIA(xSheets
, uno::UNO_QUERY_THROW
);
92 uno::Reference
<sheet::XSpreadsheet
> xSheet0(xIA
->getByIndex(0), uno::UNO_QUERY_THROW
);
94 uno::Reference
<sheet::XSheetLinkable
> xSL(xSheet0
, uno::UNO_QUERY_THROW
);
96 createFileURL("ScSheetLinksObj.ods", aFileURL
);
97 xSL
->link(aFileURL
, "Sheet1", "", "", sheet::SheetLinkMode_VALUE
);
99 uno::Reference
<beans::XPropertySet
> xPropertySet(xDoc
, uno::UNO_QUERY_THROW
);
100 uno::Reference
<container::XNameAccess
> xNA
;
101 CPPUNIT_ASSERT(xPropertySet
->getPropertyValue("SheetLinks") >>= xNA
);
106 void ScSheetLinksObj::setUp()
108 CalcUnoApiTest::setUp();
109 // create a calc document
110 m_xComponent
= loadFromDesktop("private:factory/scalc");
113 void ScSheetLinksObj::tearDown()
115 closeDocument(m_xComponent
);
116 CalcUnoApiTest::tearDown();
119 CPPUNIT_TEST_SUITE_REGISTRATION(ScSheetLinksObj
);
121 } // namespace sc_apitest
123 CPPUNIT_PLUGIN_IMPLEMENT();
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */