LibreOffice Module test (master)  1
xusedareacursor.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/XCellRangeAddressable.hpp>
13 #include <com/sun/star/sheet/XSheetCellCursor.hpp>
14 #include <com/sun/star/sheet/XSpreadsheet.hpp>
15 #include <com/sun/star/sheet/XUsedAreaCursor.hpp>
16 
17 #include <com/sun/star/table/CellRangeAddress.hpp>
18 
19 #include <cppunit/TestAssert.h>
20 
21 using namespace com::sun::star;
22 using namespace com::sun::star::uno;
23 
24 
25 namespace apitest {
26 
27 void XUsedAreaCursor::testGotoStartOfUsedArea()
28 {
29  uno::Reference< sheet::XSpreadsheet > xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
30  uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor(xSheet->createCursor(), UNO_SET_THROW);
31  uno::Reference< sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor, UNO_QUERY_THROW);
32 
33  uno::Reference< sheet::XUsedAreaCursor > xUsedAreaCursor(xSheetCellCursor, UNO_QUERY_THROW);
34 
35  xUsedAreaCursor->gotoStartOfUsedArea(false);
36  xUsedAreaCursor->gotoEndOfUsedArea(true);
37  table::CellRangeAddress cellRangeAddress = xCellRangeAddressable->getRangeAddress();
38 
39  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
40  sal_Int32(0), cellRangeAddress.StartColumn);
41  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
42  sal_Int32(2), cellRangeAddress.EndColumn);
43  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
44  sal_Int32(0), cellRangeAddress.StartRow);
45  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
46  sal_Int32(0), cellRangeAddress.EndRow);
47 
48  xUsedAreaCursor->gotoEndOfUsedArea(false);
49  cellRangeAddress = xCellRangeAddressable->getRangeAddress();
50 
51  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
52  sal_Int32(2), cellRangeAddress.StartColumn);
53  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
54  sal_Int32(2), cellRangeAddress.EndColumn);
55  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
56  sal_Int32(0), cellRangeAddress.StartRow);
57  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
58  sal_Int32(0), cellRangeAddress.EndRow);
59 }
60 
61 void XUsedAreaCursor::testGotoEndOfUsedArea()
62 {
63  uno::Reference< sheet::XSpreadsheet > xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
64  uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor(xSheet->createCursor(), UNO_SET_THROW);
65  uno::Reference< sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor, UNO_QUERY_THROW);
66 
67  uno::Reference< sheet::XUsedAreaCursor > xUsedAreaCursor(xSheetCellCursor, UNO_QUERY_THROW);
68 
69  xUsedAreaCursor->gotoEndOfUsedArea(false);
70  xUsedAreaCursor->gotoStartOfUsedArea(true);
71  table::CellRangeAddress cellRangeAddress = xCellRangeAddressable->getRangeAddress();
72 
73  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
74  sal_Int32(0), cellRangeAddress.StartColumn);
75  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
76  sal_Int32(2), cellRangeAddress.EndColumn);
77  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
78  sal_Int32(0), cellRangeAddress.StartRow);
79  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
80  sal_Int32(0), cellRangeAddress.EndRow);
81 
82  xUsedAreaCursor->gotoStartOfUsedArea(false);
83  cellRangeAddress = xCellRangeAddressable->getRangeAddress();
84 
85  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
86  sal_Int32(0), cellRangeAddress.StartColumn);
87  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
88  sal_Int32(0), cellRangeAddress.EndColumn);
89  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
90  sal_Int32(0), cellRangeAddress.StartRow);
91  CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
92  sal_Int32(0), cellRangeAddress.EndRow);
93 }
94 
95 }
96 
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */