LibreOffice Module test (master) 1
xsubtotalfield.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/GeneralFunction.hpp>
13#include <com/sun/star/sheet/SubTotalColumn.hpp>
14#include <com/sun/star/sheet/XSubTotalField.hpp>
15
16#include <com/sun/star/uno/Reference.hxx>
17#include <com/sun/star/uno/Sequence.hxx>
18
19#include <cppunit/TestAssert.h>
20
21using namespace com::sun::star;
22using namespace com::sun::star::uno;
23
24template<> inline std::string
25CPPUNIT_NS::assertion_traits<uno::Sequence< sheet::SubTotalColumn > >::toString(
26 const uno::Sequence< sheet::SubTotalColumn >& x)
27{
28 OStringStream ost;
29 ost << "Sequence: Length: " << x.getLength() << "\n";
30 for (const auto& rElement : x)
31 ost << "Column: " << rElement.Column << " Function:\n";
32 // FIXME: Find a way to print Function
33 //ost << "Column: " << element->Column << " Function: " << element->Function << "\n";
34 return ost.str();
35}
36
37namespace apitest {
38
40{
41 uno::Reference< sheet::XSubTotalField > xSTF(init(), uno::UNO_QUERY_THROW);
42
43 CPPUNIT_ASSERT_MESSAGE("Unable to get GroupColumn", xSTF->getGroupColumn() != 0);
44
45 xSTF->setGroupColumn(2);
46 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set GroupColumn to new value",
47 sal_Int32(2), xSTF->getGroupColumn());
48}
49
51{
52 uno::Reference< sheet::XSubTotalField > xSTF(init(), UNO_QUERY_THROW);
53
54 uno::Sequence< sheet::SubTotalColumn > sDefaultCols = xSTF->getSubTotalColumns();
55 CPPUNIT_ASSERT_MESSAGE("Unable to get SubTotalColumns", sDefaultCols.hasElements());
56
57 uno::Sequence< sheet::SubTotalColumn > sNewCols{ { /* Column */ 5,
58 /* Function */ sheet::GeneralFunction_AVERAGE } };
59 xSTF->setSubTotalColumns(sNewCols);
60
61 CPPUNIT_ASSERT_MESSAGE("Unable to set SubTotalColumns", sDefaultCols != xSTF->getSubTotalColumns());
62}
63
64}
65
66/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Reference< css::uno::XInterface > init()=0
float x