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