12#include <com/sun/star/table/XCellRange.hpp>
13#include <com/sun/star/table/XTableColumns.hpp>
14#include <com/sun/star/text/XSimpleText.hpp>
15#include <com/sun/star/uno/RuntimeException.hpp>
17#include <com/sun/star/uno/Reference.hxx>
19#include <cppunit/TestAssert.h>
27 uno::Reference<table::XTableColumns> xTC(
init(), uno::UNO_QUERY_THROW);
28 uno::Reference<table::XCellRange> xCR(
m_xSheet, uno::UNO_QUERY_THROW);
31 xTC->insertByIndex(1, 1);
32 CPPUNIT_ASSERT_EQUAL(OUString(
"0a"),
getCellText(xCR->getCellByPosition(0, 0)));
33 CPPUNIT_ASSERT_EQUAL(OUString(
"0b"),
getCellText(xCR->getCellByPosition(0, 1)));
34 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(1, 0)));
35 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(1, 1)));
36 CPPUNIT_ASSERT_EQUAL(OUString(
"1a"),
getCellText(xCR->getCellByPosition(2, 0)));
37 CPPUNIT_ASSERT_EQUAL(OUString(
"1b"),
getCellText(xCR->getCellByPosition(2, 1)));
38 CPPUNIT_ASSERT_EQUAL(OUString(
"2a"),
getCellText(xCR->getCellByPosition(3, 0)));
39 CPPUNIT_ASSERT_EQUAL(OUString(
"2b"),
getCellText(xCR->getCellByPosition(3, 1)));
40 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(4, 0)));
41 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(4, 1)));
44 xTC->insertByIndex(0, 1);
45 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(0, 0)));
46 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(0, 1)));
47 CPPUNIT_ASSERT_EQUAL(OUString(
"0a"),
getCellText(xCR->getCellByPosition(1, 0)));
48 CPPUNIT_ASSERT_EQUAL(OUString(
"0b"),
getCellText(xCR->getCellByPosition(1, 1)));
49 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(2, 0)));
50 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(2, 1)));
51 CPPUNIT_ASSERT_EQUAL(OUString(
"1a"),
getCellText(xCR->getCellByPosition(3, 0)));
52 CPPUNIT_ASSERT_EQUAL(OUString(
"1b"),
getCellText(xCR->getCellByPosition(3, 1)));
53 CPPUNIT_ASSERT_EQUAL(OUString(
"2a"),
getCellText(xCR->getCellByPosition(4, 0)));
54 CPPUNIT_ASSERT_EQUAL(OUString(
"2b"),
getCellText(xCR->getCellByPosition(4, 1)));
55 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(5, 0)));
56 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(5, 1)));
59 xTC->insertByIndex(0, 2);
60 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(0, 0)));
61 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(0, 1)));
62 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(1, 0)));
63 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(1, 1)));
64 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(2, 0)));
65 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(2, 1)));
66 CPPUNIT_ASSERT_EQUAL(OUString(
"0a"),
getCellText(xCR->getCellByPosition(3, 0)));
67 CPPUNIT_ASSERT_EQUAL(OUString(
"0b"),
getCellText(xCR->getCellByPosition(3, 1)));
68 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(4, 0)));
69 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(4, 1)));
70 CPPUNIT_ASSERT_EQUAL(OUString(
"1a"),
getCellText(xCR->getCellByPosition(5, 0)));
71 CPPUNIT_ASSERT_EQUAL(OUString(
"1b"),
getCellText(xCR->getCellByPosition(5, 1)));
72 CPPUNIT_ASSERT_EQUAL(OUString(
"2a"),
getCellText(xCR->getCellByPosition(6, 0)));
73 CPPUNIT_ASSERT_EQUAL(OUString(
"2b"),
getCellText(xCR->getCellByPosition(6, 1)));
74 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(7, 0)));
75 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(7, 1)));
80 uno::Reference<table::XTableColumns> xTC(
init(), uno::UNO_QUERY_THROW);
81 CPPUNIT_ASSERT_THROW(xTC->insertByIndex(-1, 1), uno::RuntimeException);
86 uno::Reference<table::XTableColumns> xTC(
init(), uno::UNO_QUERY_THROW);
87 CPPUNIT_ASSERT_THROW(xTC->insertByIndex(0, 0), uno::RuntimeException);
92 uno::Reference<table::XTableColumns> xTC(
init(), uno::UNO_QUERY_THROW);
94 CPPUNIT_ASSERT_THROW(xTC->insertByIndex(xTC->getCount(), 1), uno::RuntimeException);
99 uno::Reference<table::XTableColumns> xTC(
init(), uno::UNO_QUERY_THROW);
100 uno::Reference<table::XCellRange> xCR(
m_xSheet, uno::UNO_QUERY_THROW);
102 xTC->insertByIndex(1, 1);
103 xTC->insertByIndex(0, 1);
104 xTC->insertByIndex(0, 2);
107 xTC->removeByIndex(0, 2);
108 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(0, 0)));
109 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(0, 1)));
110 CPPUNIT_ASSERT_EQUAL(OUString(
"0a"),
getCellText(xCR->getCellByPosition(1, 0)));
111 CPPUNIT_ASSERT_EQUAL(OUString(
"0b"),
getCellText(xCR->getCellByPosition(1, 1)));
112 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(2, 0)));
113 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(2, 1)));
114 CPPUNIT_ASSERT_EQUAL(OUString(
"1a"),
getCellText(xCR->getCellByPosition(3, 0)));
115 CPPUNIT_ASSERT_EQUAL(OUString(
"1b"),
getCellText(xCR->getCellByPosition(3, 1)));
116 CPPUNIT_ASSERT_EQUAL(OUString(
"2a"),
getCellText(xCR->getCellByPosition(4, 0)));
117 CPPUNIT_ASSERT_EQUAL(OUString(
"2b"),
getCellText(xCR->getCellByPosition(4, 1)));
118 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(5, 0)));
119 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(5, 1)));
122 xTC->removeByIndex(0, 1);
123 CPPUNIT_ASSERT_EQUAL(OUString(
"0a"),
getCellText(xCR->getCellByPosition(0, 0)));
124 CPPUNIT_ASSERT_EQUAL(OUString(
"0b"),
getCellText(xCR->getCellByPosition(0, 1)));
125 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(1, 0)));
126 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(1, 1)));
127 CPPUNIT_ASSERT_EQUAL(OUString(
"1a"),
getCellText(xCR->getCellByPosition(2, 0)));
128 CPPUNIT_ASSERT_EQUAL(OUString(
"1b"),
getCellText(xCR->getCellByPosition(2, 1)));
129 CPPUNIT_ASSERT_EQUAL(OUString(
"2a"),
getCellText(xCR->getCellByPosition(3, 0)));
130 CPPUNIT_ASSERT_EQUAL(OUString(
"2b"),
getCellText(xCR->getCellByPosition(3, 1)));
131 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(4, 0)));
132 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(4, 1)));
135 xTC->removeByIndex(1, 1);
136 CPPUNIT_ASSERT_EQUAL(OUString(
"0a"),
getCellText(xCR->getCellByPosition(0, 0)));
137 CPPUNIT_ASSERT_EQUAL(OUString(
"0b"),
getCellText(xCR->getCellByPosition(0, 1)));
138 CPPUNIT_ASSERT_EQUAL(OUString(
"1a"),
getCellText(xCR->getCellByPosition(1, 0)));
139 CPPUNIT_ASSERT_EQUAL(OUString(
"1b"),
getCellText(xCR->getCellByPosition(1, 1)));
140 CPPUNIT_ASSERT_EQUAL(OUString(
"2a"),
getCellText(xCR->getCellByPosition(2, 0)));
141 CPPUNIT_ASSERT_EQUAL(OUString(
"2b"),
getCellText(xCR->getCellByPosition(2, 1)));
142 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(3, 0)));
143 CPPUNIT_ASSERT_EQUAL(OUString(
""),
getCellText(xCR->getCellByPosition(3, 1)));
148 uno::Reference<table::XTableColumns> xTC(
init(), uno::UNO_QUERY_THROW);
149 CPPUNIT_ASSERT_THROW(xTC->removeByIndex(-1, 1), uno::RuntimeException);
154 uno::Reference<table::XTableColumns> xTC(
init(), uno::UNO_QUERY_THROW);
155 CPPUNIT_ASSERT_THROW(xTC->removeByIndex(0, 0), uno::RuntimeException);
160 uno::Reference<table::XTableColumns> xTC(
init(), uno::UNO_QUERY_THROW);
162 CPPUNIT_ASSERT_THROW(xTC->removeByIndex(xTC->getCount(), 1), uno::RuntimeException);
167 uno::Reference<text::XSimpleText> xST(r_xCell, uno::UNO_QUERY_THROW);
168 return xST->getString();
void testInsertByIndexWithNegativeIndex()
css::uno::Reference< css::sheet::XSpreadsheet > m_xSheet
virtual css::uno::Reference< css::uno::XInterface > init()=0
void testRemoveByIndexWithNoColumn()
void testInsertByIndexWithOutOfBoundIndex()
void testRemoveByIndexWithOutOfBoundIndex()
void testInsertByIndexWithNoColumn()
void testRemoveByIndexWithNegativeIndex()
static OUString getCellText(const css::uno::Reference< css::table::XCell > &r_xCell)