fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sc / qa / extras / scnamedrangeobj.cxx
blob43103c0040d4b99b0b60ecf371b4effee299811c
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/unoapi_test.hxx>
11 #include <test/sheet/xnamedrange.hxx>
12 #include <test/container/xnamed.hxx>
13 #include <test/sheet/xcellrangereferrer.hxx>
15 #include <com/sun/star/beans/XPropertySet.hpp>
16 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
17 #include <com/sun/star/sheet/XSpreadsheet.hpp>
18 #include <com/sun/star/sheet/XNamedRanges.hpp>
20 using namespace css;
21 using namespace css::uno;
23 namespace sc_apitest {
25 #define NUMBER_OF_TESTS 9
27 class ScNamedRangeObj : public UnoApiTest, apitest::XNamedRange, apitest::XNamed, apitest::XCellRangeReferrer
29 public:
30 ScNamedRangeObj();
32 virtual void setUp();
33 virtual void tearDown();
35 virtual uno::Reference< uno::XInterface > init();
36 virtual uno::Reference< sheet::XNamedRange > getNamedRange(const OUString& rRangeName);
38 CPPUNIT_TEST_SUITE(ScNamedRangeObj);
39 CPPUNIT_TEST(testGetContent);
40 CPPUNIT_TEST(testSetContent);
41 CPPUNIT_TEST(testGetType);
42 CPPUNIT_TEST(testSetType);
43 CPPUNIT_TEST(testGetReferencePosition);
44 CPPUNIT_TEST(testSetReferencePosition);
45 CPPUNIT_TEST(testSetName);
46 CPPUNIT_TEST(testGetName);
47 CPPUNIT_TEST(testGetReferredCells);
48 CPPUNIT_TEST_SUITE_END();
49 private:
50 uno::Reference< sheet::XNamedRanges > init_impl();
52 static sal_Int32 nTest;
53 static uno::Reference< lang::XComponent > mxComponent;
56 sal_Int32 ScNamedRangeObj::nTest = 0;
57 uno::Reference< lang::XComponent > ScNamedRangeObj::mxComponent;
59 ScNamedRangeObj::ScNamedRangeObj():
60 UnoApiTest("/sc/qa/extras/testdocuments"),
61 apitest::XNamed(OUString("NamedRange")),
62 apitest::XCellRangeReferrer(table::CellRangeAddress(0,1,7,1,7))
66 uno::Reference< sheet::XNamedRanges > ScNamedRangeObj::init_impl()
68 OUString aFileURL;
69 createFileURL(OUString("ScNamedRangeObj.ods"), aFileURL);
70 if(!mxComponent.is())
71 mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
72 CPPUNIT_ASSERT(mxComponent.is());
74 uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW);
75 OUString aNamedRangesPropertyString("NamedRanges");
76 uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW);
77 CPPUNIT_ASSERT(xNamedRanges.is());
79 return xNamedRanges;
82 uno::Reference< sheet::XNamedRange> ScNamedRangeObj::getNamedRange(const OUString& rRangeName)
84 uno::Reference< container::XNameAccess > xNamedAccess(init_impl(), UNO_QUERY_THROW);
85 uno::Reference< sheet::XNamedRange > xNamedRange(xNamedAccess->getByName(rRangeName), UNO_QUERY_THROW);
86 CPPUNIT_ASSERT(xNamedRange.is());
88 return xNamedRange;
91 uno::Reference< uno::XInterface > ScNamedRangeObj::init()
93 return getNamedRange(OUString("NamedRange"));
96 void ScNamedRangeObj::setUp()
98 nTest++;
99 UnoApiTest::setUp();
102 void ScNamedRangeObj::tearDown()
104 if (nTest == NUMBER_OF_TESTS)
105 closeDocument(mxComponent);
107 UnoApiTest::tearDown();
110 CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangeObj);
112 CPPUNIT_PLUGIN_IMPLEMENT();
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */