nss: upgrade to release 3.73
[LibreOffice.git] / test / source / sheet / xsheetfilterable.cxx
bloba6c8b59016bab1962720bd8fce8c29617415420a
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/sheet/xsheetfilterable.hxx>
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/sheet/FilterOperator.hpp>
14 #include <com/sun/star/sheet/TableFilterField.hpp>
15 #include <com/sun/star/sheet/XSheetFilterable.hpp>
16 #include <com/sun/star/sheet/XSheetFilterDescriptor.hpp>
17 #include <com/sun/star/sheet/XSpreadsheet.hpp>
18 #include <com/sun/star/table/XColumnRowRange.hpp>
19 #include <com/sun/star/table/XTableRows.hpp>
20 #include <com/sun/star/uno/Reference.hxx>
21 #include <com/sun/star/uno/Sequence.hxx>
23 #include <cppunit/TestAssert.h>
25 using namespace css;
26 using namespace css::uno;
28 namespace apitest {
30 void XSheetFilterable::testCreateFilterDescriptor()
32 uno::Reference< sheet::XSheetFilterable > xFA(init(), UNO_QUERY_THROW);
33 uno::Reference< sheet::XSheetFilterDescriptor > xSFD = xFA->createFilterDescriptor(true);
35 uno::Sequence< sheet::TableFilterField > xTFF;
36 xTFF.realloc(2);
37 xTFF[0].IsNumeric = true;
38 xTFF[0].Field = 0;
39 xTFF[0].NumericValue = 2;
40 xTFF[0].Operator = sheet::FilterOperator_GREATER_EQUAL;
41 xTFF[1].IsNumeric = false;
42 xTFF[1].Field = 1;
43 xTFF[1].StringValue = "C";
44 xTFF[1].Operator = sheet::FilterOperator_LESS;
46 CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to create XSheetFilterDescriptor", xSFD->setFilterFields(xTFF));
49 void XSheetFilterable::testFilter()
51 uno::Reference< sheet::XSpreadsheet > xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
53 uno::Reference< sheet::XSheetFilterable > xFA(xSheet, UNO_QUERY_THROW);
54 uno::Reference< sheet::XSheetFilterDescriptor > xSFD = xFA->createFilterDescriptor(true);
56 uno::Sequence< sheet::TableFilterField > xTFF;
57 xTFF.realloc(2);
58 xTFF[0].IsNumeric = true;
59 xTFF[0].Field = 0;
60 xTFF[0].NumericValue = 2;
61 xTFF[0].Operator = sheet::FilterOperator_GREATER_EQUAL;
62 xTFF[1].IsNumeric = false;
63 xTFF[1].Field = 1;
64 xTFF[1].StringValue = "C";
65 xTFF[1].Operator = sheet::FilterOperator_LESS;
66 xSFD->setFilterFields(xTFF);
68 xSheet->getCellByPosition(0, 0)->setValue(1);
69 xSheet->getCellByPosition(0, 1)->setValue(2);
70 xSheet->getCellByPosition(0, 2)->setValue(3);
71 xSheet->getCellByPosition(1, 0)->setFormula("A");
72 xSheet->getCellByPosition(1, 1)->setFormula("B");
73 xSheet->getCellByPosition(1, 2)->setFormula("C");
74 xFA->filter(xSFD);
76 uno::Reference< table::XColumnRowRange > xColRowRange(xSheet, UNO_QUERY_THROW);
77 uno::Reference< table::XTableRows > xTableRows = xColRowRange->getRows();
78 uno::Reference< beans::XPropertySet > xRowProps(xTableRows->getByIndex(0), UNO_QUERY_THROW);
79 bool bIsVisible = true;
80 CPPUNIT_ASSERT(xRowProps->getPropertyValue("IsVisible") >>= bIsVisible);
82 CPPUNIT_ASSERT_MESSAGE("Row 1 should be invisible", !bIsVisible);
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */