diff options
author | Jens Carl <j.carl43@gmx.de> | 2017-08-07 00:23:25 +0000 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-08 07:25:33 +0200 |
commit | 27cbca2c8dccbbb299621b49e5ffd836188202f0 (patch) | |
tree | fd6eec5f648286c0f4463b41891b759013571fc5 /test | |
parent | 0bd57d62d0f15eced0e99097d9f46a86f177e9a1 (diff) |
tdf#45904 Move Java _XUsedAreaCursor tests to C++
Change-Id: I6a288fa333d6805540156f63040468f07967c0c6
Reviewed-on: https://gerrit.libreoffice.org/40817
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/sheet/xcellseries.cxx | 7 | ||||
-rw-r--r-- | test/source/sheet/xusedareacursor.cxx | 97 |
3 files changed, 103 insertions, 2 deletions
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index e69afd4d2a38..f2c6af8fe34e 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -66,6 +66,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/sheet/xsheetannotationshapesupplier \ test/source/sheet/xsheetoutline \ test/source/sheet/xstyleloader \ + test/source/sheet/xusedareacursor \ test/source/sheet/xviewpane \ test/source/sheet/xviewsplitable \ test/source/text/xtext \ diff --git a/test/source/sheet/xcellseries.cxx b/test/source/sheet/xcellseries.cxx index 61dbcecdc751..222fce29ef7e 100644 --- a/test/source/sheet/xcellseries.cxx +++ b/test/source/sheet/xcellseries.cxx @@ -10,6 +10,7 @@ #include <test/sheet/xcellseries.hxx> #include <com/sun/star/sheet/XCellSeries.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/table/XCellRange.hpp> #include "cppunit/extensions/HelperMacros.h" @@ -21,7 +22,8 @@ namespace apitest { void XCellSeries::testFillAuto() { - uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCellRange(xSheet->createCursor(), UNO_QUERY_THROW); sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue(); uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_QUERY_THROW); @@ -54,7 +56,8 @@ void XCellSeries::testFillAuto() void XCellSeries::testFillSeries() { - uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCellRange(xSheet->createCursor(), UNO_QUERY_THROW); sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue(); uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_QUERY_THROW); diff --git a/test/source/sheet/xusedareacursor.cxx b/test/source/sheet/xusedareacursor.cxx new file mode 100644 index 000000000000..fdde5f6cd52f --- /dev/null +++ b/test/source/sheet/xusedareacursor.cxx @@ -0,0 +1,97 @@ +/* -*- 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 <test/sheet/xusedareacursor.hxx> + +#include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XSheetCellCursor.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/sheet/XUsedAreaCursor.hpp> + +#include <com/sun/star/table/CellRangeAddress.hpp> + +#include "cppunit/extensions/HelperMacros.h" + +using namespace com::sun::star; +using namespace com::sun::star::uno; + + +namespace apitest { + +void XUsedAreaCursor::testGotoStartOfUsedArea() +{ + uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW); + uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor(xSheet->createCursor(), UNO_QUERY_THROW); + uno::Reference< sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor, UNO_QUERY_THROW); + + uno::Reference< sheet::XUsedAreaCursor > xUsedAreaCursor(xSheetCellCursor, UNO_QUERY_THROW); + + xUsedAreaCursor->gotoStartOfUsedArea(false); + xUsedAreaCursor->gotoEndOfUsedArea(true); + table::CellRangeAddress cellRangeAddress = xCellRangeAddressable->getRangeAddress(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column", + sal_Int32(0), cellRangeAddress.StartColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(2), cellRangeAddress.EndColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row", + sal_Int32(0), cellRangeAddress.StartRow); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(0), cellRangeAddress.EndRow); + + xUsedAreaCursor->gotoEndOfUsedArea(false); + cellRangeAddress = xCellRangeAddressable->getRangeAddress(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column", + sal_Int32(2), cellRangeAddress.StartColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(2), cellRangeAddress.EndColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row", + sal_Int32(0), cellRangeAddress.StartRow); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(0), cellRangeAddress.EndRow); +} + +void XUsedAreaCursor::testGotoEndOfUsedArea() +{ + uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW); + uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor(xSheet->createCursor(), UNO_QUERY_THROW); + uno::Reference< sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor, UNO_QUERY_THROW); + + uno::Reference< sheet::XUsedAreaCursor > xUsedAreaCursor(xSheetCellCursor, UNO_QUERY_THROW); + + xUsedAreaCursor->gotoEndOfUsedArea(false); + xUsedAreaCursor->gotoStartOfUsedArea(true); + table::CellRangeAddress cellRangeAddress = xCellRangeAddressable->getRangeAddress(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column", + sal_Int32(0), cellRangeAddress.StartColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(2), cellRangeAddress.EndColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row", + sal_Int32(0), cellRangeAddress.StartRow); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(0), cellRangeAddress.EndRow); + + xUsedAreaCursor->gotoStartOfUsedArea(false); + cellRangeAddress = xCellRangeAddressable->getRangeAddress(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column", + sal_Int32(0), cellRangeAddress.StartColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(0), cellRangeAddress.EndColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row", + sal_Int32(0), cellRangeAddress.StartRow); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(0), cellRangeAddress.EndRow); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |