LibreOffice Module test (master) 1
xdatapilottables.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/XDataPilotDescriptor.hpp>
13#include <com/sun/star/sheet/XDataPilotTables.hpp>
14#include <com/sun/star/sheet/XSpreadsheet.hpp>
15#include <com/sun/star/table/CellAddress.hpp>
16#include <com/sun/star/uno/RuntimeException.hpp>
17#include <com/sun/star/uno/Reference.hxx>
18
19#include <cppunit/TestAssert.h>
20
21using namespace css;
22using namespace css::uno;
23
24namespace apitest
25{
27{
28 uno::Reference<sheet::XDataPilotTables> xDPT(init(), UNO_QUERY_THROW);
29 uno::Reference<sheet::XSpreadsheet> xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
30
31 uno::Reference<sheet::XDataPilotDescriptor> xDPD(xDPT->createDataPilotDescriptor(),
32 UNO_SET_THROW);
33
34 xDPT->insertNewByName("XDataPilotTables", table::CellAddress(0, 9, 8), xDPD);
35 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to insert new DataPilotTable", OUString("Filter"),
36 xSheet->getCellByPosition(9, 8)->getFormula());
37
38 CPPUNIT_ASSERT_THROW_MESSAGE(
39 "No exception thrown, when inserting element with existing name",
40 xDPT->insertNewByName("XDataPilotTables", table::CellAddress(0, 7, 7), xDPD),
41 css::uno::RuntimeException);
42
43 xDPT->removeByName("XDataPilotTables");
44 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove DataPilotTable", OUString(""),
45 xSheet->getCellByPosition(9, 8)->getFormula());
46
47 CPPUNIT_ASSERT_THROW_MESSAGE("No exception, when removing no existing element",
48 xDPT->removeByName("XDataPilotTables"),
49 css::uno::RuntimeException);
50}
51}
52
53/* 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