1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/xelementaccess.hxx>
12 #include <test/container/xenumerationaccess.hxx>
13 #include <test/container/xindexaccess.hxx>
14 #include <test/container/xnameaccess.hxx>
15 #include <test/container/xnamecontainer.hxx>
16 #include <test/container/xnamereplace.hxx>
17 #include <test/lang/xserviceinfo.hxx>
18 #include <test/sheet/xspreadsheets.hxx>
19 #include <test/sheet/xspreadsheets2.hxx>
21 #include <com/sun/star/lang/XComponent.hpp>
22 #include <com/sun/star/sheet/XSpreadsheet.hpp>
23 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
24 #include <com/sun/star/uno/XInterface.hpp>
26 #include <com/sun/star/uno/Any.hxx>
27 #include <com/sun/star/uno/Reference.hxx>
29 #include <cppu/unotype.hxx>
32 using namespace css::uno
;
36 class ScTableSheetsObj
: public CalcUnoApiTest
,
37 public ::apitest::XElementAccess
,
38 public ::apitest::XEnumerationAccess
,
39 public ::apitest::XIndexAccess
,
40 public ::apitest::XNameAccess
,
41 public ::apitest::XNameContainer
,
42 public ::apitest::XNameReplace
,
43 public ::apitest::XServiceInfo
,
44 public ::apitest::XSpreadsheets
,
45 public ::apitest::XSpreadsheets2
50 virtual void setUp() override
;
51 virtual void tearDown() override
;
52 virtual uno::Reference
<uno::XInterface
> init() override
;
54 CPPUNIT_TEST_SUITE(ScTableSheetsObj
);
57 CPPUNIT_TEST(testGetElementType
);
58 CPPUNIT_TEST(testHasElements
);
61 CPPUNIT_TEST(testCreateEnumeration
);
64 CPPUNIT_TEST(testGetByIndex
);
65 CPPUNIT_TEST(testGetCount
);
68 CPPUNIT_TEST(testGetByName
);
69 CPPUNIT_TEST(testGetElementNames
);
70 CPPUNIT_TEST(testHasByName
);
73 CPPUNIT_TEST(testInsertByName
);
74 CPPUNIT_TEST(testInsertByNameEmptyName
);
75 CPPUNIT_TEST(testInsertByNameDuplicate
);
76 CPPUNIT_TEST(testRemoveByName
);
77 CPPUNIT_TEST(testRemoveByNameNoneExistingElement
);
80 CPPUNIT_TEST(testReplaceByName
);
83 CPPUNIT_TEST(testGetImplementationName
);
84 CPPUNIT_TEST(testGetSupportedServiceNames
);
85 CPPUNIT_TEST(testSupportsService
);
88 CPPUNIT_TEST(testInsertNewByName
);
89 CPPUNIT_TEST(testInsertNewByNameBadName
);
90 CPPUNIT_TEST(testCopyByName
);
91 CPPUNIT_TEST(testMoveByName
);
94 CPPUNIT_TEST(testImportedSheetNameAndIndex
);
95 CPPUNIT_TEST(testImportString
);
96 CPPUNIT_TEST(testImportValue
);
97 CPPUNIT_TEST(testImportFormulaBasicMath
);
98 CPPUNIT_TEST(testImportFormulaWithNamedRange
);
99 CPPUNIT_TEST(testImportOverExistingNamedRange
);
100 CPPUNIT_TEST(testImportNamedRangeDefinedInSource
);
101 CPPUNIT_TEST(testImportNamedRangeRedefinedInSource
);
102 CPPUNIT_TEST(testImportNewNamedRange
);
103 CPPUNIT_TEST(testImportCellStyle
);
104 CPPUNIT_TEST(testLastAfterInsertCopy
);
106 CPPUNIT_TEST_SUITE_END();
108 virtual uno::Reference
<lang::XComponent
> getComponent() override
;
109 virtual void createFileURL(const OUString
& rFileBase
, OUString
& rFileURL
) override
;
110 virtual uno::Reference
<lang::XComponent
> loadFromDesktop(const OUString
& rString
) override
;
113 uno::Reference
<lang::XComponent
> mxComponent
;
116 ScTableSheetsObj::ScTableSheetsObj()
117 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
118 , ::apitest::XElementAccess(cppu::UnoType
<sheet::XSpreadsheet
>::get())
119 , ::apitest::XIndexAccess(3)
120 , ::apitest::XNameAccess("Sheet1")
121 , ::apitest::XNameContainer("Sheet2")
122 , ::apitest::XNameReplace("Sheet2")
123 , ::apitest::XServiceInfo("ScTableSheetsObj", "com.sun.star.sheet.Spreadsheets")
127 uno::Reference
<lang::XComponent
> ScTableSheetsObj::getComponent() { return mxComponent
; }
129 void ScTableSheetsObj::createFileURL(const OUString
& rFileBase
, OUString
& rFileURL
)
131 CalcUnoApiTest::createFileURL(rFileBase
, rFileURL
);
134 uno::Reference
<lang::XComponent
> ScTableSheetsObj::loadFromDesktop(const OUString
& rString
)
136 return CalcUnoApiTest::loadFromDesktop(rString
);
139 uno::Reference
<uno::XInterface
> ScTableSheetsObj::init()
141 xDocument
.set(mxComponent
, UNO_QUERY_THROW
);
142 uno::Reference
<uno::XInterface
> xReturn(xDocument
->getSheets(), UNO_QUERY_THROW
);
144 uno::Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, uno::UNO_QUERY_THROW
);
145 XNameContainer::setElement(
146 uno::makeAny(xMSF
->createInstance("com.sun.star.sheet.Spreadsheet")));
148 XNameReplace::setElement(uno::makeAny(xMSF
->createInstance("com.sun.star.sheet.Spreadsheet")));
153 void ScTableSheetsObj::setUp()
155 CalcUnoApiTest::setUp();
156 // create a calc document
158 createFileURL("rangenamessrc.ods", aFileURL
);
159 mxComponent
= loadFromDesktop(aFileURL
);
162 void ScTableSheetsObj::tearDown()
164 closeDocument(mxComponent
);
165 CalcUnoApiTest::tearDown();
168 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableSheetsObj
);
169 } // namespace sc_apitest
171 CPPUNIT_PLUGIN_IMPLEMENT();
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */