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