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/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>
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
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
;
85 CPPUNIT_TEST_SUITE(ScCellRangeObj
);
88 CPPUNIT_TEST(testVertJustify
);
89 CPPUNIT_TEST(testRotateReference
);
92 CPPUNIT_TEST(testSheetCellRangeProperties
);
95 CPPUNIT_TEST(testGetSetArrayFormula
);
97 // XCellFormatRangesSupplier
98 CPPUNIT_TEST(testGetCellFormatRanges
);
100 // XCellRangeAddressable
101 CPPUNIT_TEST(testGetRangeAddress
);
104 CPPUNIT_TEST(testGetDataArray
);
105 CPPUNIT_TEST(testSetDataArray
);
108 CPPUNIT_TEST(testGetSetFormulaArray
);
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
);
120 CPPUNIT_TEST(testFillAuto
);
121 CPPUNIT_TEST(testFillSeries
);
124 CPPUNIT_TEST(testGetNotANumber
);
125 CPPUNIT_TEST(testIsNotANumber
);
126 CPPUNIT_TEST(testChartDataChangeEventListener
);
129 CPPUNIT_TEST(testGetColumns
);
130 CPPUNIT_TEST(testGetRows
);
133 CPPUNIT_TEST(testQueryDependents
);
134 CPPUNIT_TEST(testQueryPrecedents
);
137 CPPUNIT_TEST(testIncrementIndent
);
138 CPPUNIT_TEST(testDecrementIndent
);
141 CPPUNIT_TEST(testGetIsMergedMerge
);
143 // XMultipleOperation
144 CPPUNIT_TEST(testSetTableOperation
);
147 CPPUNIT_TEST(testReplaceAll
);
148 CPPUNIT_TEST(testCreateReplaceDescriptor
);
151 CPPUNIT_TEST(testFindAll
);
152 CPPUNIT_TEST(testFindFirst
);
155 CPPUNIT_TEST(testGetSpreadsheet
);
158 CPPUNIT_TEST(testCreateFilterDescriptor
);
159 CPPUNIT_TEST(testFilter
);
161 // XSheetFilterableEx
162 CPPUNIT_TEST(testCreateFilterDescriptorByObject
);
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();
180 uno::Reference
<lang::XComponent
> mxComponent
;
183 ScCellRangeObj::ScCellRangeObj()
184 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
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),
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));
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),
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();
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: */