xref: /AOO41X/test/testuno/source/fvt/uno/sw/paragraph/ParagraphShadow.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 
13*eba4d44aSLiu Zhe import com.sun.star.table.ShadowFormat;
14*eba4d44aSLiu Zhe import com.sun.star.table.ShadowLocation;
15*eba4d44aSLiu Zhe import com.sun.star.text.*;
16*eba4d44aSLiu Zhe import com.sun.star.beans.*;
17*eba4d44aSLiu Zhe import com.sun.star.frame.XStorable;
18*eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime;
19*eba4d44aSLiu Zhe 
20*eba4d44aSLiu Zhe public class ParagraphShadow {
21*eba4d44aSLiu Zhe 	private static final UnoApp app = new UnoApp();
22*eba4d44aSLiu Zhe 	XText xText = null;
23*eba4d44aSLiu Zhe 
24*eba4d44aSLiu Zhe 	@Before
25*eba4d44aSLiu Zhe 	public void setUp() throws Exception {
26*eba4d44aSLiu Zhe 		app.start();
27*eba4d44aSLiu Zhe 
28*eba4d44aSLiu Zhe 	}
29*eba4d44aSLiu Zhe 
30*eba4d44aSLiu Zhe 	@After
31*eba4d44aSLiu Zhe 	public void tearDown() throws Exception {
32*eba4d44aSLiu Zhe 		app.close();
33*eba4d44aSLiu Zhe 	}
34*eba4d44aSLiu Zhe 	/*
35*eba4d44aSLiu Zhe 	 * test paragraph background color
36*eba4d44aSLiu Zhe 	 * 1.new a text document
37*eba4d44aSLiu Zhe 	 * 2.insert some text
38*eba4d44aSLiu Zhe 	 * 3.set paragraph shadow
39*eba4d44aSLiu Zhe 	 * 4.save and close the document
40*eba4d44aSLiu Zhe 	 * 5.reload the saved document and check the paragraph shadow
41*eba4d44aSLiu Zhe 	 */
42*eba4d44aSLiu Zhe 	@Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.")
43*eba4d44aSLiu Zhe 	public void testParagraphShadow_BottomRight() throws Exception {
44*eba4d44aSLiu Zhe 
45*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
46*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
47*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!" +
48*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
49*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
50*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
51*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
52*eba4d44aSLiu Zhe 		//set paragraph background color
53*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat=new ShadowFormat();
54*eba4d44aSLiu Zhe 		shadowFormat.Location=ShadowLocation.BOTTOM_RIGHT;
55*eba4d44aSLiu Zhe 		shadowFormat.ShadowWidth=101;
56*eba4d44aSLiu Zhe 		shadowFormat.Color=0x00FF00FF;
57*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat);
58*eba4d44aSLiu Zhe 		//save to odt
59*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
60*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
61*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
62*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
63*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
64*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
65*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
66*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
67*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
68*eba4d44aSLiu Zhe 		//save to doc
69*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
70*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
71*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
72*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
73*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
74*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
75*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
76*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
77*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
78*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
79*eba4d44aSLiu Zhe 
80*eba4d44aSLiu Zhe 		//reopen the document
81*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
82*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
83*eba4d44aSLiu Zhe 		//verify paragraph background color
84*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat"));
85*eba4d44aSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.BOTTOM_RIGHT,shadowFormat_Assert1.Location);
86*eba4d44aSLiu Zhe 		assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth);
87*eba4d44aSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color);
88*eba4d44aSLiu Zhe 
89*eba4d44aSLiu Zhe 		//reopen the document
90*eba4d44aSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
91*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
92*eba4d44aSLiu Zhe 		//verify paragraph background color
93*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat"));
94*eba4d44aSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.BOTTOM_RIGHT,shadowFormat_Assert2.Location);
95*eba4d44aSLiu Zhe 		assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth);
96*eba4d44aSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color);
97*eba4d44aSLiu Zhe 	}
98*eba4d44aSLiu Zhe 	@Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.")
99*eba4d44aSLiu Zhe 	public void testParagraphShadow_BottomLeft() throws Exception {
100*eba4d44aSLiu Zhe 
101*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
102*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
103*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!" +
104*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
105*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
106*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
107*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
108*eba4d44aSLiu Zhe 		//set paragraph background color
109*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat=new ShadowFormat();
110*eba4d44aSLiu Zhe 		shadowFormat.Location=ShadowLocation.BOTTOM_LEFT;
111*eba4d44aSLiu Zhe 		shadowFormat.ShadowWidth=101;
112*eba4d44aSLiu Zhe 		shadowFormat.Color=0x00FF00FF;
113*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat);
114*eba4d44aSLiu Zhe 		//save to odt
115*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
116*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
117*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
118*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
119*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
120*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
121*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
122*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
123*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
124*eba4d44aSLiu Zhe 		//save to doc
125*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
126*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
127*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
128*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
129*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
130*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
131*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
132*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
133*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
134*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
135*eba4d44aSLiu Zhe 
136*eba4d44aSLiu Zhe 		//reopen the document
137*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
138*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
139*eba4d44aSLiu Zhe 		//verify paragraph background color
140*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat"));
141*eba4d44aSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.BOTTOM_LEFT,shadowFormat_Assert1.Location);
142*eba4d44aSLiu Zhe 		assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth);
143*eba4d44aSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color);
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 		//verify paragraph background color
149*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat"));
150*eba4d44aSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.BOTTOM_LEFT,shadowFormat_Assert2.Location);
151*eba4d44aSLiu Zhe 		assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth);
152*eba4d44aSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color);
153*eba4d44aSLiu Zhe 	}
154*eba4d44aSLiu Zhe 	@Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.")
155*eba4d44aSLiu Zhe 	public void testParagraphShadow_TopLeft() throws Exception {
156*eba4d44aSLiu Zhe 
157*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
158*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
159*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!" +
160*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
161*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
162*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
163*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
164*eba4d44aSLiu Zhe 		//set paragraph background color
165*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat=new ShadowFormat();
166*eba4d44aSLiu Zhe 		shadowFormat.Location=ShadowLocation.TOP_LEFT;
167*eba4d44aSLiu Zhe 		shadowFormat.ShadowWidth=101;
168*eba4d44aSLiu Zhe 		shadowFormat.Color=0x00FF00FF;
169*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat);
170*eba4d44aSLiu Zhe 		//save to odt
171*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
172*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
173*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
174*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
175*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
176*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
177*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
178*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
179*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
180*eba4d44aSLiu Zhe 		//save to doc
181*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
182*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
183*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
184*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
185*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
186*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
187*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
188*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
189*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
190*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
191*eba4d44aSLiu Zhe 
192*eba4d44aSLiu Zhe 		//reopen the document
193*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
194*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
195*eba4d44aSLiu Zhe 		//verify paragraph background color
196*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat"));
197*eba4d44aSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.TOP_LEFT,shadowFormat_Assert1.Location);
198*eba4d44aSLiu Zhe 		assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth);
199*eba4d44aSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color);
200*eba4d44aSLiu Zhe 
201*eba4d44aSLiu Zhe 		//reopen the document
202*eba4d44aSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
203*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
204*eba4d44aSLiu Zhe 		//verify paragraph background color
205*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat"));
206*eba4d44aSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.TOP_LEFT,shadowFormat_Assert2.Location);
207*eba4d44aSLiu Zhe 		assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth);
208*eba4d44aSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color);
209*eba4d44aSLiu Zhe 	}
210*eba4d44aSLiu Zhe 	@Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.")
211*eba4d44aSLiu Zhe 	public void testParagraphShadow_TopRight() throws Exception {
212*eba4d44aSLiu Zhe 
213*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
214*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
215*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!" +
216*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
217*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
218*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
219*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
220*eba4d44aSLiu Zhe 		//set paragraph background color
221*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat=new ShadowFormat();
222*eba4d44aSLiu Zhe 		shadowFormat.Location=ShadowLocation.TOP_RIGHT;
223*eba4d44aSLiu Zhe 		shadowFormat.ShadowWidth=101;
224*eba4d44aSLiu Zhe 		shadowFormat.Color=0x00FF00FF;
225*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat);
226*eba4d44aSLiu Zhe 		//save to odt
227*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
228*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
229*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
230*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
231*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
232*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
233*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
234*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
235*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
236*eba4d44aSLiu Zhe 		//save to doc
237*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
238*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
239*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
240*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
241*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
242*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
243*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
244*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
245*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
246*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
247*eba4d44aSLiu Zhe 
248*eba4d44aSLiu Zhe 		//reopen the document
249*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
250*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
251*eba4d44aSLiu Zhe 		//verify paragraph background color
252*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat"));
253*eba4d44aSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.TOP_RIGHT,shadowFormat_Assert1.Location);
254*eba4d44aSLiu Zhe 		assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth);
255*eba4d44aSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color);
256*eba4d44aSLiu Zhe 
257*eba4d44aSLiu Zhe 		//reopen the document
258*eba4d44aSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
259*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
260*eba4d44aSLiu Zhe 		//verify paragraph background color
261*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat"));
262*eba4d44aSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.TOP_RIGHT,shadowFormat_Assert2.Location);
263*eba4d44aSLiu Zhe 		assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth);
264*eba4d44aSLiu Zhe 		assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color);
265*eba4d44aSLiu Zhe 	}
266*eba4d44aSLiu Zhe 	@Test
267*eba4d44aSLiu Zhe 	public void testParagraphShadow_None() throws Exception {
268*eba4d44aSLiu Zhe 
269*eba4d44aSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
270*eba4d44aSLiu Zhe 		xText = xTextDocument.getText();
271*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!" +
272*eba4d44aSLiu Zhe 				"Hello,world!Hello,world!");
273*eba4d44aSLiu Zhe 		// create text cursor for selecting and formatting text
274*eba4d44aSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
275*eba4d44aSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
276*eba4d44aSLiu Zhe 		//set paragraph background color
277*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat=new ShadowFormat();
278*eba4d44aSLiu Zhe 		shadowFormat.Location=ShadowLocation.NONE;
279*eba4d44aSLiu Zhe 		shadowFormat.ShadowWidth=101;
280*eba4d44aSLiu Zhe 		shadowFormat.Color=0x00FF00FF;
281*eba4d44aSLiu Zhe 		xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat);
282*eba4d44aSLiu Zhe 		//save to odt
283*eba4d44aSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
284*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
285*eba4d44aSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
286*eba4d44aSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
287*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
288*eba4d44aSLiu Zhe 		aStoreProperties_odt[0].Value = true;
289*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
290*eba4d44aSLiu Zhe 		aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
291*eba4d44aSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
292*eba4d44aSLiu Zhe 		//save to doc
293*eba4d44aSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
294*eba4d44aSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
295*eba4d44aSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
296*eba4d44aSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
297*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
298*eba4d44aSLiu Zhe 		aStoreProperties_doc[0].Value = true;
299*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
300*eba4d44aSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
301*eba4d44aSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
302*eba4d44aSLiu Zhe 		app.closeDocument(xTextDocument);
303*eba4d44aSLiu Zhe 
304*eba4d44aSLiu Zhe 		//reopen the document
305*eba4d44aSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
306*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
307*eba4d44aSLiu Zhe 		//verify paragraph background color
308*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat"));
309*eba4d44aSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.NONE,shadowFormat_Assert1.Location);
310*eba4d44aSLiu Zhe 
311*eba4d44aSLiu Zhe 		//reopen the document
312*eba4d44aSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
313*eba4d44aSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
314*eba4d44aSLiu Zhe 		//verify paragraph background color
315*eba4d44aSLiu Zhe 		ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat"));
316*eba4d44aSLiu Zhe 		assertEquals("assert shadow location",ShadowLocation.NONE,shadowFormat_Assert2.Location);
317*eba4d44aSLiu Zhe 	}
318*eba4d44aSLiu Zhe }
319