nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scddelinksobj.cxx
bloba8bd6aff8775143372d2e180dc97d63b6990efb3
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/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>
16 #include <test/sheet/xddelinks.hxx>
18 #include <cppu/unotype.hxx>
19 #include <rtl/ustring.hxx>
20 #include <vcl/svapp.hxx>
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/lang/XComponent.hpp>
24 #include <com/sun/star/sheet/XDDELink.hpp>
25 #include <com/sun/star/sheet/XDDELinks.hpp>
26 #include <com/sun/star/sheet/XSpreadsheet.hpp>
27 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
28 #include <com/sun/star/sheet/XSpreadsheets.hpp>
29 #include <com/sun/star/uno/XInterface.hpp>
31 #include <com/sun/star/uno/Reference.hxx>
33 using namespace css;
34 using namespace css::uno;
35 using namespace com::sun::star;
37 namespace sc_apitest
39 class ScDDELinksObj : public CalcUnoApiTest,
40 public apitest::XDDELinks,
41 public apitest::XElementAccess,
42 public apitest::XEnumerationAccess,
43 public apitest::XIndexAccess,
44 public apitest::XNameAccess,
45 public apitest::XServiceInfo
47 public:
48 ScDDELinksObj();
50 virtual uno::Reference<uno::XInterface> init() override;
51 virtual void setUp() override;
52 virtual void tearDown() override;
54 CPPUNIT_TEST_SUITE(ScDDELinksObj);
56 // XDDELinks
57 CPPUNIT_TEST(testAddDDELink);
59 // XElementAccess
60 CPPUNIT_TEST(testGetElementType);
61 CPPUNIT_TEST(testHasElements);
63 // XEnumerationAccess
64 CPPUNIT_TEST(testCreateEnumeration);
66 // XIndexAccess
67 CPPUNIT_TEST(testGetByIndex);
68 CPPUNIT_TEST(testGetCount);
70 // XNameAccess
71 CPPUNIT_TEST(testGetByName);
72 CPPUNIT_TEST(testGetElementNames);
73 CPPUNIT_TEST(testHasByName);
75 // XServiceInfo
76 CPPUNIT_TEST(testGetImplementationName);
77 CPPUNIT_TEST(testGetSupportedServiceNames);
78 CPPUNIT_TEST(testSupportsService);
80 CPPUNIT_TEST_SUITE_END();
82 private:
83 uno::Reference<lang::XComponent> m_xComponent;
86 ScDDELinksObj::ScDDELinksObj()
87 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
88 , XDDELinks(m_directories.getURLFromSrc("/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods"))
89 , XElementAccess(cppu::UnoType<sheet::XDDELink>::get())
90 , XIndexAccess(1)
91 , XNameAccess("soffice|"
92 + m_directories.getURLFromSrc("/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods")
93 + "!Sheet1.A1")
94 , XServiceInfo("ScDDELinksObj", "com.sun.star.sheet.DDELinks")
98 uno::Reference<uno::XInterface> ScDDELinksObj::init()
100 uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xComponent, uno::UNO_QUERY_THROW);
102 uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), uno::UNO_SET_THROW);
103 uno::Reference<container::XIndexAccess> xIA(xSheets, uno::UNO_QUERY_THROW);
104 uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), uno::UNO_QUERY_THROW);
106 const OUString testdoc
107 = m_directories.getURLFromSrc("/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods");
109 xSheet->getCellByPosition(5, 5)->setFormula("=DDE(\"soffice\";\"" + testdoc
110 + "\";\"Sheet1.A1\")");
111 xSheet->getCellByPosition(1, 4)->setFormula("=DDE(\"soffice\";\"" + testdoc
112 + "\";\"Sheet1.A1\")");
113 xSheet->getCellByPosition(2, 0)->setFormula("=DDE(\"soffice\";\"" + testdoc
114 + "\";\"Sheet1.A1\")");
116 uno::Reference<beans::XPropertySet> xPropSet(xDoc, uno::UNO_QUERY_THROW);
117 uno::Any aDDELinks = xPropSet->getPropertyValue("DDELinks");
118 uno::Reference<sheet::XDDELinks> xDDELinks(aDDELinks, uno::UNO_QUERY_THROW);
120 return xDDELinks;
123 void ScDDELinksObj::setUp()
125 Application::SetAppName("soffice"); // Enable DDE
126 CalcUnoApiTest::setUp();
127 // create a calc document
128 m_xComponent = loadFromDesktop("private:factory/scalc");
131 void ScDDELinksObj::tearDown()
133 closeDocument(m_xComponent);
134 CalcUnoApiTest::tearDown();
137 CPPUNIT_TEST_SUITE_REGISTRATION(ScDDELinksObj);
139 } // namespace sc_apitest
141 CPPUNIT_PLUGIN_IMPLEMENT();
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */