12#include <com/sun/star/sheet/XArrayFormulaRange.hpp>
13#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
14#include <com/sun/star/sheet/XSheetCellCursor.hpp>
15#include <com/sun/star/sheet/XSheetOperation.hpp>
16#include <com/sun/star/sheet/XSpreadsheet.hpp>
17#include <com/sun/star/table/CellRangeAddress.hpp>
18#include <com/sun/star/table/XCellRange.hpp>
19#include <com/sun/star/table/XColumnRowRange.hpp>
20#include <com/sun/star/util/XMergeable.hpp>
22#include <com/sun/star/uno/Reference.hxx>
24#include <cppunit/TestAssert.h>
33 uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(
init(), UNO_QUERY_THROW);
35 uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor,
37 table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
38 const sal_Int32 nHeight = aCellRangeAddr.EndRow - aCellRangeAddr.StartRow + 1;
40 uno::Reference<table::XCellRange> xCellRange
41 = xSheetCellCursor->getCellRangeByPosition(0, 0, 0, nHeight - 1);
42 uno::Reference<sheet::XArrayFormulaRange> xArrayFormulaRange(xCellRange, UNO_QUERY_THROW);
43 xArrayFormulaRange->setArrayFormula(
"A1:A" + OUString::number(nHeight));
45 xSheetCellCursor->collapseToSize(1, 1);
46 xSheetCellCursor->collapseToCurrentArray();
48 uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
49 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to collapseToCurrentArray (cols)", sal_Int32(1),
50 xColRowRange->getColumns()->getCount());
51 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to collapseToCurrentArray (rows)", nHeight,
52 xColRowRange->getRows()->getCount());
53 xArrayFormulaRange->setArrayFormula(
"");
58 uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(
init(), UNO_QUERY_THROW);
60 const sal_Int32 nWidth = 4, nHeight = 4;
61 uno::Reference<sheet::XSpreadsheet> xSheet = xSheetCellCursor->getSpreadsheet();
62 uno::Reference<sheet::XSheetOperation> xSheetOp(xSheet, UNO_QUERY_THROW);
63 xSheetOp->clearContents(65535);
65 xSheetCellCursor->collapseToCurrentRegion();
66 uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
67 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to collapseToCurrentRegion (cols)", nWidth,
68 xColRowRange->getColumns()->getCount());
69 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to collapseToCurrentRegion (rows)", nHeight,
70 xColRowRange->getRows()->getCount());
75 uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(
init(), UNO_QUERY_THROW);
76 xSheetCellCursor->collapseToSize(1, 1);
78 const sal_Int32 nLeftCol = 0, nTopRow = 0, nWidth = 8, nHeight = 8;
79 uno::Reference<sheet::XSpreadsheet> xSheet = xSheetCellCursor->getSpreadsheet();
81 uno::Reference<table::XCellRange> xCellRange = xSheet->getCellRangeByPosition(
82 nLeftCol + nWidth - 8, nTopRow + nHeight - 8, nLeftCol + nWidth, nTopRow + nHeight);
84 uno::Reference<util::XMergeable> xMergeable(xCellRange, UNO_QUERY_THROW);
85 xMergeable->merge(
true);
86 CPPUNIT_ASSERT_MESSAGE(
"Unable to merge area", xMergeable->getIsMerged());
87 xSheetCellCursor->collapseToMergedArea();
88 xMergeable->merge(
false);
90 uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
91 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to collapseToMergedArea (cols)", nWidth + 1,
92 xColRowRange->getColumns()->getCount());
93 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to collapseToMergedArea (rows)", nHeight + 1,
94 xColRowRange->getRows()->getCount());
99 uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(
init(), UNO_QUERY_THROW);
101 const sal_Int32 nWidth = 1, nHeight = 1;
102 xSheetCellCursor->collapseToSize(nWidth + 3, nHeight + 3);
104 uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
105 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to collapseToSize (cols)", nWidth + 3,
106 xColRowRange->getColumns()->getCount());
107 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to collapseToSize (rows)", nHeight + 3,
108 xColRowRange->getRows()->getCount());
113 uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(
init(), UNO_QUERY_THROW);
115 xSheetCellCursor->expandToEntireColumns();
117 uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
118 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to expandToEntireColumns (cols)", sal_Int32(4),
119 xColRowRange->getColumns()->getCount());
120 CPPUNIT_ASSERT_MESSAGE(
"Unable to expandToEntireColumns (rows)",
121 xColRowRange->getRows()->getCount() >= sal_Int32(32000));
126 uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(
init(), UNO_QUERY_THROW);
128 xSheetCellCursor->expandToEntireRows();
130 uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
131 CPPUNIT_ASSERT_MESSAGE(
"Unable to expandToEntireRows (cols)",
132 xColRowRange->getColumns()->getCount() >= sal_Int32(256));
133 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to expandToEntireRows (rows)", sal_Int32(4),
134 xColRowRange->getRows()->getCount());
void testCollapseToMergedArea()
void testExpandToEntireRows()
void testCollapseToSize()
void testExpandToEntireColumns()
virtual css::uno::Reference< css::uno::XInterface > init()=0
void testCollapseToCurrentRegion()
void testCollapseToCurrentArray()