1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/sheet/xsheetfilterableex.hxx>
12 #include <com/sun/star/sheet/FilterConnection.hpp>
13 #include <com/sun/star/sheet/FilterOperator.hpp>
14 #include <com/sun/star/sheet/TableFilterField.hpp>
15 #include <com/sun/star/sheet/XSheetFilterDescriptor.hpp>
16 #include <com/sun/star/sheet/XSheetFilterable.hpp>
17 #include <com/sun/star/sheet/XSheetFilterableEx.hpp>
18 #include <com/sun/star/uno/Reference.hxx>
19 #include <com/sun/star/uno/Sequence.hxx>
21 #include <cppunit/TestAssert.h>
24 using namespace css::uno
;
28 void XSheetFilterableEx::testCreateFilterDescriptorByObject()
30 uno::Reference
<sheet::XSheetFilterableEx
> xSFEx(init(), UNO_QUERY_THROW
);
31 uno::Reference
<sheet::XSheetFilterable
> xSF(getXSpreadsheet(), UNO_QUERY_THROW
);
33 uno::Reference
<sheet::XSheetFilterDescriptor
> xSFD
= xSFEx
->createFilterDescriptorByObject(xSF
);
34 CPPUNIT_ASSERT_MESSAGE("no XSheetFilterDescriptor", xSFD
.is());
36 const uno::Sequence
<sheet::TableFilterField
> xTFF
= xSFD
->getFilterFields();
37 CPPUNIT_ASSERT_MESSAGE("The gained XSheetFilterDescriptor is empty", xTFF
.hasElements());
39 for (const auto& field
: xTFF
)
41 // we don't care about the actual value, just that we can access the fields
42 CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: StringValue",
43 !field
.StringValue
.isEmpty() || field
.StringValue
.isEmpty());
44 CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: IsNumeric",
45 !field
.IsNumeric
|| field
.IsNumeric
);
46 CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: NumericValue",
47 field
.NumericValue
!= 0.0 || field
.NumericValue
== 0.0);
48 CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: Field",
49 field
.Field
!= 0 || field
.Field
== 0);
50 CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: Connection",
51 field
.Connection
== sheet::FilterConnection_AND
52 || field
.Connection
== sheet::FilterConnection_OR
);
53 CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: Operator",
54 field
.Operator
!= sheet::FilterOperator_EMPTY
);
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */