From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- test/source/table/xcellcursor.cxx | 126 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 test/source/table/xcellcursor.cxx (limited to 'test/source/table/xcellcursor.cxx') diff --git a/test/source/table/xcellcursor.cxx b/test/source/table/xcellcursor.cxx new file mode 100644 index 000000000..6f6cc33e0 --- /dev/null +++ b/test/source/table/xcellcursor.cxx @@ -0,0 +1,126 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* +* This file is part of the LibreOffice project. +* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +using namespace com::sun::star; +using namespace com::sun::star::uno; + +namespace apitest +{ +void XCellCursor::testGoToNext() +{ + uno::Reference xCellCursor(init(), UNO_QUERY_THROW); + + uno::Reference xCellRangeAddressable(xCellCursor, + UNO_QUERY_THROW); + table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress(); + const sal_Int32 startCol = aCellRangeAddr.StartColumn; + + xCellCursor->gotoNext(); + + aCellRangeAddr = xCellRangeAddressable->getRangeAddress(); + const sal_Int32 startCol2 = aCellRangeAddr.StartColumn; + + CPPUNIT_ASSERT_MESSAGE("Successfully able to go to Next", startCol != startCol2); +} + +void XCellCursor::testGoToOffset() +{ + uno::Reference xCellCursor(init(), UNO_QUERY_THROW); + + uno::Reference xCellRangeAddressable(xCellCursor, + UNO_QUERY_THROW); + table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress(); + const sal_Int32 startRow = aCellRangeAddr.StartRow; + const sal_Int32 startCol = aCellRangeAddr.StartColumn; + + xCellCursor->gotoOffset(4, 4); + + aCellRangeAddr = xCellRangeAddressable->getRangeAddress(); + const sal_Int32 startRow2 = aCellRangeAddr.StartRow; + const sal_Int32 startCol2 = aCellRangeAddr.StartColumn; + + CPPUNIT_ASSERT_MESSAGE("Successfully able to go to Offset", + (startCol != startCol2) || (startRow == startRow2)); +} + +void XCellCursor::testGoToPrevious() +{ + uno::Reference xCellCursor(init(), UNO_QUERY_THROW); + + uno::Reference xCellRangeAddressable(xCellCursor, + UNO_QUERY_THROW); + xCellCursor->gotoOffset(4, 4); + + table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress(); + const sal_Int32 startCol = aCellRangeAddr.StartColumn; + + xCellCursor->gotoPrevious(); + + aCellRangeAddr = xCellRangeAddressable->getRangeAddress(); + const sal_Int32 startCol2 = aCellRangeAddr.StartColumn; + CPPUNIT_ASSERT_MESSAGE("Successfully able to go to Previous", startCol != startCol2); +} + +void XCellCursor::testGoToStart() +{ + uno::Reference xCellCursor(init(), UNO_QUERY_THROW); + + uno::Reference xCellRangeAddressable(xCellCursor, + UNO_QUERY_THROW); + xCellCursor->gotoStart(); + + table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress(); + + const sal_Int32 startRow = aCellRangeAddr.StartRow; + const sal_Int32 startCol = aCellRangeAddr.StartColumn; + const sal_Int32 endRow = aCellRangeAddr.EndRow; + const sal_Int32 endCol = aCellRangeAddr.EndColumn; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Successfully able to go to Start", startCol, endCol); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Successfully able to go to Start", endRow, startRow); +} + +void XCellCursor::testGoToEnd() +{ + uno::Reference xCellCursor(init(), UNO_QUERY_THROW); + uno::Reference xSpreadsheet(getXSpreadsheet(), UNO_QUERY_THROW); + uno::Reference xCellRange(xCellCursor, UNO_QUERY_THROW); + xCellRange = xSpreadsheet->getCellRangeByName("$A$1:$g$7"); + uno::Reference xSheetCellRange(xCellCursor, UNO_QUERY_THROW); + uno::Reference xSheetCellCursor(xCellCursor, UNO_QUERY_THROW); + xSheetCellCursor = xSpreadsheet->createCursorByRange(xSheetCellRange); + uno::Reference xCellRangeAddressable(xCellCursor, + UNO_QUERY_THROW); + + xCellCursor->gotoEnd(); + + table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress(); + const sal_Int32 startRow = aCellRangeAddr.StartRow; + const sal_Int32 startCol = aCellRangeAddr.StartColumn; + const sal_Int32 endRow = aCellRangeAddr.EndRow; + const sal_Int32 endCol = aCellRangeAddr.EndColumn; + CPPUNIT_ASSERT_EQUAL_MESSAGE("Successfully able to go to End", startCol, endCol); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Successfully able to go to End", endRow, startRow); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit v1.2.3