1*eba4d44aSLiu Zhe package fvt.uno.sw.table;
2f4c702faSLiu Zhe 
3f4c702faSLiu Zhe import static org.junit.Assert.*;
4f4c702faSLiu Zhe 
5f4c702faSLiu Zhe import org.junit.After;
6f4c702faSLiu Zhe import org.junit.Before;
7f4c702faSLiu Zhe import org.junit.Ignore;
8f4c702faSLiu Zhe import org.junit.Test;
9f4c702faSLiu Zhe import org.openoffice.test.common.FileUtil;
10f4c702faSLiu Zhe import org.openoffice.test.common.Testspace;
11f4c702faSLiu Zhe import org.openoffice.test.uno.UnoApp;
12f4c702faSLiu Zhe import com.sun.star.text.*;
13f4c702faSLiu Zhe import com.sun.star.beans.*;
14f4c702faSLiu Zhe import com.sun.star.container.XIndexAccess;
15f4c702faSLiu Zhe import com.sun.star.frame.XStorable;
16f4c702faSLiu Zhe import com.sun.star.lang.XMultiServiceFactory;
17f4c702faSLiu Zhe import com.sun.star.uno.UnoRuntime;
18f4c702faSLiu Zhe 
19f4c702faSLiu Zhe public class TableInsertBreak {
20f4c702faSLiu Zhe 	private static final UnoApp app = new UnoApp();
21f4c702faSLiu Zhe 	private XTextDocument xTextDocument=null;
22f4c702faSLiu Zhe 	private XMultiServiceFactory xWriterFactory=null;
23f4c702faSLiu Zhe 	private XText xText=null;
24f4c702faSLiu Zhe 
25f4c702faSLiu Zhe 	@Before
26f4c702faSLiu Zhe 	public void setUp() throws Exception {
27f4c702faSLiu Zhe 		app.start();
28f4c702faSLiu Zhe 
29f4c702faSLiu Zhe 	}
30f4c702faSLiu Zhe 
31f4c702faSLiu Zhe 	@After
32f4c702faSLiu Zhe 	public void tearDown() throws Exception {
33f4c702faSLiu Zhe 		app.close();
34f4c702faSLiu Zhe 	}
35932de486SLiu Zhe 	@Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.")
36f4c702faSLiu Zhe 	public void InsertPage_BeforeBreak_Split_KeepTogether() throws Exception {
37f4c702faSLiu Zhe 
38f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
39f4c702faSLiu Zhe 		xText=xTextDocument.getText();
40f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
41f4c702faSLiu Zhe 		// get internal service factory of the document
42f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
43f4c702faSLiu Zhe 		// Create a new table from the document's factory
44f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
45f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
46f4c702faSLiu Zhe 		//insert page break for table
47f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable);
48f4c702faSLiu Zhe 		assertEquals("assert default split",true,xCursorProps.getPropertyValue("Split"));
49f4c702faSLiu Zhe 		assertEquals("assert default keep_together",false,xCursorProps.getPropertyValue("KeepTogether"));
50f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
51f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("Split",false);
52f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("KeepTogether",true);
53f4c702faSLiu Zhe 		//save to odt
54f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
55f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
56f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
57f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
58f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
59f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
60f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
61f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
62f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
63f4c702faSLiu Zhe 		//save to doc
64f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
65f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
66f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
67f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
68f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
69f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
70f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
71f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
72f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
73f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
74f4c702faSLiu Zhe 
75f4c702faSLiu Zhe 		//reopen the document
76f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
77f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
78f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
79f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
80f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
81f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
82f4c702faSLiu Zhe 		//verify paragraph break
83f4c702faSLiu Zhe 		assertEquals("assert table break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
84f4c702faSLiu Zhe 		assertEquals("assert table split",false,xCursorProps_Assert_odt.getPropertyValue("Split"));
85f4c702faSLiu Zhe 		assertEquals("assert table keep_tpgether",true,xCursorProps_Assert_odt.getPropertyValue("KeepTogether"));
86f4c702faSLiu Zhe 
87f4c702faSLiu Zhe 		//reopen the doc document and assert table break
88f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
89f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
90f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
91f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
92f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
93f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
94f4c702faSLiu Zhe 		//verify paragraph background color
95f4c702faSLiu Zhe 		assertEquals("assert table break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
96f4c702faSLiu Zhe 		assertEquals("assert table split",false,xCursorProps_Assert_doc.getPropertyValue("Split"));
97f4c702faSLiu Zhe 		assertEquals("assert table keep_together",true,xCursorProps_Assert_doc.getPropertyValue("KeepTogether"));
98f4c702faSLiu Zhe 	}
99932de486SLiu Zhe 	@Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.")
100f4c702faSLiu Zhe 	public void InsertPage_AfterBreak() throws Exception {
101f4c702faSLiu Zhe 
102f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
103f4c702faSLiu Zhe 		xText=xTextDocument.getText();
104f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
105f4c702faSLiu Zhe 		// get internal service factory of the document
106f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
107f4c702faSLiu Zhe 		// Create a new table from the document's factory
108f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
109f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
110f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
111f4c702faSLiu Zhe 		//set table break type
112f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_AFTER);
113f4c702faSLiu Zhe 		//save to odt
114f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
115f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
116f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
117f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
118f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
119f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
120f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
121f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
122f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
123f4c702faSLiu Zhe 		//save to doc
124f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
125f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
126f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
127f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
128f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
129f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
130f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
131f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
132f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
133f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
134f4c702faSLiu Zhe 
135f4c702faSLiu Zhe 		//reopen the document
136f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
137f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
138f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
139f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
140f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
141f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
142f4c702faSLiu Zhe 		//verify paragraph break
143f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_AFTER,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
144f4c702faSLiu Zhe 
145f4c702faSLiu Zhe 		//reopen the doc document and assert table break
146f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
147f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
148f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
149f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
150f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
151f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
152f4c702faSLiu Zhe 		//verify paragraph break
153f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_AFTER,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
154f4c702faSLiu Zhe 	}
155932de486SLiu Zhe 	@Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.")
156f4c702faSLiu Zhe 	public void InsertColumn_BeforeBreak() throws Exception {
157f4c702faSLiu Zhe 
158f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
159f4c702faSLiu Zhe 		xText=xTextDocument.getText();
160f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
161f4c702faSLiu Zhe 		// get internal service factory of the document
162f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
163f4c702faSLiu Zhe 		// Create a new table from the document's factory
164f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
165f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
166f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
167f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.COLUMN_BEFORE);
168f4c702faSLiu Zhe 		//save to odt
169f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
170f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
171f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
172f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
173f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
174f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
175f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
176f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
177f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
178f4c702faSLiu Zhe 		//save to doc
179f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
180f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
181f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
182f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
183f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
184f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
185f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
186f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
187f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
188f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
189f4c702faSLiu Zhe 
190f4c702faSLiu Zhe 		//reopen the document
191f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
192f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
193f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
194f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
195f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
196f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
197f4c702faSLiu Zhe 		//verify paragraph break
198f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
199f4c702faSLiu Zhe 
200f4c702faSLiu Zhe 		//reopen the doc document and assert table break
201f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
202f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
203f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
204f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
205f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
206f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
207f4c702faSLiu Zhe 		//verify paragraph break
208f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
209f4c702faSLiu Zhe 	}
210932de486SLiu Zhe 	@Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.")
211f4c702faSLiu Zhe 	public void InsertColumn_AfterBreak() throws Exception {
212f4c702faSLiu Zhe 
213f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
214f4c702faSLiu Zhe 		xText=xTextDocument.getText();
215f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
216f4c702faSLiu Zhe 		// get internal service factory of the document
217f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
218f4c702faSLiu Zhe 		// Create a new table from the document's factory
219f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
220f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
221f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
222f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.COLUMN_AFTER);
223f4c702faSLiu Zhe 		//save to odt
224f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
225f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
226f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
227f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
228f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
229f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
230f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
231f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
232f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
233f4c702faSLiu Zhe 		//save to doc
234f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
235f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
236f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
237f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
238f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
239f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
240f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
241f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
242f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
243f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
244f4c702faSLiu Zhe 
245f4c702faSLiu Zhe 		//reopen the document
246f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
247f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
248f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
249f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
250f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
251f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
252f4c702faSLiu Zhe 		//verify paragraph break
253f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_AFTER,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
254f4c702faSLiu Zhe 
255f4c702faSLiu Zhe 		//reopen the doc document and assert table break
256f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
257f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
258f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
259f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
260f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
261f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
262f4c702faSLiu Zhe 		//verify table break
263f4c702faSLiu Zhe 		assertEquals("assert table break",com.sun.star.style.BreakType.COLUMN_AFTER,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
264f4c702faSLiu Zhe 	}
265932de486SLiu Zhe 	@Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.")
266f4c702faSLiu Zhe 	public void InsertPage_Endnote_BeforeBreak() throws Exception {
267f4c702faSLiu Zhe 
268f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
269f4c702faSLiu Zhe 		xText=xTextDocument.getText();
270f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
271f4c702faSLiu Zhe 		// get internal service factory of the document
272f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
273f4c702faSLiu Zhe 		// Create a new table from the document's factory
274f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
275f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
276f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
277f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
278f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Endnote");
279f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
280f4c702faSLiu Zhe 		//save to odt
281f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
282f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
283f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
284f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
285f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
286f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
287f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
288f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
289f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
290f4c702faSLiu Zhe 		//save to doc
291f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
292f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
293f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
294f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
295f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
296f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
297f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
298f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
299f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
300f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
301f4c702faSLiu Zhe 
302f4c702faSLiu Zhe 		//reopen the document
303f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
304f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
305f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
306f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
307f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
308f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
309f4c702faSLiu Zhe 		//verify paragraph break
310f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
311f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Endnote",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
312f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
313f4c702faSLiu Zhe 		//reopen the doc document and assert table break
314f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
315f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
316f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
317f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
318f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
319f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
320f4c702faSLiu Zhe 		//verify paragraph background color
321f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
322f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Endnote",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
323f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
324f4c702faSLiu Zhe 	}
325f4c702faSLiu Zhe 
326932de486SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the page_endnote_break type change to page_default_break when save to doc.")
327f4c702faSLiu Zhe 	public void InsertPage_Envelop_BeforeBreak() throws Exception {
328f4c702faSLiu Zhe 
329f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
330f4c702faSLiu Zhe 		xText=xTextDocument.getText();
331f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
332f4c702faSLiu Zhe 		// get internal service factory of the document
333f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
334f4c702faSLiu Zhe 		// Create a new table from the document's factory
335f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
336f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
337f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
338f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
339f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Envelope");
340f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
341f4c702faSLiu Zhe 		//save to odt
342f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
343f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
344f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
345f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
346f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
347f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
348f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
349f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
350f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
351f4c702faSLiu Zhe 		//save to doc
352f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
353f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
354f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
355f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
356f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
357f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
358f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
359f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
360f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
361f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
362f4c702faSLiu Zhe 
363f4c702faSLiu Zhe 		//reopen the document
364f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
365f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
366f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
367f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
368f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
369f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
370f4c702faSLiu Zhe 		//verify paragraph break
371f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
372f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Envelope",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
373f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
374f4c702faSLiu Zhe 		//reopen the doc document and assert table break
375f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
376f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
377f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
378f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
379f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
380f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
381f4c702faSLiu Zhe 		//verify paragraph background color
382f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
383f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Envelope",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
384f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
385f4c702faSLiu Zhe 	}
386f4c702faSLiu Zhe 
387f4c702faSLiu Zhe 	@Test
388f4c702faSLiu Zhe 	public void InsertPage_Firstpage_BeforeBreak() throws Exception {
389f4c702faSLiu Zhe 
390f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
391f4c702faSLiu Zhe 		xText=xTextDocument.getText();
392f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
393f4c702faSLiu Zhe 		// get internal service factory of the document
394f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
395f4c702faSLiu Zhe 		// Create a new table from the document's factory
396f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
397f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
398f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
399f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
400f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","First Page");
401f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
402f4c702faSLiu Zhe 		//save to odt
403f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
404f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
405f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
406f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
407f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
408f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
409f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
410f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
411f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
412f4c702faSLiu Zhe 		//save to doc
413f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
414f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
415f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
416f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
417f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
418f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
419f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
420f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
421f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
422f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
423f4c702faSLiu Zhe 
424f4c702faSLiu Zhe 		//reopen the document
425f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
426f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
427f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
428f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
429f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
430f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
431f4c702faSLiu Zhe 		//verify paragraph break
432f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
433f4c702faSLiu Zhe 		assertEquals("assert paragraph break","First Page",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
434f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
435f4c702faSLiu Zhe 		//reopen the doc document and assert table break
436f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
437f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
438f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
439f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
440f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
441f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
442f4c702faSLiu Zhe 		//verify paragraph background color
443f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
444f4c702faSLiu Zhe 		assertEquals("assert paragraph break","First Page",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
445f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
446f4c702faSLiu Zhe 	}
447932de486SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the page_endnote_break type change to page_default_break when save to doc.")
448f4c702faSLiu Zhe 	public void InsertPage_Footnote_BeforeBreak() throws Exception {
449f4c702faSLiu Zhe 
450f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
451f4c702faSLiu Zhe 		xText=xTextDocument.getText();
452f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
453f4c702faSLiu Zhe 		// get internal service factory of the document
454f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
455f4c702faSLiu Zhe 		// Create a new table from the document's factory
456f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
457f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
458f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
459f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
460f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Footnote");
461f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
462f4c702faSLiu Zhe 		//save to odt
463f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
464f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
465f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
466f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
467f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
468f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
469f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
470f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
471f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
472f4c702faSLiu Zhe 		//save to doc
473f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
474f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
475f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
476f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
477f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
478f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
479f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
480f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
481f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
482f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
483f4c702faSLiu Zhe 
484f4c702faSLiu Zhe 		//reopen the document
485f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
486f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
487f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
488f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
489f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
490f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
491f4c702faSLiu Zhe 		//verify paragraph break
492f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
493f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Footnote",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
494f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
495f4c702faSLiu Zhe 		//reopen the doc document and assert table break
496f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
497f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
498f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
499f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
500f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
501f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
502f4c702faSLiu Zhe 		//verify paragraph background color
503f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
504f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Footnote",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
505f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
506f4c702faSLiu Zhe 	}
507932de486SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the page_endnote_break type change to page_default_break when save to doc.")
508f4c702faSLiu Zhe 	public void InsertPage_HTML_BeforeBreak() throws Exception {
509f4c702faSLiu Zhe 
510f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
511f4c702faSLiu Zhe 		xText=xTextDocument.getText();
512f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
513f4c702faSLiu Zhe 		// get internal service factory of the document
514f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
515f4c702faSLiu Zhe 		// Create a new table from the document's factory
516f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
517f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
518f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
519f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
520f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","HTML");
521f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
522f4c702faSLiu Zhe 		//save to odt
523f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
524f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
525f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
526f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
527f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
528f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
529f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
530f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
531f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
532f4c702faSLiu Zhe 		//save to doc
533f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
534f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
535f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
536f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
537f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
538f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
539f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
540f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
541f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
542f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
543f4c702faSLiu Zhe 
544f4c702faSLiu Zhe 		//reopen the document
545f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
546f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
547f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
548f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
549f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
550f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
551f4c702faSLiu Zhe 		//verify paragraph break
552f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
553f4c702faSLiu Zhe 		assertEquals("assert paragraph break","HTML",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
554f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
555f4c702faSLiu Zhe 		//reopen the doc document and assert table break
556f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
557f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
558f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
559f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
560f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
561f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
562f4c702faSLiu Zhe 		//verify paragraph background color
563f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
564f4c702faSLiu Zhe 		assertEquals("assert paragraph break","HTML",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
565f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
566f4c702faSLiu Zhe 	}
567932de486SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the page_endnote_break type change to page_default_break when save to doc.")
568f4c702faSLiu Zhe 	public void InsertPage_Index_BeforeBreak() throws Exception {
569f4c702faSLiu Zhe 
570f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
571f4c702faSLiu Zhe 		xText=xTextDocument.getText();
572f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
573f4c702faSLiu Zhe 		// get internal service factory of the document
574f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
575f4c702faSLiu Zhe 		// Create a new table from the document's factory
576f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
577f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
578f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
579f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
580f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Index");
581f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
582f4c702faSLiu Zhe 		//save to odt
583f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
584f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
585f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
586f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
587f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
588f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
589f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
590f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
591f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
592f4c702faSLiu Zhe 		//save to doc
593f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
594f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
595f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
596f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
597f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
598f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
599f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
600f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
601f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
602f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
603f4c702faSLiu Zhe 
604f4c702faSLiu Zhe 		//reopen the document
605f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
606f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
607f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
608f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
609f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
610f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
611f4c702faSLiu Zhe 		//verify paragraph break
612f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
613f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Index",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
614f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
615f4c702faSLiu Zhe 		//reopen the doc document and assert table break
616f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
617f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
618f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
619f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
620f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
621f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
622f4c702faSLiu Zhe 		//verify paragraph background color
623f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
624f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Index",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
625f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
626f4c702faSLiu Zhe 	}
627932de486SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the page_endnote_break type change to page_default_break when save to doc.")
628f4c702faSLiu Zhe 	public void InsertPage_Landscape_BeforeBreak() throws Exception {
629f4c702faSLiu Zhe 
630f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
631f4c702faSLiu Zhe 		xText=xTextDocument.getText();
632f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
633f4c702faSLiu Zhe 		// get internal service factory of the document
634f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
635f4c702faSLiu Zhe 		// Create a new table from the document's factory
636f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
637f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
638f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
639f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
640f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Landscape");
641f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
642f4c702faSLiu Zhe 		//save to odt
643f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
644f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
645f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
646f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
647f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
648f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
649f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
650f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
651f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
652f4c702faSLiu Zhe 		//save to doc
653f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
654f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
655f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
656f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
657f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
658f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
659f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
660f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
661f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
662f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
663f4c702faSLiu Zhe 
664f4c702faSLiu Zhe 		//reopen the document
665f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
666f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
667f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
668f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
669f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
670f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
671f4c702faSLiu Zhe 		//verify paragraph break
672f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
673f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Landscape",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
674f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
675f4c702faSLiu Zhe 		//reopen the doc document and assert table break
676f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
677f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
678f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
679f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
680f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
681f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
682f4c702faSLiu Zhe 		//verify paragraph background color
683f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
684f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Landscape",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
685f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
686f4c702faSLiu Zhe 	}
687932de486SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the page_endnote_break type change to page_default_break when save to doc.")
688f4c702faSLiu Zhe 	public void InsertPage_LeftPage_BeforeBreak() throws Exception {
689f4c702faSLiu Zhe 
690f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
691f4c702faSLiu Zhe 		xText=xTextDocument.getText();
692f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
693f4c702faSLiu Zhe 		// get internal service factory of the document
694f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
695f4c702faSLiu Zhe 		// Create a new table from the document's factory
696f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
697f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
698f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
699f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
700f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Left Page");
701f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
702f4c702faSLiu Zhe 		//save to odt
703f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
704f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
705f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
706f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
707f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
708f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
709f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
710f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
711f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
712f4c702faSLiu Zhe 		//save to doc
713f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
714f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
715f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
716f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
717f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
718f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
719f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
720f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
721f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
722f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
723f4c702faSLiu Zhe 
724f4c702faSLiu Zhe 		//reopen the document
725f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
726f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
727f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
728f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
729f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
730f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
731f4c702faSLiu Zhe 		//verify paragraph break
732f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
733f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Left Page",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
734f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
735f4c702faSLiu Zhe 		//reopen the doc document and assert table break
736f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
737f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
738f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
739f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
740f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
741f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
742f4c702faSLiu Zhe 		//verify paragraph background color
743f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
744f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Left Page",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
745f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
746f4c702faSLiu Zhe 	}
747932de486SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the page_endnote_break type change to page_default_break when save to doc.")
748f4c702faSLiu Zhe 	public void InsertPage_RightPage_BeforeBreak() throws Exception {
749f4c702faSLiu Zhe 
750f4c702faSLiu Zhe 		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
751f4c702faSLiu Zhe 		xText=xTextDocument.getText();
752f4c702faSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
753f4c702faSLiu Zhe 		// get internal service factory of the document
754f4c702faSLiu Zhe 		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
755f4c702faSLiu Zhe 		// Create a new table from the document's factory
756f4c702faSLiu Zhe 		XTextTable xTable = (XTextTable)UnoRuntime.queryInterface(XTextTable.class, xWriterFactory.createInstance("com.sun.star.text.TextTable"));
757f4c702faSLiu Zhe 		xText.insertTextContent(xTextCursor,xTable,false);
758f4c702faSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,xTable);
759f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
760f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Right Page");
761f4c702faSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
762f4c702faSLiu Zhe 		//save to odt
763f4c702faSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
764f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
765f4c702faSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
766f4c702faSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
767f4c702faSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
768f4c702faSLiu Zhe 		aStoreProperties_odt[0].Value = true;
769f4c702faSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
770f4c702faSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
771f4c702faSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
772f4c702faSLiu Zhe 		//save to doc
773f4c702faSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
774f4c702faSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
775f4c702faSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
776f4c702faSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
777f4c702faSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
778f4c702faSLiu Zhe 		aStoreProperties_doc[0].Value = true;
779f4c702faSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
780f4c702faSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
781f4c702faSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
782f4c702faSLiu Zhe 		app.closeDocument(xTextDocument);
783f4c702faSLiu Zhe 
784f4c702faSLiu Zhe 		//reopen the document
785f4c702faSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
786f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_odt = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_odt );
787f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_odt.getTextTables());
788f4c702faSLiu Zhe 		Object xTable_obj_odt=xIndexedTables_odt.getByIndex(0);
789f4c702faSLiu Zhe 		XTextTable xTable_Assert_odt=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_odt);
790f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_odt);
791f4c702faSLiu Zhe 		//verify paragraph break
792f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
793f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Right Page",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
794f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
795f4c702faSLiu Zhe 		//reopen the doc document and assert table break
796f4c702faSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
797f4c702faSLiu Zhe 		XTextTablesSupplier xTablesSupplier_doc = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, assertDocument_doc );
798f4c702faSLiu Zhe 		XIndexAccess xIndexedTables_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTablesSupplier_doc.getTextTables());
799f4c702faSLiu Zhe 		Object xTable_obj_doc=xIndexedTables_doc.getByIndex(0);
800f4c702faSLiu Zhe 		XTextTable xTable_Assert_doc=(XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTable_obj_doc);
801f4c702faSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTable_Assert_doc);
802f4c702faSLiu Zhe 		//verify paragraph background color
803f4c702faSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
804f4c702faSLiu Zhe 		assertEquals("assert paragraph break","Right Page",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
805f4c702faSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
806f4c702faSLiu Zhe 	}
807f4c702faSLiu Zhe }
808