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 ParagraphOutlineAndNumbering { 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 /* 32*eba4d44aSLiu Zhe * test paragraph background color 33*eba4d44aSLiu Zhe * 1.new a text document 34*eba4d44aSLiu Zhe * 2.insert some text 35*eba4d44aSLiu Zhe * 3.set paragraph outline and numbering 36*eba4d44aSLiu Zhe * 4.save and close the document 37*eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph outline and numbering 38*eba4d44aSLiu Zhe */ 39*eba4d44aSLiu Zhe @Test@Ignore("Bug #120753 - [testUNO patch]paragraph outline level and numbering style change when save to doc") 40*eba4d44aSLiu Zhe public void testOutlineAndNumbering_NumberStyle() throws Exception { 41*eba4d44aSLiu Zhe 42*eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 43*eba4d44aSLiu Zhe xText = xTextDocument.getText(); 44*eba4d44aSLiu Zhe xText.setString("we are Chinese,they are American.\nwe are all living in one earth!Hello,world!Hello,world!\nHello,world!Hello,world!Hello,world!Hello,world!" + 45*eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 46*eba4d44aSLiu Zhe XTextCursor xTextCursor=xText.createTextCursor(); 47*eba4d44aSLiu Zhe XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 48*eba4d44aSLiu Zhe xTextProps.setPropertyValue("OutlineLevel", (short)6); 49*eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingStyleName", "Numbering 2"); 50*eba4d44aSLiu Zhe xTextProps.setPropertyValue("ParaIsNumberingRestart", true); 51*eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingStartValue", (short)7); 52*eba4d44aSLiu Zhe xTextProps.setPropertyValue("ParaLineNumberCount",true); 53*eba4d44aSLiu Zhe xTextProps.setPropertyValue("ParaLineNumberStartValue",(long)4); 54*eba4d44aSLiu Zhe //save to odt 55*eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 56*eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 57*eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 58*eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 59*eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 60*eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 61*eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 62*eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 63*eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 64*eba4d44aSLiu Zhe //save to doc 65*eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 66*eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 67*eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 68*eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 69*eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 70*eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 71*eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 72*eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 73*eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 74*eba4d44aSLiu Zhe //app.closeDocument(xTextDocument); 75*eba4d44aSLiu Zhe 76*eba4d44aSLiu Zhe //reopen the document 77*eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 78*eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 79*eba4d44aSLiu Zhe //verify paragraph outline and numbering 80*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(short)6,xCursorProps_Assert_odt.getPropertyValue("OutlineLevel")); 81*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering","Numbering 2",xCursorProps_Assert_odt.getPropertyValue("NumberingStyleName")); 82*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",true,xCursorProps_Assert_odt.getPropertyValue("ParaIsNumberingRestart")); 83*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(short)7,xCursorProps_Assert_odt.getPropertyValue("NumberingStartValue")); 84*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",true,xCursorProps_Assert_odt.getPropertyValue("ParaLineNumberCount")); 85*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(long)4,xCursorProps_Assert_odt.getPropertyValue("ParaLineNumberStartValue")); 86*eba4d44aSLiu Zhe 87*eba4d44aSLiu Zhe //reopen the document 88*eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 89*eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 90*eba4d44aSLiu Zhe //verify paragraph outline and numbering 91*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(short)6,xCursorProps_Assert_doc.getPropertyValue("OutlineLevel")); 92*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering","Numbering 2",xCursorProps_Assert_doc.getPropertyValue("NumberingStyleName")); 93*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",true,xCursorProps_Assert_doc.getPropertyValue("ParaIsNumberingRestart")); 94*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(short)7,xCursorProps_Assert_doc.getPropertyValue("NumberingStartValue")); 95*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",true,xCursorProps_Assert_doc.getPropertyValue("ParaLineNumberCount")); 96*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(long)4,xCursorProps_Assert_doc.getPropertyValue("ParaLineNumberStartValue")); 97*eba4d44aSLiu Zhe 98*eba4d44aSLiu Zhe } 99*eba4d44aSLiu Zhe @Test@Ignore("Bug #120753 - [testUNO patch]paragraph outline level and numbering style change when save to doc") 100*eba4d44aSLiu Zhe public void testOutlineAndNumbering_ListStyle() throws Exception { 101*eba4d44aSLiu Zhe 102*eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 103*eba4d44aSLiu Zhe xText = xTextDocument.getText(); 104*eba4d44aSLiu Zhe xText.setString("we are Chinese,they are American.\nwe are all living in one earth!Hello,world!Hello,world!\nHello,world!Hello,world!Hello,world!Hello,world!" + 105*eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 106*eba4d44aSLiu Zhe XTextCursor xTextCursor=xText.createTextCursor(); 107*eba4d44aSLiu Zhe XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 108*eba4d44aSLiu Zhe xTextProps.setPropertyValue("OutlineLevel", (short)3); 109*eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingStyleName", "List 3"); 110*eba4d44aSLiu Zhe xTextProps.setPropertyValue("ParaIsNumberingRestart", true); 111*eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingStartValue", (short)6); 112*eba4d44aSLiu Zhe xTextProps.setPropertyValue("ParaLineNumberCount",true); 113*eba4d44aSLiu Zhe xTextProps.setPropertyValue("ParaLineNumberStartValue",(long)4); 114*eba4d44aSLiu Zhe //save to odt 115*eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 116*eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 117*eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 118*eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 119*eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 120*eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 121*eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 122*eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 123*eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 124*eba4d44aSLiu Zhe //save to doc 125*eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 126*eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 127*eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 128*eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 129*eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 130*eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 131*eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 132*eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 133*eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 134*eba4d44aSLiu Zhe //app.closeDocument(xTextDocument); 135*eba4d44aSLiu Zhe 136*eba4d44aSLiu Zhe //reopen the document 137*eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 138*eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 139*eba4d44aSLiu Zhe //verify paragraph outline and numbering 140*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(short)3,xCursorProps_Assert_odt.getPropertyValue("OutlineLevel")); 141*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering","List 3",xCursorProps_Assert_odt.getPropertyValue("NumberingStyleName")); 142*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",true,xCursorProps_Assert_odt.getPropertyValue("ParaIsNumberingRestart")); 143*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(short)6,xCursorProps_Assert_odt.getPropertyValue("NumberingStartValue")); 144*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",true,xCursorProps_Assert_odt.getPropertyValue("ParaLineNumberCount")); 145*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(long)4,xCursorProps_Assert_odt.getPropertyValue("ParaLineNumberStartValue")); 146*eba4d44aSLiu Zhe 147*eba4d44aSLiu Zhe 148*eba4d44aSLiu Zhe //reopen the document 149*eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 150*eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 151*eba4d44aSLiu Zhe //verify paragraph outline and numbering 152*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(short)3,xCursorProps_Assert_doc.getPropertyValue("OutlineLevel")); 153*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering","List 3",xCursorProps_Assert_doc.getPropertyValue("NumberingStyleName")); 154*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",true,xCursorProps_Assert_doc.getPropertyValue("ParaIsNumberingRestart")); 155*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(short)6,xCursorProps_Assert_doc.getPropertyValue("NumberingStartValue")); 156*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",true,xCursorProps_Assert_doc.getPropertyValue("ParaLineNumberCount")); 157*eba4d44aSLiu Zhe assertEquals("assert paragraph outline and numbering",(long)4,xCursorProps_Assert_doc.getPropertyValue("ParaLineNumberStartValue")); 158*eba4d44aSLiu Zhe 159*eba4d44aSLiu Zhe } 160*eba4d44aSLiu Zhe } 161