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/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>
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
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
);
40 CPPUNIT_TEST(testGetReferredCells
);
43 CPPUNIT_TEST(testSetName
);
44 CPPUNIT_TEST(testGetName
);
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();
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));
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());
88 uno::Reference
< uno::XInterface
> ScNamedRangeObj::init()
90 return getNamedRange("NamedRange");
93 void ScNamedRangeObj::setUp()
95 CalcUnoApiTest::setUp();
96 // create a calc document
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: */