xref: /AOO41X/test/testuno/source/fvt/uno/sw/paragraph/ParagraphLineSpacing.java (revision eba4d44a33e5be0b2528d5a9a6f0dcbf65adaa0d)
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 org.openoffice.test.vcl.Tester.*;
13*eba4d44aSLiu Zhe import com.sun.star.text.*;
14*eba4d44aSLiu Zhe import com.sun.star.beans.*;
15*eba4d44aSLiu Zhe import com.sun.star.frame.XStorable;
16*eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime;
17*eba4d44aSLiu Zhe import com.sun.star.style.*;
18*eba4d44aSLiu Zhe 
19*eba4d44aSLiu Zhe public class ParagraphLineSpacing {
20*eba4d44aSLiu Zhe 	private static final UnoApp app = new UnoApp();
21*eba4d44aSLiu Zhe 	XText xText = null;
22*eba4d44aSLiu Zhe 
23*eba4d44aSLiu Zhe 	@Before
24*eba4d44aSLiu Zhe 	public void setUp() throws Exception {
25*eba4d44aSLiu Zhe 		app.start();
26*eba4d44aSLiu Zhe 
27*eba4d44aSLiu Zhe 	}
28*eba4d44aSLiu Zhe 
29*eba4d44aSLiu Zhe 	@After
30*eba4d44aSLiu Zhe 	public void tearDown() throws Exception {
31*eba4d44aSLiu Zhe 		app.close();
32*eba4d44aSLiu Zhe 	}
33*eba4d44aSLiu Zhe 	/*
34*eba4d44aSLiu Zhe 	 * test paragraph line spacing is fix
35*eba4d44aSLiu Zhe 	 * 1.new a text document
36*eba4d44aSLiu Zhe 	 * 2.insert some text
37*eba4d44aSLiu Zhe 	 * 3.set paragraph line spacing is fix
38*eba4d44aSLiu Zhe 	 * 4.save and close the document
39*eba4d44aSLiu Zhe 	 * 5.reload the saved document and check the paragraph line spacing
40*eba4d44aSLiu Zhe 	 */
41*eba4d44aSLiu Zhe 	@Test
42*eba4d44aSLiu Zhe 	public void testParagraphLineSpacingFix() throws Exception {
43*eba4d44aSLiu Zhe 
44*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
45*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
46*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!" +
47*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
48*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
49*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
50*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
51*eba4d44aSLiu Zhe 		//set paragraph line spacing
52*eba4d44aSLiu Zhe 		LineSpacing lineSpacing = new LineSpacing();
53*eba4d44aSLiu Zhe 		lineSpacing.Mode = LineSpacingMode.FIX;
54*eba4d44aSLiu Zhe 		lineSpacing.Height = 5000;
55*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing);
56*eba4d44aSLiu Zhe 		//save to odt
57*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
58*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
59*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
60*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
61*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
62*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
63*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
64*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
65*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
66*eba4d44aSLiu Zhe 		//save to doc
67*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
68*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
69*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
70*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
71*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
72*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
73*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
74*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
75*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
76*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
77*eba4d44aSLiu Zhe 
78*eba4d44aSLiu Zhe 		//reopen the document and assert paragraph line spacing
79*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
80*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor());
81*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing"));
82*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.FIX,paraLineSpacing_assert_odt.Mode);
83*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_odt.Height);
84*eba4d44aSLiu Zhe 
85*eba4d44aSLiu Zhe 		//reopen the document and assert paragraph line spacing
86*eba4d44aSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
87*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor());
88*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing"));
89*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.FIX,paraLineSpacing_assert_doc.Mode);
90*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_doc.Height);
91*eba4d44aSLiu Zhe 	}
92*eba4d44aSLiu Zhe 	/*
93*eba4d44aSLiu Zhe 	 * test paragraph line spacing is leading
94*eba4d44aSLiu Zhe 	 * 1.new a text document
95*eba4d44aSLiu Zhe 	 * 2.insert some text
96*eba4d44aSLiu Zhe 	 * 3.set paragraph line spacing is leading
97*eba4d44aSLiu Zhe 	 * 4.save and close the document
98*eba4d44aSLiu Zhe 	 * 5.reload the saved document and check the paragraph line spacing
99*eba4d44aSLiu Zhe 	 */
100*eba4d44aSLiu Zhe 	@Test@Ignore("Bug #120647 - [testUNO patch]line spacing leading setting change to at least when save to doc")
101*eba4d44aSLiu Zhe 	public void testParagraphLineSpacingLeading() throws Exception {
102*eba4d44aSLiu Zhe 
103*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
104*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
105*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!" +
106*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
107*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
108*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
109*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
110*eba4d44aSLiu Zhe 		//set paragraph line spacing
111*eba4d44aSLiu Zhe 		LineSpacing lineSpacing = new LineSpacing();
112*eba4d44aSLiu Zhe 		lineSpacing.Mode = LineSpacingMode.LEADING;
113*eba4d44aSLiu Zhe 		lineSpacing.Height = 5000;
114*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing);
115*eba4d44aSLiu Zhe 		//save to odt
116*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
117*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
118*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
119*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
120*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
121*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
122*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
123*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
124*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
125*eba4d44aSLiu Zhe 		//save to doc
126*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
127*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
128*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
129*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
130*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
131*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
132*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
133*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
134*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
135*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
136*eba4d44aSLiu Zhe 
137*eba4d44aSLiu Zhe 		//reopen the document
138*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
139*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor());
140*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing"));
141*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
142*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.LEADING,paraLineSpacing_assert_odt.Mode);
143*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_odt.Height);
144*eba4d44aSLiu Zhe 
145*eba4d44aSLiu Zhe 		//reopen the document
146*eba4d44aSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
147*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor());
148*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing"));
149*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
150*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.LEADING,paraLineSpacing_assert_doc.Mode);
151*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_doc.Height);
152*eba4d44aSLiu Zhe 	}
153*eba4d44aSLiu Zhe 	/*
154*eba4d44aSLiu Zhe 	 * test paragraph line spacing is minimum
155*eba4d44aSLiu Zhe 	 * 1.new a text document
156*eba4d44aSLiu Zhe 	 * 2.insert some text
157*eba4d44aSLiu Zhe 	 * 3.set paragraph line spacing is minimum
158*eba4d44aSLiu Zhe 	 * 4.save and close the document
159*eba4d44aSLiu Zhe 	 * 5.reload the saved document and check the paragraph line spacing
160*eba4d44aSLiu Zhe 	 */
161*eba4d44aSLiu Zhe 	@Test
162*eba4d44aSLiu Zhe 	public void testParagraphLineSpacingMinimum() throws Exception {
163*eba4d44aSLiu Zhe 
164*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
165*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
166*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!" +
167*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
168*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
169*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
170*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
171*eba4d44aSLiu Zhe 		//set paragraph line spacing
172*eba4d44aSLiu Zhe 		LineSpacing lineSpacing = new LineSpacing();
173*eba4d44aSLiu Zhe 		lineSpacing.Mode = LineSpacingMode.MINIMUM;
174*eba4d44aSLiu Zhe 		lineSpacing.Height = 5000;
175*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing);
176*eba4d44aSLiu Zhe 		//save to odt
177*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
178*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
179*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
180*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
181*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
182*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
183*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
184*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
185*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
186*eba4d44aSLiu Zhe 		//save to doc
187*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
188*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
189*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
190*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
191*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
192*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
193*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
194*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
195*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
196*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
197*eba4d44aSLiu Zhe 
198*eba4d44aSLiu Zhe 		//reopen the document
199*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
200*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor());
201*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing"));
202*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
203*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.MINIMUM,paraLineSpacing_assert_odt.Mode);
204*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_odt.Height);
205*eba4d44aSLiu Zhe 
206*eba4d44aSLiu Zhe 		//reopen the document
207*eba4d44aSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
208*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor());
209*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing"));
210*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
211*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.MINIMUM,paraLineSpacing_assert_doc.Mode);
212*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_doc.Height);
213*eba4d44aSLiu Zhe 	}
214*eba4d44aSLiu Zhe 	/*
215*eba4d44aSLiu Zhe 	 * test paragraph line spacing is prop
216*eba4d44aSLiu Zhe 	 * 1.new a text document
217*eba4d44aSLiu Zhe 	 * 2.insert some text
218*eba4d44aSLiu Zhe 	 * 3.set paragraph alignment is prop
219*eba4d44aSLiu Zhe 	 * 4.save and close the document
220*eba4d44aSLiu Zhe 	 * 5.reload the saved document and check the paragraph line spacing
221*eba4d44aSLiu Zhe 	 */
222*eba4d44aSLiu Zhe 	@Test
223*eba4d44aSLiu Zhe 	public void testParagraphLineSpacingProp() throws Exception {
224*eba4d44aSLiu Zhe 
225*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
226*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
227*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!" +
228*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
229*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
230*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
231*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
232*eba4d44aSLiu Zhe 		//set paragraph line spacing
233*eba4d44aSLiu Zhe 		LineSpacing lineSpacing = new LineSpacing();
234*eba4d44aSLiu Zhe 		lineSpacing.Mode = LineSpacingMode.PROP;
235*eba4d44aSLiu Zhe 		lineSpacing.Height = 150;
236*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing);
237*eba4d44aSLiu Zhe 		//save to odt
238*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
239*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
240*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
241*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
242*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
243*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
244*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
245*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
246*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
247*eba4d44aSLiu Zhe 		//save to doc
248*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
249*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
250*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
251*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
252*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
253*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
254*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
255*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
256*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
257*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
258*eba4d44aSLiu Zhe 
259*eba4d44aSLiu Zhe 		//reopen the document
260*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
261*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor());
262*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing"));
263*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
264*eba4d44aSLiu Zhe 		assertEquals("assert line spacing is prop",LineSpacingMode.PROP,paraLineSpacing_assert_odt.Mode);
265*eba4d44aSLiu Zhe 		assertEquals("assert line spacing height is 150",150,paraLineSpacing_assert_odt.Height);
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 		LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing"));
271*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
272*eba4d44aSLiu Zhe 		assertEquals("assert line spacing is prop",LineSpacingMode.PROP,paraLineSpacing_assert_doc.Mode);
273*eba4d44aSLiu Zhe 		assertEquals("assert line spacing height is 150",150,paraLineSpacing_assert_doc.Height);
274*eba4d44aSLiu Zhe 	}
275*eba4d44aSLiu Zhe 	/*
276*eba4d44aSLiu Zhe 	 * test paragraph line spacing is single
277*eba4d44aSLiu Zhe 	 * 1.new a text document
278*eba4d44aSLiu Zhe 	 * 2.insert some text
279*eba4d44aSLiu Zhe 	 * 3.set paragraph line spacing is single
280*eba4d44aSLiu Zhe 	 * 4.save and close the document
281*eba4d44aSLiu Zhe 	 * 5.reload the saved document and check the paragraph line spacing
282*eba4d44aSLiu Zhe 	 */
283*eba4d44aSLiu Zhe 	@Test@Ignore("Bug #120649 - [testUNO patch]single line spacing change to at least of 0.07 when save to doc")
284*eba4d44aSLiu Zhe 	public void testParagraphLineSpacingSingle() throws Exception {
285*eba4d44aSLiu Zhe 
286*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
287*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
288*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!" +
289*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
290*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
291*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
292*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
293*eba4d44aSLiu Zhe 		//set paragraph line spacing
294*eba4d44aSLiu Zhe 		LineSpacing lineSpacing = new LineSpacing();
295*eba4d44aSLiu Zhe 		lineSpacing.Height = 100;
296*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing);
297*eba4d44aSLiu Zhe 		//save to odt
298*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
299*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
300*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
301*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
302*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
303*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
304*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
305*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
306*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
307*eba4d44aSLiu Zhe 		//save to doc
308*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
309*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
310*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
311*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
312*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
313*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
314*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
315*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
316*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
317*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
318*eba4d44aSLiu Zhe 
319*eba4d44aSLiu Zhe 		//reopen the document
320*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
321*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor());
322*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing"));
323*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
324*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is single",100,paraLineSpacing_assert_odt.Height);
325*eba4d44aSLiu Zhe 
326*eba4d44aSLiu Zhe 		//reopen the document
327*eba4d44aSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
328*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor());
329*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing"));
330*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
331*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is single",100,paraLineSpacing_assert_doc.Height);
332*eba4d44aSLiu Zhe 	}
333*eba4d44aSLiu Zhe 	/*
334*eba4d44aSLiu Zhe 	 * test paragraph line spacing is double
335*eba4d44aSLiu Zhe 	 * 1.new a text document
336*eba4d44aSLiu Zhe 	 * 2.insert some text
337*eba4d44aSLiu Zhe 	 * 3.set paragraph line spacing is double
338*eba4d44aSLiu Zhe 	 * 4.save and close the document
339*eba4d44aSLiu Zhe 	 * 5.reload the saved document and check the paragraph line spacing
340*eba4d44aSLiu Zhe 	 */
341*eba4d44aSLiu Zhe 	@Test
342*eba4d44aSLiu Zhe 	public void testParagraphLineSpacingDouble() throws Exception {
343*eba4d44aSLiu Zhe 
344*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
345*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
346*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!" +
347*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
348*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
349*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
350*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
351*eba4d44aSLiu Zhe 		//set paragraph line spacing
352*eba4d44aSLiu Zhe 		LineSpacing lineSpacing = new LineSpacing();
353*eba4d44aSLiu Zhe 		lineSpacing.Height = 200;
354*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing);
355*eba4d44aSLiu Zhe 		//save to odt
356*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
357*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
358*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
359*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
360*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
361*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
362*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
363*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
364*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
365*eba4d44aSLiu Zhe 		//save to doc
366*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
367*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
368*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
369*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
370*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
371*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
372*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
373*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
374*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
375*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
376*eba4d44aSLiu Zhe 
377*eba4d44aSLiu Zhe 		//reopen the document and assert line spacing
378*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
379*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor());
380*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing"));
381*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
382*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is single",200,paraLineSpacing_assert_odt.Height);
383*eba4d44aSLiu Zhe 
384*eba4d44aSLiu Zhe 		//reopen the document and assert line spacing
385*eba4d44aSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
386*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor());
387*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing"));
388*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
389*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is single",200,paraLineSpacing_assert_doc.Height);
390*eba4d44aSLiu Zhe 	}
391*eba4d44aSLiu Zhe 	/*
392*eba4d44aSLiu Zhe 	 * test paragraph line spacing is 1.5line
393*eba4d44aSLiu Zhe 	 * 1.new a text document
394*eba4d44aSLiu Zhe 	 * 2.insert some text
395*eba4d44aSLiu Zhe 	 * 3.set paragraph line spacing is 1.5line
396*eba4d44aSLiu Zhe 	 * 4.save and close the document
397*eba4d44aSLiu Zhe 	 * 5.reload the saved document and check the paragraph line spacing
398*eba4d44aSLiu Zhe 	 */
399*eba4d44aSLiu Zhe 	@Test
400*eba4d44aSLiu Zhe 	public void testParagraphLineSpacingUserDefine() throws Exception {
401*eba4d44aSLiu Zhe 
402*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
403*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
404*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!" +
405*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
406*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
407*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
408*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
409*eba4d44aSLiu Zhe 		//set paragraph line spacing
410*eba4d44aSLiu Zhe 		LineSpacing lineSpacing = new LineSpacing();
411*eba4d44aSLiu Zhe 		lineSpacing.Height = 150;
412*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing);
413*eba4d44aSLiu Zhe 		//save to odt
414*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
415*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
416*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
417*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
418*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
419*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
420*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
421*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
422*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
423*eba4d44aSLiu Zhe 		//save to doc
424*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
425*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
426*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
427*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
428*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
429*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
430*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
431*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
432*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
433*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
434*eba4d44aSLiu Zhe 
435*eba4d44aSLiu Zhe 		//reopen the document
436*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
437*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor());
438*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing"));
439*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
440*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is single",150,paraLineSpacing_assert_odt.Height);
441*eba4d44aSLiu Zhe 
442*eba4d44aSLiu Zhe 		//reopen the document
443*eba4d44aSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
444*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor());
445*eba4d44aSLiu Zhe 		LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing"));
446*eba4d44aSLiu Zhe 		//verify paragraph line spacing property
447*eba4d44aSLiu Zhe 		assertEquals("assert first paragraph line spacing is single",150,paraLineSpacing_assert_doc.Height);
448*eba4d44aSLiu Zhe 	}
449*eba4d44aSLiu Zhe }
450