1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include <test/sheet/xusedareacursor.hxx>
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>
17 #include <com/sun/star/table/CellRangeAddress.hpp>
19 #include <cppunit/TestAssert.h>
21 using namespace com::sun::star
;
22 using namespace com::sun::star::uno
;
27 void XUsedAreaCursor::testGotoStartOfUsedArea()
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
);
33 uno::Reference
< sheet::XUsedAreaCursor
> xUsedAreaCursor(xSheetCellCursor
, UNO_QUERY_THROW
);
35 xUsedAreaCursor
->gotoStartOfUsedArea(false);
36 xUsedAreaCursor
->gotoEndOfUsedArea(true);
37 table::CellRangeAddress cellRangeAddress
= xCellRangeAddressable
->getRangeAddress();
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
);
48 xUsedAreaCursor
->gotoEndOfUsedArea(false);
49 cellRangeAddress
= xCellRangeAddressable
->getRangeAddress();
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
);
61 void XUsedAreaCursor::testGotoEndOfUsedArea()
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
);
67 uno::Reference
< sheet::XUsedAreaCursor
> xUsedAreaCursor(xSheetCellCursor
, UNO_QUERY_THROW
);
69 xUsedAreaCursor
->gotoEndOfUsedArea(false);
70 xUsedAreaCursor
->gotoStartOfUsedArea(true);
71 table::CellRangeAddress cellRangeAddress
= xCellRangeAddressable
->getRangeAddress();
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
);
82 xUsedAreaCursor
->gotoStartOfUsedArea(false);
83 cellRangeAddress
= xCellRangeAddressable
->getRangeAddress();
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
);
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */