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,\ ...@@ -568,7 +568,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery \ qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery \
qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \ qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \
qadevOOo/tests/java/ifc/sheet/_XRangeSelection \ qadevOOo/tests/java/ifc/sheet/_XRangeSelection \
qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
qadevOOo/tests/java/ifc/style/_CharacterProperties \ qadevOOo/tests/java/ifc/style/_CharacterProperties \
qadevOOo/tests/java/ifc/style/_CharacterPropertiesAsian \ qadevOOo/tests/java/ifc/style/_CharacterPropertiesAsian \
qadevOOo/tests/java/ifc/style/_CharacterPropertiesComplex \ qadevOOo/tests/java/ifc/style/_CharacterPropertiesComplex \
......
...@@ -194,12 +194,6 @@ ...@@ -194,12 +194,6 @@
"ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"setRowDescriptions()" "ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"setRowDescriptions()"
"ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"getColumnDescriptions()" "ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"getColumnDescriptions()"
"ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"setColumnDescriptions()" "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";"addModifyListener()"
"ScCellCursorObj";"com::sun::star::util::XModifyBroadcaster#optional";"removeModifyListener()" "ScCellCursorObj";"com::sun::star::util::XModifyBroadcaster#optional";"removeModifyListener()"
"ScCellCursorObj";"com::sun::star::util::XImportable";"createImportDescriptor()" "ScCellCursorObj";"com::sun::star::util::XImportable";"createImportDescriptor()"
......
/*
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
package ifc.sheet;
import lib.MultiMethodTest;
import com.sun.star.sheet.CellFlags;
import com.sun.star.sheet.XArrayFormulaRange;
import com.sun.star.sheet.XCellRangeAddressable;
import com.sun.star.sheet.XSheetCellCursor;
import com.sun.star.sheet.XSheetOperation;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.table.CellRangeAddress;
import com.sun.star.table.XCellRange;
import com.sun.star.table.XColumnRowRange;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.util.XMergeable;
/**
* Testing <code>com.sun.star.sheet.XSheetCellCursor</code>
* interface methods :
* <ul>
* <li><code> collapseToCurrentRegion()</code></li>
* <li><code> collapseToCurrentArray()</code></li>
* <li><code> collapseToMergedArea()</code></li>
* <li><code> expandToEntireColumns()</code></li>
* <li><code> expandToEntireRows()</code></li>
* <li><code> collapseToSize()</code></li>
* </ul> <p>
* Component must also implement the following interfaces :
* <ul>
* <li> <code> com.sun.star.sheet.XCellRangeAddressable </code> :
* to get range address </li>
* <ul> <p>
* Range of cursor must be of size 4 x 4. <p>
* @see com.sun.star.sheet.XSheetCellCursor
*/
public class _XSheetCellCursor extends MultiMethodTest {
public XSheetCellCursor oObj = null;
/**
* Test creates the array formula, assigns this array to another array,
* collapses cursor into one cell, applies method, checks the size of the
* result range, erases array formula, checks that array formula has been
* cleared. <p>
* Has <b>OK</b> status if no exceptions were thrown, if size of the result
* range is equal to size of the range where the array formula was set and
* if array formula was successfully cleared. <p>
*/
public void _collapseToCurrentArray() {
boolean bResult = false;
XCellRangeAddressable crAddr = UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj);
CellRangeAddress addr = crAddr.getRangeAddress() ;
int leftCol = addr.StartColumn ;
int topRow = addr.StartRow ;
int width = addr.EndColumn - addr.StartColumn + 1 ;
int height = addr.EndRow - addr.StartRow + 1 ;
log.println( "Object area is ((" + leftCol + "," + topRow + "),(" +
(leftCol + width - 1) + "," + (topRow + height - 1) + ")" );
XCellRange new_range = null;
try {
// first we need to create an array formula
new_range =
oObj.getCellRangeByPosition(0, 0, 0, height - 1);
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.print("Get cell range by position failed: ");
e.printStackTrace(log);
tRes.tested("collapseToCurrentArray()", false);
}
log.println("DB: Successfully new range created");
XArrayFormulaRange arrFormulaRange = UnoRuntime.queryInterface (XArrayFormulaRange.class, new_range);
// write a simple formula (this array assigns another array)
arrFormulaRange.setArrayFormula("A1:A" + height) ;
// collapse cursor into one cell and then try to apply the method
oObj.collapseToSize (1, 1) ;
oObj.collapseToCurrentArray() ;
// check the size of result range
int cols = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getColumns().getCount();
int rows = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getRows().getCount();
if (cols == 1 && rows == height) {
bResult = true;
} else {
bResult = false;
log.println("The size of cell range must be 1x" + height +
", but after method call it was " + cols + "x" + rows);
}
// erase array formula
arrFormulaRange.setArrayFormula("");
// check if array formula has been cleared with last statement
try {
// if array formula isn't cleared exception is thrown
new_range.getCellByPosition(0,0).setValue(111) ;
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
bResult = false ;
log.println(
"Array formula hasn't been cleared with setArrayFormula(\"\")");
XSheetOperation clearRange = UnoRuntime.queryInterface (XSheetOperation.class, new_range);
int allFlags =
CellFlags.ANNOTATION | CellFlags.DATETIME | CellFlags.EDITATTR;
allFlags = allFlags
| CellFlags.HARDATTR | CellFlags.OBJECTS | CellFlags.STRING;
allFlags = allFlags
| CellFlags.VALUE | CellFlags.FORMULA | CellFlags.STYLES;
clearRange.clearContents(allFlags) ;
}
tRes.tested("collapseToCurrentArray()", bResult );
}
/**
* Test clears contents of spreadsheet, collapses cursor to current range,
* checks size of cursor range, fills a cell that is close to
* cursor range, collapses cursor to current range, checks size of cursor
* range again and restores original size. <p>
* Has <b> OK </b> status if after clearing of content and collapsing cursor
* range size remains 4 x 4, if after filling of cell and collapsing cursor
* range extends by one in both dimensions and no exceptions were thrown.<p>
*/
public void _collapseToCurrentRegion(){
boolean bResult = true;
int width = 4, height = 4;
XSpreadsheet oSheet = oObj.getSpreadsheet();
UnoRuntime.queryInterface(
XSheetOperation.class, oSheet).clearContents(65535);
oObj.collapseToCurrentRegion();
int cols = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getColumns().getCount();
int rows = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getRows().getCount();
if (cols != width || rows != height) {
bResult = false ;
log.println("After collapseToCurrentRegion()"
+ " call Region must have size " + width + "x" + height
+ " but it is " + cols + "x" + rows);
}
tRes.tested("collapseToCurrentRegion()", bResult);
// restore original size
oObj.collapseToSize(width, height);
}
/**
* Test merges a cells of range that has a greater size, collapses cursor to
* merged area, checks size of cursor range and restores original size
* of cursor range. <p>
* Has <b> OK </b> status if after merging of cells and collapsing cursor
* range extends by one in both dimensions and no exceptions were thrown.<p>
*/
public void _collapseToMergedArea(){
int width = 1, height = 1 ;
int leftCol = 0, topRow = 0 ;
boolean bResult = true ;
log.println("DB: Starting collapseToMergedArea() method test ...") ;
XSpreadsheet oSheet = oObj.getSpreadsheet() ;
log.println ("DB: got Spreadsheet.") ;
XCellRange newRange = null;
try {
newRange = oSheet.getCellRangeByPosition (
leftCol + width - 1, topRow + height - 1,
leftCol + width, topRow + height );
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Can't get cell range by position");
e.printStackTrace(log);
bResult = false;
}
XMergeable mergeRange = UnoRuntime.queryInterface (XMergeable.class, newRange);
mergeRange.merge(true);
log.println("DB: Successfully merged.") ;
oObj.collapseToMergedArea() ;
log.println("DB: Successfully collapseToMergedArea() method called");
// unmerge area to restore SpreadSheet
mergeRange.merge(false);
log.println("DB: Successfully unmerged.") ;
// checking results
int cols = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getColumns().getCount();
int rows = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getRows().getCount();
log.println("DB: Column and row numbers successfully get") ;
if (cols == width + 1 && rows == height + 3) {
bResult &= true;
} else {
bResult = false;
log.println(
"After collapseToMergedArea() call region must have size "
+ (width + 1) + "x" + (height + 1) + " but it is " + cols
+ "x" + rows );
}
tRes.tested("collapseToMergedArea()", bResult) ;
// restore original size
oObj.collapseToSize(width, height);
}
/**
* Test collapses cursor to the new size, checks size
* of cursor range and restores original size of cursor range. <p>
* Has <b> OK </b> status if after collapsing cursor
* range extends by three in both dimensions. <p>
*/
public void _collapseToSize(){
boolean bResult = false;
int width = 1, height = 1;
// collapseToSize() method test
oObj.collapseToSize (width + 3, height + 3);
// checking results
int cols = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getColumns().getCount();
int rows = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getRows().getCount();
if (cols == width + 3 && rows == height + 3) {
bResult = true ;
} else {
bResult = false ;
log.println( "After collapseToSize() call region must have size "
+ (width + 3) + "x" + (height + 3) + " but it is "
+ cols + "x" +rows);
}
tRes.tested("collapseToSize()", bResult) ;
// restore original size
oObj.collapseToSize(width, height) ;
}
/**
* Test expands cursor to entire columns, checks size
* of cursor range and restores original size of cursor range. <p>
* Has <b> OK </b> status if after expanding cursor
* range extends to all rows in the columns (number of rows is greater than
* 32000 and number of columns remains the same). <p>
*/
public void _expandToEntireColumns(){
boolean bResult = false;
int width = 1, height = 1 ;
// expandToEntireColumns() method test
oObj.expandToEntireColumns () ;
// checking results
int cols = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getColumns().getCount();
int rows = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getRows().getCount();
if (cols == width && rows >= 32000) {
bResult = true ;
} else {
bResult = false ;
log.println(
"After expandToEntireColumns() call region must have size "+
width + "x(>=32000) but it is " + cols + "x" + rows);
}
tRes.tested("expandToEntireColumns()", bResult) ;
// restore original size
oObj.collapseToSize(width, height) ;
}
/**
* Test expands cursor to entire rows, checks size
* of cursor range and restores original size of cursor range. <p>
* Has <b> OK </b> status if after expanding cursor
* range extends to all columns in the rows (number of columns is greater
* than 256 and number of rows remains the same). <p>
*/
public void _expandToEntireRows(){
boolean bResult = false;
int width = 1, height = 1 ;
// expandToEntireRows() method test
oObj.expandToEntireRows () ;
// checking results
int cols = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getColumns().getCount();
int rows = UnoRuntime.queryInterface(
XColumnRowRange.class, oObj).getRows().getCount();
if (cols >= 256 && rows == height) {
bResult = true;
} else {
bResult = false ;
log.println("After expandToEntireRows() call region " +
"must have size (>=256)x" + height + " but it is " +
cols + "x" + rows );
}
tRes.tested("expandToEntireRows()", bResult) ;
// restore original size
oObj.collapseToSize(width, height) ;
}
} // EOC _XSheetCellCursor
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <test/sheet/xcellseries.hxx> #include <test/sheet/xcellseries.hxx>
#include <test/sheet/xformulaquery.hxx> #include <test/sheet/xformulaquery.hxx>
#include <test/sheet/xmultipleoperation.hxx> #include <test/sheet/xmultipleoperation.hxx>
#include <test/sheet/xsheetcellcursor.hxx>
#include <test/sheet/xsheetcellrange.hxx> #include <test/sheet/xsheetcellrange.hxx>
#include <test/sheet/xsheetfilterable.hxx> #include <test/sheet/xsheetfilterable.hxx>
#include <test/sheet/xsheetfilterableex.hxx> #include <test/sheet/xsheetfilterableex.hxx>
...@@ -43,6 +44,7 @@ class ScCellCursorObj : public CalcUnoApiTest, public apitest::SheetCellRange, ...@@ -43,6 +44,7 @@ class ScCellCursorObj : public CalcUnoApiTest, public apitest::SheetCellRange,
public apitest::XCellSeries, public apitest::XCellSeries,
public apitest::XFormulaQuery, public apitest::XFormulaQuery,
public apitest::XMultipleOperation, public apitest::XMultipleOperation,
public apitest::XSheetCellCursor,
public apitest::XSheetCellRange, public apitest::XSheetCellRange,
public apitest::XSheetFilterable, public apitest::XSheetFilterable,
public apitest::XSheetFilterableEx, public apitest::XSheetFilterableEx,
...@@ -92,6 +94,14 @@ public: ...@@ -92,6 +94,14 @@ public:
// XMultipleOperation // XMultipleOperation
CPPUNIT_TEST(testSetTableOperation); CPPUNIT_TEST(testSetTableOperation);
// XSheetCellCursor
CPPUNIT_TEST(testCollapseToCurrentArray);
CPPUNIT_TEST(testCollapseToCurrentRegion);
CPPUNIT_TEST(testCollapseToMergedArea);
CPPUNIT_TEST(testCollapseToSize);
CPPUNIT_TEST(testExpandToEntireColumns);
CPPUNIT_TEST(testExpandToEntireRows);
// XSheetCellRange // XSheetCellRange
CPPUNIT_TEST(testGetSpreadsheet); CPPUNIT_TEST(testGetSpreadsheet);
...@@ -141,6 +151,11 @@ uno::Reference< uno::XInterface > ScCellCursorObj::init() ...@@ -141,6 +151,11 @@ uno::Reference< uno::XInterface > ScCellCursorObj::init()
uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xCellRange, UNO_QUERY_THROW); uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xCellRange, UNO_QUERY_THROW);
uno::Reference<table::XCellCursor> xCellCursor(xSheet->createCursorByRange(xSheetCellRange), 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; 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. # This file is part of the LibreOffice project.
# #
...@@ -123,8 +123,9 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ ...@@ -123,8 +123,9 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xsheetannotationssupplier \ test/source/sheet/xsheetannotationssupplier \
test/source/sheet/xsheetannotationshapesupplier \ test/source/sheet/xsheetannotationshapesupplier \
test/source/sheet/xsheetauditing \ test/source/sheet/xsheetauditing \
test/source/sheet/xsheetcellrangecontainer \ test/source/sheet/xsheetcellcursor \
test/source/sheet/xsheetcellrange \ test/source/sheet/xsheetcellrange \
test/source/sheet/xsheetcellrangecontainer \
test/source/sheet/xsheetcellranges \ test/source/sheet/xsheetcellranges \
test/source/sheet/xsheetconditionalentries \ test/source/sheet/xsheetconditionalentries \
test/source/sheet/xsheetconditionalentry \ 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