1*eba4d44aSLiu Zhe package fvt.uno.sw.table;
299039f9fSLiu Zhe 
399039f9fSLiu Zhe import static org.junit.Assert.*;
499039f9fSLiu Zhe 
599039f9fSLiu Zhe import org.junit.After;
699039f9fSLiu Zhe import org.junit.Before;
799039f9fSLiu Zhe import org.junit.Test;
899039f9fSLiu Zhe import org.openoffice.test.common.FileUtil;
999039f9fSLiu Zhe import org.openoffice.test.common.Testspace;
1099039f9fSLiu Zhe import org.openoffice.test.uno.UnoApp;
1199039f9fSLiu Zhe 
1299039f9fSLiu Zhe import com.sun.star.uno.UnoRuntime;
1399039f9fSLiu Zhe import com.sun.star.text.*;
1499039f9fSLiu Zhe import com.sun.star.lang.XMultiServiceFactory;
1599039f9fSLiu Zhe import com.sun.star.beans.PropertyValue;
1699039f9fSLiu Zhe import com.sun.star.beans.XPropertySet;
1799039f9fSLiu Zhe import com.sun.star.container.XIndexAccess;
1899039f9fSLiu Zhe import com.sun.star.table.*;
1999039f9fSLiu Zhe import com.sun.star.frame.XStorable;
2099039f9fSLiu Zhe 
2199039f9fSLiu Zhe 
22093442a8SLiu Zhe public class TableBasic {
2399039f9fSLiu Zhe 
2499039f9fSLiu Zhe 	private static final UnoApp app = new UnoApp();
2599039f9fSLiu Zhe 	private XTextDocument xTextDocument=null;
2699039f9fSLiu Zhe 	private XMultiServiceFactory xWriterFactory=null;
2799039f9fSLiu Zhe 	private XText xText=null;
2899039f9fSLiu Zhe 	@Before
2999039f9fSLiu Zhe 	public void setUp() throws Exception {
3099039f9fSLiu Zhe 		app.start();
3199039f9fSLiu Zhe 	}
3299039f9fSLiu Zhe 
3399039f9fSLiu Zhe 	@After
3499039f9fSLiu Zhe 	public void tearDown() throws Exception {
3599039f9fSLiu Zhe 		app.close();
3699039f9fSLiu Zhe 	}
3799039f9fSLiu Zhe   /*
3899039f9fSLiu Zhe    * test create table
3999039f9fSLiu Zhe    * 1.new a text document and create a table,5 rows,4 columns
4099039f9fSLiu Zhe    * 2.save to odt,close it and reopen new saved document
4199039f9fSLiu Zhe    * 3.check the table column count and row count
4299039f9fSLiu Zhe    */
4399039f9fSLiu Zhe 	@Test
4499039f9fSLiu Zhe 	public void testCreateTable() throws Exception {
4599039f9fSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
4699039f9fSLiu Zhe 		xText=xTextDocument.getText();
4799039f9fSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
4899039f9fSLiu Zhe 		// get internal service factory of the document
4999039f9fSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
5099039f9fSLiu Zhe 		// Create a new table from the document's factory
5199039f9fSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
5299039f9fSLiu Zhe 		xTable.initialize(5, 4);
5399039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
5499039f9fSLiu Zhe 
5599039f9fSLiu Zhe 		//save and reload text document
5699039f9fSLiu Zhe 		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
5799039f9fSLiu Zhe 		PropertyValue[] aStoreProperties = new PropertyValue[2];
5899039f9fSLiu Zhe 		aStoreProperties[0] = new PropertyValue();
5999039f9fSLiu Zhe 		aStoreProperties[1] = new PropertyValue();
6099039f9fSLiu Zhe 		aStoreProperties[0].Name = "Override";
6199039f9fSLiu Zhe 		aStoreProperties[0].Value = true;
6299039f9fSLiu Zhe 		aStoreProperties[1].Name = "FilterName";
6399039f9fSLiu Zhe 		aStoreProperties[1].Value = "StarOffice XML (Writer)";
6499039f9fSLiu Zhe 		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
6599039f9fSLiu Zhe 		app.closeDocument(xTextDocument);
6699039f9fSLiu Zhe 
6799039f9fSLiu Zhe 		//reopen the document and assert create table successfully
6899039f9fSLiu Zhe 		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
6999039f9fSLiu Zhe 		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
7099039f9fSLiu Zhe 		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
7199039f9fSLiu Zhe 		Object xTable_obj=xIndexedTables.getByIndex(0);
7299039f9fSLiu Zhe 		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj);
7399039f9fSLiu Zhe 		XTableRows xRows=xTable_Assert.getRows();
7499039f9fSLiu Zhe 		assertEquals("assert inserted table has 5 rows",5, xRows.getCount());
7599039f9fSLiu Zhe 		XTableColumns xColumns=xTable_Assert.getColumns();
7699039f9fSLiu Zhe 		assertEquals("assert inserted table has 4 columns",4, xColumns.getCount());
7799039f9fSLiu Zhe 	}
7899039f9fSLiu Zhe 	/*
7999039f9fSLiu Zhe 	 * test insert/delete row/column
8099039f9fSLiu Zhe 	 * 1.new a text document and new a table 5x4
8199039f9fSLiu Zhe 	 * 2.insert 2 rows,4 columns
8299039f9fSLiu Zhe 	 * 3.check the total row count and column count
8399039f9fSLiu Zhe 	 * 4.delete 3 row,2 column
8499039f9fSLiu Zhe 	 * 5.check the total row count and column count
8599039f9fSLiu Zhe 	 */
8699039f9fSLiu Zhe 	@Test
8799039f9fSLiu Zhe 	public void testInsert_Delete_Rows_Columns() throws Exception {
8899039f9fSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
8999039f9fSLiu Zhe 		xText=xTextDocument.getText();
9099039f9fSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
9199039f9fSLiu Zhe 		// get internal service factory of the document
9299039f9fSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
9399039f9fSLiu Zhe 		// Create a new table from the document's factory
9499039f9fSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
9599039f9fSLiu Zhe 		xTable.initialize(5, 4);
9699039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
9799039f9fSLiu Zhe 		XTableRows xRows=xTable.getRows();
9899039f9fSLiu Zhe 		XTableColumns xColumns=xTable.getColumns();
9999039f9fSLiu Zhe 		xRows.insertByIndex(0, 2);
10099039f9fSLiu Zhe 		xColumns.insertByIndex(3, 4);
10199039f9fSLiu Zhe 		assertEquals("assert inserted 2 rows",7, xRows.getCount());
10299039f9fSLiu Zhe 		assertEquals("assert inserted 2 columns",8, xColumns.getCount());
10399039f9fSLiu Zhe 		xRows.removeByIndex(0, 3);
10499039f9fSLiu Zhe 		xColumns.removeByIndex(3, 2);
10599039f9fSLiu Zhe 		assertEquals("assert delete 3 rows",4, xRows.getCount());
10699039f9fSLiu Zhe 		assertEquals("assert delete 2 columns",6, xColumns.getCount());
10799039f9fSLiu Zhe 		app.closeDocument(xTextDocument);
10899039f9fSLiu Zhe 	}
10999039f9fSLiu Zhe 	/*
11099039f9fSLiu Zhe 	 * test table tow height
11199039f9fSLiu Zhe 	 * 1.new a text document and new a table
11299039f9fSLiu Zhe 	 * 2.set the first row height and not auto fit
11399039f9fSLiu Zhe 	 * 3.save to odt,close it and reopen new saved document
11499039f9fSLiu Zhe 	 * 4.check the table first row height setting
11599039f9fSLiu Zhe 	 */
11699039f9fSLiu Zhe 	@Test
11799039f9fSLiu Zhe 	public void testSetRowHeight() throws Exception {
11899039f9fSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
11999039f9fSLiu Zhe 		xText=xTextDocument.getText();
12099039f9fSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
12199039f9fSLiu Zhe 		// get internal service factory of the document
12299039f9fSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
12399039f9fSLiu Zhe 		// Create a new table from the document's factory
12499039f9fSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
12599039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
12699039f9fSLiu Zhe 		XTableRows xRows=xTable.getRows();
12799039f9fSLiu Zhe 		//set first row not auto fit and user-defined height
12899039f9fSLiu Zhe 		XPropertySet xRowsProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xRows.getByIndex(0));
12999039f9fSLiu Zhe 		xRowsProps.setPropertyValue("IsAutoHeight",false);
13099039f9fSLiu Zhe 		xRowsProps.setPropertyValue("Height",5001);
13199039f9fSLiu Zhe 		//save and reload text document
13299039f9fSLiu Zhe 		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
13399039f9fSLiu Zhe 		PropertyValue[] aStoreProperties = new PropertyValue[2];
13499039f9fSLiu Zhe 		aStoreProperties[0] = new PropertyValue();
13599039f9fSLiu Zhe 		aStoreProperties[1] = new PropertyValue();
13699039f9fSLiu Zhe 		aStoreProperties[0].Name = "Override";
13799039f9fSLiu Zhe 		aStoreProperties[0].Value = true;
13899039f9fSLiu Zhe 		aStoreProperties[1].Name = "FilterName";
13999039f9fSLiu Zhe 		aStoreProperties[1].Value = "StarOffice XML (Writer)";
14099039f9fSLiu Zhe 		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
14199039f9fSLiu Zhe 		app.closeDocument(xTextDocument);
14299039f9fSLiu Zhe 
14399039f9fSLiu Zhe 		//reopen the document and assert row height setting
14499039f9fSLiu Zhe 		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
14599039f9fSLiu Zhe 		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
14699039f9fSLiu Zhe 		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
14799039f9fSLiu Zhe 		Object xTable_obj=xIndexedTables.getByIndex(0);
14899039f9fSLiu Zhe 		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj);
14999039f9fSLiu Zhe 		XTableRows xRows_Assert=xTable_Assert.getRows();
15099039f9fSLiu Zhe 		XPropertySet xRowsProps_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRows_Assert.getByIndex(0));
15199039f9fSLiu Zhe 		assertEquals("assert the second row height is 5001",5001,xRowsProps_assert.getPropertyValue("Height"));
15299039f9fSLiu Zhe 		assertEquals("assert the second row height is not autofitable",false, xRowsProps_assert.getPropertyValue("IsAutoHeight"));
15399039f9fSLiu Zhe 	}
15499039f9fSLiu Zhe 	/*
15599039f9fSLiu Zhe 	 * test table border setting
15699039f9fSLiu Zhe 	 * 1.new a text document and create a table
15799039f9fSLiu Zhe 	 * 2.set table border line color and style
15899039f9fSLiu Zhe 	 * 3.save to odt,close it and reopen new saved document
15999039f9fSLiu Zhe 	 * 4.check the table border setting
16099039f9fSLiu Zhe 	 */
16199039f9fSLiu Zhe 	@Test
16299039f9fSLiu Zhe 	public void testSetTableBorder() throws Exception {
16399039f9fSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
16499039f9fSLiu Zhe 		xText=xTextDocument.getText();
16599039f9fSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
16699039f9fSLiu Zhe 		// get internal service factory of the document
16799039f9fSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
16899039f9fSLiu Zhe 		// Create a new table from the document's factory
16999039f9fSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
17099039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
17199039f9fSLiu Zhe 		XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable);
17299039f9fSLiu Zhe 		//set table border
17399039f9fSLiu Zhe 		TableBorder tableBorder = new TableBorder();
17499039f9fSLiu Zhe 		BorderLine[]borderLine=new BorderLine[] {new BorderLine(),new BorderLine(),new BorderLine(),new BorderLine(),new BorderLine(),new BorderLine()};
17599039f9fSLiu Zhe 		borderLine[0].Color=0x00FF0000;
17699039f9fSLiu Zhe 		borderLine[0].InnerLineWidth=101;
17799039f9fSLiu Zhe 		borderLine[0].OuterLineWidth=19;
17899039f9fSLiu Zhe 		borderLine[0].LineDistance=100;
17999039f9fSLiu Zhe 		borderLine[1].Color =0x00FFFF00;
18099039f9fSLiu Zhe 		borderLine[1].InnerLineWidth=101;
18199039f9fSLiu Zhe 		borderLine[1].OuterLineWidth=19;
18299039f9fSLiu Zhe 		borderLine[1].LineDistance=101;
18399039f9fSLiu Zhe 		borderLine[2].Color =0x0000FF00;
18499039f9fSLiu Zhe 		borderLine[2].InnerLineWidth=150;
18599039f9fSLiu Zhe 		borderLine[2].OuterLineWidth=19;
18699039f9fSLiu Zhe 		borderLine[2].LineDistance=101;
18799039f9fSLiu Zhe 		borderLine[3].Color =0x0000FF00;
18899039f9fSLiu Zhe 		borderLine[3].InnerLineWidth=150;
18999039f9fSLiu Zhe 		borderLine[3].OuterLineWidth=19;
19099039f9fSLiu Zhe 		borderLine[3].LineDistance=101;
19199039f9fSLiu Zhe 		borderLine[4].Color =0x0000FF00;
19299039f9fSLiu Zhe 		borderLine[4].InnerLineWidth=150;
19399039f9fSLiu Zhe 		borderLine[4].OuterLineWidth=19;
19499039f9fSLiu Zhe 		borderLine[4].LineDistance=101;
19599039f9fSLiu Zhe 		borderLine[5].Color =0x0000FF00;
19699039f9fSLiu Zhe 		borderLine[5].InnerLineWidth=150;
19799039f9fSLiu Zhe 		borderLine[5].OuterLineWidth=19;
19899039f9fSLiu Zhe 		borderLine[5].LineDistance=101;
19999039f9fSLiu Zhe 		tableBorder.TopLine =borderLine[0];
20099039f9fSLiu Zhe 		tableBorder.BottomLine =borderLine[1];
20199039f9fSLiu Zhe 		tableBorder.LeftLine =borderLine[2];
20299039f9fSLiu Zhe 		tableBorder.RightLine =borderLine[3];
20399039f9fSLiu Zhe 		tableBorder.HorizontalLine =borderLine[4];
20499039f9fSLiu Zhe 		tableBorder.VerticalLine =borderLine[5];
20599039f9fSLiu Zhe 		tableBorder.IsBottomLineValid = true;
20699039f9fSLiu Zhe 		tableBorder.IsLeftLineValid = true;
20799039f9fSLiu Zhe 		tableBorder.IsRightLineValid = true;
20899039f9fSLiu Zhe 		tableBorder.IsTopLineValid = true;
20999039f9fSLiu Zhe 		tableBorder.IsHorizontalLineValid = true;
21099039f9fSLiu Zhe 		tableBorder.IsVerticalLineValid = true;
21199039f9fSLiu Zhe 		xTableProps.setPropertyValue("TableBorder", tableBorder);
21299039f9fSLiu Zhe 		//save and reload text document
21399039f9fSLiu Zhe 		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
21499039f9fSLiu Zhe 		PropertyValue[] aStoreProperties = new PropertyValue[2];
21599039f9fSLiu Zhe 		aStoreProperties[0] = new PropertyValue();
21699039f9fSLiu Zhe 		aStoreProperties[1] = new PropertyValue();
21799039f9fSLiu Zhe 		aStoreProperties[0].Name = "Override";
21899039f9fSLiu Zhe 		aStoreProperties[0].Value = true;
21999039f9fSLiu Zhe 		aStoreProperties[1].Name = "FilterName";
22099039f9fSLiu Zhe 		aStoreProperties[1].Value = "StarOffice XML (Writer)";
22199039f9fSLiu Zhe 		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
22299039f9fSLiu Zhe 		app.closeDocument(xTextDocument);
22399039f9fSLiu Zhe 
22499039f9fSLiu Zhe 		//reopen the document and assert table border setting
22599039f9fSLiu Zhe 		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
22699039f9fSLiu Zhe 		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
22799039f9fSLiu Zhe 		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
22899039f9fSLiu Zhe 		Object xTable_obj=xIndexedTables.getByIndex(0);
22999039f9fSLiu Zhe 		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj);
23099039f9fSLiu Zhe 		XPropertySet xTableProps_Assert = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert);
23199039f9fSLiu Zhe 		TableBorder tableBorder_Assert=(TableBorder) UnoRuntime.queryInterface(TableBorder.class, xTableProps_Assert.getPropertyValue("TableBorder"));
23299039f9fSLiu Zhe 		assertEquals("assert topline color as setting",0x00FF0000,tableBorder_Assert.TopLine.Color);
23399039f9fSLiu Zhe 		assertEquals("assert topline innerline width as setting",101,tableBorder_Assert.TopLine.InnerLineWidth);
23499039f9fSLiu Zhe 		assertEquals("assert topline outerlinewidth as setting",19,tableBorder_Assert.TopLine.OuterLineWidth);
23599039f9fSLiu Zhe 		assertEquals("assert topline linedistance as setting",101,tableBorder_Assert.TopLine.LineDistance);
23699039f9fSLiu Zhe 		assertEquals("assert bottomline color as setting",0x00FFFF00,tableBorder_Assert.BottomLine.Color);
23799039f9fSLiu Zhe 		assertEquals("assert bottomline innerline width as setting",101,tableBorder_Assert.BottomLine.InnerLineWidth);
23899039f9fSLiu Zhe 		assertEquals("assert bottomline outerlinewidth as setting",19,tableBorder_Assert.BottomLine.OuterLineWidth);
23999039f9fSLiu Zhe 		assertEquals("assert bottomline linedistance as setting",101,tableBorder_Assert.BottomLine.LineDistance);
24099039f9fSLiu Zhe 		assertEquals("assert leftline color as setting",0x0000FF00,tableBorder_Assert.LeftLine.Color);
24199039f9fSLiu Zhe 		assertEquals("assert leftline innerline width as setting",150,tableBorder_Assert.LeftLine.InnerLineWidth);
24299039f9fSLiu Zhe 		assertEquals("assert leftline outerlinewidth as setting",19,tableBorder_Assert.LeftLine.OuterLineWidth);
24399039f9fSLiu Zhe 		assertEquals("assert leftline linedistance as setting",101,tableBorder_Assert.LeftLine.LineDistance);
24499039f9fSLiu Zhe 		assertEquals("assert rightline color as setting",0x0000FF00,tableBorder_Assert.RightLine.Color);
24599039f9fSLiu Zhe 		assertEquals("assert rightline linedistance as setting",101,tableBorder_Assert.RightLine.LineDistance);
24699039f9fSLiu Zhe 		assertEquals("assert rightline innerline width as setting",150,tableBorder_Assert.RightLine.InnerLineWidth);
24799039f9fSLiu Zhe 		assertEquals("assert rightline outerlinewidth as setting",19,tableBorder_Assert.RightLine.OuterLineWidth);
24899039f9fSLiu Zhe 		assertEquals("assert HorizontalLine color as setting",0x0000FF00,tableBorder_Assert.HorizontalLine.Color);
24999039f9fSLiu Zhe 		assertEquals("assert HorizontalLine innerline width as setting",150,tableBorder_Assert.HorizontalLine.InnerLineWidth);
25099039f9fSLiu Zhe 		assertEquals("assert HorizontalLine outerlinewidth as setting",19,tableBorder_Assert.HorizontalLine.OuterLineWidth);
25199039f9fSLiu Zhe 		assertEquals("assert HorizontalLine linedistance as setting",101,tableBorder_Assert.HorizontalLine.LineDistance);
25299039f9fSLiu Zhe 		assertEquals("assert VerticalLine color as setting",0x0000FF00,tableBorder_Assert.VerticalLine.Color);
25399039f9fSLiu Zhe 		assertEquals("assert VerticalLine innerline width as setting",150,tableBorder_Assert.VerticalLine.InnerLineWidth);
25499039f9fSLiu Zhe 		assertEquals("assert VerticalLine outerlinewidth as setting",19,tableBorder_Assert.VerticalLine.OuterLineWidth);
25599039f9fSLiu Zhe 		assertEquals("assert VerticalLine linedistance as setting",101,tableBorder_Assert.VerticalLine.LineDistance);
25699039f9fSLiu Zhe 	}
25799039f9fSLiu Zhe 	/*
25899039f9fSLiu Zhe 	 * test table spacing to page and alignment
25999039f9fSLiu Zhe 	 * 1.new a text document
26099039f9fSLiu Zhe 	 * 2.create a table
26199039f9fSLiu Zhe 	 * 3.set the table alignment to automatic,and spacing to margin
26299039f9fSLiu Zhe 	 * 4.repeat step2 5 times,and set second table alignment to manual/center/left/from left/right,and spacing to margin
26399039f9fSLiu Zhe 	 * 5.save to odt,close it and reopen the new saved document
26499039f9fSLiu Zhe 	 * 6.reopen and check the every table alignment and spacing to margin
26599039f9fSLiu Zhe 	 */
26699039f9fSLiu Zhe 	@Test
26799039f9fSLiu Zhe 	public void testSetTable_AlignmentAndMarginToPage() throws Exception {
26899039f9fSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
26999039f9fSLiu Zhe 		xText=xTextDocument.getText();
27099039f9fSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
27199039f9fSLiu Zhe 		// get internal service factory of the document
27299039f9fSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
27399039f9fSLiu Zhe 		// Create  new table from the document's factory
27499039f9fSLiu Zhe 		XTextTable xTable1 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
27599039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable1,false);
27699039f9fSLiu Zhe 		XPropertySet xTableProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable1);
27799039f9fSLiu Zhe 		xTableProps1.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.FULL);
27899039f9fSLiu Zhe 		xTableProps1.setPropertyValue("LeftMargin",2591);
27999039f9fSLiu Zhe 		xTableProps1.setPropertyValue("RightMargin",3000);
28099039f9fSLiu Zhe 		xTableProps1.setPropertyValue("TopMargin",2000);
28199039f9fSLiu Zhe 		xTableProps1.setPropertyValue("BottomMargin",2000);
28299039f9fSLiu Zhe 		XTextTable xTable2 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
28399039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable2,false);
28499039f9fSLiu Zhe 		XPropertySet xTableProps2 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable2);
28599039f9fSLiu Zhe 		xTableProps2.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.NONE);
28699039f9fSLiu Zhe 		xTableProps2.setPropertyValue("LeftMargin",2591);
28799039f9fSLiu Zhe 		xTableProps2.setPropertyValue("RightMargin",3000);
28899039f9fSLiu Zhe 		xTableProps2.setPropertyValue("TopMargin",2000);
28999039f9fSLiu Zhe 		xTableProps2.setPropertyValue("BottomMargin",2000);
29099039f9fSLiu Zhe 		XTextTable xTable3 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
29199039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable3,false);
29299039f9fSLiu Zhe 		XPropertySet xTableProps3 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable3);
29399039f9fSLiu Zhe 		xTableProps3.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.CENTER);
29499039f9fSLiu Zhe 		xTableProps3.setPropertyValue("LeftMargin",2000);
29599039f9fSLiu Zhe 		xTableProps3.setPropertyValue("RightMargin",3000);
29699039f9fSLiu Zhe 		xTableProps3.setPropertyValue("TopMargin",2000);
29799039f9fSLiu Zhe 		xTableProps3.setPropertyValue("BottomMargin",2000);
29899039f9fSLiu Zhe 		XTextTable xTable4 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
29999039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable4,false);
30099039f9fSLiu Zhe 		XPropertySet xTableProps4 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable4);
30199039f9fSLiu Zhe 		xTableProps4.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.LEFT);
30299039f9fSLiu Zhe 		xTableProps4.setPropertyValue("KeepTogether",true);
30399039f9fSLiu Zhe 		xTableProps4.setPropertyValue("RightMargin",2000);
30499039f9fSLiu Zhe 		xTableProps4.setPropertyValue("TopMargin",2000);
30599039f9fSLiu Zhe 		xTableProps4.setPropertyValue("BottomMargin",2000);
30699039f9fSLiu Zhe 		XTextTable xTable5 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
30799039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable5,false);
30899039f9fSLiu Zhe 		XPropertySet xTableProps5 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable5);
30999039f9fSLiu Zhe 		xTableProps5.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.LEFT_AND_WIDTH);
31099039f9fSLiu Zhe 		xTableProps5.setPropertyValue("TopMargin",2000);
31199039f9fSLiu Zhe 		xTableProps5.setPropertyValue("BottomMargin",2000);
31299039f9fSLiu Zhe 		XTextTable xTable6 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
31399039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable6,false);
31499039f9fSLiu Zhe 		XPropertySet xTableProps6 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable6);
31599039f9fSLiu Zhe 		xTableProps6.setPropertyValue("HoriOrient",com.sun.star.text.HoriOrientation.RIGHT);
31699039f9fSLiu Zhe 		xTableProps6.setPropertyValue("TopMargin",2000);
31799039f9fSLiu Zhe 		xTableProps6.setPropertyValue("BottomMargin",2000);
31899039f9fSLiu Zhe 		//save and reload text document
31999039f9fSLiu Zhe 		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
32099039f9fSLiu Zhe 		PropertyValue[] aStoreProperties = new PropertyValue[2];
32199039f9fSLiu Zhe 		aStoreProperties[0] = new PropertyValue();
32299039f9fSLiu Zhe 		aStoreProperties[1] = new PropertyValue();
32399039f9fSLiu Zhe 		aStoreProperties[0].Name = "Override";
32499039f9fSLiu Zhe 		aStoreProperties[0].Value = true;
32599039f9fSLiu Zhe 		aStoreProperties[1].Name = "FilterName";
32699039f9fSLiu Zhe 		aStoreProperties[1].Value = "StarOffice XML (Writer)";
32799039f9fSLiu Zhe 		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
32899039f9fSLiu Zhe 		app.closeDocument(xTextDocument);
32999039f9fSLiu Zhe 
33099039f9fSLiu Zhe 		//reopen the document and assert table margin to page setting
33199039f9fSLiu Zhe 		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
33299039f9fSLiu Zhe 		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
33399039f9fSLiu Zhe 		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
33499039f9fSLiu Zhe 		Object xTable_obj1=xIndexedTables.getByIndex(0);
33599039f9fSLiu Zhe 		XTextTable xTable_Assert1=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj1);
33699039f9fSLiu Zhe 		XPropertySet xTableProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert1);
33799039f9fSLiu Zhe 		assertEquals("assert table alignment as automatic",com.sun.star.text.HoriOrientation.FULL,xTableProps_assert1.getPropertyValue("HoriOrient"));
33899039f9fSLiu Zhe 		assertEquals("assert left margin to page",0,xTableProps_assert1.getPropertyValue("LeftMargin"));
33999039f9fSLiu Zhe 		assertEquals("assert right margin to page",0,xTableProps_assert1.getPropertyValue("RightMargin"));
34099039f9fSLiu Zhe 		assertEquals("assert top margin to page",2000,xTableProps_assert1.getPropertyValue("TopMargin"));
34199039f9fSLiu Zhe 		assertEquals("assert bottom margin to page",2000,xTableProps_assert1.getPropertyValue("BottomMargin"));
34299039f9fSLiu Zhe 		Object xTable_obj2=xIndexedTables.getByIndex(1);
34399039f9fSLiu Zhe 		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj2);
34499039f9fSLiu Zhe 		XPropertySet xTableProps_assert2 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert);
34599039f9fSLiu Zhe 		assertEquals("assert table alignment as manual",com.sun.star.text.HoriOrientation.NONE,xTableProps_assert2.getPropertyValue("HoriOrient"));
34699039f9fSLiu Zhe 		assertEquals("assert left margin to page",2591,xTableProps_assert2.getPropertyValue("LeftMargin"));
34799039f9fSLiu Zhe 		assertEquals("assert right margin to page",3000,xTableProps_assert2.getPropertyValue("RightMargin"));
34899039f9fSLiu Zhe 		assertEquals("assert top margin to page",2000,xTableProps_assert2.getPropertyValue("TopMargin"));
34999039f9fSLiu Zhe 		assertEquals("assert bottom margin to page",2000,xTableProps_assert2.getPropertyValue("BottomMargin"));
35099039f9fSLiu Zhe 		Object xTable_obj3=xIndexedTables.getByIndex(2);
35199039f9fSLiu Zhe 		XTextTable xTable_Assert3=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj3);
35299039f9fSLiu Zhe 		XPropertySet xTableProps_assert3 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert3);
35399039f9fSLiu Zhe 		assertEquals("assert table alignment as center",com.sun.star.text.HoriOrientation.CENTER,xTableProps_assert3.getPropertyValue("HoriOrient"));
35499039f9fSLiu Zhe 		assertEquals("assert top margin to page",2000,xTableProps_assert3.getPropertyValue("TopMargin"));
35599039f9fSLiu Zhe 		assertEquals("assert bottom margin to page",2000,xTableProps_assert3.getPropertyValue("BottomMargin"));
35699039f9fSLiu Zhe 		Object xTable_obj4=xIndexedTables.getByIndex(3);
35799039f9fSLiu Zhe 		XTextTable xTable_Assert4=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj4);
35899039f9fSLiu Zhe 		XPropertySet xTableProps_assert4 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert4);
35999039f9fSLiu Zhe 		assertEquals("assert table alignment as left",com.sun.star.text.HoriOrientation.LEFT,xTableProps_assert4.getPropertyValue("HoriOrient"));
36099039f9fSLiu Zhe 		assertEquals("assert top margin to page",2000,xTableProps_assert4.getPropertyValue("TopMargin"));
36199039f9fSLiu Zhe 		assertEquals("assert bottom margin to page",2000,xTableProps_assert4.getPropertyValue("BottomMargin"));
36299039f9fSLiu Zhe 		Object xTable_obj5=xIndexedTables.getByIndex(4);
36399039f9fSLiu Zhe 		XTextTable xTable_Assert5=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj5);
36499039f9fSLiu Zhe 		XPropertySet xTableProps_assert5 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert5);
36599039f9fSLiu Zhe 		assertEquals("assert table alignment as from left",com.sun.star.text.HoriOrientation.LEFT,xTableProps_assert5.getPropertyValue("HoriOrient"));
36699039f9fSLiu Zhe 		assertEquals("assert top margin to page",2000,xTableProps_assert5.getPropertyValue("TopMargin"));
36799039f9fSLiu Zhe 		assertEquals("assert bottom margin to page",2000,xTableProps_assert5.getPropertyValue("BottomMargin"));
36899039f9fSLiu Zhe 		Object xTable_obj6=xIndexedTables.getByIndex(5);
36999039f9fSLiu Zhe 		XTextTable xTable_Assert6=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj6);
37099039f9fSLiu Zhe 		XPropertySet xTableProps_assert6 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert6);
37199039f9fSLiu Zhe 		assertEquals("assert table alignment as right",com.sun.star.text.HoriOrientation.RIGHT,xTableProps_assert6.getPropertyValue("HoriOrient"));
37299039f9fSLiu Zhe 		assertEquals("assert top margin to page",2000,xTableProps_assert5.getPropertyValue("TopMargin"));
37399039f9fSLiu Zhe 		assertEquals("assert bottom margin to page",2000,xTableProps_assert5.getPropertyValue("BottomMargin"));
37499039f9fSLiu Zhe 	}
37599039f9fSLiu Zhe 	/*
37699039f9fSLiu Zhe 	 * test set table background with color
37799039f9fSLiu Zhe 	 * 1.new a text document and new a table
37899039f9fSLiu Zhe 	 * 2.set table background with color
37999039f9fSLiu Zhe 	 * 3.save to odt and close it,then reopen the new saved document
38099039f9fSLiu Zhe 	 * 4.check the table background color
38199039f9fSLiu Zhe 	 */
38299039f9fSLiu Zhe 	@Test
38399039f9fSLiu Zhe 	public void testSetTableBackColor() throws Exception {
38499039f9fSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
38599039f9fSLiu Zhe 		xText=xTextDocument.getText();
38699039f9fSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
38799039f9fSLiu Zhe 		// get internal service factory of the document
38899039f9fSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
38999039f9fSLiu Zhe 		// Create a new table from the document's factory
39099039f9fSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
39199039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
39299039f9fSLiu Zhe 		XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable);
39399039f9fSLiu Zhe 		xTableProps.setPropertyValue("BackColor",0x0000FF00);
39499039f9fSLiu Zhe 
39599039f9fSLiu Zhe 		//save and reload text document
39699039f9fSLiu Zhe 		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
39799039f9fSLiu Zhe 		PropertyValue[] aStoreProperties = new PropertyValue[2];
39899039f9fSLiu Zhe 		aStoreProperties[0] = new PropertyValue();
39999039f9fSLiu Zhe 		aStoreProperties[1] = new PropertyValue();
40099039f9fSLiu Zhe 		aStoreProperties[0].Name = "Override";
40199039f9fSLiu Zhe 		aStoreProperties[0].Value = true;
40299039f9fSLiu Zhe 		aStoreProperties[1].Name = "FilterName";
40399039f9fSLiu Zhe 		aStoreProperties[1].Value = "StarOffice XML (Writer)";
40499039f9fSLiu Zhe 		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
40599039f9fSLiu Zhe 		app.closeDocument(xTextDocument);
40699039f9fSLiu Zhe 
40799039f9fSLiu Zhe 		//reopen the document and assert table margin to page setting
40899039f9fSLiu Zhe 		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
40999039f9fSLiu Zhe 		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
41099039f9fSLiu Zhe 		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
41199039f9fSLiu Zhe 		Object xTable_obj=xIndexedTables.getByIndex(0);
41299039f9fSLiu Zhe 		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj);
41399039f9fSLiu Zhe 		XPropertySet xTableProps_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert);
41499039f9fSLiu Zhe 		assertEquals("verify table background color",0x0000FF00,xTableProps_assert.getPropertyValue("BackColor"));
41599039f9fSLiu Zhe 	}
41699039f9fSLiu Zhe 	/*test table repeat heading setting
41799039f9fSLiu Zhe 	 * 1.new a text document and create a table
41899039f9fSLiu Zhe 	 * 2.set table first row as repeat heading
41999039f9fSLiu Zhe 	 * 3.save to odt and close it,then reopen the document
42099039f9fSLiu Zhe 	 * 4.check the table first row as repeat heading
42199039f9fSLiu Zhe 	 */
42299039f9fSLiu Zhe 
42399039f9fSLiu Zhe 	@Test
42499039f9fSLiu Zhe 	public void testSetTableRepeatHeading() throws Exception {
42599039f9fSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
42699039f9fSLiu Zhe 		xText=xTextDocument.getText();
42799039f9fSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
42899039f9fSLiu Zhe 		// get internal service factory of the document
42999039f9fSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
43099039f9fSLiu Zhe 		// Create a new table from the document's factory
43199039f9fSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
43299039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
43399039f9fSLiu Zhe 		XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable);
43499039f9fSLiu Zhe 		//set table first one row as table heading
43599039f9fSLiu Zhe 		xTableProps.setPropertyValue("RepeatHeadline",true);
43699039f9fSLiu Zhe 		xTableProps.setPropertyValue("HeaderRowCount",1);
43799039f9fSLiu Zhe 
43899039f9fSLiu Zhe 		//save and reload text document
43999039f9fSLiu Zhe 		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
44099039f9fSLiu Zhe 		PropertyValue[] aStoreProperties = new PropertyValue[2];
44199039f9fSLiu Zhe 		aStoreProperties[0] = new PropertyValue();
44299039f9fSLiu Zhe 		aStoreProperties[1] = new PropertyValue();
44399039f9fSLiu Zhe 		aStoreProperties[0].Name = "Override";
44499039f9fSLiu Zhe 		aStoreProperties[0].Value = true;
44599039f9fSLiu Zhe 		aStoreProperties[1].Name = "FilterName";
44699039f9fSLiu Zhe 		aStoreProperties[1].Value = "StarOffice XML (Writer)";
44799039f9fSLiu Zhe 		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
44899039f9fSLiu Zhe 		app.closeDocument(xTextDocument);
44999039f9fSLiu Zhe 
45099039f9fSLiu Zhe 		//reopen the document and assert table repeat heading setting
45199039f9fSLiu Zhe 		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
45299039f9fSLiu Zhe 		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
45399039f9fSLiu Zhe 		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
45499039f9fSLiu Zhe 		Object xTable_obj=xIndexedTables.getByIndex(0);
45599039f9fSLiu Zhe 		XTextTable xTable_Assert=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj);
45699039f9fSLiu Zhe 		XPropertySet xTableProps_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert);
45799039f9fSLiu Zhe 		assertEquals("verify table heading row number",1,xTableProps_assert.getPropertyValue("HeaderRowCount"));
45899039f9fSLiu Zhe 		assertEquals("verify table heading repeat",true,xTableProps_assert.getPropertyValue("RepeatHeadline"));
45999039f9fSLiu Zhe 	}
46099039f9fSLiu Zhe 	/*
46199039f9fSLiu Zhe 	 * test table shadow setting
46299039f9fSLiu Zhe 	 * 1.new a text document
46399039f9fSLiu Zhe 	 * 2.create 5 tables
46499039f9fSLiu Zhe 	 * 3.set the 5 table shadow location to bottom_right,bottom_left,none,top_left,top_right,and shadow width
46599039f9fSLiu Zhe 	 * 4.save to odt and close it,then reopen the new saved document
46699039f9fSLiu Zhe 	 * 5.check the 5 table shadow location and width
46799039f9fSLiu Zhe 	 */
46899039f9fSLiu Zhe 	@Test
46999039f9fSLiu Zhe 	public void testSetTableShadow() throws Exception {
47099039f9fSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
47199039f9fSLiu Zhe 		xText=xTextDocument.getText();
47299039f9fSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
47399039f9fSLiu Zhe 		// get internal service factory of the document
47499039f9fSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
47599039f9fSLiu Zhe 		// Create new table from the document's factory
47699039f9fSLiu Zhe 		XTextTable xTable1 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
47799039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable1,false);
47899039f9fSLiu Zhe 		XPropertySet xTableProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable1);
47999039f9fSLiu Zhe 		XTextTable xTable2 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
48099039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable2,false);
48199039f9fSLiu Zhe 		XPropertySet xTableProps2 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable2);
48299039f9fSLiu Zhe 		XTextTable xTable3 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
48399039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable3,false);
48499039f9fSLiu Zhe 		XPropertySet xTableProps3 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable3);
48599039f9fSLiu Zhe 		XTextTable xTable4 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
48699039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable4,false);
48799039f9fSLiu Zhe 		XPropertySet xTableProps4 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable4);
48899039f9fSLiu Zhe 		XTextTable xTable5 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
48999039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable5,false);
49099039f9fSLiu Zhe 		XPropertySet xTableProps5 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable5);
49199039f9fSLiu Zhe 		//set table shadow
49299039f9fSLiu Zhe 		ShadowFormat[] shadowFormat=new ShadowFormat[] {new ShadowFormat(),new ShadowFormat(),new ShadowFormat(),new ShadowFormat(),new ShadowFormat()};
49399039f9fSLiu Zhe 		shadowFormat[0].Location=ShadowLocation.BOTTOM_RIGHT;
49499039f9fSLiu Zhe 		shadowFormat[0].ShadowWidth=100;
49599039f9fSLiu Zhe 		shadowFormat[0].Color=0x00FF00FF;
49699039f9fSLiu Zhe 		shadowFormat[1].Location=ShadowLocation.BOTTOM_LEFT;
49799039f9fSLiu Zhe 		shadowFormat[1].ShadowWidth=100;
49899039f9fSLiu Zhe 		shadowFormat[1].Color=0x00FF00FF;
49999039f9fSLiu Zhe 		shadowFormat[2].Location=ShadowLocation.NONE;
50099039f9fSLiu Zhe 		shadowFormat[3].Location=ShadowLocation.TOP_LEFT;
50199039f9fSLiu Zhe 		shadowFormat[3].ShadowWidth=100;
50299039f9fSLiu Zhe 		shadowFormat[3].Color=0x00FF00FF;
50399039f9fSLiu Zhe 		shadowFormat[4].Location=ShadowLocation.TOP_RIGHT;
50499039f9fSLiu Zhe 		shadowFormat[4].ShadowWidth=100;
50599039f9fSLiu Zhe 		shadowFormat[4].Color=0x00FF00FF;
50699039f9fSLiu Zhe 		xTableProps1.setPropertyValue("ShadowFormat",shadowFormat[0]);
50799039f9fSLiu Zhe 		xTableProps2.setPropertyValue("ShadowFormat",shadowFormat[1]);
50899039f9fSLiu Zhe 		xTableProps3.setPropertyValue("ShadowFormat",shadowFormat[2]);
50999039f9fSLiu Zhe 		xTableProps4.setPropertyValue("ShadowFormat",shadowFormat[3]);
51099039f9fSLiu Zhe 		xTableProps5.setPropertyValue("ShadowFormat",shadowFormat[4]);
51199039f9fSLiu Zhe 
51299039f9fSLiu Zhe 		//save and reload text document
51399039f9fSLiu Zhe 		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
51499039f9fSLiu Zhe 		PropertyValue[] aStoreProperties = new PropertyValue[2];
51599039f9fSLiu Zhe 		aStoreProperties[0] = new PropertyValue();
51699039f9fSLiu Zhe 		aStoreProperties[1] = new PropertyValue();
51799039f9fSLiu Zhe 		aStoreProperties[0].Name = "Override";
51899039f9fSLiu Zhe 		aStoreProperties[0].Value = true;
51999039f9fSLiu Zhe 		aStoreProperties[1].Name = "FilterName";
52099039f9fSLiu Zhe 		aStoreProperties[1].Value = "StarOffice XML (Writer)";
52199039f9fSLiu Zhe 		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
52299039f9fSLiu Zhe 		app.closeDocument(xTextDocument);
52399039f9fSLiu Zhe 
52499039f9fSLiu Zhe 		//reopen the document and assert table shadow setting
52599039f9fSLiu Zhe 		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
52699039f9fSLiu Zhe 		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
52799039f9fSLiu Zhe 		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
52899039f9fSLiu Zhe 		Object xTable_obj1=xIndexedTables.getByIndex(0);
52999039f9fSLiu Zhe 		XTextTable xTable_Assert1=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj1);
53099039f9fSLiu Zhe 		XPropertySet xTableProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert1);
53199039f9fSLiu Zhe 		ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTableProps_assert1.getPropertyValue("ShadowFormat"));
53299039f9fSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.BOTTOM_RIGHT,shadowFormat_Assert1.Location);
53399039f9fSLiu Zhe 		assertEquals("assert shadow width",100,shadowFormat_Assert1.ShadowWidth);
53499039f9fSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color);
53599039f9fSLiu Zhe 
53699039f9fSLiu Zhe 		Object xTable_obj2=xIndexedTables.getByIndex(1);
53799039f9fSLiu Zhe 		XTextTable xTable_Assert2=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj2);
53899039f9fSLiu Zhe 		XPropertySet xTableProps_assert2 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert2);
53999039f9fSLiu Zhe 		ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTableProps_assert2.getPropertyValue("ShadowFormat"));
54099039f9fSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.BOTTOM_LEFT,shadowFormat_Assert2.Location);
54199039f9fSLiu Zhe 		assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth);
54299039f9fSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color);
54399039f9fSLiu Zhe 
54499039f9fSLiu Zhe 		Object xTable_obj3=xIndexedTables.getByIndex(2);
54599039f9fSLiu Zhe 		XTextTable xTable_Assert3=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj3);
54699039f9fSLiu Zhe 		XPropertySet xTableProps_assert3 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert3);
54799039f9fSLiu Zhe 		ShadowFormat shadowFormat_Assert3=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTableProps_assert3.getPropertyValue("ShadowFormat"));
54899039f9fSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.NONE,shadowFormat_Assert3.Location);
54999039f9fSLiu Zhe 
55099039f9fSLiu Zhe 		Object xTable_obj4=xIndexedTables.getByIndex(3);
55199039f9fSLiu Zhe 		XTextTable xTable_Assert4=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj4);
55299039f9fSLiu Zhe 		XPropertySet xTableProps_assert4 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert4);
55399039f9fSLiu Zhe 		ShadowFormat shadowFormat_Assert4=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTableProps_assert4.getPropertyValue("ShadowFormat"));
55499039f9fSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.TOP_LEFT,shadowFormat_Assert4.Location);
55599039f9fSLiu Zhe 		assertEquals("assert shadow width",100,shadowFormat_Assert4.ShadowWidth);
55699039f9fSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert4.Color);
55799039f9fSLiu Zhe 
55899039f9fSLiu Zhe 		Object xTable_obj5=xIndexedTables.getByIndex(4);
55999039f9fSLiu Zhe 		XTextTable xTable_Assert5=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj5);
56099039f9fSLiu Zhe 		XPropertySet xTableProps_assert5 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert5);
56199039f9fSLiu Zhe 		ShadowFormat shadowFormat_Assert5=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTableProps_assert5.getPropertyValue("ShadowFormat"));
56299039f9fSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.TOP_RIGHT,shadowFormat_Assert5.Location);
56399039f9fSLiu Zhe 		assertEquals("assert shadow width",100,shadowFormat_Assert5.ShadowWidth);
56499039f9fSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert5.Color);
56599039f9fSLiu Zhe 	}
56699039f9fSLiu Zhe 	/*
56799039f9fSLiu Zhe 	 * test set table background with graphic
56899039f9fSLiu Zhe 	 * 1.new a text document and create a table
56999039f9fSLiu Zhe 	 * 2.set table background with a picture
57099039f9fSLiu Zhe 	 * 3.save to odt and closet it,then reopen the new saved document
57199039f9fSLiu Zhe 	 * 4.check the table background
57299039f9fSLiu Zhe 	 */
57399039f9fSLiu Zhe 	@Test
57499039f9fSLiu Zhe 	public void testSetTableBackGraphic() throws Exception {
57599039f9fSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
57699039f9fSLiu Zhe 		xText=xTextDocument.getText();
57799039f9fSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
57899039f9fSLiu Zhe 		// get internal service factory of the document
57999039f9fSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
58099039f9fSLiu Zhe 		// Create a new table from the document's factory
58199039f9fSLiu Zhe 		XTextTable xTable1 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
58299039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable1,false);
58399039f9fSLiu Zhe 		XPropertySet xTableProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable1);
5846b55ece7SLiu Zhe 		xTableProps1.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
58599039f9fSLiu Zhe 		xTableProps1.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
58699039f9fSLiu Zhe 		xTableProps1.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_BOTTOM);
58799039f9fSLiu Zhe 
58899039f9fSLiu Zhe 		XTextTable xTable2 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
58999039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable2,false);
59099039f9fSLiu Zhe 		XPropertySet xTableProps2 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable2);
5916b55ece7SLiu Zhe 		xTableProps2.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
59299039f9fSLiu Zhe 		xTableProps2.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
59399039f9fSLiu Zhe 		xTableProps2.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_MIDDLE);
59499039f9fSLiu Zhe 
59599039f9fSLiu Zhe 		XTextTable xTable3 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
59699039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable3,false);
59799039f9fSLiu Zhe 		XPropertySet xTableProps3 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable3);
5986b55ece7SLiu Zhe 		xTableProps3.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
59999039f9fSLiu Zhe 		xTableProps3.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
60099039f9fSLiu Zhe 		xTableProps3.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_TOP);
60199039f9fSLiu Zhe 
60299039f9fSLiu Zhe 		XTextTable xTable4 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
60399039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable4,false);
60499039f9fSLiu Zhe 		XPropertySet xTableProps4 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable4);
6056b55ece7SLiu Zhe 		xTableProps4.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
60699039f9fSLiu Zhe 		xTableProps4.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
60799039f9fSLiu Zhe 		xTableProps4.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_BOTTOM);
60899039f9fSLiu Zhe 
60999039f9fSLiu Zhe 		XTextTable xTable5 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
61099039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable5,false);
61199039f9fSLiu Zhe 		XPropertySet xTableProps5 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable5);
6126b55ece7SLiu Zhe 		xTableProps5.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
61399039f9fSLiu Zhe 		xTableProps5.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
61499039f9fSLiu Zhe 		xTableProps5.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_MIDDLE);
61599039f9fSLiu Zhe 
61699039f9fSLiu Zhe 		XTextTable xTable6 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
61799039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable6,false);
61899039f9fSLiu Zhe 		XPropertySet xTableProps6 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable6);
6196b55ece7SLiu Zhe 		xTableProps6.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
62099039f9fSLiu Zhe 		xTableProps6.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
62199039f9fSLiu Zhe 		xTableProps6.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_TOP);
62299039f9fSLiu Zhe 
62399039f9fSLiu Zhe 		XTextTable xTable7 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
62499039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable7,false);
62599039f9fSLiu Zhe 		XPropertySet xTableProps7 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable7);
6266b55ece7SLiu Zhe 		xTableProps7.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
62799039f9fSLiu Zhe 		xTableProps7.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
62899039f9fSLiu Zhe 		xTableProps7.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.NONE);
62999039f9fSLiu Zhe 
63099039f9fSLiu Zhe 		XTextTable xTable8 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
63199039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable8,false);
63299039f9fSLiu Zhe 		XPropertySet xTableProps8 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable8);
6336b55ece7SLiu Zhe 		xTableProps8.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
63499039f9fSLiu Zhe 		xTableProps8.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
63599039f9fSLiu Zhe 		xTableProps8.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_BOTTOM);
63699039f9fSLiu Zhe 
63799039f9fSLiu Zhe 		XTextTable xTable9 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
63899039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable9,false);
63999039f9fSLiu Zhe 		XPropertySet xTableProps9 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable9);
6406b55ece7SLiu Zhe 		xTableProps9.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
64199039f9fSLiu Zhe 		xTableProps9.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
64299039f9fSLiu Zhe 		xTableProps9.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_MIDDLE);
64399039f9fSLiu Zhe 
64499039f9fSLiu Zhe 		XTextTable xTable10 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
64599039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable10,false);
64699039f9fSLiu Zhe 		XPropertySet xTableProps10 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable10);
6476b55ece7SLiu Zhe 		xTableProps10.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
64899039f9fSLiu Zhe 		xTableProps10.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
64999039f9fSLiu Zhe 		xTableProps10.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_TOP);
65099039f9fSLiu Zhe 
65199039f9fSLiu Zhe 		XTextTable xTable11 = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
65299039f9fSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable11,false);
65399039f9fSLiu Zhe 		XPropertySet xTableProps11 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTable11);
6546b55ece7SLiu Zhe 		xTableProps11.setPropertyValue("BackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")));
65599039f9fSLiu Zhe 		xTableProps11.setPropertyValue("BackGraphicFilter","draw_jpg_Export");
65699039f9fSLiu Zhe 		xTableProps11.setPropertyValue("BackGraphicLocation",com.sun.star.style.GraphicLocation.AREA);
65799039f9fSLiu Zhe 		//save and reload text document
65899039f9fSLiu Zhe 		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
65999039f9fSLiu Zhe 		PropertyValue[] aStoreProperties = new PropertyValue[2];
66099039f9fSLiu Zhe 		aStoreProperties[0] = new PropertyValue();
66199039f9fSLiu Zhe 		aStoreProperties[1] = new PropertyValue();
66299039f9fSLiu Zhe 		aStoreProperties[0].Name = "Override";
66399039f9fSLiu Zhe 		aStoreProperties[0].Value = true;
66499039f9fSLiu Zhe 		aStoreProperties[1].Name = "FilterName";
66599039f9fSLiu Zhe 		aStoreProperties[1].Value = "StarOffice XML (Writer)";
66699039f9fSLiu Zhe 		xStorable.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties);
66799039f9fSLiu Zhe 		app.closeDocument(xTextDocument);
66899039f9fSLiu Zhe 
66999039f9fSLiu Zhe 		//reopen the document and assert table margin to page setting
67099039f9fSLiu Zhe 		XTextDocument assertDocument=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
67199039f9fSLiu Zhe 		XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument );
67299039f9fSLiu Zhe 		XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier.getTextTables());
67399039f9fSLiu Zhe 		Object xTable_obj1=xIndexedTables.getByIndex(0);
67499039f9fSLiu Zhe 		XTextTable xTable_Assert1=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj1);
67599039f9fSLiu Zhe 		XPropertySet xTableProps1_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert1);
67699039f9fSLiu Zhe 		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.LEFT_BOTTOM,xTableProps1_assert.getPropertyValue("BackGraphicLocation"));
67799039f9fSLiu Zhe 		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps1_assert.getPropertyValue("BackGraphicFilter"));
6786b55ece7SLiu Zhe 		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xTableProps1_assert.getPropertyValue("BackGraphicURL"));
67999039f9fSLiu Zhe 
68099039f9fSLiu Zhe 		Object xTable_obj2=xIndexedTables.getByIndex(1);
68199039f9fSLiu Zhe 		XTextTable xTable_Assert2=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj2);
68299039f9fSLiu Zhe 		XPropertySet xTableProps2_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert2);
68399039f9fSLiu Zhe 		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.LEFT_MIDDLE,xTableProps2_assert.getPropertyValue("BackGraphicLocation"));
68499039f9fSLiu Zhe 		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps2_assert.getPropertyValue("BackGraphicFilter"));
6856b55ece7SLiu Zhe 		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xTableProps2_assert.getPropertyValue("BackGraphicURL"));
68699039f9fSLiu Zhe 
68799039f9fSLiu Zhe 		Object xTable_obj3=xIndexedTables.getByIndex(2);
68899039f9fSLiu Zhe 		XTextTable xTable_Assert3=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj3);
68999039f9fSLiu Zhe 		XPropertySet xTableProps3_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert3);
69099039f9fSLiu Zhe 		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.LEFT_TOP,xTableProps3_assert.getPropertyValue("BackGraphicLocation"));
69199039f9fSLiu Zhe 		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps3_assert.getPropertyValue("BackGraphicFilter"));
6926b55ece7SLiu Zhe 		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xTableProps3_assert.getPropertyValue("BackGraphicURL"));
69399039f9fSLiu Zhe 
69499039f9fSLiu Zhe 		Object xTable_obj4=xIndexedTables.getByIndex(3);
69599039f9fSLiu Zhe 		XTextTable xTable_Assert4=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj4);
69699039f9fSLiu Zhe 		XPropertySet xTableProps4_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert4);
69799039f9fSLiu Zhe 		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_BOTTOM,xTableProps4_assert.getPropertyValue("BackGraphicLocation"));
69899039f9fSLiu Zhe 		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps4_assert.getPropertyValue("BackGraphicFilter"));
6996b55ece7SLiu Zhe 		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xTableProps4_assert.getPropertyValue("BackGraphicURL"));
70099039f9fSLiu Zhe 
70199039f9fSLiu Zhe 		Object xTable_obj5=xIndexedTables.getByIndex(4);
70299039f9fSLiu Zhe 		XTextTable xTable_Assert5=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj5);
70399039f9fSLiu Zhe 		XPropertySet xTableProps5_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert5);
70499039f9fSLiu Zhe 		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_MIDDLE,xTableProps5_assert.getPropertyValue("BackGraphicLocation"));
70599039f9fSLiu Zhe 		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps5_assert.getPropertyValue("BackGraphicFilter"));
7066b55ece7SLiu Zhe 		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xTableProps5_assert.getPropertyValue("BackGraphicURL"));
70799039f9fSLiu Zhe 
70899039f9fSLiu Zhe 		Object xTable_obj6=xIndexedTables.getByIndex(5);
70999039f9fSLiu Zhe 		XTextTable xTable_Assert6=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj6);
71099039f9fSLiu Zhe 		XPropertySet xTableProps6_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert6);
71199039f9fSLiu Zhe 		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_TOP,xTableProps6_assert.getPropertyValue("BackGraphicLocation"));
71299039f9fSLiu Zhe 		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps6_assert.getPropertyValue("BackGraphicFilter"));
7136b55ece7SLiu Zhe 		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xTableProps6_assert.getPropertyValue("BackGraphicURL"));
71499039f9fSLiu Zhe 
71599039f9fSLiu Zhe 		Object xTable_obj7=xIndexedTables.getByIndex(6);
71699039f9fSLiu Zhe 		XTextTable xTable_Assert7=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj7);
71799039f9fSLiu Zhe 		XPropertySet xTableProps7_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert7);
71899039f9fSLiu Zhe 		assertEquals("verify table backgraphic location is title",com.sun.star.style.GraphicLocation.NONE,xTableProps7_assert.getPropertyValue("BackGraphicLocation"));
71999039f9fSLiu Zhe 
72099039f9fSLiu Zhe 		Object xTable_obj8=xIndexedTables.getByIndex(7);
72199039f9fSLiu Zhe 		XTextTable xTable_Assert8=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj8);
72299039f9fSLiu Zhe 		XPropertySet xTableProps8_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert8);
72399039f9fSLiu Zhe 		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_BOTTOM,xTableProps8_assert.getPropertyValue("BackGraphicLocation"));
72499039f9fSLiu Zhe 		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps8_assert.getPropertyValue("BackGraphicFilter"));
7256b55ece7SLiu Zhe 		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xTableProps8_assert.getPropertyValue("BackGraphicURL"));
72699039f9fSLiu Zhe 
72799039f9fSLiu Zhe 		Object xTable_obj9=xIndexedTables.getByIndex(8);
72899039f9fSLiu Zhe 		XTextTable xTable_Assert9=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj9);
72999039f9fSLiu Zhe 		XPropertySet xTableProps9_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert9);
73099039f9fSLiu Zhe 		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_MIDDLE,xTableProps9_assert.getPropertyValue("BackGraphicLocation"));
73199039f9fSLiu Zhe 		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps9_assert.getPropertyValue("BackGraphicFilter"));
7326b55ece7SLiu Zhe 		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xTableProps9_assert.getPropertyValue("BackGraphicURL"));
73399039f9fSLiu Zhe 
73499039f9fSLiu Zhe 		Object xTable_obj10=xIndexedTables.getByIndex(9);
73599039f9fSLiu Zhe 		XTextTable xTable_Assert10=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj10);
73699039f9fSLiu Zhe 		XPropertySet xTableProps10_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert10);
73799039f9fSLiu Zhe 		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_TOP,xTableProps10_assert.getPropertyValue("BackGraphicLocation"));
73899039f9fSLiu Zhe 		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps10_assert.getPropertyValue("BackGraphicFilter"));
7396b55ece7SLiu Zhe 		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xTableProps10_assert.getPropertyValue("BackGraphicURL"));
74099039f9fSLiu Zhe 
74199039f9fSLiu Zhe 		Object xTable_obj11=xIndexedTables.getByIndex(10);
74299039f9fSLiu Zhe 		XTextTable xTable_Assert11=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj11);
74399039f9fSLiu Zhe 		XPropertySet xTableProps11_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTable_Assert11);
74499039f9fSLiu Zhe 		assertEquals("verify table backgraphic location",com.sun.star.style.GraphicLocation.AREA,xTableProps11_assert.getPropertyValue("BackGraphicLocation"));
74599039f9fSLiu Zhe 		assertEquals("verify table backgraphic fileter","draw_jpg_Export",xTableProps11_assert.getPropertyValue("BackGraphicFilter"));
7466b55ece7SLiu Zhe 		assertEquals("verify table backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xTableProps11_assert.getPropertyValue("BackGraphicURL"));
74799039f9fSLiu Zhe 	}
74899039f9fSLiu Zhe }
74999039f9fSLiu Zhe 
750