nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scdatabaserangeobj.cxx
blobd7ffdf80c3bf13d493e6e3769b506939e485b50f
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/sheet/databaserange.hxx>
12 #include <test/sheet/xcellrangereferrer.hxx>
13 #include <test/sheet/xdatabaserange.hxx>
15 #include <com/sun/star/beans/XPropertySet.hpp>
16 #include <com/sun/star/container/XNameAccess.hpp>
17 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
18 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
19 #include <com/sun/star/sheet/XDatabaseRange.hpp>
20 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
22 using namespace css;
23 using namespace css::uno;
25 namespace sc_apitest {
27 class ScDatabaseRangeObj : public CalcUnoApiTest,
28 public apitest::DatabaseRange,
29 public apitest::XCellRangeReferrer,
30 public apitest::XDatabaseRange
32 public:
33 virtual void setUp() override;
34 virtual void tearDown() override;
36 virtual uno::Reference< uno::XInterface > init() override;
37 virtual uno::Reference< uno::XInterface > init( const OUString& rDBName ) override;
39 ScDatabaseRangeObj();
41 CPPUNIT_TEST_SUITE(ScDatabaseRangeObj);
43 // DatabaseRange
44 CPPUNIT_TEST(testMoveCells);
45 CPPUNIT_TEST(testKeepFormats);
46 CPPUNIT_TEST(testStripData);
47 CPPUNIT_TEST(testAutoFilter);
48 CPPUNIT_TEST(testUseFilterCriteriaSource);
49 CPPUNIT_TEST(testFilterCriteriaSource);
50 CPPUNIT_TEST(testRefreshPeriod);
51 CPPUNIT_TEST(testFromSelection);
52 CPPUNIT_TEST(testTokenIndex);
53 CPPUNIT_TEST(testTotalsRow);
54 CPPUNIT_TEST(testContainsHeader);
56 // XCellRangeReferrer
57 CPPUNIT_TEST(testGetReferredCells);
59 // XDatabaseRange
60 CPPUNIT_TEST(testDataArea);
61 CPPUNIT_TEST(testGetSortDescriptor);
62 CPPUNIT_TEST(testGetSubtotalDescriptor);
63 CPPUNIT_TEST(testGetImportDescriptor);
64 CPPUNIT_TEST(testGetFilterDescriptor);
65 CPPUNIT_TEST(testRefresh);
67 CPPUNIT_TEST_SUITE_END();
68 private:
69 uno::Reference< lang::XComponent > mxComponent;
72 ScDatabaseRangeObj::ScDatabaseRangeObj()
73 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
77 uno::Reference<uno::XInterface> ScDatabaseRangeObj::init()
79 return init("DataArea");
82 uno::Reference< uno::XInterface > ScDatabaseRangeObj::init( const OUString& rDBName )
84 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
86 uno::Reference< beans::XPropertySet > xPropSet(xDoc, UNO_QUERY_THROW);
87 uno::Reference< container::XNameAccess > xNameAccess( xPropSet->getPropertyValue("DatabaseRanges"), UNO_QUERY_THROW);
89 uno::Reference<sheet::XCellRangeReferrer> xCRR(xNameAccess->getByName(rDBName), UNO_QUERY_THROW);
90 uno::Reference<sheet::XCellRangeAddressable> xCRA(xCRR->getReferredCells(), UNO_QUERY_THROW);
91 setCellRange(xCRA->getRangeAddress());
93 uno::Reference< sheet::XDatabaseRange > xDBRange( xNameAccess->getByName(rDBName), UNO_QUERY_THROW);
94 CPPUNIT_ASSERT(xDBRange.is());
96 return xDBRange;
99 void ScDatabaseRangeObj::setUp()
101 CalcUnoApiTest::setUp();
103 OUString aFileURL;
104 createFileURL("ScDatabaseRangeObj.ods", aFileURL);
105 mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
109 void ScDatabaseRangeObj::tearDown()
111 closeDocument(mxComponent);
112 CalcUnoApiTest::tearDown();
115 CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangeObj);
119 CPPUNIT_PLUGIN_IMPLEMENT();
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */