1*eba4d44aSLiu Zhe package fvt.uno.sw.paragraph;
29f0ca99bSLiu Zhe 
39f0ca99bSLiu Zhe import static org.junit.Assert.*;
49f0ca99bSLiu Zhe 
59f0ca99bSLiu Zhe import org.junit.After;
69f0ca99bSLiu Zhe import org.junit.Before;
79f0ca99bSLiu Zhe import org.junit.Ignore;
89f0ca99bSLiu Zhe import org.junit.Test;
99f0ca99bSLiu Zhe import org.openoffice.test.common.FileUtil;
109f0ca99bSLiu Zhe import org.openoffice.test.common.Testspace;
119f0ca99bSLiu Zhe import org.openoffice.test.uno.UnoApp;
129f0ca99bSLiu Zhe import com.sun.star.text.*;
139f0ca99bSLiu Zhe import com.sun.star.beans.*;
149f0ca99bSLiu Zhe import com.sun.star.frame.XStorable;
159f0ca99bSLiu Zhe import com.sun.star.uno.UnoRuntime;
169f0ca99bSLiu Zhe 
179f0ca99bSLiu Zhe public class ParagraphInsertBreak {
189f0ca99bSLiu Zhe 	private static final UnoApp app = new UnoApp();
199f0ca99bSLiu Zhe 	XText xText = null;
209f0ca99bSLiu Zhe 
219f0ca99bSLiu Zhe 	@Before
229f0ca99bSLiu Zhe 	public void setUp() throws Exception {
239f0ca99bSLiu Zhe 		app.start();
249f0ca99bSLiu Zhe 
259f0ca99bSLiu Zhe 	}
269f0ca99bSLiu Zhe 
279f0ca99bSLiu Zhe 	@After
289f0ca99bSLiu Zhe 	public void tearDown() throws Exception {
299f0ca99bSLiu Zhe 		app.close();
309f0ca99bSLiu Zhe 	}
319f0ca99bSLiu Zhe 	@Test
329f0ca99bSLiu Zhe 	public void InsertPage_BeforeBreak_NoSplit_KeepTogether() throws Exception {
339f0ca99bSLiu Zhe 
349f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
359f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
369f0ca99bSLiu Zhe 		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!" +
379f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
389f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
399f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
409f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
419f0ca99bSLiu Zhe 		//set paragraph break type
429f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
439f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("ParaSplit",false);
449f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("ParaKeepTogether",true);
459f0ca99bSLiu Zhe 		//save to odt
469f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
479f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
489f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
499f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
509f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
519f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
529f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
539f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
549f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
559f0ca99bSLiu Zhe 		//save to doc
569f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
579f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
589f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
599f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
609f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
619f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
629f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
639f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
649f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
659f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
669f0ca99bSLiu Zhe 
679f0ca99bSLiu Zhe 		//reopen the document
689f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
699f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
709f0ca99bSLiu Zhe 		//verify paragraph break
719f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
729f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",false,xCursorProps_Assert_odt.getPropertyValue("ParaSplit"));
739f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",true,xCursorProps_Assert_odt.getPropertyValue("ParaKeepTogether"));
749f0ca99bSLiu Zhe 
759f0ca99bSLiu Zhe 		//reopen the document
769f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
779f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
789f0ca99bSLiu Zhe 		//verify paragraph background color
799f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
809f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",false,xCursorProps_Assert_doc.getPropertyValue("ParaSplit"));
819f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",true,xCursorProps_Assert_doc.getPropertyValue("ParaKeepTogether"));
829f0ca99bSLiu Zhe 	}
839f0ca99bSLiu Zhe 	@Test
849f0ca99bSLiu Zhe 	public void InsertPage_BeforeBreak_Orphan_WindowControl() throws Exception {
859f0ca99bSLiu Zhe 
869f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
879f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
889f0ca99bSLiu Zhe 		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!" +
899f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
909f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
919f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
929f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
939f0ca99bSLiu Zhe 		//set paragraph break type
949f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
959f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("ParaOrphans",(byte)2);
969f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("ParaWidows",(byte)2);
979f0ca99bSLiu Zhe 		//save to odt
989f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
999f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
1009f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
1019f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
1029f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
1039f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
1049f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
1059f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
1069f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
1079f0ca99bSLiu Zhe 		//save to doc
1089f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
1099f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
1109f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
1119f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
1129f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
1139f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
1149f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
1159f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
1169f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
1179f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
1189f0ca99bSLiu Zhe 
1199f0ca99bSLiu Zhe 		//reopen the document
1209f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
1219f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
1229f0ca99bSLiu Zhe 		//verify paragraph break
1239f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
1249f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(byte)2,xCursorProps_Assert_odt.getPropertyValue("ParaOrphans"));
1259f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(byte)2,xCursorProps_Assert_odt.getPropertyValue("ParaWidows"));
1269f0ca99bSLiu Zhe 
1279f0ca99bSLiu Zhe 		//reopen the document
1289f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
1299f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
1309f0ca99bSLiu Zhe 		//verify paragraph background color
1319f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
1329f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(byte)2,xCursorProps_Assert_odt.getPropertyValue("ParaOrphans"));
1339f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(byte)2,xCursorProps_Assert_odt.getPropertyValue("ParaWidows"));
1349f0ca99bSLiu Zhe 	}
135af986861SLiu Zhe 	@Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.")
1369f0ca99bSLiu Zhe 	public void InsertPage_AfterBreak() throws Exception {
1379f0ca99bSLiu Zhe 
1389f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
1399f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
1409f0ca99bSLiu Zhe 		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!" +
1419f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
1429f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
1439f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
1449f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
1459f0ca99bSLiu Zhe 		//set paragraph break type
1469f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_AFTER);
1479f0ca99bSLiu Zhe 		//save to odt
1489f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
1499f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
1509f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
1519f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
1529f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
1539f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
1549f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
1559f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
1569f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
1579f0ca99bSLiu Zhe 		//save to doc
1589f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
1599f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
1609f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
1619f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
1629f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
1639f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
1649f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
1659f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
1669f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
1679f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
1689f0ca99bSLiu Zhe 
1699f0ca99bSLiu Zhe 		//reopen the document
1709f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
1719f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
1729f0ca99bSLiu Zhe 		//verify paragraph break
1739f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_AFTER,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
1749f0ca99bSLiu Zhe 
1759f0ca99bSLiu Zhe 		//reopen the document
1769f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
1779f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
1789f0ca99bSLiu Zhe 		//verify paragraph break
1799f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_AFTER,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
1809f0ca99bSLiu Zhe 	}
181af986861SLiu Zhe 	@Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.")
1829f0ca99bSLiu Zhe 	public void InsertColumn_BeforeBreak() throws Exception {
1839f0ca99bSLiu Zhe 
1849f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
1859f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
1869f0ca99bSLiu Zhe 		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!" +
1879f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
1889f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
1899f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
1909f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
1919f0ca99bSLiu Zhe 		//set paragraph break type
1929f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.COLUMN_BEFORE);
1939f0ca99bSLiu Zhe 		//save to odt
1949f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
1959f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
1969f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
1979f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
1989f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
1999f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
2009f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
2019f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
2029f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
2039f0ca99bSLiu Zhe 		//save to doc
2049f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
2059f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
2069f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
2079f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
2089f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
2099f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
2109f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
2119f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
2129f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
2139f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
2149f0ca99bSLiu Zhe 
2159f0ca99bSLiu Zhe 		//reopen the document
2169f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
2179f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
2189f0ca99bSLiu Zhe 		//verify paragraph break
2199f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
2209f0ca99bSLiu Zhe 
2219f0ca99bSLiu Zhe 		//reopen the document
2229f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
2239f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
2249f0ca99bSLiu Zhe 		//verify paragraph break
2259f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
2269f0ca99bSLiu Zhe 	}
227af986861SLiu Zhe 	@Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.")
2289f0ca99bSLiu Zhe 	public void InsertColumn_AfterBreak() throws Exception {
2299f0ca99bSLiu Zhe 
2309f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
2319f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
2329f0ca99bSLiu Zhe 		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!" +
2339f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
2349f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
2359f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
2369f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
2379f0ca99bSLiu Zhe 		//set paragraph break type
2389f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.COLUMN_AFTER);
2399f0ca99bSLiu Zhe 		//save to odt
2409f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
2419f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
2429f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
2439f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
2449f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
2459f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
2469f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
2479f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
2489f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
2499f0ca99bSLiu Zhe 		//save to doc
2509f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
2519f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
2529f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
2539f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
2549f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
2559f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
2569f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
2579f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
2589f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
2599f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
2609f0ca99bSLiu Zhe 
2619f0ca99bSLiu Zhe 		//reopen the document
2629f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
2639f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
2649f0ca99bSLiu Zhe 		//verify paragraph break
2659f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_AFTER,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
2669f0ca99bSLiu Zhe 
2679f0ca99bSLiu Zhe 		//reopen the document
2689f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
2699f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
2709f0ca99bSLiu Zhe 		//verify paragraph break
2719f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_AFTER,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
2729f0ca99bSLiu Zhe 	}
273af986861SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.")
2749f0ca99bSLiu Zhe 	public void InsertPage_Endnote_BeforeBreak() throws Exception {
2759f0ca99bSLiu Zhe 
2769f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
2779f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
2789f0ca99bSLiu Zhe 		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!" +
2799f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
2809f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
2819f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
2829f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
2839f0ca99bSLiu Zhe 		//set paragraph break type
2849f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
2859f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Endnote");
2869f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
2879f0ca99bSLiu Zhe 		//save to odt
2889f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
2899f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
2909f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
2919f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
2929f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
2939f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
2949f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
2959f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
2969f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
2979f0ca99bSLiu Zhe 		//save to doc
2989f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
2999f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
3009f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
3019f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
3029f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
3039f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
3049f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
3059f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
3069f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
3079f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
3089f0ca99bSLiu Zhe 
3099f0ca99bSLiu Zhe 		//reopen the document
3109f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
3119f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
3129f0ca99bSLiu Zhe 		//verify paragraph break
3139f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
3149f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Endnote",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
3159f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
3169f0ca99bSLiu Zhe 		//reopen the document
3179f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
3189f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
3199f0ca99bSLiu Zhe 		//verify paragraph background color
3209f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
3219f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Endnote",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
3229f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
3239f0ca99bSLiu Zhe 	}
3249f0ca99bSLiu Zhe 
325af986861SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.")
3269f0ca99bSLiu Zhe 	public void InsertPage_Envelop_BeforeBreak() throws Exception {
3279f0ca99bSLiu Zhe 
3289f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
3299f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
3309f0ca99bSLiu Zhe 		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!" +
3319f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
3329f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
3339f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
3349f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
3359f0ca99bSLiu Zhe 		//set paragraph break type
3369f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
3379f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Envelope");
3389f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
3399f0ca99bSLiu Zhe 		//save to odt
3409f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
3419f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
3429f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
3439f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
3449f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
3459f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
3469f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
3479f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
3489f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
3499f0ca99bSLiu Zhe 		//save to doc
3509f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
3519f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
3529f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
3539f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
3549f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
3559f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
3569f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
3579f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
3589f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
3599f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
3609f0ca99bSLiu Zhe 
3619f0ca99bSLiu Zhe 		//reopen the document
3629f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
3639f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
3649f0ca99bSLiu Zhe 		//verify paragraph break
3659f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
3669f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Envelope",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
3679f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
3689f0ca99bSLiu Zhe 		//reopen the document
3699f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
3709f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
3719f0ca99bSLiu Zhe 		//verify paragraph background color
3729f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
3739f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Envelope",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
3749f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
3759f0ca99bSLiu Zhe 	}
3769f0ca99bSLiu Zhe 
3779f0ca99bSLiu Zhe 	@Test
3789f0ca99bSLiu Zhe 	public void InsertPage_Firstpage_BeforeBreak() throws Exception {
3799f0ca99bSLiu Zhe 
3809f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
3819f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
3829f0ca99bSLiu Zhe 		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!" +
3839f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
3849f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
3859f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
3869f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
3879f0ca99bSLiu Zhe 		//set paragraph break type
3889f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
3899f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","First Page");
3909f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
3919f0ca99bSLiu Zhe 		//save to odt
3929f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
3939f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
3949f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
3959f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
3969f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
3979f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
3989f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
3999f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
4009f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
4019f0ca99bSLiu Zhe 		//save to doc
4029f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
4039f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
4049f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
4059f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
4069f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
4079f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
4089f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
4099f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
4109f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
4119f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
4129f0ca99bSLiu Zhe 
4139f0ca99bSLiu Zhe 		//reopen the document
4149f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
4159f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
4169f0ca99bSLiu Zhe 		//verify paragraph break
4179f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
4189f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","First Page",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
4199f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
4209f0ca99bSLiu Zhe 		//reopen the document
4219f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
4229f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
4239f0ca99bSLiu Zhe 		//verify paragraph background color
4249f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
4259f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","First Page",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
4269f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
4279f0ca99bSLiu Zhe 	}
428af986861SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.")
4299f0ca99bSLiu Zhe 	public void InsertPage_Footnote_BeforeBreak() throws Exception {
4309f0ca99bSLiu Zhe 
4319f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
4329f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
4339f0ca99bSLiu Zhe 		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!" +
4349f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
4359f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
4369f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
4379f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
4389f0ca99bSLiu Zhe 		//set paragraph break type
4399f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
4409f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Footnote");
4419f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
4429f0ca99bSLiu Zhe 		//save to odt
4439f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
4449f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
4459f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
4469f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
4479f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
4489f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
4499f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
4509f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
4519f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
4529f0ca99bSLiu Zhe 		//save to doc
4539f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
4549f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
4559f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
4569f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
4579f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
4589f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
4599f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
4609f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
4619f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
4629f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
4639f0ca99bSLiu Zhe 
4649f0ca99bSLiu Zhe 		//reopen the document
4659f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
4669f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
4679f0ca99bSLiu Zhe 		//verify paragraph break
4689f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
4699f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Footnote",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
4709f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
4719f0ca99bSLiu Zhe 		//reopen the document
4729f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
4739f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
4749f0ca99bSLiu Zhe 		//verify paragraph background color
4759f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
4769f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Footnote",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
4779f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
4789f0ca99bSLiu Zhe 	}
479af986861SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.")
4809f0ca99bSLiu Zhe 	public void InsertPage_HTML_BeforeBreak() throws Exception {
4819f0ca99bSLiu Zhe 
4829f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
4839f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
4849f0ca99bSLiu Zhe 		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!" +
4859f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
4869f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
4879f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
4889f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
4899f0ca99bSLiu Zhe 		//set paragraph break type
4909f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
4919f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","HTML");
4929f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
4939f0ca99bSLiu Zhe 		//save to odt
4949f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
4959f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
4969f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
4979f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
4989f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
4999f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
5009f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
5019f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
5029f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
5039f0ca99bSLiu Zhe 		//save to doc
5049f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
5059f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
5069f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
5079f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
5089f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
5099f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
5109f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
5119f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
5129f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
5139f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
5149f0ca99bSLiu Zhe 
5159f0ca99bSLiu Zhe 		//reopen the document
5169f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
5179f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
5189f0ca99bSLiu Zhe 		//verify paragraph break
5199f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
5209f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","HTML",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
5219f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
5229f0ca99bSLiu Zhe 		//reopen the document
5239f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
5249f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
5259f0ca99bSLiu Zhe 		//verify paragraph background color
5269f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
5279f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","HTML",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
5289f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
5299f0ca99bSLiu Zhe 	}
530af986861SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.")
5319f0ca99bSLiu Zhe 	public void InsertPage_Index_BeforeBreak() throws Exception {
5329f0ca99bSLiu Zhe 
5339f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
5349f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
5359f0ca99bSLiu Zhe 		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!" +
5369f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
5379f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
5389f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
5399f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
5409f0ca99bSLiu Zhe 		//set paragraph break type
5419f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
5429f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Index");
5439f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
5449f0ca99bSLiu Zhe 		//save to odt
5459f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
5469f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
5479f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
5489f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
5499f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
5509f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
5519f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
5529f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
5539f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
5549f0ca99bSLiu Zhe 		//save to doc
5559f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
5569f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
5579f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
5589f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
5599f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
5609f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
5619f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
5629f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
5639f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
5649f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
5659f0ca99bSLiu Zhe 
5669f0ca99bSLiu Zhe 		//reopen the document
5679f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
5689f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
5699f0ca99bSLiu Zhe 		//verify paragraph break
5709f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
5719f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Index",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
5729f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
5739f0ca99bSLiu Zhe 		//reopen the document
5749f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
5759f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
5769f0ca99bSLiu Zhe 		//verify paragraph background color
5779f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
5789f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Index",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
5799f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
5809f0ca99bSLiu Zhe 	}
581af986861SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.")
5829f0ca99bSLiu Zhe 	public void InsertPage_Landscape_BeforeBreak() throws Exception {
5839f0ca99bSLiu Zhe 
5849f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
5859f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
5869f0ca99bSLiu Zhe 		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!" +
5879f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
5889f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
5899f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
5909f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
5919f0ca99bSLiu Zhe 		//set paragraph break type
5929f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
5939f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Landscape");
5949f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
5959f0ca99bSLiu Zhe 		//save to odt
5969f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
5979f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
5989f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
5999f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
6009f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
6019f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
6029f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
6039f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
6049f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
6059f0ca99bSLiu Zhe 		//save to doc
6069f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
6079f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
6089f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
6099f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
6109f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
6119f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
6129f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
6139f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
6149f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
6159f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
6169f0ca99bSLiu Zhe 
6179f0ca99bSLiu Zhe 		//reopen the document
6189f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
6199f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
6209f0ca99bSLiu Zhe 		//verify paragraph break
6219f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
6229f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Landscape",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
6239f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
6249f0ca99bSLiu Zhe 		//reopen the document
6259f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
6269f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
6279f0ca99bSLiu Zhe 		//verify paragraph background color
6289f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
6299f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Landscape",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
6309f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
6319f0ca99bSLiu Zhe 	}
632af986861SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.")
6339f0ca99bSLiu Zhe 	public void InsertPage_LeftPage_BeforeBreak() throws Exception {
6349f0ca99bSLiu Zhe 
6359f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
6369f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
6379f0ca99bSLiu Zhe 		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!" +
6389f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
6399f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
6409f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
6419f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
6429f0ca99bSLiu Zhe 		//set paragraph break type
6439f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
6449f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Left Page");
6459f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
6469f0ca99bSLiu Zhe 		//save to odt
6479f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
6489f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
6499f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
6509f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
6519f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
6529f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
6539f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
6549f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
6559f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
6569f0ca99bSLiu Zhe 		//save to doc
6579f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
6589f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
6599f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
6609f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
6619f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
6629f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
6639f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
6649f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
6659f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
6669f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
6679f0ca99bSLiu Zhe 
6689f0ca99bSLiu Zhe 		//reopen the document
6699f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
6709f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
6719f0ca99bSLiu Zhe 		//verify paragraph break
6729f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
6739f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Left Page",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
6749f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
6759f0ca99bSLiu Zhe 		//reopen the document
6769f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
6779f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
6789f0ca99bSLiu Zhe 		//verify paragraph background color
6799f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
6809f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Left Page",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
6819f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
6829f0ca99bSLiu Zhe 	}
683af986861SLiu Zhe 	@Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.")
6849f0ca99bSLiu Zhe 	public void InsertPage_RightPage_BeforeBreak() throws Exception {
6859f0ca99bSLiu Zhe 
6869f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
6879f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
6889f0ca99bSLiu Zhe 		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!" +
6899f0ca99bSLiu Zhe 				"Hello,world!Hello,world!");
6909f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
6919f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
6929f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
6939f0ca99bSLiu Zhe 		//set paragraph break type
6949f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE);
6959f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageDescName","Right Page");
6969f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("PageNumberOffset",(short)3);
6979f0ca99bSLiu Zhe 		//save to odt
6989f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
6999f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
7009f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
7019f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
7029f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
7039f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
7049f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
7059f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
7069f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
7079f0ca99bSLiu Zhe 		//save to doc
7089f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
7099f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
7109f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
7119f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
7129f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
7139f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
7149f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
7159f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
7169f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
7179f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
7189f0ca99bSLiu Zhe 
7199f0ca99bSLiu Zhe 		//reopen the document
7209f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
7219f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
7229f0ca99bSLiu Zhe 		//verify paragraph break
7239f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType"));
7249f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Right Page",xCursorProps_Assert_odt.getPropertyValue("PageDescName"));
7259f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset"));
7269f0ca99bSLiu Zhe 		//reopen the document
7279f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
7289f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
7299f0ca99bSLiu Zhe 		//verify paragraph background color
7309f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType"));
7319f0ca99bSLiu Zhe 		assertEquals("assert paragraph break","Right Page",xCursorProps_Assert_doc.getPropertyValue("PageDescName"));
7329f0ca99bSLiu Zhe 		assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset"));
7339f0ca99bSLiu Zhe 	}
7349f0ca99bSLiu Zhe }
735