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