nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scdatabaserangesobj.cxx
blob39c190f310d70e7739ff561c242f5b4717c37201
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/xdatabaseranges.hxx>
18 #include <com/sun/star/beans/XPropertySet.hpp>
19 #include <com/sun/star/lang/XComponent.hpp>
20 #include <com/sun/star/sheet/XDatabaseRange.hpp>
21 #include <com/sun/star/sheet/XDatabaseRanges.hpp>
22 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
23 #include <com/sun/star/table/CellRangeAddress.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;
32 using namespace com::sun::star;
34 namespace sc_apitest
36 class ScDatabaseRangesObj : public CalcUnoApiTest,
37 public apitest::XDatabaseRanges,
38 public apitest::XElementAccess,
39 public apitest::XEnumerationAccess,
40 public apitest::XIndexAccess,
41 public apitest::XNameAccess,
42 public apitest::XServiceInfo
44 public:
45 ScDatabaseRangesObj();
47 virtual uno::Reference<uno::XInterface> init() override;
48 virtual void setUp() override;
49 virtual void tearDown() override;
51 CPPUNIT_TEST_SUITE(ScDatabaseRangesObj);
53 // XDatabaseRanges
54 CPPUNIT_TEST(testAddRemoveDbRanges);
56 // XElementAccess
57 CPPUNIT_TEST(testGetElementType);
58 CPPUNIT_TEST(testHasElements);
60 // XEnumerationAccess
61 CPPUNIT_TEST(testCreateEnumeration);
63 // XIndexAccess
64 CPPUNIT_TEST(testGetByIndex);
65 CPPUNIT_TEST(testGetCount);
67 // XNameAccess
68 CPPUNIT_TEST(testGetByName);
69 CPPUNIT_TEST(testGetElementNames);
70 CPPUNIT_TEST(testHasByName);
72 // XServiceInfo
73 CPPUNIT_TEST(testGetImplementationName);
74 CPPUNIT_TEST(testGetSupportedServiceNames);
75 CPPUNIT_TEST(testSupportsService);
77 CPPUNIT_TEST_SUITE_END();
79 private:
80 uno::Reference<lang::XComponent> mxComponent;
83 ScDatabaseRangesObj::ScDatabaseRangesObj()
84 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
85 , XElementAccess(cppu::UnoType<sheet::XDatabaseRange>::get())
86 , XIndexAccess(1)
87 , XNameAccess("DbRange")
88 , XServiceInfo("ScDatabaseRangesObj", "com.sun.star.sheet.DatabaseRanges")
92 uno::Reference<uno::XInterface> ScDatabaseRangesObj::init()
94 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
96 uno::Reference<beans::XPropertySet> xPropSet(xDoc, UNO_QUERY_THROW);
97 uno::Reference<sheet::XDatabaseRanges> xDbRanges(xPropSet->getPropertyValue("DatabaseRanges"),
98 UNO_QUERY_THROW);
100 if (!xDbRanges->hasByName("DbRange"))
101 xDbRanges->addNewByName("DbRange", table::CellRangeAddress(0, 2, 4, 5, 6));
103 return xDbRanges;
106 void ScDatabaseRangesObj::setUp()
108 CalcUnoApiTest::setUp();
109 // create a calc document
110 mxComponent = loadFromDesktop("private:factory/scalc");
113 void ScDatabaseRangesObj::tearDown()
115 closeDocument(mxComponent);
116 CalcUnoApiTest::tearDown();
119 CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangesObj);
121 } // namespace sc_apitest
123 CPPUNIT_PLUGIN_IMPLEMENT();
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */