Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * Major Contributor(s):
16 : * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
17 : *
18 : * All Rights Reserved.
19 : *
20 : * For minor contributions see the git repository.
21 : *
22 : * Alternatively, the contents of this file may be used under the terms of
23 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 : * instead of those above.
27 : */
28 :
29 : #include <test/unoapi_test.hxx>
30 : #include <test/sheet/xspreadsheets2.hxx>
31 : #include <test/container/xnamecontainer.hxx>
32 :
33 : #include <com/sun/star/beans/XPropertySet.hpp>
34 : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
35 :
36 : namespace sc_apitest {
37 :
38 : #define NUMBER_OF_TESTS 13
39 :
40 52 : class ScTableSheetsObj : public UnoApiTest, public ::apitest::XSpreadsheets2, apitest::XNameContainer
41 : {
42 : public:
43 : ScTableSheetsObj();
44 :
45 : virtual void setUp();
46 : virtual void tearDown();
47 :
48 4 : CPPUNIT_TEST_SUITE(ScTableSheetsObj);
49 2 : CPPUNIT_TEST(testImportValue);
50 2 : CPPUNIT_TEST(testImportString);
51 2 : CPPUNIT_TEST(testImportedSheetNameAndIndex);
52 2 : CPPUNIT_TEST(testImportString);
53 2 : CPPUNIT_TEST(testImportValue);
54 2 : CPPUNIT_TEST(testImportFormulaBasicMath);
55 2 : CPPUNIT_TEST(testImportFormulaWithNamedRange);
56 2 : CPPUNIT_TEST(testImportOverExistingNamedRange);
57 2 : CPPUNIT_TEST(testImportNamedRangeDefinedInSource);
58 2 : CPPUNIT_TEST(testImportNamedRangeRedefinedInSource);
59 2 : CPPUNIT_TEST(testImportNewNamedRange);
60 2 : CPPUNIT_TEST(testImportCellStyle);
61 2 : CPPUNIT_TEST(testRemoveByName);
62 4 : CPPUNIT_TEST_SUITE_END();
63 :
64 : virtual uno::Reference< lang::XComponent > getComponent();
65 : virtual void createFileURL(const rtl::OUString& rFileBase, rtl::OUString& rFileURL);
66 : virtual uno::Reference< lang::XComponent > loadFromDesktop(const rtl::OUString& rString);
67 : virtual uno::Reference< uno::XInterface > init();
68 : protected:
69 : static uno::Reference< lang::XComponent > mxComponent;
70 : static sal_Int32 nTest;
71 : };
72 :
73 2 : uno::Reference< lang::XComponent > ScTableSheetsObj::mxComponent;
74 : sal_Int32 ScTableSheetsObj::nTest = 0;
75 :
76 26 : ScTableSheetsObj::ScTableSheetsObj():
77 26 : apitest::XNameContainer(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Sheet2")))
78 : {
79 :
80 26 : }
81 :
82 0 : uno::Reference< lang::XComponent > ScTableSheetsObj::getComponent()
83 : {
84 0 : return mxComponent;
85 : }
86 :
87 28 : void ScTableSheetsObj::createFileURL(const rtl::OUString& rFileBase, rtl::OUString& rFileURL)
88 : {
89 28 : UnoApiTest::createFileURL(rFileBase, rFileURL);
90 28 : }
91 :
92 4 : uno::Reference< lang::XComponent > ScTableSheetsObj::loadFromDesktop(const rtl::OUString& rString)
93 : {
94 4 : return UnoApiTest::loadFromDesktop(rString);
95 : }
96 :
97 26 : uno::Reference< uno::XInterface > ScTableSheetsObj::init()
98 : {
99 26 : rtl::OUString aFileURL;
100 26 : createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rangenamessrc.ods")), aFileURL);
101 26 : if(!mxComponent.is())
102 2 : mxComponent = loadFromDesktop(aFileURL);
103 26 : CPPUNIT_ASSERT(mxComponent.is());
104 26 : xDocument = uno::Reference< sheet::XSpreadsheetDocument >(mxComponent, UNO_QUERY_THROW);
105 26 : uno::Reference< uno::XInterface > xReturn( xDocument->getSheets(), UNO_QUERY_THROW);
106 :
107 26 : return xReturn;
108 : }
109 :
110 26 : void ScTableSheetsObj::setUp()
111 : {
112 26 : nTest++;
113 26 : CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
114 26 : UnoApiTest::setUp();
115 26 : }
116 :
117 26 : void ScTableSheetsObj::tearDown()
118 : {
119 26 : if (nTest == NUMBER_OF_TESTS)
120 2 : closeDocument(mxComponent);
121 :
122 26 : UnoApiTest::tearDown();
123 26 : }
124 :
125 2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScTableSheetsObj);
126 :
127 2 : CPPUNIT_PLUGIN_IMPLEMENT();
128 :
129 6 : }
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|