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