Kaydet (Commit) 8164399d authored tarafından Jens Carl's avatar Jens Carl

tdf#45904 Move _XSheetCellCursor Java tests to C++

Change-Id: I9d12f9a13d3e0c59b7a28ff91563878efde22b68
Reviewed-on: https://gerrit.libreoffice.org/45067
Tested-by: Jenkins
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst dc8ed4b8
/* -*- 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/.
*/
#ifndef INCLUDED_TEST_SHEET_XSHEETCELLCURSOR_HXX
#define INCLUDED_TEST_SHEET_XSHEETCELLCURSOR_HXX
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <test/testdllapi.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST XSheetCellCursor
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void testCollapseToCurrentArray();
void testCollapseToCurrentRegion();
void testCollapseToMergedArea();
void testCollapseToSize();
void testExpandToEntireColumns();
void testExpandToEntireRows();
protected:
~XSheetCellCursor() {}
};
}
#endif // INCLUDED_TEST_SHEET_XSHEETCELLCURSOR_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -568,7 +568,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery \
qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \
qadevOOo/tests/java/ifc/sheet/_XRangeSelection \
qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
qadevOOo/tests/java/ifc/style/_CharacterProperties \
qadevOOo/tests/java/ifc/style/_CharacterPropertiesAsian \
qadevOOo/tests/java/ifc/style/_CharacterPropertiesComplex \
......
......@@ -194,12 +194,6 @@
"ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"setRowDescriptions()"
"ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"getColumnDescriptions()"
"ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"setColumnDescriptions()"
"ScCellCursorObj";"com::sun::star::sheet::XSheetCellCursor";"collapseToCurrentRegion()"
"ScCellCursorObj";"com::sun::star::sheet::XSheetCellCursor";"collapseToCurrentArray()"
"ScCellCursorObj";"com::sun::star::sheet::XSheetCellCursor";"collapseToMergedArea()"
"ScCellCursorObj";"com::sun::star::sheet::XSheetCellCursor";"expandToEntireColumns()"
"ScCellCursorObj";"com::sun::star::sheet::XSheetCellCursor";"expandToEntireRows()"
"ScCellCursorObj";"com::sun::star::sheet::XSheetCellCursor";"collapseToSize()"
"ScCellCursorObj";"com::sun::star::util::XModifyBroadcaster#optional";"addModifyListener()"
"ScCellCursorObj";"com::sun::star::util::XModifyBroadcaster#optional";"removeModifyListener()"
"ScCellCursorObj";"com::sun::star::util::XImportable";"createImportDescriptor()"
......
......@@ -17,6 +17,7 @@
#include <test/sheet/xcellseries.hxx>
#include <test/sheet/xformulaquery.hxx>
#include <test/sheet/xmultipleoperation.hxx>
#include <test/sheet/xsheetcellcursor.hxx>
#include <test/sheet/xsheetcellrange.hxx>
#include <test/sheet/xsheetfilterable.hxx>
#include <test/sheet/xsheetfilterableex.hxx>
......@@ -43,6 +44,7 @@ class ScCellCursorObj : public CalcUnoApiTest, public apitest::SheetCellRange,
public apitest::XCellSeries,
public apitest::XFormulaQuery,
public apitest::XMultipleOperation,
public apitest::XSheetCellCursor,
public apitest::XSheetCellRange,
public apitest::XSheetFilterable,
public apitest::XSheetFilterableEx,
......@@ -92,6 +94,14 @@ public:
// XMultipleOperation
CPPUNIT_TEST(testSetTableOperation);
// XSheetCellCursor
CPPUNIT_TEST(testCollapseToCurrentArray);
CPPUNIT_TEST(testCollapseToCurrentRegion);
CPPUNIT_TEST(testCollapseToMergedArea);
CPPUNIT_TEST(testCollapseToSize);
CPPUNIT_TEST(testExpandToEntireColumns);
CPPUNIT_TEST(testExpandToEntireRows);
// XSheetCellRange
CPPUNIT_TEST(testGetSpreadsheet);
......@@ -141,6 +151,11 @@ uno::Reference< uno::XInterface > ScCellCursorObj::init()
uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xCellRange, UNO_QUERY_THROW);
uno::Reference<table::XCellCursor> xCellCursor(xSheet->createCursorByRange(xSheetCellRange), UNO_QUERY_THROW);
xSheet->getCellByPosition(1, 1)->setValue(1);
xSheet->getCellByPosition(4, 5)->setValue(1);
xSheet->getCellByPosition(3, 2)->setFormula("xTextDoc");
xSheet->getCellByPosition(3, 3)->setFormula("xTextDoc");
return xCellCursor;
}
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
a -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
......@@ -123,8 +123,9 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xsheetannotationssupplier \
test/source/sheet/xsheetannotationshapesupplier \
test/source/sheet/xsheetauditing \
test/source/sheet/xsheetcellrangecontainer \
test/source/sheet/xsheetcellcursor \
test/source/sheet/xsheetcellrange \
test/source/sheet/xsheetcellrangecontainer \
test/source/sheet/xsheetcellranges \
test/source/sheet/xsheetconditionalentries \
test/source/sheet/xsheetconditionalentry \
......
/* -*- 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/xsheetcellcursor.hxx>
#include <com/sun/star/sheet/XArrayFormulaRange.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
#include <com/sun/star/sheet/XSheetCellCursor.hpp>
#include <com/sun/star/sheet/XSheetOperation.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/table/XColumnRowRange.hpp>
#include <com/sun/star/util/XMergeable.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace com::sun::star;
using namespace com::sun::star::uno;
namespace apitest
{
void XSheetCellCursor::testCollapseToCurrentArray()
{
uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor,
UNO_QUERY_THROW);
table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
const sal_Int32 nHeight = aCellRangeAddr.EndRow - aCellRangeAddr.StartRow + 1;
uno::Reference<table::XCellRange> xCellRange
= xSheetCellCursor->getCellRangeByPosition(0, 0, 0, nHeight - 1);
uno::Reference<sheet::XArrayFormulaRange> xArrayFormulaRange(xCellRange, UNO_QUERY_THROW);
xArrayFormulaRange->setArrayFormula("A1:A" + OUString::number(nHeight));
xSheetCellCursor->collapseToSize(1, 1);
xSheetCellCursor->collapseToCurrentArray();
uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToCurrentArray (cols)", sal_Int32(1),
xColRowRange->getColumns()->getCount());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToCurrentArray (rows)", nHeight,
xColRowRange->getRows()->getCount());
xArrayFormulaRange->setArrayFormula("");
}
void XSheetCellCursor::testCollapseToCurrentRegion()
{
uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
const sal_Int32 nWidth = 4, nHeight = 4;
uno::Reference<sheet::XSpreadsheet> xSheet = xSheetCellCursor->getSpreadsheet();
uno::Reference<sheet::XSheetOperation> xSheetOp(xSheet, UNO_QUERY_THROW);
xSheetOp->clearContents(65535);
xSheetCellCursor->collapseToCurrentRegion();
uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToCurrentRegion (cols)", nWidth,
xColRowRange->getColumns()->getCount());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToCurrentRegion (rows)", nHeight,
xColRowRange->getRows()->getCount());
}
void XSheetCellCursor::testCollapseToMergedArea()
{
uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
xSheetCellCursor->collapseToSize(1, 1);
const sal_Int32 nLeftCol = 0, nTopRow = 0, nWidth = 8, nHeight = 8;
uno::Reference<sheet::XSpreadsheet> xSheet = xSheetCellCursor->getSpreadsheet();
uno::Reference<table::XCellRange> xCellRange = xSheet->getCellRangeByPosition(
nLeftCol + nWidth - 8, nTopRow + nHeight - 8, nLeftCol + nWidth, nTopRow + nHeight);
uno::Reference<util::XMergeable> xMergeable(xCellRange, UNO_QUERY_THROW);
xMergeable->merge(true);
CPPUNIT_ASSERT_MESSAGE("Unable to merge area", xMergeable->getIsMerged());
xSheetCellCursor->collapseToMergedArea();
xMergeable->merge(false);
uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToMergedArea (cols)", nWidth + 1,
xColRowRange->getColumns()->getCount());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToMergedArea (rows)", nHeight + 1,
xColRowRange->getRows()->getCount());
}
void XSheetCellCursor::testCollapseToSize()
{
uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
const sal_Int32 nWidth = 1, nHeight = 1;
xSheetCellCursor->collapseToSize(nWidth + 3, nHeight + 3);
uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToSize (cols)", nWidth + 3,
xColRowRange->getColumns()->getCount());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToSize (rows)", nHeight + 3,
xColRowRange->getRows()->getCount());
}
void XSheetCellCursor::testExpandToEntireColumns()
{
uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
xSheetCellCursor->expandToEntireColumns();
uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to expandToEntireColumns (cols)", sal_Int32(4),
xColRowRange->getColumns()->getCount());
CPPUNIT_ASSERT_MESSAGE("Unable to expandToEntireColumns (rows)",
xColRowRange->getRows()->getCount() >= sal_Int32(32000));
}
void XSheetCellCursor::testExpandToEntireRows()
{
uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
xSheetCellCursor->expandToEntireRows();
uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Unable to expandToEntireRows (cols)",
xColRowRange->getColumns()->getCount() >= sal_Int32(256));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to expandToEntireRows (rows)", sal_Int32(4),
xColRowRange->getRows()->getCount());
}
}
/* vim:set shiftnWidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment