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>
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>
31 using namespace css::uno
;
32 using namespace com::sun::star
;
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
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
);
54 CPPUNIT_TEST(testAddRemoveDbRanges
);
57 CPPUNIT_TEST(testGetElementType
);
58 CPPUNIT_TEST(testHasElements
);
61 CPPUNIT_TEST(testCreateEnumeration
);
64 CPPUNIT_TEST(testGetByIndex
);
65 CPPUNIT_TEST(testGetCount
);
68 CPPUNIT_TEST(testGetByName
);
69 CPPUNIT_TEST(testGetElementNames
);
70 CPPUNIT_TEST(testHasByName
);
73 CPPUNIT_TEST(testGetImplementationName
);
74 CPPUNIT_TEST(testGetSupportedServiceNames
);
75 CPPUNIT_TEST(testSupportsService
);
77 CPPUNIT_TEST_SUITE_END();
80 uno::Reference
<lang::XComponent
> mxComponent
;
83 ScDatabaseRangesObj::ScDatabaseRangesObj()
84 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
85 , XElementAccess(cppu::UnoType
<sheet::XDatabaseRange
>::get())
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"),
100 if (!xDbRanges
->hasByName("DbRange"))
101 xDbRanges
->addNewByName("DbRange", table::CellRangeAddress(0, 2, 4, 5, 6));
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: */