LibreOffice Module test (master) 1
xcellrangesquery.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/XCellRangesQuery.hpp>
13#include <com/sun/star/sheet/XSheetCellRanges.hpp>
14#include <com/sun/star/table/CellAddress.hpp>
15#include <com/sun/star/sheet/CellFlags.hpp>
16
17#include <cppunit/TestAssert.h>
18
19using namespace com::sun::star;
20using namespace com::sun::star::uno;
21
22
23namespace apitest {
24
26{
27 uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
28 uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryColumnDifferences(table::CellAddress(0, 1, 1));
29 OUString aResult = xRanges->getRangeAddressesAsString();
30 std::cout << "testQueryColumnDifference: Result: " << aResult << std::endl;
31 CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryColumnDifference", OUString( "Sheet1.B1:C1,Sheet1.B3:C5" ), aResult);
32}
33
35{
36 uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
37 uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE);
38 OUString aResult = xRanges->getRangeAddressesAsString();
39 std::cout << "testQueryContentDifference: Result: " << aResult << std::endl;
40 CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryContentDifference", OUString( "Sheet1.B3,Sheet1.C2" ), aResult);
41}
42
44{
45 uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
46 uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryEmptyCells();
47 OUString aResult = xRanges->getRangeAddressesAsString();
48 std::cout << "testQueryEmptyCells: Result: " << aResult << std::endl;
49 CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryEmptyCells", OUString( "Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:E5" ), aResult);
50}
51
53{
54 uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
55 uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA);
56 OUString aResult = xRanges->getRangeAddressesAsString();
57 std::cout << "testQueryFormulaCells: Result: " << aResult << std::endl;
58 CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryFormulaCells", OUString( "Sheet1.B2" ), aResult);
59}
60
62{
63 uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
64 uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7));
65 OUString aResult = xRanges->getRangeAddressesAsString();
66 std::cout << "testQueryIntersection: Result: " << aResult << std::endl;
67 CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryIntersection", OUString( "Sheet1.D4:E5" ), aResult);
68}
69
71{
72 uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
73 uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1));
74 OUString aResult = xRanges->getRangeAddressesAsString();
75 std::cout << "testQueryRowDifference: Result: " << aResult << std::endl;
76 CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryRowDifference", OUString( "Sheet1.A2:A4,Sheet1.C2:E4" ), aResult);
77}
78
80{
81 uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
82 uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
83 OUString aResult = xRanges->getRangeAddressesAsString();
84 std::cout << "testQueryVisibleCells: Result: " << aResult << std::endl;
85 CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryVisibleCells", OUString( "Sheet1.A1:E5" ), aResult);
86}
87
88}
89
90/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::uno::XInterface > init()=0