nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / sccellrangeobj.cxx
blob689783dafcbdabab82916e566134dae292ad33f1
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/calc_unoapi_test.hxx>
11 #include <test/chart/xchartdata.hxx>
12 #include <test/sheet/cellproperties.hxx>
13 #include <test/sheet/sheetcellrange.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/xcellrangesquery.hxx>
20 #include <test/sheet/xcellseries.hxx>
21 #include <test/sheet/xformulaquery.hxx>
22 #include <test/sheet/xmultipleoperation.hxx>
23 #include <test/sheet/xsheetcellrange.hxx>
24 #include <test/sheet/xsheetfilterable.hxx>
25 #include <test/sheet/xsheetfilterableex.hxx>
26 #include <test/sheet/xsheetoperation.hxx>
27 #include <test/sheet/xsubtotalcalculatable.hxx>
28 #include <test/sheet/xuniquecellformatrangessupplier.hxx>
29 #include <test/table/xcolumnrowrange.hxx>
30 #include <test/util/xindent.hxx>
31 #include <test/util/xmergeable.hxx>
32 #include <test/util/xreplaceable.hxx>
33 #include <test/util/xsearchable.hxx>
34 #include <comphelper/propertysequence.hxx>
36 #include <com/sun/star/sheet/XSpreadsheet.hpp>
37 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
38 #include <com/sun/star/table/XCellRange.hpp>
39 #include <com/sun/star/util/SortField.hpp>
40 #include <com/sun/star/util/XSortable.hpp>
42 #include <com/sun/star/uno/Any.hxx>
43 #include <com/sun/star/uno/Reference.hxx>
44 #include <com/sun/star/uno/Sequence.hxx>
46 using namespace css;
48 namespace sc_apitest
50 class ScCellRangeObj : public CalcUnoApiTest,
51 public apitest::CellProperties,
52 public apitest::SheetCellRange,
53 public apitest::XArrayFormulaRange,
54 public apitest::XCellFormatRangesSupplier,
55 public apitest::XCellRangeAddressable,
56 public apitest::XCellRangeData,
57 public apitest::XCellRangeFormula,
58 public apitest::XCellRangesQuery,
59 public apitest::XCellSeries,
60 public apitest::XChartData,
61 public apitest::XColumnRowRange,
62 public apitest::XFormulaQuery,
63 public apitest::XIndent,
64 public apitest::XMergeable,
65 public apitest::XMultipleOperation,
66 public apitest::XReplaceable,
67 public apitest::XSearchable,
68 public apitest::XSheetCellRange,
69 public apitest::XSheetFilterable,
70 public apitest::XSheetFilterableEx,
71 public apitest::XSheetOperation,
72 public apitest::XSubTotalCalculatable,
73 public apitest::XUniqueCellFormatRangesSupplier
75 public:
76 ScCellRangeObj();
78 virtual void setUp() override;
79 virtual void tearDown() override;
80 virtual uno::Reference<uno::XInterface> init() override;
81 virtual uno::Reference<uno::XInterface> getXCellRangeData() override;
82 virtual uno::Reference<uno::XInterface> getXSpreadsheet() override;
83 void testSortOOB();
85 CPPUNIT_TEST_SUITE(ScCellRangeObj);
87 // CellProperties
88 CPPUNIT_TEST(testVertJustify);
89 CPPUNIT_TEST(testRotateReference);
91 // SheetCellRange
92 CPPUNIT_TEST(testSheetCellRangeProperties);
94 // XArrayFormulaRange
95 CPPUNIT_TEST(testGetSetArrayFormula);
97 // XCellFormatRangesSupplier
98 CPPUNIT_TEST(testGetCellFormatRanges);
100 // XCellRangeAddressable
101 CPPUNIT_TEST(testGetRangeAddress);
103 // XCellRangeData
104 CPPUNIT_TEST(testGetDataArray);
105 CPPUNIT_TEST(testSetDataArray);
107 // XCellRangeFormula
108 CPPUNIT_TEST(testGetSetFormulaArray);
110 // XCellRangesQuery
111 CPPUNIT_TEST(testQueryColumnDifference);
112 CPPUNIT_TEST(testQueryContentDifference);
113 CPPUNIT_TEST(testQueryEmptyCells);
114 //CPPUNIT_TEST(testQueryFormulaCells);
115 CPPUNIT_TEST(testQueryIntersection);
116 CPPUNIT_TEST(testQueryRowDifference);
117 CPPUNIT_TEST(testQueryVisibleCells);
119 // XCellSeries
120 CPPUNIT_TEST(testFillAuto);
121 CPPUNIT_TEST(testFillSeries);
123 // XChartData
124 CPPUNIT_TEST(testGetNotANumber);
125 CPPUNIT_TEST(testIsNotANumber);
126 CPPUNIT_TEST(testChartDataChangeEventListener);
128 // XColumnRowRange
129 CPPUNIT_TEST(testGetColumns);
130 CPPUNIT_TEST(testGetRows);
132 // XFormulaQuery
133 CPPUNIT_TEST(testQueryDependents);
134 CPPUNIT_TEST(testQueryPrecedents);
136 // XIndent
137 CPPUNIT_TEST(testIncrementIndent);
138 CPPUNIT_TEST(testDecrementIndent);
140 // XMergeable
141 CPPUNIT_TEST(testGetIsMergedMerge);
143 // XMultipleOperation
144 CPPUNIT_TEST(testSetTableOperation);
146 // XReplaceable
147 CPPUNIT_TEST(testReplaceAll);
148 CPPUNIT_TEST(testCreateReplaceDescriptor);
150 // XSearchable
151 CPPUNIT_TEST(testFindAll);
152 CPPUNIT_TEST(testFindFirst);
154 // XSheetCellRange
155 CPPUNIT_TEST(testGetSpreadsheet);
157 // XSheetFilterable
158 CPPUNIT_TEST(testCreateFilterDescriptor);
159 CPPUNIT_TEST(testFilter);
161 // XSheetFilterableEx
162 CPPUNIT_TEST(testCreateFilterDescriptorByObject);
164 // XSheetOperation
165 CPPUNIT_TEST(testComputeFunction);
166 CPPUNIT_TEST(testClearContents);
168 // XSubTotalCalculatable
169 CPPUNIT_TEST(testCreateSubTotalDescriptor);
170 CPPUNIT_TEST(testApplyRemoveSubTotals);
172 // XUniqueCellFormatRangesSupplier
173 CPPUNIT_TEST(testGetUniqueCellFormatRanges);
175 CPPUNIT_TEST(testSortOOB);
177 CPPUNIT_TEST_SUITE_END();
179 private:
180 uno::Reference<lang::XComponent> mxComponent;
183 ScCellRangeObj::ScCellRangeObj()
184 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
185 , XCellSeries(2, 1)
186 , XFormulaQuery(table::CellRangeAddress(0, 15, 15, 15, 15),
187 table::CellRangeAddress(0, 0, 15, 0, 15))
188 , XReplaceable("15", "35")
189 , XSearchable("15", 1)
193 uno::Reference<uno::XInterface> ScCellRangeObj::init()
195 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
197 uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
198 uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
200 uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0, 0, 4, 4),
201 uno::UNO_SET_THROW);
203 return xReturn;
206 uno::Reference<uno::XInterface> ScCellRangeObj::getXSpreadsheet()
208 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
210 uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
211 uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
213 setXCell(xSheet->getCellByPosition(15, 15));
215 return xSheet;
218 uno::Reference<uno::XInterface> ScCellRangeObj::getXCellRangeData()
220 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
222 uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
223 uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(1), uno::UNO_QUERY_THROW);
225 uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0, 0, 3, 3),
226 uno::UNO_SET_THROW);
228 return xReturn;
231 void ScCellRangeObj::testSortOOB()
233 uno::Reference<util::XSortable> xSortable(init(), uno::UNO_QUERY_THROW);
234 uno::Sequence<beans::PropertyValue> aEmptyDescriptor;
235 xSortable->sort(aEmptyDescriptor);
237 uno::Sequence<util::SortField> aSort(1);
238 aSort[0].Field = 0xffffff;
239 aSort[0].SortAscending = true;
241 uno::Sequence<beans::PropertyValue> aProps(
242 comphelper::InitPropertySequence({ { "SortFields", uno::Any(aSort) } }));
244 xSortable->sort(aProps);
247 void ScCellRangeObj::setUp()
249 CalcUnoApiTest::setUp();
251 OUString aFileURL;
252 createFileURL("xcellrangesquery.ods", aFileURL);
253 mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
256 void ScCellRangeObj::tearDown()
258 closeDocument(mxComponent);
259 CalcUnoApiTest::tearDown();
262 CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangeObj);
264 } // namespace sc_apitest
266 CPPUNIT_PLUGIN_IMPLEMENT();
268 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */