1*eba4d44aSLiu Zhe package fvt.uno.sw.paragraph; 287127aedSLiu Zhe 387127aedSLiu Zhe import static org.junit.Assert.*; 487127aedSLiu Zhe 587127aedSLiu Zhe import org.junit.After; 687127aedSLiu Zhe import org.junit.Before; 787127aedSLiu Zhe import org.junit.Ignore; 887127aedSLiu Zhe import org.junit.Test; 987127aedSLiu Zhe import org.openoffice.test.common.FileUtil; 1087127aedSLiu Zhe import org.openoffice.test.common.Testspace; 1187127aedSLiu Zhe import org.openoffice.test.uno.UnoApp; 1287127aedSLiu Zhe //import org.openoffice.test.vcl.Tester.*; 1387127aedSLiu Zhe import com.sun.star.text.*; 1487127aedSLiu Zhe import com.sun.star.beans.*; 1587127aedSLiu Zhe import com.sun.star.frame.XStorable; 1687127aedSLiu Zhe import com.sun.star.uno.UnoRuntime; 1787127aedSLiu Zhe import com.sun.star.style.*; 1887127aedSLiu Zhe 1987127aedSLiu Zhe public class ParagraphLineSpacing { 2087127aedSLiu Zhe private static final UnoApp app = new UnoApp(); 2187127aedSLiu Zhe XText xText = null; 2287127aedSLiu Zhe 2387127aedSLiu Zhe @Before 2487127aedSLiu Zhe public void setUp() throws Exception { 2587127aedSLiu Zhe app.start(); 2687127aedSLiu Zhe 2787127aedSLiu Zhe } 2887127aedSLiu Zhe 2987127aedSLiu Zhe @After 3087127aedSLiu Zhe public void tearDown() throws Exception { 3187127aedSLiu Zhe app.close(); 3287127aedSLiu Zhe } 3387127aedSLiu Zhe /* 3487127aedSLiu Zhe * test paragraph line spacing is fix 3587127aedSLiu Zhe * 1.new a text document 3687127aedSLiu Zhe * 2.insert some text 3787127aedSLiu Zhe * 3.set paragraph line spacing is fix 3887127aedSLiu Zhe * 4.save and close the document 3987127aedSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 4087127aedSLiu Zhe */ 4187127aedSLiu Zhe @Test 4287127aedSLiu Zhe public void testParagraphLineSpacingFix() throws Exception { 4387127aedSLiu Zhe 4487127aedSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 4587127aedSLiu Zhe xText = xTextDocument.getText(); 4687127aedSLiu 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!" + 4787127aedSLiu Zhe "Hello,world!Hello,world!"); 4887127aedSLiu Zhe // create text cursor for selecting and formatting text 4987127aedSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 5087127aedSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 5187127aedSLiu Zhe //set paragraph line spacing 5287127aedSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 5387127aedSLiu Zhe lineSpacing.Mode = LineSpacingMode.FIX; 5487127aedSLiu Zhe lineSpacing.Height = 5000; 5587127aedSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 5687127aedSLiu Zhe //save to odt 5787127aedSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 5887127aedSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 5987127aedSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 6087127aedSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 6187127aedSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 6287127aedSLiu Zhe aStoreProperties_odt[0].Value = true; 6387127aedSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 6487127aedSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 6587127aedSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 6687127aedSLiu Zhe //save to doc 6787127aedSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 6887127aedSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 6987127aedSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 7087127aedSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 7187127aedSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 7287127aedSLiu Zhe aStoreProperties_doc[0].Value = true; 7387127aedSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 7487127aedSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 7587127aedSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 7687127aedSLiu Zhe app.closeDocument(xTextDocument); 7787127aedSLiu Zhe 7887127aedSLiu Zhe //reopen the document and assert paragraph line spacing 7987127aedSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 8087127aedSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 8187127aedSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 8287127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.FIX,paraLineSpacing_assert_odt.Mode); 8387127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_odt.Height); 8487127aedSLiu Zhe 8587127aedSLiu Zhe //reopen the document and assert paragraph line spacing 8687127aedSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 8787127aedSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 8887127aedSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 8987127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.FIX,paraLineSpacing_assert_doc.Mode); 9087127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_doc.Height); 9187127aedSLiu Zhe } 9287127aedSLiu Zhe /* 9387127aedSLiu Zhe * test paragraph line spacing is leading 9487127aedSLiu Zhe * 1.new a text document 9587127aedSLiu Zhe * 2.insert some text 9687127aedSLiu Zhe * 3.set paragraph line spacing is leading 9787127aedSLiu Zhe * 4.save and close the document 9887127aedSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 9987127aedSLiu Zhe */ 100af986861SLiu Zhe @Test@Ignore("Bug #120647 - [testUNO patch]line spacing leading setting change to at least when save to doc") 10187127aedSLiu Zhe public void testParagraphLineSpacingLeading() throws Exception { 10287127aedSLiu Zhe 10387127aedSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 10487127aedSLiu Zhe xText = xTextDocument.getText(); 10587127aedSLiu 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!" + 10687127aedSLiu Zhe "Hello,world!Hello,world!"); 10787127aedSLiu Zhe // create text cursor for selecting and formatting text 10887127aedSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 10987127aedSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 11087127aedSLiu Zhe //set paragraph line spacing 11187127aedSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 11287127aedSLiu Zhe lineSpacing.Mode = LineSpacingMode.LEADING; 11387127aedSLiu Zhe lineSpacing.Height = 5000; 11487127aedSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 11587127aedSLiu Zhe //save to odt 11687127aedSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 11787127aedSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 11887127aedSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 11987127aedSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 12087127aedSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 12187127aedSLiu Zhe aStoreProperties_odt[0].Value = true; 12287127aedSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 12387127aedSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 12487127aedSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 12587127aedSLiu Zhe //save to doc 12687127aedSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 12787127aedSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 12887127aedSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 12987127aedSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 13087127aedSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 13187127aedSLiu Zhe aStoreProperties_doc[0].Value = true; 13287127aedSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 13387127aedSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 13487127aedSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 13587127aedSLiu Zhe app.closeDocument(xTextDocument); 13687127aedSLiu Zhe 13787127aedSLiu Zhe //reopen the document 13887127aedSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 13987127aedSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 14087127aedSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 14187127aedSLiu Zhe //verify paragraph line spacing property 14287127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.LEADING,paraLineSpacing_assert_odt.Mode); 14387127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_odt.Height); 14487127aedSLiu Zhe 14587127aedSLiu Zhe //reopen the document 14687127aedSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 14787127aedSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 14887127aedSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 14987127aedSLiu Zhe //verify paragraph line spacing property 15087127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.LEADING,paraLineSpacing_assert_doc.Mode); 15187127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_doc.Height); 15287127aedSLiu Zhe } 15387127aedSLiu Zhe /* 15487127aedSLiu Zhe * test paragraph line spacing is minimum 15587127aedSLiu Zhe * 1.new a text document 15687127aedSLiu Zhe * 2.insert some text 15787127aedSLiu Zhe * 3.set paragraph line spacing is minimum 15887127aedSLiu Zhe * 4.save and close the document 15987127aedSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 16087127aedSLiu Zhe */ 16187127aedSLiu Zhe @Test 16287127aedSLiu Zhe public void testParagraphLineSpacingMinimum() throws Exception { 16387127aedSLiu Zhe 16487127aedSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 16587127aedSLiu Zhe xText = xTextDocument.getText(); 16687127aedSLiu 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!" + 16787127aedSLiu Zhe "Hello,world!Hello,world!"); 16887127aedSLiu Zhe // create text cursor for selecting and formatting text 16987127aedSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 17087127aedSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 17187127aedSLiu Zhe //set paragraph line spacing 17287127aedSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 17387127aedSLiu Zhe lineSpacing.Mode = LineSpacingMode.MINIMUM; 17487127aedSLiu Zhe lineSpacing.Height = 5000; 17587127aedSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 17687127aedSLiu Zhe //save to odt 17787127aedSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 17887127aedSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 17987127aedSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 18087127aedSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 18187127aedSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 18287127aedSLiu Zhe aStoreProperties_odt[0].Value = true; 18387127aedSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 18487127aedSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 18587127aedSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 18687127aedSLiu Zhe //save to doc 18787127aedSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 18887127aedSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 18987127aedSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 19087127aedSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 19187127aedSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 19287127aedSLiu Zhe aStoreProperties_doc[0].Value = true; 19387127aedSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 19487127aedSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 19587127aedSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 19687127aedSLiu Zhe app.closeDocument(xTextDocument); 19787127aedSLiu Zhe 19887127aedSLiu Zhe //reopen the document 19987127aedSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 20087127aedSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 20187127aedSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 20287127aedSLiu Zhe //verify paragraph line spacing property 20387127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.MINIMUM,paraLineSpacing_assert_odt.Mode); 20487127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_odt.Height); 20587127aedSLiu Zhe 20687127aedSLiu Zhe //reopen the document 20787127aedSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 20887127aedSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 20987127aedSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 21087127aedSLiu Zhe //verify paragraph line spacing property 21187127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.MINIMUM,paraLineSpacing_assert_doc.Mode); 21287127aedSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_doc.Height); 21387127aedSLiu Zhe } 21487127aedSLiu Zhe /* 21587127aedSLiu Zhe * test paragraph line spacing is prop 21687127aedSLiu Zhe * 1.new a text document 21787127aedSLiu Zhe * 2.insert some text 21887127aedSLiu Zhe * 3.set paragraph alignment is prop 21987127aedSLiu Zhe * 4.save and close the document 22087127aedSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 22187127aedSLiu Zhe */ 22287127aedSLiu Zhe @Test 22387127aedSLiu Zhe public void testParagraphLineSpacingProp() throws Exception { 22487127aedSLiu Zhe 22587127aedSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 22687127aedSLiu Zhe xText = xTextDocument.getText(); 22787127aedSLiu 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!" + 22887127aedSLiu Zhe "Hello,world!Hello,world!"); 22987127aedSLiu Zhe // create text cursor for selecting and formatting text 23087127aedSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 23187127aedSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 23287127aedSLiu Zhe //set paragraph line spacing 23387127aedSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 23487127aedSLiu Zhe lineSpacing.Mode = LineSpacingMode.PROP; 23587127aedSLiu Zhe lineSpacing.Height = 150; 23687127aedSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 23787127aedSLiu Zhe //save to odt 23887127aedSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 23987127aedSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 24087127aedSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 24187127aedSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 24287127aedSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 24387127aedSLiu Zhe aStoreProperties_odt[0].Value = true; 24487127aedSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 24587127aedSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 24687127aedSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 24787127aedSLiu Zhe //save to doc 24887127aedSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 24987127aedSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 25087127aedSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 25187127aedSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 25287127aedSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 25387127aedSLiu Zhe aStoreProperties_doc[0].Value = true; 25487127aedSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 25587127aedSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 25687127aedSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 25787127aedSLiu Zhe app.closeDocument(xTextDocument); 25887127aedSLiu Zhe 25987127aedSLiu Zhe //reopen the document 26087127aedSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 26187127aedSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 26287127aedSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 26387127aedSLiu Zhe //verify paragraph line spacing property 26487127aedSLiu Zhe assertEquals("assert line spacing is prop",LineSpacingMode.PROP,paraLineSpacing_assert_odt.Mode); 26587127aedSLiu Zhe assertEquals("assert line spacing height is 150",150,paraLineSpacing_assert_odt.Height); 26687127aedSLiu Zhe 26787127aedSLiu Zhe //reopen the document 26887127aedSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 26987127aedSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 27087127aedSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 27187127aedSLiu Zhe //verify paragraph line spacing property 27287127aedSLiu Zhe assertEquals("assert line spacing is prop",LineSpacingMode.PROP,paraLineSpacing_assert_doc.Mode); 27387127aedSLiu Zhe assertEquals("assert line spacing height is 150",150,paraLineSpacing_assert_doc.Height); 27487127aedSLiu Zhe } 27587127aedSLiu Zhe /* 27687127aedSLiu Zhe * test paragraph line spacing is single 27787127aedSLiu Zhe * 1.new a text document 27887127aedSLiu Zhe * 2.insert some text 27987127aedSLiu Zhe * 3.set paragraph line spacing is single 28087127aedSLiu Zhe * 4.save and close the document 28187127aedSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 28287127aedSLiu Zhe */ 283af986861SLiu Zhe @Test@Ignore("Bug #120649 - [testUNO patch]single line spacing change to at least of 0.07 when save to doc") 28487127aedSLiu Zhe public void testParagraphLineSpacingSingle() throws Exception { 28587127aedSLiu Zhe 28687127aedSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 28787127aedSLiu Zhe xText = xTextDocument.getText(); 28887127aedSLiu 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!" + 28987127aedSLiu Zhe "Hello,world!Hello,world!"); 29087127aedSLiu Zhe // create text cursor for selecting and formatting text 29187127aedSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 29287127aedSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 29387127aedSLiu Zhe //set paragraph line spacing 29487127aedSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 29587127aedSLiu Zhe lineSpacing.Height = 100; 29687127aedSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 29787127aedSLiu Zhe //save to odt 29887127aedSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 29987127aedSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 30087127aedSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 30187127aedSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 30287127aedSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 30387127aedSLiu Zhe aStoreProperties_odt[0].Value = true; 30487127aedSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 30587127aedSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 30687127aedSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 30787127aedSLiu Zhe //save to doc 30887127aedSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 30987127aedSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 31087127aedSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 31187127aedSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 31287127aedSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 31387127aedSLiu Zhe aStoreProperties_doc[0].Value = true; 31487127aedSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 31587127aedSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 31687127aedSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 31787127aedSLiu Zhe app.closeDocument(xTextDocument); 31887127aedSLiu Zhe 31987127aedSLiu Zhe //reopen the document 32087127aedSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 32187127aedSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 32287127aedSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 32387127aedSLiu Zhe //verify paragraph line spacing property 32487127aedSLiu Zhe assertEquals("assert first paragraph line spacing is single",100,paraLineSpacing_assert_odt.Height); 32587127aedSLiu Zhe 32687127aedSLiu Zhe //reopen the document 32787127aedSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 32887127aedSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 32987127aedSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 33087127aedSLiu Zhe //verify paragraph line spacing property 33187127aedSLiu Zhe assertEquals("assert first paragraph line spacing is single",100,paraLineSpacing_assert_doc.Height); 33287127aedSLiu Zhe } 33387127aedSLiu Zhe /* 33487127aedSLiu Zhe * test paragraph line spacing is double 33587127aedSLiu Zhe * 1.new a text document 33687127aedSLiu Zhe * 2.insert some text 33787127aedSLiu Zhe * 3.set paragraph line spacing is double 33887127aedSLiu Zhe * 4.save and close the document 33987127aedSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 34087127aedSLiu Zhe */ 34187127aedSLiu Zhe @Test 34287127aedSLiu Zhe public void testParagraphLineSpacingDouble() throws Exception { 34387127aedSLiu Zhe 34487127aedSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 34587127aedSLiu Zhe xText = xTextDocument.getText(); 34687127aedSLiu 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!" + 34787127aedSLiu Zhe "Hello,world!Hello,world!"); 34887127aedSLiu Zhe // create text cursor for selecting and formatting text 34987127aedSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 35087127aedSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 35187127aedSLiu Zhe //set paragraph line spacing 35287127aedSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 35387127aedSLiu Zhe lineSpacing.Height = 200; 35487127aedSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 35587127aedSLiu Zhe //save to odt 35687127aedSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 35787127aedSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 35887127aedSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 35987127aedSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 36087127aedSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 36187127aedSLiu Zhe aStoreProperties_odt[0].Value = true; 36287127aedSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 36387127aedSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 36487127aedSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 36587127aedSLiu Zhe //save to doc 36687127aedSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 36787127aedSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 36887127aedSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 36987127aedSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 37087127aedSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 37187127aedSLiu Zhe aStoreProperties_doc[0].Value = true; 37287127aedSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 37387127aedSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 37487127aedSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 37587127aedSLiu Zhe app.closeDocument(xTextDocument); 37687127aedSLiu Zhe 37787127aedSLiu Zhe //reopen the document and assert line spacing 37887127aedSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 37987127aedSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 38087127aedSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 38187127aedSLiu Zhe //verify paragraph line spacing property 38287127aedSLiu Zhe assertEquals("assert first paragraph line spacing is single",200,paraLineSpacing_assert_odt.Height); 38387127aedSLiu Zhe 38487127aedSLiu Zhe //reopen the document and assert line spacing 38587127aedSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 38687127aedSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 38787127aedSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 38887127aedSLiu Zhe //verify paragraph line spacing property 38987127aedSLiu Zhe assertEquals("assert first paragraph line spacing is single",200,paraLineSpacing_assert_doc.Height); 39087127aedSLiu Zhe } 39187127aedSLiu Zhe /* 39287127aedSLiu Zhe * test paragraph line spacing is 1.5line 39387127aedSLiu Zhe * 1.new a text document 39487127aedSLiu Zhe * 2.insert some text 39587127aedSLiu Zhe * 3.set paragraph line spacing is 1.5line 39687127aedSLiu Zhe * 4.save and close the document 39787127aedSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 39887127aedSLiu Zhe */ 39987127aedSLiu Zhe @Test 40087127aedSLiu Zhe public void testParagraphLineSpacingUserDefine() throws Exception { 40187127aedSLiu Zhe 40287127aedSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 40387127aedSLiu Zhe xText = xTextDocument.getText(); 40487127aedSLiu 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!" + 40587127aedSLiu Zhe "Hello,world!Hello,world!"); 40687127aedSLiu Zhe // create text cursor for selecting and formatting text 40787127aedSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 40887127aedSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 40987127aedSLiu Zhe //set paragraph line spacing 41087127aedSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 41187127aedSLiu Zhe lineSpacing.Height = 150; 41287127aedSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 41387127aedSLiu Zhe //save to odt 41487127aedSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 41587127aedSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 41687127aedSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 41787127aedSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 41887127aedSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 41987127aedSLiu Zhe aStoreProperties_odt[0].Value = true; 42087127aedSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 42187127aedSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 42287127aedSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 42387127aedSLiu Zhe //save to doc 42487127aedSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 42587127aedSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 42687127aedSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 42787127aedSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 42887127aedSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 42987127aedSLiu Zhe aStoreProperties_doc[0].Value = true; 43087127aedSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 43187127aedSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 43287127aedSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 43387127aedSLiu Zhe app.closeDocument(xTextDocument); 43487127aedSLiu Zhe 43587127aedSLiu Zhe //reopen the document 43687127aedSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 43787127aedSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 43887127aedSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 43987127aedSLiu Zhe //verify paragraph line spacing property 44087127aedSLiu Zhe assertEquals("assert first paragraph line spacing is single",150,paraLineSpacing_assert_odt.Height); 44187127aedSLiu Zhe 44287127aedSLiu Zhe //reopen the document 44387127aedSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 44487127aedSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 44587127aedSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 44687127aedSLiu Zhe //verify paragraph line spacing property 44787127aedSLiu Zhe assertEquals("assert first paragraph line spacing is single",150,paraLineSpacing_assert_doc.Height); 44887127aedSLiu Zhe } 44987127aedSLiu Zhe } 450