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