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