12#include <com/sun/star/sheet/TableOperationMode.hpp>
13#include <com/sun/star/sheet/XCellAddressable.hpp>
14#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
15#include <com/sun/star/sheet/XMultipleOperation.hpp>
16#include <com/sun/star/sheet/XSpreadsheet.hpp>
17#include <com/sun/star/table/XCell.hpp>
18#include <com/sun/star/table/XCellRange.hpp>
19#include <com/sun/star/uno/Reference.hxx>
21#include <cppunit/TestAssert.h>
24using namespace css::uno;
30 uno::Reference<sheet::XMultipleOperation> xMultipleOperation(
init(), UNO_QUERY_THROW);
32 uno::Reference<sheet::XSpreadsheet> xSheet(
getXSpreadsheet(), UNO_QUERY_THROW);
33 uno::Reference<table::XCellRange> xCellRange(xSheet->getCellRangeByName(
"$A$20:$A$20"),
35 uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddr(xCellRange, UNO_QUERY_THROW);
37 uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(0, 19);
38 xCell->setFormula(
"=a18+a19");
40 uno::Reference<table::XCell> xCell1 = xSheet->getCellByPosition(0, 17);
41 uno::Reference<sheet::XCellAddressable> xCellAddr1(xCell1, UNO_QUERY_THROW);
43 uno::Reference<table::XCell> xCell2 = xSheet->getCellByPosition(0, 18);
44 uno::Reference<sheet::XCellAddressable> xCellAddr2(xCell2, UNO_QUERY_THROW);
47 xMultipleOperation->setTableOperation(
48 xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_ROW,
49 xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress());
51 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check cell at position 1,1 (OpMode: ROW)", 5.0,
52 xSheet->getCellByPosition(1, 1)->getValue());
53 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check cell at position 2,1 (OpMode: ROW)", 10.0,
54 xSheet->getCellByPosition(2, 1)->getValue());
55 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check cell at position 3,1 (OpMode: ROW)", 15.0,
56 xSheet->getCellByPosition(3, 1)->getValue());
59 xMultipleOperation->setTableOperation(
60 xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_COLUMN,
61 xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress());
63 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check cell at position 1,1 (OpMode: COLUMN)", 12.0,
64 xSheet->getCellByPosition(1, 1)->getValue());
65 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check cell at position 1,2 (OpMode: COLUMN)", 24.0,
66 xSheet->getCellByPosition(1, 2)->getValue());
67 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check cell at position 1,3 (OpMode: COLUMN)", 36.0,
68 xSheet->getCellByPosition(1, 3)->getValue());
71 xMultipleOperation->setTableOperation(
72 xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_BOTH,
73 xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress());
75 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check cell at position 1,1 (OpMode: BOTH)", 17.0,
76 xSheet->getCellByPosition(1, 1)->getValue());
77 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check cell at position 2,2 (OpMode: BOTH)", 34.0,
78 xSheet->getCellByPosition(2, 2)->getValue());
79 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Check cell at position 3,3 (OpMode: BOTH)", 51.0,
80 xSheet->getCellByPosition(3, 3)->getValue());
85 for (
unsigned int i = 1;
i < 5;
i++)
87 uno::Reference<table::XCell> xCellFill = xSheet->getCellByPosition(0,
i);
88 xCellFill->setValue(
i * 12);
89 xCellFill = xSheet->getCellByPosition(
i, 0);
90 xCellFill->setValue(
i * 5);
static void fillCells(css::uno::Reference< css::sheet::XSpreadsheet > const &)
virtual css::uno::Reference< css::uno::XInterface > init()=0
virtual css::uno::Reference< css::uno::XInterface > getXSpreadsheet()=0
void testSetTableOperation()