calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / sc / qa / extras / scsheetlinksobj.cxx
blob7504eaaa99e440cb7a501978c9615cd00da35a8c
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/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>
31 using namespace css;
33 namespace sc_apitest
35 class ScSheetLinksObj : public UnoApiTest,
36 public apitest::XElementAccess,
37 public apitest::XEnumerationAccess,
38 public apitest::XIndexAccess,
39 public apitest::XNameAccess,
40 public apitest::XServiceInfo
42 public:
43 ScSheetLinksObj();
45 virtual uno::Reference<uno::XInterface> init() override;
46 virtual void setUp() override;
48 CPPUNIT_TEST_SUITE(ScSheetLinksObj);
50 // XElementAccess
51 CPPUNIT_TEST(testGetElementType);
52 CPPUNIT_TEST(testHasElements);
54 // XEnumerationAccess
55 CPPUNIT_TEST(testCreateEnumeration);
57 // XIndexAccess
58 CPPUNIT_TEST(testGetByIndex);
59 CPPUNIT_TEST(testGetCount);
61 // XNameAccess
62 CPPUNIT_TEST(testGetByName);
63 CPPUNIT_TEST(testGetElementNames);
64 CPPUNIT_TEST(testHasByName);
66 // XServiceInfo
67 CPPUNIT_TEST(testGetImplementationName);
68 CPPUNIT_TEST(testGetSupportedServiceNames);
69 CPPUNIT_TEST(testSupportsService);
71 CPPUNIT_TEST_SUITE_END();
74 ScSheetLinksObj::ScSheetLinksObj()
75 : UnoApiTest("/sc/qa/extras/testdocuments")
76 , XElementAccess(cppu::UnoType<beans::XPropertySet>::get())
77 , XIndexAccess(1)
78 , XNameAccess(m_directories.getURLFromSrc(u"/sc/qa/extras/testdocuments/ScSheetLinksObj.ods"))
79 , XServiceInfo("ScSheetLinksObj", "com.sun.star.sheet.SheetLinks")
83 uno::Reference<uno::XInterface> ScSheetLinksObj::init()
85 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
86 uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), uno::UNO_SET_THROW);
87 uno::Reference<container::XIndexAccess> xIA(xSheets, uno::UNO_QUERY_THROW);
88 uno::Reference<sheet::XSpreadsheet> xSheet0(xIA->getByIndex(0), uno::UNO_QUERY_THROW);
90 uno::Reference<sheet::XSheetLinkable> xSL(xSheet0, uno::UNO_QUERY_THROW);
91 OUString aFileURL = createFileURL(u"ScSheetLinksObj.ods");
92 xSL->link(aFileURL, "Sheet1", "", "", sheet::SheetLinkMode_VALUE);
94 uno::Reference<beans::XPropertySet> xPropertySet(xDoc, uno::UNO_QUERY_THROW);
95 uno::Reference<container::XNameAccess> xNA;
96 CPPUNIT_ASSERT(xPropertySet->getPropertyValue("SheetLinks") >>= xNA);
98 return xNA;
101 void ScSheetLinksObj::setUp()
103 UnoApiTest::setUp();
104 // create a calc document
105 mxComponent = loadFromDesktop("private:factory/scalc");
108 CPPUNIT_TEST_SUITE_REGISTRATION(ScSheetLinksObj);
110 } // namespace sc_apitest
112 CPPUNIT_PLUGIN_IMPLEMENT();
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */