View | Details | Raw Unified | Return to issue 120388
Collapse All | Expand All

(-)testuno/source/testcase/uno/sw/table/testTable.java (+749 lines)
Line 0 Link Here
1
package testcase.uno.sw.table;
2
3
import static org.junit.Assert.*;
4
5
import org.junit.After;
6
import org.junit.Before;
7
import org.junit.Test;
8
import org.openoffice.test.common.FileUtil;
9
import org.openoffice.test.common.Testspace;
10
import org.openoffice.test.uno.UnoApp;
11
12
import com.sun.star.uno.UnoRuntime;
13
import com.sun.star.text.*;
14
import com.sun.star.lang.XMultiServiceFactory;
15
import com.sun.star.beans.PropertyValue;
16
import com.sun.star.beans.XPropertySet;
17
import com.sun.star.container.XIndexAccess;
18
import com.sun.star.table.*;
19
import com.sun.star.frame.XStorable;
20
21
22
public class testTable {
23
24
	private static final UnoApp app = new UnoApp();
25
	private XTextDocument xTextDocument=null;
26
	private XMultiServiceFactory xWriterFactory=null;
27
	private XText xText=null;
28
	@Before
29
	public void setUp() throws Exception {
30
		app.start();		
31
	}
32
33
	@After
34
	public void tearDown() throws Exception {
35
		app.close();
36
	}
37
  /*
38
   * test create table
39
   * 1.new a text document and create a table,5 rows,4 columns
40
   * 2.save to odt,close it and reopen new saved document
41
   * 3.check the table column count and row count
42
   */
43
	@Test
44
	public void testCreateTable() throws Exception {
45
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
46
		xText=xTextDocument.getText();
47
		XTextCursor xTextCursor = xText.createTextCursor();
48
		// get internal service factory of the document
49
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
50
		// Create a new table from the document's factory
51
		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
52
		xTable.initialize(5, 4);
53
		xText.insertTextContent(xTextCursor,xTable,false);
54
55
		//save and reload text document
56
		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
57
		PropertyValue[] aStoreProperties = new PropertyValue[2];
58
		aStoreProperties[0] = new PropertyValue();
59
		aStoreProperties[1] = new PropertyValue();
60
		aStoreProperties[0].Name = "Override";
61
		aStoreProperties[0].Value = true;
62
		aStoreProperties[1].Name = "FilterName";
63
		aStoreProperties[1].Value = "StarOffice XML (Writer)";
64
		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
65
		app.closeDocument(xTextDocument);
66
67
		//reopen the document and assert create table successfully
68
		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
69
		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
70
		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
71
		Object xTable_obj=xIndexedTables.getByIndex(0);
72
		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj);
73
		XTableRows xRows=xTable_Assert.getRows();
74
		assertEquals("assert inserted table has 5 rows",5, xRows.getCount());
75
		XTableColumns xColumns=xTable_Assert.getColumns();
76
		assertEquals("assert inserted table has 4 columns",4, xColumns.getCount());
77
	}
78
	/*
79
	 * test insert/delete row/column
80
	 * 1.new a text document and new a table 5x4
81
	 * 2.insert 2 rows,4 columns
82
	 * 3.check the total row count and column count
83
	 * 4.delete 3 row,2 column
84
	 * 5.check the total row count and column count
85
	 */
86
	@Test
87
	public void testInsert_Delete_Rows_Columns() throws Exception {
88
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
89
		xText=xTextDocument.getText();
90
		XTextCursor xTextCursor = xText.createTextCursor();
91
		// get internal service factory of the document
92
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
93
		// Create a new table from the document's factory
94
		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
95
		xTable.initialize(5, 4);
96
		xText.insertTextContent(xTextCursor,xTable,false);
97
		XTableRows xRows=xTable.getRows();
98
		XTableColumns xColumns=xTable.getColumns();
99
		xRows.insertByIndex(0, 2);
100
		xColumns.insertByIndex(3, 4);
101
		assertEquals("assert inserted 2 rows",7, xRows.getCount());
102
		assertEquals("assert inserted 2 columns",8, xColumns.getCount());
103
		xRows.removeByIndex(0, 3);
104
		xColumns.removeByIndex(3, 2);
105
		assertEquals("assert delete 3 rows",4, xRows.getCount());
106
		assertEquals("assert delete 2 columns",6, xColumns.getCount());
107
		app.closeDocument(xTextDocument);
108
	}
109
	/*
110
	 * test table tow height
111
	 * 1.new a text document and new a table
112
	 * 2.set the first row height and not auto fit
113
	 * 3.save to odt,close it and reopen new saved document
114
	 * 4.check the table first row height setting
115
	 */
116
	@Test
117
	public void testSetRowHeight() throws Exception {
118
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
119
		xText=xTextDocument.getText();
120
		XTextCursor xTextCursor = xText.createTextCursor();
121
		// get internal service factory of the document
122
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
123
		// Create a new table from the document's factory
124
		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
125
		xText.insertTextContent(xTextCursor,xTable,false);
126
		XTableRows xRows=xTable.getRows();
127
		//set first row not auto fit and user-defined height
128
		XPropertySet xRowsProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xRows.getByIndex(0));
129
		xRowsProps.setPropertyValue("IsAutoHeight",false);
130
		xRowsProps.setPropertyValue("Height",5001);
131
		//save and reload text document
132
		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
133
		PropertyValue[] aStoreProperties = new PropertyValue[2];
134
		aStoreProperties[0] = new PropertyValue();
135
		aStoreProperties[1] = new PropertyValue();
136
		aStoreProperties[0].Name = "Override";
137
		aStoreProperties[0].Value = true;
138
		aStoreProperties[1].Name = "FilterName";
139
		aStoreProperties[1].Value = "StarOffice XML (Writer)";
140
		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
141
		app.closeDocument(xTextDocument);
142
143
		//reopen the document and assert row height setting
144
		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
145
		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
146
		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
147
		Object xTable_obj=xIndexedTables.getByIndex(0);
148
		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj);
149
		XTableRows xRows_Assert=xTable_Assert.getRows();
150
		XPropertySet xRowsProps_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRows_Assert.getByIndex(0));
151
		assertEquals("assert the second row height is 5001",5001,xRowsProps_assert.getPropertyValue("Height"));
152
		assertEquals("assert the second row height is not autofitable",false, xRowsProps_assert.getPropertyValue("IsAutoHeight"));
153
	}
154
	/*
155
	 * test table border setting
156
	 * 1.new a text document and create a table
157
	 * 2.set table border line color and style
158
	 * 3.save to odt,close it and reopen new saved document
159
	 * 4.check the table border setting
160
	 */
161
	@Test
162
	public void testSetTableBorder() throws Exception {
163
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
164
		xText=xTextDocument.getText();
165
		XTextCursor xTextCursor = xText.createTextCursor();
166
		// get internal service factory of the document
167
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
168
		// Create a new table from the document's factory
169
		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
170
		xText.insertTextContent(xTextCursor,xTable,false);
171
		XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable);
172
		//set table border
173
		TableBorder tableBorder = new TableBorder();	
174
		BorderLine[]borderLine=new BorderLine[] {new BorderLine(),new BorderLine(),new BorderLine(),new BorderLine(),new BorderLine(),new BorderLine()};
175
		borderLine[0].Color=0x00FF0000;
176
		borderLine[0].InnerLineWidth=101;
177
		borderLine[0].OuterLineWidth=19;
178
		borderLine[0].LineDistance=100;
179
		borderLine[1].Color =0x00FFFF00;
180
		borderLine[1].InnerLineWidth=101;
181
		borderLine[1].OuterLineWidth=19;
182
		borderLine[1].LineDistance=101;	
183
		borderLine[2].Color =0x0000FF00;
184
		borderLine[2].InnerLineWidth=150;
185
		borderLine[2].OuterLineWidth=19;
186
		borderLine[2].LineDistance=101;
187
		borderLine[3].Color =0x0000FF00;
188
		borderLine[3].InnerLineWidth=150;
189
		borderLine[3].OuterLineWidth=19;
190
		borderLine[3].LineDistance=101;		
191
		borderLine[4].Color =0x0000FF00;
192
		borderLine[4].InnerLineWidth=150;
193
		borderLine[4].OuterLineWidth=19;
194
		borderLine[4].LineDistance=101;		
195
		borderLine[5].Color =0x0000FF00;
196
		borderLine[5].InnerLineWidth=150;
197
		borderLine[5].OuterLineWidth=19;
198
		borderLine[5].LineDistance=101;		
199
		tableBorder.TopLine =borderLine[0];
200
		tableBorder.BottomLine =borderLine[1];
201
		tableBorder.LeftLine =borderLine[2];
202
		tableBorder.RightLine =borderLine[3];
203
		tableBorder.HorizontalLine =borderLine[4];
204
		tableBorder.VerticalLine =borderLine[5];
205
		tableBorder.IsBottomLineValid = true;
206
		tableBorder.IsLeftLineValid = true;
207
		tableBorder.IsRightLineValid = true;
208
		tableBorder.IsTopLineValid = true;
209
		tableBorder.IsHorizontalLineValid = true;
210
		tableBorder.IsVerticalLineValid = true;	
211
		xTableProps.setPropertyValue("TableBorder", tableBorder);
212
		//save and reload text document
213
		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
214
		PropertyValue[] aStoreProperties = new PropertyValue[2];
215
		aStoreProperties[0] = new PropertyValue();
216
		aStoreProperties[1] = new PropertyValue();
217
		aStoreProperties[0].Name = "Override";
218
		aStoreProperties[0].Value = true;
219
		aStoreProperties[1].Name = "FilterName";
220
		aStoreProperties[1].Value = "StarOffice XML (Writer)";
221
		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
222
		app.closeDocument(xTextDocument);
223
224
		//reopen the document and assert table border setting
225
		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
226
		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
227
		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
228
		Object xTable_obj=xIndexedTables.getByIndex(0);
229
		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj);
230
		XPropertySet xTableProps_Assert = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert);
231
		TableBorder tableBorder_Assert=(TableBorder) UnoRuntime.queryInterface(TableBorder.class, xTableProps_Assert.getPropertyValue("TableBorder"));
232
		assertEquals("assert topline color as setting",0x00FF0000,tableBorder_Assert.TopLine.Color);
233
		assertEquals("assert topline innerline width as setting",101,tableBorder_Assert.TopLine.InnerLineWidth);
234
		assertEquals("assert topline outerlinewidth as setting",19,tableBorder_Assert.TopLine.OuterLineWidth);
235
		assertEquals("assert topline linedistance as setting",101,tableBorder_Assert.TopLine.LineDistance);
236
		assertEquals("assert bottomline color as setting",0x00FFFF00,tableBorder_Assert.BottomLine.Color);
237
		assertEquals("assert bottomline innerline width as setting",101,tableBorder_Assert.BottomLine.InnerLineWidth);
238
		assertEquals("assert bottomline outerlinewidth as setting",19,tableBorder_Assert.BottomLine.OuterLineWidth);
239
		assertEquals("assert bottomline linedistance as setting",101,tableBorder_Assert.BottomLine.LineDistance);		
240
		assertEquals("assert leftline color as setting",0x0000FF00,tableBorder_Assert.LeftLine.Color);
241
		assertEquals("assert leftline innerline width as setting",150,tableBorder_Assert.LeftLine.InnerLineWidth);
242
		assertEquals("assert leftline outerlinewidth as setting",19,tableBorder_Assert.LeftLine.OuterLineWidth);
243
		assertEquals("assert leftline linedistance as setting",101,tableBorder_Assert.LeftLine.LineDistance);		
244
		assertEquals("assert rightline color as setting",0x0000FF00,tableBorder_Assert.RightLine.Color);
245
		assertEquals("assert rightline linedistance as setting",101,tableBorder_Assert.RightLine.LineDistance);		
246
		assertEquals("assert rightline innerline width as setting",150,tableBorder_Assert.RightLine.InnerLineWidth);
247
		assertEquals("assert rightline outerlinewidth as setting",19,tableBorder_Assert.RightLine.OuterLineWidth);	
248
		assertEquals("assert HorizontalLine color as setting",0x0000FF00,tableBorder_Assert.HorizontalLine.Color);
249
		assertEquals("assert HorizontalLine innerline width as setting",150,tableBorder_Assert.HorizontalLine.InnerLineWidth);
250
		assertEquals("assert HorizontalLine outerlinewidth as setting",19,tableBorder_Assert.HorizontalLine.OuterLineWidth);
251
		assertEquals("assert HorizontalLine linedistance as setting",101,tableBorder_Assert.HorizontalLine.LineDistance);		
252
		assertEquals("assert VerticalLine color as setting",0x0000FF00,tableBorder_Assert.VerticalLine.Color);
253
		assertEquals("assert VerticalLine innerline width as setting",150,tableBorder_Assert.VerticalLine.InnerLineWidth);
254
		assertEquals("assert VerticalLine outerlinewidth as setting",19,tableBorder_Assert.VerticalLine.OuterLineWidth);
255
		assertEquals("assert VerticalLine linedistance as setting",101,tableBorder_Assert.VerticalLine.LineDistance);
256
	}
257
	/*
258
	 * test table spacing to page and alignment
259
	 * 1.new a text document
260
	 * 2.create a table
261
	 * 3.set the table alignment to automatic,and spacing to margin
262
	 * 4.repeat step2 5 times,and set second table alignment to manual/center/left/from left/right,and spacing to margin
263
	 * 5.save to odt,close it and reopen the new saved document
264
	 * 6.reopen and check the every table alignment and spacing to margin
265
	 */
266
	@Test
267
	public void testSetTable_AlignmentAndMarginToPage() throws Exception {
268
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
269
		xText=xTextDocument.getText();
270
		XTextCursor xTextCursor = xText.createTextCursor();
271
		// get internal service factory of the document
272
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
273
		// Create  new table from the document's factory
274
		XTextTable xTable1 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
275
		xText.insertTextContent(xTextCursor,xTable1,false);
276
		XPropertySet xTableProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable1);
277
		xTableProps1.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.FULL);				
278
		xTableProps1.setPropertyValue("LeftMargin",2591);
279
		xTableProps1.setPropertyValue("RightMargin",3000);
280
		xTableProps1.setPropertyValue("TopMargin",2000);
281
		xTableProps1.setPropertyValue("BottomMargin",2000);
282
		XTextTable xTable2 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
283
		xText.insertTextContent(xTextCursor,xTable2,false);
284
		XPropertySet xTableProps2 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable2);
285
		xTableProps2.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.NONE);
286
		xTableProps2.setPropertyValue("LeftMargin",2591);
287
		xTableProps2.setPropertyValue("RightMargin",3000);
288
		xTableProps2.setPropertyValue("TopMargin",2000);
289
		xTableProps2.setPropertyValue("BottomMargin",2000);
290
		XTextTable xTable3 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
291
		xText.insertTextContent(xTextCursor,xTable3,false);
292
		XPropertySet xTableProps3 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable3);
293
		xTableProps3.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.CENTER);
294
		xTableProps3.setPropertyValue("LeftMargin",2000);
295
		xTableProps3.setPropertyValue("RightMargin",3000);
296
		xTableProps3.setPropertyValue("TopMargin",2000);
297
		xTableProps3.setPropertyValue("BottomMargin",2000);
298
		XTextTable xTable4 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
299
		xText.insertTextContent(xTextCursor,xTable4,false);
300
		XPropertySet xTableProps4 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable4);
301
		xTableProps4.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.LEFT);
302
		xTableProps4.setPropertyValue("KeepTogether",true);
303
		xTableProps4.setPropertyValue("RightMargin",2000);
304
		xTableProps4.setPropertyValue("TopMargin",2000);
305
		xTableProps4.setPropertyValue("BottomMargin",2000);
306
		XTextTable xTable5 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
307
		xText.insertTextContent(xTextCursor,xTable5,false);
308
		XPropertySet xTableProps5 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable5);
309
		xTableProps5.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.LEFT_AND_WIDTH);
310
		xTableProps5.setPropertyValue("TopMargin",2000);
311
		xTableProps5.setPropertyValue("BottomMargin",2000);
312
		XTextTable xTable6 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
313
		xText.insertTextContent(xTextCursor,xTable6,false);
314
		XPropertySet xTableProps6 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable6);
315
		xTableProps6.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.RIGHT);
316
		xTableProps6.setPropertyValue("TopMargin",2000);
317
		xTableProps6.setPropertyValue("BottomMargin",2000);		
318
		//save and reload text document
319
		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
320
		PropertyValue[] aStoreProperties = new PropertyValue[2];
321
		aStoreProperties[0] = new PropertyValue();
322
		aStoreProperties[1] = new PropertyValue();
323
		aStoreProperties[0].Name = "Override";
324
		aStoreProperties[0].Value = true;
325
		aStoreProperties[1].Name = "FilterName";
326
		aStoreProperties[1].Value = "StarOffice XML (Writer)";
327
		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
328
		app.closeDocument(xTextDocument);
329
330
		//reopen the document and assert table margin to page setting
331
		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
332
		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
333
		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
334
		Object xTable_obj1=xIndexedTables.getByIndex(0);
335
		XTextTable xTable_Assert1=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj1);
336
		XPropertySet xTableProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert1);
337
		assertEquals("assert table alignment as automatic",com.sun.star.text.HoriOrientation.FULL,xTableProps_assert1.getPropertyValue("HoriOrient"));
338
		assertEquals("assert left margin to page",0,xTableProps_assert1.getPropertyValue("LeftMargin"));
339
		assertEquals("assert right margin to page",0,xTableProps_assert1.getPropertyValue("RightMargin"));
340
		assertEquals("assert top margin to page",2000,xTableProps_assert1.getPropertyValue("TopMargin"));
341
		assertEquals("assert bottom margin to page",2000,xTableProps_assert1.getPropertyValue("BottomMargin"));
342
		Object xTable_obj2=xIndexedTables.getByIndex(1);
343
		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj2);
344
		XPropertySet xTableProps_assert2 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert);
345
		assertEquals("assert table alignment as manual",com.sun.star.text.HoriOrientation.NONE,xTableProps_assert2.getPropertyValue("HoriOrient"));
346
		assertEquals("assert left margin to page",2591,xTableProps_assert2.getPropertyValue("LeftMargin"));
347
		assertEquals("assert right margin to page",3000,xTableProps_assert2.getPropertyValue("RightMargin"));
348
		assertEquals("assert top margin to page",2000,xTableProps_assert2.getPropertyValue("TopMargin"));
349
		assertEquals("assert bottom margin to page",2000,xTableProps_assert2.getPropertyValue("BottomMargin"));
350
		Object xTable_obj3=xIndexedTables.getByIndex(2);
351
		XTextTable xTable_Assert3=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj3);
352
		XPropertySet xTableProps_assert3 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert3);
353
		assertEquals("assert table alignment as center",com.sun.star.text.HoriOrientation.CENTER,xTableProps_assert3.getPropertyValue("HoriOrient"));
354
		assertEquals("assert top margin to page",2000,xTableProps_assert3.getPropertyValue("TopMargin"));
355
		assertEquals("assert bottom margin to page",2000,xTableProps_assert3.getPropertyValue("BottomMargin"));
356
		Object xTable_obj4=xIndexedTables.getByIndex(3);
357
		XTextTable xTable_Assert4=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj4);
358
		XPropertySet xTableProps_assert4 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert4);
359
		assertEquals("assert table alignment as left",com.sun.star.text.HoriOrientation.LEFT,xTableProps_assert4.getPropertyValue("HoriOrient"));
360
		assertEquals("assert top margin to page",2000,xTableProps_assert4.getPropertyValue("TopMargin"));
361
		assertEquals("assert bottom margin to page",2000,xTableProps_assert4.getPropertyValue("BottomMargin"));
362
		Object xTable_obj5=xIndexedTables.getByIndex(4);
363
		XTextTable xTable_Assert5=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj5);
364
		XPropertySet xTableProps_assert5 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert5);
365
		assertEquals("assert table alignment as from left",com.sun.star.text.HoriOrientation.LEFT,xTableProps_assert5.getPropertyValue("HoriOrient"));
366
		assertEquals("assert top margin to page",2000,xTableProps_assert5.getPropertyValue("TopMargin"));
367
		assertEquals("assert bottom margin to page",2000,xTableProps_assert5.getPropertyValue("BottomMargin"));
368
		Object xTable_obj6=xIndexedTables.getByIndex(5);
369
		XTextTable xTable_Assert6=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj6);
370
		XPropertySet xTableProps_assert6 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert6);
371
		assertEquals("assert table alignment as right",com.sun.star.text.HoriOrientation.RIGHT,xTableProps_assert6.getPropertyValue("HoriOrient"));
372
		assertEquals("assert top margin to page",2000,xTableProps_assert5.getPropertyValue("TopMargin"));
373
		assertEquals("assert bottom margin to page",2000,xTableProps_assert5.getPropertyValue("BottomMargin"));
374
	}
375
	/*
376
	 * test set table background with color
377
	 * 1.new a text document and new a table
378
	 * 2.set table background with color
379
	 * 3.save to odt and close it,then reopen the new saved document
380
	 * 4.check the table background color
381
	 */
382
	@Test
383
	public void testSetTableBackColor() throws Exception {
384
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
385
		xText=xTextDocument.getText();
386
		XTextCursor xTextCursor = xText.createTextCursor();
387
		// get internal service factory of the document
388
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
389
		// Create a new table from the document's factory
390
		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
391
		xText.insertTextContent(xTextCursor,xTable,false);
392
		XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable);
393
		xTableProps.setPropertyValue("BackColor",0x0000FF00);
394
395
		//save and reload text document
396
		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
397
		PropertyValue[] aStoreProperties = new PropertyValue[2];
398
		aStoreProperties[0] = new PropertyValue();
399
		aStoreProperties[1] = new PropertyValue();
400
		aStoreProperties[0].Name = "Override";
401
		aStoreProperties[0].Value = true;
402
		aStoreProperties[1].Name = "FilterName";
403
		aStoreProperties[1].Value = "StarOffice XML (Writer)";
404
		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
405
		app.closeDocument(xTextDocument);
406
407
		//reopen the document and assert table margin to page setting
408
		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
409
		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
410
		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
411
		Object xTable_obj=xIndexedTables.getByIndex(0);
412
		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj);
413
		XPropertySet xTableProps_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert);
414
		assertEquals("verify table background color",0x0000FF00,xTableProps_assert.getPropertyValue("BackColor"));
415
	}
416
	/*test table repeat heading setting
417
	 * 1.new a text document and create a table
418
	 * 2.set table first row as repeat heading
419
	 * 3.save to odt and close it,then reopen the document
420
	 * 4.check the table first row as repeat heading
421
	 */
422
	
423
	@Test
424
	public void testSetTableRepeatHeading() throws Exception {
425
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
426
		xText=xTextDocument.getText();
427
		XTextCursor xTextCursor = xText.createTextCursor();
428
		// get internal service factory of the document
429
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
430
		// Create a new table from the document's factory
431
		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
432
		xText.insertTextContent(xTextCursor,xTable,false);
433
		XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable);
434
		//set table first one row as table heading
435
		xTableProps.setPropertyValue("RepeatHeadline",true);
436
		xTableProps.setPropertyValue("HeaderRowCount",1);
437
438
		//save and reload text document
439
		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
440
		PropertyValue[] aStoreProperties = new PropertyValue[2];
441
		aStoreProperties[0] = new PropertyValue();
442
		aStoreProperties[1] = new PropertyValue();
443
		aStoreProperties[0].Name = "Override";
444
		aStoreProperties[0].Value = true;
445
		aStoreProperties[1].Name = "FilterName";
446
		aStoreProperties[1].Value = "StarOffice XML (Writer)";
447
		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
448
		app.closeDocument(xTextDocument);
449
450
		//reopen the document and assert table repeat heading setting
451
		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
452
		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
453
		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
454
		Object xTable_obj=xIndexedTables.getByIndex(0);
455
		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj);
456
		XPropertySet xTableProps_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert);
457
		assertEquals("verify table heading row number",1,xTableProps_assert.getPropertyValue("HeaderRowCount"));
458
		assertEquals("verify table heading repeat",true,xTableProps_assert.getPropertyValue("RepeatHeadline"));
459
	}
460
	/*
461
	 * test table shadow setting
462
	 * 1.new a text document
463
	 * 2.create 5 tables
464
	 * 3.set the 5 table shadow location to bottom_right,bottom_left,none,top_left,top_right,and shadow width
465
	 * 4.save to odt and close it,then reopen the new saved document
466
	 * 5.check the 5 table shadow location and width
467
	 */
468
	@Test
469
	public void testSetTableShadow() throws Exception {
470
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
471
		xText=xTextDocument.getText();
472
		XTextCursor xTextCursor = xText.createTextCursor();
473
		// get internal service factory of the document
474
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
475
		// Create new table from the document's factory
476
		XTextTable xTable1 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
477
		xText.insertTextContent(xTextCursor,xTable1,false);
478
		XPropertySet xTableProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable1);
479
		XTextTable xTable2 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
480
		xText.insertTextContent(xTextCursor,xTable2,false);
481
		XPropertySet xTableProps2 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable2);
482
		XTextTable xTable3 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
483
		xText.insertTextContent(xTextCursor,xTable3,false);
484
		XPropertySet xTableProps3 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable3);
485
		XTextTable xTable4 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
486
		xText.insertTextContent(xTextCursor,xTable4,false);
487
		XPropertySet xTableProps4 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable4);
488
		XTextTable xTable5 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
489
		xText.insertTextContent(xTextCursor,xTable5,false);
490
		XPropertySet xTableProps5 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable5);		
491
		//set table shadow
492
		ShadowFormat[] shadowFormat=new ShadowFormat[] {new ShadowFormat(),new ShadowFormat(),new ShadowFormat(),new ShadowFormat(),new ShadowFormat()};
493
		shadowFormat[0].Location=ShadowLocation.BOTTOM_RIGHT;
494
		shadowFormat[0].ShadowWidth=100;
495
		shadowFormat[0].Color=0x00FF00FF;
496
		shadowFormat[1].Location=ShadowLocation.BOTTOM_LEFT;
497
		shadowFormat[1].ShadowWidth=100;
498
		shadowFormat[1].Color=0x00FF00FF;
499
		shadowFormat[2].Location=ShadowLocation.NONE;
500
		shadowFormat[3].Location=ShadowLocation.TOP_LEFT;
501
		shadowFormat[3].ShadowWidth=100;
502
		shadowFormat[3].Color=0x00FF00FF;
503
		shadowFormat[4].Location=ShadowLocation.TOP_RIGHT;
504
		shadowFormat[4].ShadowWidth=100;
505
		shadowFormat[4].Color=0x00FF00FF;		
506
		xTableProps1.setPropertyValue("ShadowFormat",shadowFormat[0]);
507
		xTableProps2.setPropertyValue("ShadowFormat",shadowFormat[1]);
508
		xTableProps3.setPropertyValue("ShadowFormat",shadowFormat[2]);
509
		xTableProps4.setPropertyValue("ShadowFormat",shadowFormat[3]);
510
		xTableProps5.setPropertyValue("ShadowFormat",shadowFormat[4]);
511
512
		//save and reload text document
513
		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
514
		PropertyValue[] aStoreProperties = new PropertyValue[2];
515
		aStoreProperties[0] = new PropertyValue();
516
		aStoreProperties[1] = new PropertyValue();
517
		aStoreProperties[0].Name = "Override";
518
		aStoreProperties[0].Value = true;
519
		aStoreProperties[1].Name = "FilterName";
520
		aStoreProperties[1].Value = "StarOffice XML (Writer)";
521
		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
522
		app.closeDocument(xTextDocument);
523
524
		//reopen the document and assert table shadow setting
525
		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
526
		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
527
		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
528
		Object xTable_obj1=xIndexedTables.getByIndex(0);
529
		XTextTable xTable_Assert1=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj1);
530
		XPropertySet xTableProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert1);
531
		ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTableProps_assert1.getPropertyValue("ShadowFormat"));
532
		assertEquals("assert shadow location",ShadowLocation.BOTTOM_RIGHT,shadowFormat_Assert1.Location);
533
		assertEquals("assert shadow width",100,shadowFormat_Assert1.ShadowWidth);
534
		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color);
535
		
536
		Object xTable_obj2=xIndexedTables.getByIndex(1);
537
		XTextTable xTable_Assert2=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj2);
538
		XPropertySet xTableProps_assert2 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert2);
539
		ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTableProps_assert2.getPropertyValue("ShadowFormat"));
540
		assertEquals("assert shadow location",ShadowLocation.BOTTOM_LEFT,shadowFormat_Assert2.Location);
541
		assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth);
542
		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color);
543
		
544
		Object xTable_obj3=xIndexedTables.getByIndex(2);
545
		XTextTable xTable_Assert3=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj3);
546
		XPropertySet xTableProps_assert3 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert3);
547
		ShadowFormat shadowFormat_Assert3=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTableProps_assert3.getPropertyValue("ShadowFormat"));
548
		assertEquals("assert shadow location",ShadowLocation.NONE,shadowFormat_Assert3.Location);
549
		
550
		Object xTable_obj4=xIndexedTables.getByIndex(3);
551
		XTextTable xTable_Assert4=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj4);
552
		XPropertySet xTableProps_assert4 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert4);
553
		ShadowFormat shadowFormat_Assert4=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTableProps_assert4.getPropertyValue("ShadowFormat"));
554
		assertEquals("assert shadow location",ShadowLocation.TOP_LEFT,shadowFormat_Assert4.Location);
555
		assertEquals("assert shadow width",100,shadowFormat_Assert4.ShadowWidth);
556
		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert4.Color);
557
		
558
		Object xTable_obj5=xIndexedTables.getByIndex(4);
559
		XTextTable xTable_Assert5=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj5);
560
		XPropertySet xTableProps_assert5 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert5);
561
		ShadowFormat shadowFormat_Assert5=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTableProps_assert5.getPropertyValue("ShadowFormat"));
562
		assertEquals("assert shadow location",ShadowLocation.TOP_RIGHT,shadowFormat_Assert5.Location);
563
		assertEquals("assert shadow width",100,shadowFormat_Assert5.ShadowWidth);
564
		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert5.Color);
565
	}
566
	/*
567
	 * test set table background with graphic
568
	 * 1.new a text document and create a table
569
	 * 2.set table background with a picture
570
	 * 3.save to odt and closet it,then reopen the new saved document
571
	 * 4.check the table background
572
	 */
573
	@Test
574
	public void testSetTableBackGraphic() throws Exception {
575
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
576
		xText=xTextDocument.getText();
577
		XTextCursor xTextCursor = xText.createTextCursor();
578
		// get internal service factory of the document
579
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
580
		// Create a new table from the document's factory
581
		XTextTable xTable1 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
582
		xText.insertTextContent(xTextCursor,xTable1,false);
583
		XPropertySet xTableProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable1);
584
		xTableProps1.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
585
		xTableProps1.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
586
		xTableProps1.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_BOTTOM);
587
		
588
		XTextTable xTable2 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
589
		xText.insertTextContent(xTextCursor,xTable2,false);
590
		XPropertySet xTableProps2 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable2);
591
		xTableProps2.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
592
		xTableProps2.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
593
		xTableProps2.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_MIDDLE);
594
595
		XTextTable xTable3 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
596
		xText.insertTextContent(xTextCursor,xTable3,false);
597
		XPropertySet xTableProps3 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable3);
598
		xTableProps3.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
599
		xTableProps3.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
600
		xTableProps3.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_TOP);		
601
602
		XTextTable xTable4 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
603
		xText.insertTextContent(xTextCursor,xTable4,false);
604
		XPropertySet xTableProps4 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable4);
605
		xTableProps4.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
606
		xTableProps4.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
607
		xTableProps4.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_BOTTOM);
608
		
609
		XTextTable xTable5 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
610
		xText.insertTextContent(xTextCursor,xTable5,false);
611
		XPropertySet xTableProps5 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable5);
612
		xTableProps5.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
613
		xTableProps5.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
614
		xTableProps5.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_MIDDLE);
615
		
616
		XTextTable xTable6 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
617
		xText.insertTextContent(xTextCursor,xTable6,false);
618
		XPropertySet xTableProps6 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable6);
619
		xTableProps6.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
620
		xTableProps6.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
621
		xTableProps6.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_TOP);	
622
		
623
		XTextTable xTable7 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
624
		xText.insertTextContent(xTextCursor,xTable7,false);
625
		XPropertySet xTableProps7 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable7);
626
		xTableProps7.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
627
		xTableProps7.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
628
		xTableProps7.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.NONE);
629
		
630
		XTextTable xTable8 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
631
		xText.insertTextContent(xTextCursor,xTable8,false);
632
		XPropertySet xTableProps8 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable8);
633
		xTableProps8.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
634
		xTableProps8.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
635
		xTableProps8.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_BOTTOM);
636
		
637
		XTextTable xTable9 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
638
		xText.insertTextContent(xTextCursor,xTable9,false);
639
		XPropertySet xTableProps9 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable9);
640
		xTableProps9.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
641
		xTableProps9.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
642
		xTableProps9.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_MIDDLE);
643
		
644
		XTextTable xTable10 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
645
		xText.insertTextContent(xTextCursor,xTable10,false);
646
		XPropertySet xTableProps10 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable10);
647
		xTableProps10.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
648
		xTableProps10.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
649
		xTableProps10.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_TOP);
650
		
651
		XTextTable xTable11 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
652
		xText.insertTextContent(xTextCursor,xTable11,false);
653
		XPropertySet xTableProps11 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable11);
654
		xTableProps11.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")));
655
		xTableProps11.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
656
		xTableProps11.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.AREA);		
657
		//save and reload text document
658
		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
659
		PropertyValue[] aStoreProperties = new PropertyValue[2];
660
		aStoreProperties[0] = new PropertyValue();
661
		aStoreProperties[1] = new PropertyValue();
662
		aStoreProperties[0].Name = "Override";
663
		aStoreProperties[0].Value = true;
664
		aStoreProperties[1].Name = "FilterName";
665
		aStoreProperties[1].Value = "StarOffice XML (Writer)";
666
		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
667
		app.closeDocument(xTextDocument);
668
669
		//reopen the document and assert table margin to page setting
670
		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
671
		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
672
		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
673
		Object xTable_obj1=xIndexedTables.getByIndex(0);
674
		XTextTable xTable_Assert1=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj1);
675
		XPropertySet xTableProps1_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert1);
676
		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.LEFT_BOTTOM,xTableProps1_assert.getPropertyValue("BackGraphicLocation"));
677
		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps1_assert.getPropertyValue("BackGraphicFilter"));
678
		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")),xTableProps1_assert.getPropertyValue("BackGraphicURL"));
679
		
680
		Object xTable_obj2=xIndexedTables.getByIndex(1);
681
		XTextTable xTable_Assert2=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj2);
682
		XPropertySet xTableProps2_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert2);
683
		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.LEFT_MIDDLE,xTableProps2_assert.getPropertyValue("BackGraphicLocation"));
684
		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps2_assert.getPropertyValue("BackGraphicFilter"));
685
		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")),xTableProps2_assert.getPropertyValue("BackGraphicURL"));
686
		
687
		Object xTable_obj3=xIndexedTables.getByIndex(2);
688
		XTextTable xTable_Assert3=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj3);
689
		XPropertySet xTableProps3_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert3);
690
		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.LEFT_TOP,xTableProps3_assert.getPropertyValue("BackGraphicLocation"));
691
		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps3_assert.getPropertyValue("BackGraphicFilter"));
692
		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")),xTableProps3_assert.getPropertyValue("BackGraphicURL"));
693
		
694
		Object xTable_obj4=xIndexedTables.getByIndex(3);
695
		XTextTable xTable_Assert4=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj4);
696
		XPropertySet xTableProps4_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert4);
697
		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_BOTTOM,xTableProps4_assert.getPropertyValue("BackGraphicLocation"));
698
		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps4_assert.getPropertyValue("BackGraphicFilter"));
699
		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")),xTableProps4_assert.getPropertyValue("BackGraphicURL"));
700
		
701
		Object xTable_obj5=xIndexedTables.getByIndex(4);
702
		XTextTable xTable_Assert5=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj5);
703
		XPropertySet xTableProps5_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert5);
704
		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_MIDDLE,xTableProps5_assert.getPropertyValue("BackGraphicLocation"));
705
		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps5_assert.getPropertyValue("BackGraphicFilter"));
706
		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")),xTableProps5_assert.getPropertyValue("BackGraphicURL"));
707
		
708
		Object xTable_obj6=xIndexedTables.getByIndex(5);
709
		XTextTable xTable_Assert6=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj6);
710
		XPropertySet xTableProps6_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert6);
711
		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_TOP,xTableProps6_assert.getPropertyValue("BackGraphicLocation"));
712
		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps6_assert.getPropertyValue("BackGraphicFilter"));
713
		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")),xTableProps6_assert.getPropertyValue("BackGraphicURL"));
714
		
715
		Object xTable_obj7=xIndexedTables.getByIndex(6);
716
		XTextTable xTable_Assert7=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj7);
717
		XPropertySet xTableProps7_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert7);
718
		assertEquals("verify table backgraphic location is title",com.sun.star.style.GraphicLocation.NONE,xTableProps7_assert.getPropertyValue("BackGraphicLocation"));
719
		
720
		Object xTable_obj8=xIndexedTables.getByIndex(7);
721
		XTextTable xTable_Assert8=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj8);
722
		XPropertySet xTableProps8_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert8);
723
		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_BOTTOM,xTableProps8_assert.getPropertyValue("BackGraphicLocation"));
724
		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps8_assert.getPropertyValue("BackGraphicFilter"));
725
		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")),xTableProps8_assert.getPropertyValue("BackGraphicURL"));
726
		
727
		Object xTable_obj9=xIndexedTables.getByIndex(8);
728
		XTextTable xTable_Assert9=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj9);
729
		XPropertySet xTableProps9_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert9);
730
		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_MIDDLE,xTableProps9_assert.getPropertyValue("BackGraphicLocation"));
731
		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps9_assert.getPropertyValue("BackGraphicFilter"));
732
		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")),xTableProps9_assert.getPropertyValue("BackGraphicURL"));
733
		
734
		Object xTable_obj10=xIndexedTables.getByIndex(9);
735
		XTextTable xTable_Assert10=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj10);
736
		XPropertySet xTableProps10_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert10);
737
		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_TOP,xTableProps10_assert.getPropertyValue("BackGraphicLocation"));
738
		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps10_assert.getPropertyValue("BackGraphicFilter"));
739
		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")),xTableProps10_assert.getPropertyValue("BackGraphicURL"));
740
		
741
		Object xTable_obj11=xIndexedTables.getByIndex(10);
742
		XTextTable xTable_Assert11=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj11);
743
		XPropertySet xTableProps11_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert11);
744
		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.AREA,xTableProps11_assert.getPropertyValue("BackGraphicLocation"));
745
		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps11_assert.getPropertyValue("BackGraphicFilter"));
746
		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("testcase/uno/sw/table/Desert.jpg")),xTableProps11_assert.getPropertyValue("BackGraphicURL"));				
747
	}	
748
}
749

Return to issue 120388