Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : : *
5 : : * The contents of this file are subject to the Mozilla Public License Version
6 : : * 1.1 (the "License"); you may not use this file except in compliance with
7 : : * the License or as specified alternatively below. You may obtain a copy of
8 : : * the License at http://www.mozilla.org/MPL/
9 : : *
10 : : * Software distributed under the License is distributed on an "AS IS" basis,
11 : : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : : * for the specific language governing rights and limitations under the
13 : : * License.
14 : : *
15 : : * Major Contributor(s):
16 : : * [ Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer) ]
17 : : *
18 : : * All Rights Reserved.
19 : : *
20 : : * For minor contributions see the git repository.
21 : : *
22 : : * Alternatively, the contents of this file may be used under the terms of
23 : : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 : : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 : : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 : : * instead of those above.
27 : : */
28 : :
29 : : #include <test/sheet/xcellrangesquery.hxx>
30 : :
31 : : #include <com/sun/star/sheet/XCellRangesQuery.hpp>
32 : : #include <com/sun/star/sheet/XSheetCellRanges.hpp>
33 : : #include <com/sun/star/table/CellAddress.hpp>
34 : : #include <com/sun/star/sheet/CellFlags.hpp>
35 : :
36 : : #include "cppunit/extensions/HelperMacros.h"
37 : :
38 : : using namespace com::sun::star;
39 : : using namespace com::sun::star::uno;
40 : :
41 : :
42 : : namespace apitest {
43 : :
44 : 2 : void XCellRangesQuery::testQueryColumnDifference()
45 : : {
46 [ + - ]: 2 : rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.B1:C1,Sheet1.B3:C5"));
47 [ + - ][ + - ]: 2 : uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
48 [ + - ][ + - ]: 2 : uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryColumnDifferences(table::CellAddress(0, 1, 1));
49 [ + - ][ + - ]: 2 : rtl::OUString aResult = xRanges->getRangeAddressesAsString();
50 [ + - ][ + - ]: 2 : std::cout << "testQueryColumnDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
[ + - ][ + - ]
51 [ + - ][ + - ]: 2 : CPPUNIT_ASSERT_MESSAGE("testQueryColumnDifference", aResult == aExpected);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
52 : 2 : }
53 : :
54 : 2 : void XCellRangesQuery::testQueryContentDifference()
55 : : {
56 [ + - ]: 2 : rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.B2:B3"));
57 [ + - ][ + - ]: 2 : uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
58 [ + - ][ + - ]: 2 : uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE);
59 [ + - ][ + - ]: 2 : rtl::OUString aResult = xRanges->getRangeAddressesAsString();
60 [ + - ][ + - ]: 2 : std::cout << "testQueryContentDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
[ + - ][ + - ]
61 [ + - ][ + - ]: 2 : CPPUNIT_ASSERT_MESSAGE("testQueryContentDifference", aResult == aExpected);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
62 : 2 : }
63 : :
64 : 2 : void XCellRangesQuery::testQueryEmptyCells()
65 : : {
66 [ + - ]: 2 : rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:D5"));
67 [ + - ][ + - ]: 2 : uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
68 [ + - ][ + - ]: 2 : uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryEmptyCells();
69 [ + - ][ + - ]: 2 : rtl::OUString aResult = xRanges->getRangeAddressesAsString();
70 [ + - ][ + - ]: 2 : std::cout << "testQueryEmptyCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
[ + - ][ + - ]
71 [ + - ][ + - ]: 2 : CPPUNIT_ASSERT_MESSAGE("testQueryEmptyCells", aResult == aExpected);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
72 : 2 : }
73 : :
74 : 0 : void XCellRangesQuery::testQueryFormulaCells()
75 : : {
76 [ # # ]: 0 : rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.C2"));
77 [ # # ][ # # ]: 0 : uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
78 [ # # ][ # # ]: 0 : uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA);
79 [ # # ][ # # ]: 0 : rtl::OUString aResult = xRanges->getRangeAddressesAsString();
80 [ # # ][ # # ]: 0 : std::cout << "testQueryFormulaCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
[ # # ][ # # ]
81 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
82 : 0 : }
83 : :
84 : 2 : void XCellRangesQuery::testQueryIntersection()
85 : : {
86 [ + - ]: 2 : rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.D4:D5"));
87 [ + - ][ + - ]: 2 : uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
88 [ + - ][ + - ]: 2 : uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7));
89 [ + - ][ + - ]: 2 : rtl::OUString aResult = xRanges->getRangeAddressesAsString();
90 [ + - ][ + - ]: 2 : std::cout << "testQueryIntersection: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
[ + - ][ + - ]
91 [ + - ][ + - ]: 2 : CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
92 : 2 : }
93 : :
94 : 2 : void XCellRangesQuery::testQueryRowDifference()
95 : : {
96 [ + - ]: 2 : rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A2:A4,Sheet1.C2:D4"));
97 [ + - ][ + - ]: 2 : uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
98 [ + - ][ + - ]: 2 : uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1));
99 [ + - ][ + - ]: 2 : rtl::OUString aResult = xRanges->getRangeAddressesAsString();
100 [ + - ][ + - ]: 2 : std::cout << "testQueryRowDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
[ + - ][ + - ]
101 [ + - ][ + - ]: 2 : CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
102 : 2 : }
103 : :
104 : 2 : void XCellRangesQuery::testQueryVisibleCells()
105 : : {
106 [ + - ]: 2 : rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A1:D5"));
107 [ + - ][ + - ]: 2 : uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
108 [ + - ][ + - ]: 2 : uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
109 [ + - ][ + - ]: 2 : rtl::OUString aResult = xRanges->getRangeAddressesAsString();
110 [ + - ][ + - ]: 2 : std::cout << "testQueryVisibleCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
[ + - ][ + - ]
111 [ + - ][ + - ]: 2 : CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
112 : 2 : }
113 : :
114 [ + - ][ + - ]: 66 : }
115 : :
116 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|