From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- test/source/sheet/xsheetfilterable.cxx | 87 ++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 test/source/sheet/xsheetfilterable.cxx (limited to 'test/source/sheet/xsheetfilterable.cxx') diff --git a/test/source/sheet/xsheetfilterable.cxx b/test/source/sheet/xsheetfilterable.cxx new file mode 100644 index 000000000..a6c8b5901 --- /dev/null +++ b/test/source/sheet/xsheetfilterable.cxx @@ -0,0 +1,87 @@ +/* -*- 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 + +using namespace css; +using namespace css::uno; + +namespace apitest { + +void XSheetFilterable::testCreateFilterDescriptor() +{ + uno::Reference< sheet::XSheetFilterable > xFA(init(), UNO_QUERY_THROW); + uno::Reference< sheet::XSheetFilterDescriptor > xSFD = xFA->createFilterDescriptor(true); + + uno::Sequence< sheet::TableFilterField > xTFF; + xTFF.realloc(2); + xTFF[0].IsNumeric = true; + xTFF[0].Field = 0; + xTFF[0].NumericValue = 2; + xTFF[0].Operator = sheet::FilterOperator_GREATER_EQUAL; + xTFF[1].IsNumeric = false; + xTFF[1].Field = 1; + xTFF[1].StringValue = "C"; + xTFF[1].Operator = sheet::FilterOperator_LESS; + + CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to create XSheetFilterDescriptor", xSFD->setFilterFields(xTFF)); +} + +void XSheetFilterable::testFilter() +{ + uno::Reference< sheet::XSpreadsheet > xSheet(getXSpreadsheet(), UNO_QUERY_THROW); + + uno::Reference< sheet::XSheetFilterable > xFA(xSheet, UNO_QUERY_THROW); + uno::Reference< sheet::XSheetFilterDescriptor > xSFD = xFA->createFilterDescriptor(true); + + uno::Sequence< sheet::TableFilterField > xTFF; + xTFF.realloc(2); + xTFF[0].IsNumeric = true; + xTFF[0].Field = 0; + xTFF[0].NumericValue = 2; + xTFF[0].Operator = sheet::FilterOperator_GREATER_EQUAL; + xTFF[1].IsNumeric = false; + xTFF[1].Field = 1; + xTFF[1].StringValue = "C"; + xTFF[1].Operator = sheet::FilterOperator_LESS; + xSFD->setFilterFields(xTFF); + + xSheet->getCellByPosition(0, 0)->setValue(1); + xSheet->getCellByPosition(0, 1)->setValue(2); + xSheet->getCellByPosition(0, 2)->setValue(3); + xSheet->getCellByPosition(1, 0)->setFormula("A"); + xSheet->getCellByPosition(1, 1)->setFormula("B"); + xSheet->getCellByPosition(1, 2)->setFormula("C"); + xFA->filter(xSFD); + + uno::Reference< table::XColumnRowRange > xColRowRange(xSheet, UNO_QUERY_THROW); + uno::Reference< table::XTableRows > xTableRows = xColRowRange->getRows(); + uno::Reference< beans::XPropertySet > xRowProps(xTableRows->getByIndex(0), UNO_QUERY_THROW); + bool bIsVisible = true; + CPPUNIT_ASSERT(xRowProps->getPropertyValue("IsVisible") >>= bIsVisible); + + CPPUNIT_ASSERT_MESSAGE("Row 1 should be invisible", !bIsVisible); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3