LibreOffice Module test (master) 1
xcellcursor.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/XSheetCellRange.hpp>
15#include <com/sun/star/sheet/XSpreadsheet.hpp>
16#include <com/sun/star/table/CellRangeAddress.hpp>
17#include <com/sun/star/table/XCellCursor.hpp>
18#include <com/sun/star/table/XCellRange.hpp>
19
20#include <com/sun/star/uno/Reference.hxx>
21
22#include <cppunit/TestAssert.h>
23
24using namespace com::sun::star;
25using namespace com::sun::star::uno;
26
27namespace apitest
28{
30{
31 uno::Reference<table::XCellCursor> xCellCursor(init(), UNO_QUERY_THROW);
32
33 uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xCellCursor,
34 UNO_QUERY_THROW);
35 table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
36 const sal_Int32 startCol = aCellRangeAddr.StartColumn;
37
38 xCellCursor->gotoNext();
39
40 aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
41 const sal_Int32 startCol2 = aCellRangeAddr.StartColumn;
42
43 CPPUNIT_ASSERT_MESSAGE("Successfully able to go to Next", startCol != startCol2);
44}
45
47{
48 uno::Reference<table::XCellCursor> xCellCursor(init(), UNO_QUERY_THROW);
49
50 uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xCellCursor,
51 UNO_QUERY_THROW);
52 table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
53 const sal_Int32 startRow = aCellRangeAddr.StartRow;
54 const sal_Int32 startCol = aCellRangeAddr.StartColumn;
55
56 xCellCursor->gotoOffset(4, 4);
57
58 aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
59 const sal_Int32 startRow2 = aCellRangeAddr.StartRow;
60 const sal_Int32 startCol2 = aCellRangeAddr.StartColumn;
61
62 CPPUNIT_ASSERT_MESSAGE("Successfully able to go to Offset",
63 (startCol != startCol2) || (startRow == startRow2));
64}
65
67{
68 uno::Reference<table::XCellCursor> xCellCursor(init(), UNO_QUERY_THROW);
69
70 uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xCellCursor,
71 UNO_QUERY_THROW);
72 xCellCursor->gotoOffset(4, 4);
73
74 table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
75 const sal_Int32 startCol = aCellRangeAddr.StartColumn;
76
77 xCellCursor->gotoPrevious();
78
79 aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
80 const sal_Int32 startCol2 = aCellRangeAddr.StartColumn;
81 CPPUNIT_ASSERT_MESSAGE("Successfully able to go to Previous", startCol != startCol2);
82}
83
85{
86 uno::Reference<table::XCellCursor> xCellCursor(init(), UNO_QUERY_THROW);
87
88 uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xCellCursor,
89 UNO_QUERY_THROW);
90 xCellCursor->gotoStart();
91
92 table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
93
94 const sal_Int32 startRow = aCellRangeAddr.StartRow;
95 const sal_Int32 startCol = aCellRangeAddr.StartColumn;
96 const sal_Int32 endRow = aCellRangeAddr.EndRow;
97 const sal_Int32 endCol = aCellRangeAddr.EndColumn;
98 CPPUNIT_ASSERT_EQUAL_MESSAGE("Successfully able to go to Start", startCol, endCol);
99 CPPUNIT_ASSERT_EQUAL_MESSAGE("Successfully able to go to Start", endRow, startRow);
100}
101
103{
104 uno::Reference<table::XCellCursor> xCellCursor(init(), UNO_QUERY_THROW);
105 uno::Reference<sheet::XSpreadsheet> xSpreadsheet(getXSpreadsheet(), UNO_QUERY_THROW);
106 uno::Reference<table::XCellRange> xCellRange(xCellCursor, UNO_QUERY_THROW);
107 xCellRange = xSpreadsheet->getCellRangeByName("$A$1:$g$7");
108 uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xCellCursor, UNO_QUERY_THROW);
109 uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(xCellCursor, UNO_QUERY_THROW);
110 xSheetCellCursor = xSpreadsheet->createCursorByRange(xSheetCellRange);
111 uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xCellCursor,
112 UNO_QUERY_THROW);
113
114 xCellCursor->gotoEnd();
115
116 table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
117 const sal_Int32 startRow = aCellRangeAddr.StartRow;
118 const sal_Int32 startCol = aCellRangeAddr.StartColumn;
119 const sal_Int32 endRow = aCellRangeAddr.EndRow;
120 const sal_Int32 endCol = aCellRangeAddr.EndColumn;
121 CPPUNIT_ASSERT_EQUAL_MESSAGE("Successfully able to go to End", startCol, endCol);
122 CPPUNIT_ASSERT_EQUAL_MESSAGE("Successfully able to go to End", endRow, startRow);
123}
124}
125
126/* 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