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