Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / qa / extras / sctablesheetobj.cxx
blob8b5b3dbaa056094cecb377a9be86b28f1937dd0b
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/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>
51 #include <sheetlimits.hxx>
53 using namespace css;
54 using namespace css::uno;
56 namespace sc_apitest
59 class ScTableSheetObj : public UnoApiTest, public apitest::Scenario,
60 public apitest::SheetCellRange,
61 public apitest::Spreadsheet,
62 public apitest::XArrayFormulaRange,
63 public apitest::XCellFormatRangesSupplier,
64 public apitest::XCellRangeAddressable,
65 public apitest::XCellRangeData,
66 public apitest::XCellRangeFormula,
67 public apitest::XCellRangeMovement,
68 public apitest::XCellSeries,
69 public apitest::XColumnRowRange,
70 public apitest::XDataPilotTablesSupplier,
71 public apitest::XFormulaQuery,
72 public apitest::XIndent,
73 public apitest::XMergeable,
74 public apitest::XMultipleOperation,
75 public apitest::XPrintAreas,
76 public apitest::XReplaceable,
77 public apitest::XScenario,
78 public apitest::XScenarioEnhanced,
79 public apitest::XScenariosSupplier,
80 public apitest::XSearchable,
81 public apitest::XSheetAnnotationsSupplier,
82 public apitest::XSheetAuditing,
83 public apitest::XSheetCellRange,
84 public apitest::XSheetFilterable,
85 public apitest::XSheetFilterableEx,
86 public apitest::XSheetLinkable,
87 public apitest::XSheetOperation,
88 public apitest::XSheetPageBreak,
89 public apitest::XSpreadsheet,
90 public apitest::XSubTotalCalculatable,
91 public apitest::XTableChartsSupplier,
92 public apitest::XUniqueCellFormatRangesSupplier
94 public:
95 ScTableSheetObj();
97 virtual void setUp() override;
99 virtual OUString getFileURL() override;
101 virtual uno::Reference< uno::XInterface > init() override;
102 virtual uno::Reference< uno::XInterface > getXCellRangeData() override;
103 virtual uno::Reference< uno::XInterface > getXSpreadsheetDocument() override;
104 virtual uno::Reference< uno::XInterface > getXSpreadsheet() override;
105 virtual uno::Reference< uno::XInterface > getScenarioSpreadsheet() override;
107 CPPUNIT_TEST_SUITE(ScTableSheetObj);
109 // Scenario
110 CPPUNIT_TEST(testScenarioProperties);
112 // SheetCellRange
113 CPPUNIT_TEST(testSheetCellRangeProperties);
115 // Spreadsheet
116 CPPUNIT_TEST(testSpreadsheetProperties);
118 // XArrayFormulaRange
119 #if 0 // disable, because it makes no sense to set an ArrayFormula over the whole sheet
120 CPPUNIT_TEST(testGetSetArrayFormula);
121 #endif
123 // XCellFormatRangesSupplier
124 CPPUNIT_TEST(testGetCellFormatRanges);
126 // XCellRangeAddressable
127 CPPUNIT_TEST(testGetRangeAddress);
129 // XCellRangeData
130 CPPUNIT_TEST(testGetDataArrayOnTableSheet);
131 CPPUNIT_TEST(testSetDataArrayOnTableSheet);
133 // XCellRangeFormula
134 #if 0 // disable, because it makes no sense to set a FormulaArray over the whole sheet
135 CPPUNIT_TEST(testGetSetFormulaArray);
136 #endif
138 // XCellRangeMovement
139 CPPUNIT_TEST(testInsertCells);
140 CPPUNIT_TEST(testCopyRange);
141 CPPUNIT_TEST(testMoveRange);
142 CPPUNIT_TEST(testRemoveRange);
144 // XCellSeries
145 CPPUNIT_TEST(testFillAuto);
146 CPPUNIT_TEST(testFillSeries);
148 // XColumnRowRange
149 CPPUNIT_TEST(testGetColumns);
150 CPPUNIT_TEST(testGetRows);
152 // XDataPilotTablesSupplier
153 CPPUNIT_TEST(testGetDataPilotTables);
155 // XFormulaQuery
156 CPPUNIT_TEST(testQueryDependents);
157 CPPUNIT_TEST(testQueryPrecedents);
159 // XIndent
160 CPPUNIT_TEST(testIncrementIndent);
161 CPPUNIT_TEST(testDecrementIndent);
163 // XMergeable
164 CPPUNIT_TEST(testGetIsMergedMerge);
166 // XSearchable
167 CPPUNIT_TEST(testFindAll);
168 CPPUNIT_TEST(testFindNext);
169 CPPUNIT_TEST(testFindFirst);
171 // XMultipleOperation
172 #if 0 // disable, because test never finishes (see i87863)
173 CPPUNIT_TEST(testSetTableOperation);
174 #endif
176 // XPrintAreas
177 CPPUNIT_TEST(testSetAndGetPrintTitleColumns);
178 CPPUNIT_TEST(testSetAndGetPrintTitleRows);
180 // XReplaceable
181 CPPUNIT_TEST(testReplaceAll);
182 CPPUNIT_TEST(testCreateReplaceDescriptor);
184 // XScenario
185 // test was disabled in qadevOOo/tests/java/ifc/sheet/_XScenario.java
186 CPPUNIT_TEST(testScenario);
188 // XScenarioEnhanced
189 CPPUNIT_TEST(testGetRanges);
191 // XScenariosSupplier
192 CPPUNIT_TEST(testGetScenarios);
194 // XSheetAnnotationsSupplier
195 CPPUNIT_TEST(testGetAnnotations);
197 // XSheetAuditing
198 CPPUNIT_TEST(testShowHideDependents);
199 CPPUNIT_TEST(testShowHidePrecedents);
200 CPPUNIT_TEST(testClearArrows);
201 CPPUNIT_TEST(testShowErrors);
202 CPPUNIT_TEST(testShowInvalid);
204 // XSheetCellRange
205 CPPUNIT_TEST(testGetSpreadsheet);
207 // XSheetFilterable
208 CPPUNIT_TEST(testCreateFilterDescriptor);
209 CPPUNIT_TEST(testFilter);
211 // XSheetFilterableEx
212 #if 0 // temporarily disabled, takes too long (see i87876)
213 CPPUNIT_TEST(testCreateFilterDescriptorByObject);
214 #endif
216 // XSheetLinkable
217 CPPUNIT_TEST(testSheetLinkable);
219 // XSheetOperation
220 CPPUNIT_TEST(testComputeFunction);
221 CPPUNIT_TEST(testClearContents);
223 // XSheetPageBreak
224 CPPUNIT_TEST(testGetColumnPageBreaks);
225 CPPUNIT_TEST(testGetRowPageBreaks);
226 CPPUNIT_TEST(testRemoveAllManualPageBreaks);
228 // XSpreadsheet
229 CPPUNIT_TEST(testCreateCursor);
230 CPPUNIT_TEST(testCreateCursorByRange);
232 // XSubTotalCalculatable
233 CPPUNIT_TEST(testCreateSubTotalDescriptor);
234 CPPUNIT_TEST(testApplyRemoveSubTotals);
236 // XTableChartsSupplier
237 CPPUNIT_TEST(testGetCharts);
239 // XUniqueCellFormatRangesSupplier
240 CPPUNIT_TEST(testGetUniqueCellFormatRanges);
242 CPPUNIT_TEST_SUITE_END();
244 private:
245 OUString maFileURL;
248 ScTableSheetObj::ScTableSheetObj():
249 UnoApiTest("/sc/qa/extras/testdocuments"),
250 apitest::XCellSeries(1, 0),
251 apitest::XFormulaQuery(
252 table::CellRangeAddress(0, 0, 0, ScSheetLimits::CreateDefault().MaxCol(), ScSheetLimits::CreateDefault().MaxRow()),
253 table::CellRangeAddress(0, 0, 0, ScSheetLimits::CreateDefault().MaxCol(), ScSheetLimits::CreateDefault().MaxRow()),
254 0, 0),
255 apitest::XReplaceable("searchReplaceString", "replaceReplaceString"),
256 apitest::XSearchable("test", 4)
260 uno::Reference< uno::XInterface > ScTableSheetObj::init()
262 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
264 uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_SET_THROW);
265 uno::Reference<container::XIndexAccess> xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
266 uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW);
268 xSheet->getCellByPosition(5 ,5)->setValue(15);
269 xSheet->getCellByPosition(2 ,0)->setValue(-5.15);
270 xSheet->getCellByPosition(2 ,0)->setFormula("= B5 + C1");
272 xSheet->getCellByPosition(6, 6)->setValue(3);
273 xSheet->getCellByPosition(7, 6)->setValue(3);
274 xSheet->getCellByPosition(8, 6)->setFormula("= SUM(G7:H7)");
275 xSheet->getCellByPosition(9, 6)->setFormula("= G7*I7");
277 uno::Sequence<table::CellRangeAddress> aCellRangeAddr { { 0, 0, 0, 10, 10 } };
279 uno::Reference<sheet::XScenariosSupplier> xScence(xSheet, UNO_QUERY_THROW);
280 xScence->getScenarios()->addNewByName("Scenario", aCellRangeAddr, "Comment");
281 xSheets->getByName("Scenario");
283 return xSheet;
286 uno::Reference< uno::XInterface > ScTableSheetObj::getXCellRangeData()
288 return init();
291 uno::Reference<uno::XInterface> ScTableSheetObj::getXSpreadsheetDocument()
293 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
294 return xDoc;
297 uno::Reference<uno::XInterface> ScTableSheetObj::getScenarioSpreadsheet()
299 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
301 uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_SET_THROW);
302 uno::Reference<container::XIndexAccess> xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
303 uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW);
305 xSheet->getCellByPosition(5 ,5)->setValue(15);
306 xSheet->getCellByPosition(2 ,0)->setValue(-5.15);
307 xSheet->getCellByPosition(2 ,0)->setFormula("= B5 + C1");
309 xSheet->getCellByPosition(6, 6)->setValue(3);
310 xSheet->getCellByPosition(7, 6)->setValue(3);
311 xSheet->getCellByPosition(8, 6)->setFormula("= SUM(G7:H7)");
312 xSheet->getCellByPosition(9, 6)->setFormula("= G7*I7");
314 uno::Sequence<table::CellRangeAddress> aCellRangeAddr { { 0, 0, 0, 10, 10 } };
316 uno::Reference<sheet::XScenariosSupplier> xScence(xSheet, UNO_QUERY_THROW);
317 xScence->getScenarios()->addNewByName("Scenario", aCellRangeAddr, "Comment");
318 uno::Reference<sheet::XSpreadsheet> sSheet(xSheets->getByName("Scenario"), UNO_QUERY_THROW);
320 return sSheet;
323 uno::Reference< uno::XInterface > ScTableSheetObj::getXSpreadsheet()
325 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
327 uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_SET_THROW);
328 uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
329 uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
331 xSheet->getCellByPosition(5 ,5)->setValue(15);
332 xSheet->getCellByPosition(2 ,0)->setValue(-5.15);
333 xSheet->getCellByPosition(2 ,0)->setFormula("= B5 + C1");
335 xSheet->getCellByPosition(6, 6)->setValue(3);
336 xSheet->getCellByPosition(7, 6)->setValue(3);
337 xSheet->getCellByPosition(8, 6)->setFormula("= SUM(G7:H7)");
338 xSheet->getCellByPosition(9, 6)->setFormula("= G7*I7");
340 uno::Sequence<table::CellRangeAddress> aCellRangeAddr { {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));
346 return xSheet;
349 OUString ScTableSheetObj::getFileURL()
351 return maFileURL;
354 void ScTableSheetObj::setUp()
356 UnoApiTest::setUp();
357 maFileURL = loadFromURL(u"ScTableSheetObj.ods");
360 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableSheetObj);
364 CPPUNIT_PLUGIN_IMPLEMENT();
366 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */