From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- sc/qa/extras/sccellrangeobj.cxx | 257 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100644 sc/qa/extras/sccellrangeobj.cxx (limited to 'sc/qa/extras/sccellrangeobj.cxx') diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx new file mode 100644 index 0000000000..5470ae7579 --- /dev/null +++ b/sc/qa/extras/sccellrangeobj.cxx @@ -0,0 +1,257 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace css; + +namespace sc_apitest +{ +class ScCellRangeObj : public UnoApiTest, + public apitest::CellProperties, + public apitest::SheetCellRange, + public apitest::XArrayFormulaRange, + public apitest::XCellFormatRangesSupplier, + public apitest::XCellRangeAddressable, + public apitest::XCellRangeData, + public apitest::XCellRangeFormula, + public apitest::XCellRangesQuery, + public apitest::XCellSeries, + public apitest::XChartData, + public apitest::XColumnRowRange, + public apitest::XFormulaQuery, + public apitest::XIndent, + public apitest::XMergeable, + public apitest::XMultipleOperation, + public apitest::XReplaceable, + public apitest::XSearchable, + public apitest::XSheetCellRange, + public apitest::XSheetFilterable, + public apitest::XSheetFilterableEx, + public apitest::XSheetOperation, + public apitest::XSubTotalCalculatable, + public apitest::XUniqueCellFormatRangesSupplier +{ +public: + ScCellRangeObj(); + + virtual void setUp() override; + virtual uno::Reference init() override; + virtual uno::Reference getXCellRangeData() override; + virtual uno::Reference getXSpreadsheet() override; + void testSortOOB(); + + CPPUNIT_TEST_SUITE(ScCellRangeObj); + + // CellProperties + CPPUNIT_TEST(testVertJustify); + CPPUNIT_TEST(testRotateReference); + + // SheetCellRange + CPPUNIT_TEST(testSheetCellRangeProperties); + + // XArrayFormulaRange + CPPUNIT_TEST(testGetSetArrayFormula); + + // XCellFormatRangesSupplier + CPPUNIT_TEST(testGetCellFormatRanges); + + // XCellRangeAddressable + CPPUNIT_TEST(testGetRangeAddress); + + // XCellRangeData + CPPUNIT_TEST(testGetDataArray); + CPPUNIT_TEST(testSetDataArray); + + // XCellRangeFormula + CPPUNIT_TEST(testGetSetFormulaArray); + + // XCellRangesQuery + CPPUNIT_TEST(testQueryColumnDifference); + CPPUNIT_TEST(testQueryContentDifference); + CPPUNIT_TEST(testQueryEmptyCells); + //CPPUNIT_TEST(testQueryFormulaCells); + CPPUNIT_TEST(testQueryIntersection); + CPPUNIT_TEST(testQueryRowDifference); + CPPUNIT_TEST(testQueryVisibleCells); + + // XCellSeries + CPPUNIT_TEST(testFillAuto); + CPPUNIT_TEST(testFillSeries); + + // XChartData + CPPUNIT_TEST(testGetNotANumber); + CPPUNIT_TEST(testIsNotANumber); + CPPUNIT_TEST(testChartDataChangeEventListener); + + // XColumnRowRange + CPPUNIT_TEST(testGetColumns); + CPPUNIT_TEST(testGetRows); + + // XFormulaQuery + CPPUNIT_TEST(testQueryDependents); + CPPUNIT_TEST(testQueryPrecedents); + + // XIndent + CPPUNIT_TEST(testIncrementIndent); + CPPUNIT_TEST(testDecrementIndent); + + // XMergeable + CPPUNIT_TEST(testGetIsMergedMerge); + + // XMultipleOperation + CPPUNIT_TEST(testSetTableOperation); + + // XReplaceable + CPPUNIT_TEST(testReplaceAll); + CPPUNIT_TEST(testCreateReplaceDescriptor); + + // XSearchable + CPPUNIT_TEST(testFindAll); + CPPUNIT_TEST(testFindFirst); + + // XSheetCellRange + CPPUNIT_TEST(testGetSpreadsheet); + + // XSheetFilterable + CPPUNIT_TEST(testCreateFilterDescriptor); + CPPUNIT_TEST(testFilter); + + // XSheetFilterableEx + CPPUNIT_TEST(testCreateFilterDescriptorByObject); + + // XSheetOperation + CPPUNIT_TEST(testComputeFunction); + CPPUNIT_TEST(testClearContents); + + // XSubTotalCalculatable + CPPUNIT_TEST(testCreateSubTotalDescriptor); + CPPUNIT_TEST(testApplyRemoveSubTotals); + + // XUniqueCellFormatRangesSupplier + CPPUNIT_TEST(testGetUniqueCellFormatRanges); + + CPPUNIT_TEST(testSortOOB); + + CPPUNIT_TEST_SUITE_END(); +}; + +ScCellRangeObj::ScCellRangeObj() + : UnoApiTest("/sc/qa/extras/testdocuments") + , XCellSeries(2, 1) + , XFormulaQuery(table::CellRangeAddress(0, 15, 15, 15, 15), + table::CellRangeAddress(0, 0, 15, 0, 15)) + , XReplaceable("15", "35") + , XSearchable("15", 1) +{ +} + +uno::Reference ScCellRangeObj::init() +{ + uno::Reference xDoc(mxComponent, uno::UNO_QUERY_THROW); + + uno::Reference xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW); + + uno::Reference xReturn(xSheet->getCellRangeByPosition(0, 0, 4, 4), + uno::UNO_SET_THROW); + + return xReturn; +} + +uno::Reference ScCellRangeObj::getXSpreadsheet() +{ + uno::Reference xDoc(mxComponent, uno::UNO_QUERY_THROW); + + uno::Reference xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW); + + setXCell(xSheet->getCellByPosition(15, 15)); + + return xSheet; +} + +uno::Reference ScCellRangeObj::getXCellRangeData() +{ + uno::Reference xDoc(mxComponent, uno::UNO_QUERY_THROW); + + uno::Reference xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference xSheet(xIndex->getByIndex(1), uno::UNO_QUERY_THROW); + + uno::Reference xReturn(xSheet->getCellRangeByPosition(0, 0, 3, 3), + uno::UNO_SET_THROW); + + return xReturn; +} + +void ScCellRangeObj::testSortOOB() +{ + uno::Reference xSortable(init(), uno::UNO_QUERY_THROW); + uno::Sequence aEmptyDescriptor; + xSortable->sort(aEmptyDescriptor); + + uno::Sequence aSort(1); + auto pSort = aSort.getArray(); + pSort[0].Field = 0xffffff; + pSort[0].SortAscending = true; + + uno::Sequence aProps( + comphelper::InitPropertySequence({ { "SortFields", uno::Any(aSort) } })); + + xSortable->sort(aProps); +} + +void ScCellRangeObj::setUp() +{ + UnoApiTest::setUp(); + + loadFromFile(u"xcellrangesquery.ods"); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangeObj); + +} // namespace sc_apitest + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3