LibreOffice Module test (master) 1
xsheetfilterableex.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 */
9
11
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>
20
21#include <cppunit/TestAssert.h>
22
23using namespace css;
24using namespace css::uno;
25
26namespace apitest
27{
29{
30 uno::Reference<sheet::XSheetFilterableEx> xSFEx(init(), UNO_QUERY_THROW);
31 uno::Reference<sheet::XSheetFilterable> xSF(getXSpreadsheet(), UNO_QUERY_THROW);
32
33 uno::Reference<sheet::XSheetFilterDescriptor> xSFD = xSFEx->createFilterDescriptorByObject(xSF);
34 CPPUNIT_ASSERT_MESSAGE("no XSheetFilterDescriptor", xSFD.is());
35
36 const uno::Sequence<sheet::TableFilterField> xTFF = xSFD->getFilterFields();
37 CPPUNIT_ASSERT_MESSAGE("The gained XSheetFilterDescriptor is empty", xTFF.hasElements());
38
39 for (const auto& field : xTFF)
40 {
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);
55 }
56}
57}
58
59/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Reference< css::uno::XInterface > getXSpreadsheet()=0
virtual css::uno::Reference< css::uno::XInterface > init()=0