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/sheet/scenario.hxx>
12 #include <test/sheet/sheetcellrange.hxx>
13 #include <test/sheet/spreadsheet.hxx>
14 #include <test/sheet/xarrayformularange.hxx>
15 #include <test/sheet/xcellformatrangessupplier.hxx>
16 #include <test/sheet/xcellrangeaddressable.hxx>
17 #include <test/sheet/xcellrangedata.hxx>
18 #include <test/sheet/xcellrangeformula.hxx>
19 #include <test/sheet/xcellrangemovement.hxx>
20 #include <test/sheet/xcellseries.hxx>
21 #include <test/sheet/xdatapilottablessupplier.hxx>
22 #include <test/sheet/xformulaquery.hxx>
23 #include <test/sheet/xmultipleoperation.hxx>
24 #include <test/sheet/xprintareas.hxx>
25 #include <test/sheet/xscenario.hxx>
26 #include <test/sheet/xscenarioenhanced.hxx>
27 #include <test/sheet/xscenariossupplier.hxx>
28 #include <test/sheet/xsheetannotationssupplier.hxx>
29 #include <test/sheet/xsheetauditing.hxx>
30 #include <test/sheet/xsheetcellrange.hxx>
31 #include <test/sheet/xsheetfilterable.hxx>
32 #include <test/sheet/xsheetfilterableex.hxx>
33 #include <test/sheet/xsheetlinkable.hxx>
34 #include <test/sheet/xsheetoperation.hxx>
35 #include <test/sheet/xsheetpagebreak.hxx>
36 #include <test/sheet/xspreadsheet.hxx>
37 #include <test/sheet/xsubtotalcalculatable.hxx>
38 #include <test/sheet/xuniquecellformatrangessupplier.hxx>
39 #include <test/table/xcolumnrowrange.hxx>
40 #include <test/table/xtablechartssupplier.hxx>
41 #include <test/util/xindent.hxx>
42 #include <test/util/xmergeable.hxx>
43 #include <test/util/xreplaceable.hxx>
44 #include <test/util/xsearchable.hxx>
46 #include <com/sun/star/sheet/XScenariosSupplier.hpp>
47 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
48 #include <com/sun/star/sheet/XSpreadsheet.hpp>
49 #include <com/sun/star/table/CellRangeAddress.hpp>
52 using namespace css::uno
;
57 class ScTableSheetObj
: public CalcUnoApiTest
, public apitest::Scenario
,
58 public apitest::SheetCellRange
,
59 public apitest::Spreadsheet
,
60 public apitest::XArrayFormulaRange
,
61 public apitest::XCellFormatRangesSupplier
,
62 public apitest::XCellRangeAddressable
,
63 public apitest::XCellRangeData
,
64 public apitest::XCellRangeFormula
,
65 public apitest::XCellRangeMovement
,
66 public apitest::XCellSeries
,
67 public apitest::XColumnRowRange
,
68 public apitest::XDataPilotTablesSupplier
,
69 public apitest::XFormulaQuery
,
70 public apitest::XIndent
,
71 public apitest::XMergeable
,
72 public apitest::XMultipleOperation
,
73 public apitest::XPrintAreas
,
74 public apitest::XReplaceable
,
75 public apitest::XScenario
,
76 public apitest::XScenarioEnhanced
,
77 public apitest::XScenariosSupplier
,
78 public apitest::XSearchable
,
79 public apitest::XSheetAnnotationsSupplier
,
80 public apitest::XSheetAuditing
,
81 public apitest::XSheetCellRange
,
82 public apitest::XSheetFilterable
,
83 public apitest::XSheetFilterableEx
,
84 public apitest::XSheetLinkable
,
85 public apitest::XSheetOperation
,
86 public apitest::XSheetPageBreak
,
87 public apitest::XSpreadsheet
,
88 public apitest::XSubTotalCalculatable
,
89 public apitest::XTableChartsSupplier
,
90 public apitest::XUniqueCellFormatRangesSupplier
95 virtual void setUp() override
;
96 virtual void tearDown() override
;
98 virtual OUString
getFileURL() override
;
100 virtual uno::Reference
< uno::XInterface
> init() override
;
101 virtual uno::Reference
< uno::XInterface
> getXCellRangeData() override
;
102 virtual uno::Reference
< uno::XInterface
> getXSpreadsheetDocument() override
;
103 virtual uno::Reference
< uno::XInterface
> getXSpreadsheet() override
;
104 virtual uno::Reference
< uno::XInterface
> getScenarioSpreadsheet() override
;
106 CPPUNIT_TEST_SUITE(ScTableSheetObj
);
109 CPPUNIT_TEST(testScenarioProperties
);
112 CPPUNIT_TEST(testSheetCellRangeProperties
);
115 CPPUNIT_TEST(testSpreadsheetProperties
);
117 // XArrayFormulaRange
118 #if 0 // disable, because it makes no sense to set an ArrayFormula over the whole sheet
119 CPPUNIT_TEST(testGetSetArrayFormula
);
122 // XCellFormatRangesSupplier
123 CPPUNIT_TEST(testGetCellFormatRanges
);
125 // XCellRangeAddressable
126 CPPUNIT_TEST(testGetRangeAddress
);
129 CPPUNIT_TEST(testGetDataArrayOnTableSheet
);
130 CPPUNIT_TEST(testSetDataArrayOnTableSheet
);
133 #if 0 // disable, because it makes no sense to set a FormulaArray over the whole sheet
134 CPPUNIT_TEST(testGetSetFormulaArray
);
137 // XCellRangeMovement
138 CPPUNIT_TEST(testInsertCells
);
139 CPPUNIT_TEST(testCopyRange
);
140 CPPUNIT_TEST(testMoveRange
);
141 CPPUNIT_TEST(testRemoveRange
);
144 CPPUNIT_TEST(testFillAuto
);
145 CPPUNIT_TEST(testFillSeries
);
148 CPPUNIT_TEST(testGetColumns
);
149 CPPUNIT_TEST(testGetRows
);
151 // XDataPilotTablesSupplier
152 CPPUNIT_TEST(testGetDataPilotTables
);
155 CPPUNIT_TEST(testQueryDependents
);
156 CPPUNIT_TEST(testQueryPrecedents
);
159 CPPUNIT_TEST(testIncrementIndent
);
160 CPPUNIT_TEST(testDecrementIndent
);
163 CPPUNIT_TEST(testGetIsMergedMerge
);
166 CPPUNIT_TEST(testFindAll
);
167 CPPUNIT_TEST(testFindNext
);
168 CPPUNIT_TEST(testFindFirst
);
170 // XMultipleOperation
171 #if 0 // disable, because test never finishes (see i87863)
172 CPPUNIT_TEST(testSetTableOperation
);
176 CPPUNIT_TEST(testSetAndGetPrintTitleColumns
);
177 CPPUNIT_TEST(testSetAndGetPrintTitleRows
);
180 CPPUNIT_TEST(testReplaceAll
);
181 CPPUNIT_TEST(testCreateReplaceDescriptor
);
184 // test was disabled in qadevOOo/tests/java/ifc/sheet/_XScenario.java
185 CPPUNIT_TEST(testScenario
);
188 CPPUNIT_TEST(testGetRanges
);
190 // XScenariosSupplier
191 CPPUNIT_TEST(testGetScenarios
);
193 // XSheetAnnotationsSupplier
194 CPPUNIT_TEST(testGetAnnotations
);
197 CPPUNIT_TEST(testShowHideDependents
);
198 CPPUNIT_TEST(testShowHidePrecedents
);
199 CPPUNIT_TEST(testClearArrows
);
200 CPPUNIT_TEST(testShowErrors
);
201 CPPUNIT_TEST(testShowInvalid
);
204 CPPUNIT_TEST(testGetSpreadsheet
);
207 CPPUNIT_TEST(testCreateFilterDescriptor
);
208 CPPUNIT_TEST(testFilter
);
210 // XSheetFilterableEx
211 #if 0 // temporarily disabled, takes too long (see i87876)
212 CPPUNIT_TEST(testCreateFilterDescriptorByObject
);
216 CPPUNIT_TEST(testSheetLinkable
);
219 CPPUNIT_TEST(testComputeFunction
);
220 CPPUNIT_TEST(testClearContents
);
223 CPPUNIT_TEST(testGetColumnPageBreaks
);
224 CPPUNIT_TEST(testGetRowPageBreaks
);
225 CPPUNIT_TEST(testRemoveAllManualPageBreaks
);
228 CPPUNIT_TEST(testCreateCursor
);
229 CPPUNIT_TEST(testCreateCursorByRange
);
231 // XSubTotalCalculatable
232 CPPUNIT_TEST(testCreateSubTotalDescriptor
);
233 CPPUNIT_TEST(testApplyRemoveSubTotals
);
235 // XTableChartsSupplier
236 CPPUNIT_TEST(testGetCharts
);
238 // XUniqueCellFormatRangesSupplier
239 CPPUNIT_TEST(testGetUniqueCellFormatRanges
);
241 CPPUNIT_TEST_SUITE_END();
245 uno::Reference
< lang::XComponent
> mxComponent
;
248 ScTableSheetObj::ScTableSheetObj():
249 CalcUnoApiTest("/sc/qa/extras/testdocuments"),
250 apitest::XCellSeries(1, 0),
251 apitest::XFormulaQuery(table::CellRangeAddress(0, 0, 0, 1023, 1048575), table::CellRangeAddress(0, 0, 0, 1023, 1048575), 0, 0),
252 apitest::XReplaceable("searchReplaceString", "replaceReplaceString"),
253 apitest::XSearchable("test", 4)
257 uno::Reference
< uno::XInterface
> ScTableSheetObj::init()
259 uno::Reference
< sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
261 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), UNO_SET_THROW
);
262 uno::Reference
<container::XIndexAccess
> xIndex (xDoc
->getSheets(), UNO_QUERY_THROW
);
263 uno::Reference
<sheet::XSpreadsheet
> xSheet(xIndex
->getByIndex(0), UNO_QUERY_THROW
);
265 xSheet
->getCellByPosition(5 ,5)->setValue(15);
266 xSheet
->getCellByPosition(2 ,0)->setValue(-5.15);
267 xSheet
->getCellByPosition(2 ,0)->setFormula("= B5 + C1");
269 xSheet
->getCellByPosition(6, 6)->setValue(3);
270 xSheet
->getCellByPosition(7, 6)->setValue(3);
271 xSheet
->getCellByPosition(8, 6)->setFormula("= SUM(G7:H7)");
272 xSheet
->getCellByPosition(9, 6)->setFormula("= G7*I7");
274 uno::Sequence
<table::CellRangeAddress
> aCellRangeAddr(1);
275 aCellRangeAddr
[0] = table::CellRangeAddress(0, 0, 0, 10, 10);
277 uno::Reference
<sheet::XScenariosSupplier
> xScence(xSheet
, UNO_QUERY_THROW
);
278 xScence
->getScenarios()->addNewByName("Scenario", aCellRangeAddr
, "Comment");
279 xSheets
->getByName("Scenario");
284 uno::Reference
< uno::XInterface
> ScTableSheetObj::getXCellRangeData()
289 uno::Reference
<uno::XInterface
> ScTableSheetObj::getXSpreadsheetDocument()
291 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
295 uno::Reference
<uno::XInterface
> ScTableSheetObj::getScenarioSpreadsheet()
297 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
299 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), UNO_SET_THROW
);
300 uno::Reference
<container::XIndexAccess
> xIndex (xDoc
->getSheets(), UNO_QUERY_THROW
);
301 uno::Reference
<sheet::XSpreadsheet
> xSheet(xIndex
->getByIndex(0), UNO_QUERY_THROW
);
303 xSheet
->getCellByPosition(5 ,5)->setValue(15);
304 xSheet
->getCellByPosition(2 ,0)->setValue(-5.15);
305 xSheet
->getCellByPosition(2 ,0)->setFormula("= B5 + C1");
307 xSheet
->getCellByPosition(6, 6)->setValue(3);
308 xSheet
->getCellByPosition(7, 6)->setValue(3);
309 xSheet
->getCellByPosition(8, 6)->setFormula("= SUM(G7:H7)");
310 xSheet
->getCellByPosition(9, 6)->setFormula("= G7*I7");
312 uno::Sequence
<table::CellRangeAddress
> aCellRangeAddr(1);
313 aCellRangeAddr
[0] = table::CellRangeAddress(0, 0, 0, 10, 10);
315 uno::Reference
<sheet::XScenariosSupplier
> xScence(xSheet
, UNO_QUERY_THROW
);
316 xScence
->getScenarios()->addNewByName("Scenario", aCellRangeAddr
, "Comment");
317 uno::Reference
<sheet::XSpreadsheet
> sSheet(xSheets
->getByName("Scenario"), UNO_QUERY_THROW
);
322 uno::Reference
< uno::XInterface
> ScTableSheetObj::getXSpreadsheet()
324 uno::Reference
< sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
326 uno::Reference
<sheet::XSpreadsheets
> xSheets(xDoc
->getSheets(), UNO_SET_THROW
);
327 uno::Reference
< container::XIndexAccess
> xIndex (xDoc
->getSheets(), UNO_QUERY_THROW
);
328 uno::Reference
< sheet::XSpreadsheet
> xSheet( xIndex
->getByIndex(0), UNO_QUERY_THROW
);
330 xSheet
->getCellByPosition(5 ,5)->setValue(15);
331 xSheet
->getCellByPosition(2 ,0)->setValue(-5.15);
332 xSheet
->getCellByPosition(2 ,0)->setFormula("= B5 + C1");
334 xSheet
->getCellByPosition(6, 6)->setValue(3);
335 xSheet
->getCellByPosition(7, 6)->setValue(3);
336 xSheet
->getCellByPosition(8, 6)->setFormula("= SUM(G7:H7)");
337 xSheet
->getCellByPosition(9, 6)->setFormula("= G7*I7");
339 uno::Sequence
<table::CellRangeAddress
> aCellRangeAddr(1);
340 aCellRangeAddr
[0] = table::CellRangeAddress(0, 0, 0, 10, 10);
341 uno::Reference
<sheet::XScenariosSupplier
> xScence(xSheet
, UNO_QUERY_THROW
);
342 xScence
->getScenarios()->addNewByName("Scenario", aCellRangeAddr
, "Comment");
343 xSheets
->getByName("Scenario");
345 setXCell(xSheet
->getCellByPosition(15, 15));
349 OUString
ScTableSheetObj::getFileURL()
354 void ScTableSheetObj::setUp()
356 CalcUnoApiTest::setUp();
357 createFileURL("ScTableSheetObj.ods", maFileURL
);
358 mxComponent
= loadFromDesktop(maFileURL
, "com.sun.star.sheet.SpreadsheetDocument");
361 void ScTableSheetObj::tearDown()
363 closeDocument(mxComponent
);
364 CalcUnoApiTest::tearDown();
367 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableSheetObj
);
371 CPPUNIT_PLUGIN_IMPLEMENT();
373 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */