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/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 UnoApiTest
,
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 uno::Reference
<uno::XInterface
> init() override
;
53 CPPUNIT_TEST_SUITE(ScTableSheetsObj
);
56 CPPUNIT_TEST(testGetElementType
);
57 CPPUNIT_TEST(testHasElements
);
60 CPPUNIT_TEST(testCreateEnumeration
);
63 CPPUNIT_TEST(testGetByIndex
);
64 CPPUNIT_TEST(testGetCount
);
67 CPPUNIT_TEST(testGetByName
);
68 CPPUNIT_TEST(testGetElementNames
);
69 CPPUNIT_TEST(testHasByName
);
72 CPPUNIT_TEST(testInsertByName
);
73 CPPUNIT_TEST(testInsertByNameEmptyName
);
74 CPPUNIT_TEST(testInsertByNameDuplicate
);
75 CPPUNIT_TEST(testRemoveByName
);
76 CPPUNIT_TEST(testRemoveByNameNoneExistingElement
);
79 CPPUNIT_TEST(testReplaceByName
);
82 CPPUNIT_TEST(testGetImplementationName
);
83 CPPUNIT_TEST(testGetSupportedServiceNames
);
84 CPPUNIT_TEST(testSupportsService
);
87 CPPUNIT_TEST(testInsertNewByName
);
88 CPPUNIT_TEST(testInsertNewByNameBadName
);
89 CPPUNIT_TEST(testCopyByName
);
90 CPPUNIT_TEST(testMoveByName
);
93 CPPUNIT_TEST(testImportedSheetNameAndIndex
);
94 CPPUNIT_TEST(testImportString
);
95 CPPUNIT_TEST(testImportValue
);
96 CPPUNIT_TEST(testImportFormulaBasicMath
);
97 CPPUNIT_TEST(testImportFormulaWithNamedRange
);
98 CPPUNIT_TEST(testImportOverExistingNamedRange
);
99 CPPUNIT_TEST(testImportNamedRangeDefinedInSource
);
100 CPPUNIT_TEST(testImportNamedRangeRedefinedInSource
);
101 CPPUNIT_TEST(testImportNewNamedRange
);
102 CPPUNIT_TEST(testImportCellStyle
);
103 CPPUNIT_TEST(testLastAfterInsertCopy
);
105 CPPUNIT_TEST_SUITE_END();
107 virtual uno::Reference
<lang::XComponent
> loadFromDesktop(const OUString
& rFileBase
) override
;
110 ScTableSheetsObj::ScTableSheetsObj()
111 : UnoApiTest("/sc/qa/extras/testdocuments")
112 , ::apitest::XElementAccess(cppu::UnoType
<sheet::XSpreadsheet
>::get())
113 , ::apitest::XIndexAccess(3)
114 , ::apitest::XNameAccess("Sheet1")
115 , ::apitest::XNameContainer("Sheet2")
116 , ::apitest::XNameReplace("Sheet2")
117 , ::apitest::XServiceInfo("ScTableSheetsObj", "com.sun.star.sheet.Spreadsheets")
121 uno::Reference
<lang::XComponent
> ScTableSheetsObj::loadFromDesktop(const OUString
& rFileBase
)
123 OUString aString
= createFileURL(rFileBase
);
124 return UnoApiTest::loadFromDesktop(aString
);
127 uno::Reference
<uno::XInterface
> ScTableSheetsObj::init()
129 xDocument
.set(mxComponent
, UNO_QUERY_THROW
);
130 uno::Reference
<uno::XInterface
> xReturn(xDocument
->getSheets(), UNO_QUERY_THROW
);
132 uno::Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, uno::UNO_QUERY_THROW
);
133 XNameContainer::setElement(uno::Any(xMSF
->createInstance("com.sun.star.sheet.Spreadsheet")));
135 XNameReplace::setElement(uno::Any(xMSF
->createInstance("com.sun.star.sheet.Spreadsheet")));
140 void ScTableSheetsObj::setUp()
143 // create a calc document
144 loadFromURL(u
"rangenamessrc.ods");
147 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableSheetsObj
);
148 } // namespace sc_apitest
150 CPPUNIT_PLUGIN_IMPLEMENT();
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */