nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scnamedrangeobj.cxx
blob710b40bb265418b7cbf47d16e591cb57787a31df
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/container/xnamed.hxx>
12 #include <test/sheet/xnamedrange.hxx>
13 #include <test/sheet/xcellrangereferrer.hxx>
15 #include <com/sun/star/beans/XPropertySet.hpp>
16 #include <com/sun/star/sheet/XNamedRanges.hpp>
18 using namespace css;
19 using namespace css::uno;
21 namespace sc_apitest {
23 class ScNamedRangeObj : public CalcUnoApiTest,
24 public apitest::XCellRangeReferrer,
25 public apitest::XNamed,
26 public apitest::XNamedRange
28 public:
29 ScNamedRangeObj();
31 virtual void setUp() override;
32 virtual void tearDown() override;
34 virtual uno::Reference< uno::XInterface > init() override;
35 virtual uno::Reference< sheet::XNamedRange > getNamedRange(const OUString& rRangeName) override;
37 CPPUNIT_TEST_SUITE(ScNamedRangeObj);
39 // XCellRangeReferrer
40 CPPUNIT_TEST(testGetReferredCells);
42 // XNamed
43 CPPUNIT_TEST(testSetName);
44 CPPUNIT_TEST(testGetName);
46 // XNamedRange
47 CPPUNIT_TEST(testGetContent);
48 CPPUNIT_TEST(testSetContent);
49 CPPUNIT_TEST(testGetType);
50 CPPUNIT_TEST(testSetType);
51 CPPUNIT_TEST(testGetReferencePosition);
52 CPPUNIT_TEST(testSetReferencePosition);
54 CPPUNIT_TEST_SUITE_END();
55 private:
56 uno::Reference< sheet::XNamedRanges > init_impl();
57 uno::Reference< lang::XComponent > mxComponent;
60 ScNamedRangeObj::ScNamedRangeObj():
61 CalcUnoApiTest("/sc/qa/extras/testdocuments"),
62 apitest::XNamed("NamedRange")
66 uno::Reference< sheet::XNamedRanges > ScNamedRangeObj::init_impl()
68 CPPUNIT_ASSERT_MESSAGE("no component loaded", mxComponent.is());
70 uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW);
71 uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue("NamedRanges"), UNO_QUERY_THROW);
72 CPPUNIT_ASSERT(xNamedRanges.is());
74 setCellRange(table::CellRangeAddress(0, 1, 7, 1, 7));
76 return xNamedRanges;
79 uno::Reference< sheet::XNamedRange> ScNamedRangeObj::getNamedRange(const OUString& rRangeName)
81 uno::Reference< container::XNameAccess > xNamedAccess(init_impl(), UNO_QUERY_THROW);
82 uno::Reference< sheet::XNamedRange > xNamedRange(xNamedAccess->getByName(rRangeName), UNO_QUERY_THROW);
83 CPPUNIT_ASSERT(xNamedRange.is());
85 return xNamedRange;
88 uno::Reference< uno::XInterface > ScNamedRangeObj::init()
90 return getNamedRange("NamedRange");
93 void ScNamedRangeObj::setUp()
95 CalcUnoApiTest::setUp();
96 // create a calc document
97 OUString aFileURL;
98 createFileURL("ScNamedRangeObj.ods", aFileURL);
99 mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
102 void ScNamedRangeObj::tearDown()
104 closeDocument(mxComponent);
105 CalcUnoApiTest::tearDown();
108 CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangeObj);
112 CPPUNIT_PLUGIN_IMPLEMENT();
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */