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