nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scnamedrangesobj.cxx
blob1b61fa098262a567ddd43625a5eb12d465ed8f16
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/beans/xpropertyset.hxx>
12 #include <test/container/xelementaccess.hxx>
13 #include <test/container/xenumerationaccess.hxx>
14 #include <test/container/xindexaccess.hxx>
15 #include <test/container/xnameaccess.hxx>
16 #include <test/document/xactionlockable.hxx>
17 #include <test/lang/xserviceinfo.hxx>
18 #include <test/sheet/xnamedranges.hxx>
20 #include <com/sun/star/beans/XPropertySet.hpp>
21 #include <com/sun/star/sheet/XNamedRange.hpp>
22 #include <com/sun/star/sheet/XNamedRanges.hpp>
23 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
24 #include <com/sun/star/uno/XInterface.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
28 #include <cppu/unotype.hxx>
30 using namespace css;
31 using namespace css::uno;
33 namespace sc_apitest
35 class ScNamedRangesObj : public CalcUnoApiTest,
36 public apitest::XActionLockable,
37 public apitest::XElementAccess,
38 public apitest::XEnumerationAccess,
39 public apitest::XIndexAccess,
40 public apitest::XNameAccess,
41 public apitest::XNamedRanges,
42 public apitest::XPropertySet,
43 public apitest::XServiceInfo
45 public:
46 ScNamedRangesObj();
48 virtual void setUp() override;
49 virtual void tearDown() override;
51 virtual uno::Reference<uno::XInterface> init() override;
52 virtual uno::Reference<uno::XInterface> getXNamedRanges(sal_Int32 nSheet = 0) override;
54 CPPUNIT_TEST_SUITE(ScNamedRangesObj);
56 // XActionLockable
57 CPPUNIT_TEST(testAddRemoveActionLock);
58 CPPUNIT_TEST(testSetResetActionLock);
60 // XElementAccess
61 CPPUNIT_TEST(testGetElementType);
62 CPPUNIT_TEST(testHasElements);
64 // XEnumerationAccess
65 CPPUNIT_TEST(testCreateEnumeration);
67 // XIndexAccess
68 CPPUNIT_TEST(testGetByIndex);
69 CPPUNIT_TEST(testGetCount);
71 // XNamedRanges
72 CPPUNIT_TEST(testGetByName);
73 CPPUNIT_TEST(testGetElementNames);
74 CPPUNIT_TEST(testHasByName);
76 // XNamedRanges
77 CPPUNIT_TEST(testAddNewByName);
78 CPPUNIT_TEST(testAddNewFromTitles);
79 //CPPUNIT_TEST_EXCEPTION(testRemoveByName, uno::RuntimeException);
80 CPPUNIT_TEST(testOutputList);
82 // XPropertySet
83 CPPUNIT_TEST(testGetPropertySetInfo);
84 CPPUNIT_TEST(testGetPropertyValue);
85 CPPUNIT_TEST(testSetPropertyValue);
86 CPPUNIT_TEST(testPropertyChangeListener);
87 CPPUNIT_TEST(testVetoableChangeListener);
89 // XServiceInfo
90 CPPUNIT_TEST(testGetImplementationName);
91 CPPUNIT_TEST(testGetSupportedServiceNames);
92 CPPUNIT_TEST(testSupportsService);
94 CPPUNIT_TEST_SUITE_END();
96 private:
97 uno::Reference<lang::XComponent> mxComponent;
100 ScNamedRangesObj::ScNamedRangesObj()
101 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
102 , XElementAccess(cppu::UnoType<sheet::XNamedRange>::get())
103 , XIndexAccess(4)
104 , XNameAccess("initial1")
105 , XServiceInfo("ScNamedRangesObj", "com.sun.star.sheet.NamedRanges")
109 uno::Reference<uno::XInterface> ScNamedRangesObj::init()
111 uno::Reference<beans::XPropertySet> xPropSet(mxComponent, UNO_QUERY_THROW);
112 uno::Reference<sheet::XNamedRanges> xNamedRanges(xPropSet->getPropertyValue("NamedRanges"),
113 UNO_QUERY_THROW);
115 //set value from xnamedranges.hxx
116 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
117 uno::Reference<container::XIndexAccess> xIndexAccess(xDoc->getSheets(), UNO_QUERY_THROW);
118 xSheet.set(xIndexAccess->getByIndex(0), UNO_QUERY_THROW);
120 return xNamedRanges;
123 uno::Reference<uno::XInterface> ScNamedRangesObj::getXNamedRanges(sal_Int32 nSheet)
125 uno::Reference<beans::XPropertySet> xPropSet(mxComponent, UNO_QUERY_THROW);
126 uno::Reference<sheet::XNamedRanges> xNamedRanges(xPropSet->getPropertyValue("NamedRanges"),
127 UNO_QUERY_THROW);
129 //set value from xnamedranges.hxx
130 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
131 uno::Reference<container::XIndexAccess> xIndexAccess(xDoc->getSheets(), UNO_QUERY_THROW);
132 xSheet.set(xIndexAccess->getByIndex(nSheet), UNO_QUERY_THROW);
134 return xNamedRanges;
137 void ScNamedRangesObj::setUp()
139 CalcUnoApiTest::setUp();
140 // create a calc document
141 OUString aFileURL;
142 createFileURL("ScNamedRangeObj.ods", aFileURL);
143 mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
146 void ScNamedRangesObj::tearDown()
148 closeDocument(mxComponent);
149 CalcUnoApiTest::tearDown();
152 CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangesObj);
154 } // namespace sc_apitest
156 CPPUNIT_PLUGIN_IMPLEMENT();
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */