1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/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>
23 using namespace css::uno
;
25 namespace sc_apitest
{
27 class ScDatabaseRangeObj
: public UnoApiTest
,
28 public apitest::DatabaseRange
,
29 public apitest::XCellRangeReferrer
,
30 public apitest::XDatabaseRange
33 virtual void setUp() override
;
35 virtual uno::Reference
< uno::XInterface
> init() override
;
36 virtual uno::Reference
< uno::XInterface
> init( const OUString
& rDBName
) override
;
40 CPPUNIT_TEST_SUITE(ScDatabaseRangeObj
);
43 CPPUNIT_TEST(testMoveCells
);
44 CPPUNIT_TEST(testKeepFormats
);
45 CPPUNIT_TEST(testStripData
);
46 CPPUNIT_TEST(testAutoFilter
);
47 CPPUNIT_TEST(testUseFilterCriteriaSource
);
48 CPPUNIT_TEST(testFilterCriteriaSource
);
49 CPPUNIT_TEST(testRefreshPeriod
);
50 CPPUNIT_TEST(testFromSelection
);
51 CPPUNIT_TEST(testTokenIndex
);
52 CPPUNIT_TEST(testTotalsRow
);
53 CPPUNIT_TEST(testContainsHeader
);
56 CPPUNIT_TEST(testGetReferredCells
);
59 CPPUNIT_TEST(testDataArea
);
60 CPPUNIT_TEST(testGetSortDescriptor
);
61 CPPUNIT_TEST(testGetSubtotalDescriptor
);
62 CPPUNIT_TEST(testGetImportDescriptor
);
63 CPPUNIT_TEST(testGetFilterDescriptor
);
64 CPPUNIT_TEST(testRefresh
);
66 CPPUNIT_TEST_SUITE_END();
69 ScDatabaseRangeObj::ScDatabaseRangeObj()
70 : UnoApiTest("/sc/qa/extras/testdocuments")
74 uno::Reference
<uno::XInterface
> ScDatabaseRangeObj::init()
76 return init("DataArea");
79 uno::Reference
< uno::XInterface
> ScDatabaseRangeObj::init( const OUString
& rDBName
)
81 uno::Reference
< sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
83 uno::Reference
< beans::XPropertySet
> xPropSet(xDoc
, UNO_QUERY_THROW
);
84 uno::Reference
< container::XNameAccess
> xNameAccess( xPropSet
->getPropertyValue("DatabaseRanges"), UNO_QUERY_THROW
);
86 uno::Reference
<sheet::XCellRangeReferrer
> xCRR(xNameAccess
->getByName(rDBName
), UNO_QUERY_THROW
);
87 uno::Reference
<sheet::XCellRangeAddressable
> xCRA(xCRR
->getReferredCells(), UNO_QUERY_THROW
);
88 setCellRange(xCRA
->getRangeAddress());
90 uno::Reference
< sheet::XDatabaseRange
> xDBRange( xNameAccess
->getByName(rDBName
), UNO_QUERY_THROW
);
91 CPPUNIT_ASSERT(xDBRange
.is());
96 void ScDatabaseRangeObj::setUp()
100 loadFromURL(u
"ScDatabaseRangeObj.ods");
103 CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangeObj
);
107 CPPUNIT_PLUGIN_IMPLEMENT();
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */