xref: /trunk/test/testuno/source/fvt/uno/sw/paragraph/ParagraphTexttoTextAlignment.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.Test;
8*eba4d44aSLiu Zhe import org.openoffice.test.common.FileUtil;
9*eba4d44aSLiu Zhe import org.openoffice.test.common.Testspace;
10*eba4d44aSLiu Zhe import org.openoffice.test.uno.UnoApp;
11*eba4d44aSLiu Zhe import com.sun.star.text.*;
12*eba4d44aSLiu Zhe import com.sun.star.beans.*;
13*eba4d44aSLiu Zhe import com.sun.star.frame.XStorable;
14*eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime;
15*eba4d44aSLiu Zhe 
16*eba4d44aSLiu Zhe public class ParagraphTexttoTextAlignment {
17*eba4d44aSLiu Zhe     private static final UnoApp app = new UnoApp();
18*eba4d44aSLiu Zhe     XText xText = null;
19*eba4d44aSLiu Zhe 
20*eba4d44aSLiu Zhe     @Before
21*eba4d44aSLiu Zhe     public void setUp() throws Exception {
22*eba4d44aSLiu Zhe         app.start();
23*eba4d44aSLiu Zhe 
24*eba4d44aSLiu Zhe     }
25*eba4d44aSLiu Zhe 
26*eba4d44aSLiu Zhe     @After
27*eba4d44aSLiu Zhe     public void tearDown() throws Exception {
28*eba4d44aSLiu Zhe         app.close();
29*eba4d44aSLiu Zhe     }
30*eba4d44aSLiu Zhe     /*
31*eba4d44aSLiu Zhe      * test paragraph background color
32*eba4d44aSLiu Zhe      * 1.new a text document
33*eba4d44aSLiu Zhe      * 2.insert some text
34*eba4d44aSLiu Zhe      * 3.set paragraph text to text alignment
35*eba4d44aSLiu Zhe      * 4.save and close the document
36*eba4d44aSLiu Zhe      * 5.reload the saved document and check the paragraph text to text alignment
37*eba4d44aSLiu Zhe      */
38*eba4d44aSLiu Zhe     @Test
39*eba4d44aSLiu Zhe     public void testTexttoTextAlignment_Baseline() throws Exception {
40*eba4d44aSLiu Zhe 
41*eba4d44aSLiu Zhe         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
42*eba4d44aSLiu Zhe         xText = xTextDocument.getText();
43*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!" +
44*eba4d44aSLiu Zhe                 "Hello,world!Hello,world!");
45*eba4d44aSLiu Zhe         // create text cursor for selecting and formatting text
46*eba4d44aSLiu Zhe         XTextCursor xTextCursor = xText.createTextCursor();
47*eba4d44aSLiu Zhe         XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
48*eba4d44aSLiu Zhe         xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.BASELINE);
49*eba4d44aSLiu Zhe         //save to odt
50*eba4d44aSLiu Zhe         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
51*eba4d44aSLiu Zhe         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
52*eba4d44aSLiu Zhe         aStoreProperties_odt[0] = new PropertyValue();
53*eba4d44aSLiu Zhe         aStoreProperties_odt[1] = new PropertyValue();
54*eba4d44aSLiu Zhe         aStoreProperties_odt[0].Name = "Override";
55*eba4d44aSLiu Zhe         aStoreProperties_odt[0].Value = true;
56*eba4d44aSLiu Zhe         aStoreProperties_odt[1].Name = "FilterName";
57*eba4d44aSLiu Zhe         aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
58*eba4d44aSLiu Zhe         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
59*eba4d44aSLiu Zhe         //save to doc
60*eba4d44aSLiu Zhe         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
61*eba4d44aSLiu Zhe         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
62*eba4d44aSLiu Zhe         aStoreProperties_doc[0] = new PropertyValue();
63*eba4d44aSLiu Zhe         aStoreProperties_doc[1] = new PropertyValue();
64*eba4d44aSLiu Zhe         aStoreProperties_doc[0].Name = "Override";
65*eba4d44aSLiu Zhe         aStoreProperties_doc[0].Value = true;
66*eba4d44aSLiu Zhe         aStoreProperties_doc[1].Name = "FilterName";
67*eba4d44aSLiu Zhe         aStoreProperties_doc[1].Value = "MS Word 97";
68*eba4d44aSLiu Zhe         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
69*eba4d44aSLiu Zhe         app.closeDocument(xTextDocument);
70*eba4d44aSLiu Zhe 
71*eba4d44aSLiu Zhe         //reopen the document
72*eba4d44aSLiu Zhe         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
73*eba4d44aSLiu Zhe         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
74*eba4d44aSLiu Zhe         //verify paragraph text to text alignment
75*eba4d44aSLiu Zhe         assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BASELINE,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment"));
76*eba4d44aSLiu Zhe 
77*eba4d44aSLiu Zhe         //reopen the document
78*eba4d44aSLiu Zhe         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
79*eba4d44aSLiu Zhe         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
80*eba4d44aSLiu Zhe         //verify paragraph text to text alignment
81*eba4d44aSLiu Zhe         assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BASELINE,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment"));
82*eba4d44aSLiu Zhe     }
83*eba4d44aSLiu Zhe     @Test
84*eba4d44aSLiu Zhe     public void testTexttoTextAlignment_Bottom() throws Exception {
85*eba4d44aSLiu Zhe 
86*eba4d44aSLiu Zhe         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
87*eba4d44aSLiu Zhe         xText = xTextDocument.getText();
88*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!" +
89*eba4d44aSLiu Zhe                 "Hello,world!Hello,world!");
90*eba4d44aSLiu Zhe         // create text cursor for selecting and formatting text
91*eba4d44aSLiu Zhe         XTextCursor xTextCursor = xText.createTextCursor();
92*eba4d44aSLiu Zhe         XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
93*eba4d44aSLiu Zhe         xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.BOTTOM);
94*eba4d44aSLiu Zhe         //save to odt
95*eba4d44aSLiu Zhe         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
96*eba4d44aSLiu Zhe         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
97*eba4d44aSLiu Zhe         aStoreProperties_odt[0] = new PropertyValue();
98*eba4d44aSLiu Zhe         aStoreProperties_odt[1] = new PropertyValue();
99*eba4d44aSLiu Zhe         aStoreProperties_odt[0].Name = "Override";
100*eba4d44aSLiu Zhe         aStoreProperties_odt[0].Value = true;
101*eba4d44aSLiu Zhe         aStoreProperties_odt[1].Name = "FilterName";
102*eba4d44aSLiu Zhe         aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
103*eba4d44aSLiu Zhe         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
104*eba4d44aSLiu Zhe         //save to doc
105*eba4d44aSLiu Zhe         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
106*eba4d44aSLiu Zhe         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
107*eba4d44aSLiu Zhe         aStoreProperties_doc[0] = new PropertyValue();
108*eba4d44aSLiu Zhe         aStoreProperties_doc[1] = new PropertyValue();
109*eba4d44aSLiu Zhe         aStoreProperties_doc[0].Name = "Override";
110*eba4d44aSLiu Zhe         aStoreProperties_doc[0].Value = true;
111*eba4d44aSLiu Zhe         aStoreProperties_doc[1].Name = "FilterName";
112*eba4d44aSLiu Zhe         aStoreProperties_doc[1].Value = "MS Word 97";
113*eba4d44aSLiu Zhe         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
114*eba4d44aSLiu Zhe         app.closeDocument(xTextDocument);
115*eba4d44aSLiu Zhe 
116*eba4d44aSLiu Zhe         //reopen the document
117*eba4d44aSLiu Zhe         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
118*eba4d44aSLiu Zhe         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
119*eba4d44aSLiu Zhe         //verify paragraph text to text alignment
120*eba4d44aSLiu Zhe         assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BOTTOM,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment"));
121*eba4d44aSLiu Zhe 
122*eba4d44aSLiu Zhe         //reopen the document
123*eba4d44aSLiu Zhe         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
124*eba4d44aSLiu Zhe         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
125*eba4d44aSLiu Zhe         //verify paragraph text to text alignment
126*eba4d44aSLiu Zhe         assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BOTTOM,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment"));
127*eba4d44aSLiu Zhe     }
128*eba4d44aSLiu Zhe     @Test
129*eba4d44aSLiu Zhe     public void testTexttoTextAlignment_Center() throws Exception {
130*eba4d44aSLiu Zhe 
131*eba4d44aSLiu Zhe         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
132*eba4d44aSLiu Zhe         xText = xTextDocument.getText();
133*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!" +
134*eba4d44aSLiu Zhe                 "Hello,world!Hello,world!");
135*eba4d44aSLiu Zhe         // create text cursor for selecting and formatting text
136*eba4d44aSLiu Zhe         XTextCursor xTextCursor = xText.createTextCursor();
137*eba4d44aSLiu Zhe         XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
138*eba4d44aSLiu Zhe         xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.CENTER);
139*eba4d44aSLiu Zhe         //save to odt
140*eba4d44aSLiu Zhe         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
141*eba4d44aSLiu Zhe         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
142*eba4d44aSLiu Zhe         aStoreProperties_odt[0] = new PropertyValue();
143*eba4d44aSLiu Zhe         aStoreProperties_odt[1] = new PropertyValue();
144*eba4d44aSLiu Zhe         aStoreProperties_odt[0].Name = "Override";
145*eba4d44aSLiu Zhe         aStoreProperties_odt[0].Value = true;
146*eba4d44aSLiu Zhe         aStoreProperties_odt[1].Name = "FilterName";
147*eba4d44aSLiu Zhe         aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
148*eba4d44aSLiu Zhe         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
149*eba4d44aSLiu Zhe         //save to doc
150*eba4d44aSLiu Zhe         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
151*eba4d44aSLiu Zhe         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
152*eba4d44aSLiu Zhe         aStoreProperties_doc[0] = new PropertyValue();
153*eba4d44aSLiu Zhe         aStoreProperties_doc[1] = new PropertyValue();
154*eba4d44aSLiu Zhe         aStoreProperties_doc[0].Name = "Override";
155*eba4d44aSLiu Zhe         aStoreProperties_doc[0].Value = true;
156*eba4d44aSLiu Zhe         aStoreProperties_doc[1].Name = "FilterName";
157*eba4d44aSLiu Zhe         aStoreProperties_doc[1].Value = "MS Word 97";
158*eba4d44aSLiu Zhe         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
159*eba4d44aSLiu Zhe         app.closeDocument(xTextDocument);
160*eba4d44aSLiu Zhe 
161*eba4d44aSLiu Zhe         //reopen the document
162*eba4d44aSLiu Zhe         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
163*eba4d44aSLiu Zhe         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
164*eba4d44aSLiu Zhe         //verify paragraph text to text alignment
165*eba4d44aSLiu Zhe         assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.CENTER,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment"));
166*eba4d44aSLiu Zhe 
167*eba4d44aSLiu Zhe         //reopen the document
168*eba4d44aSLiu Zhe         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
169*eba4d44aSLiu Zhe         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
170*eba4d44aSLiu Zhe         //verify paragraph text to text alignment
171*eba4d44aSLiu Zhe         assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.CENTER,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment"));
172*eba4d44aSLiu Zhe     }
173*eba4d44aSLiu Zhe     @Test
174*eba4d44aSLiu Zhe     public void testTexttoTextAlignment_Top() throws Exception {
175*eba4d44aSLiu Zhe 
176*eba4d44aSLiu Zhe         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
177*eba4d44aSLiu Zhe         xText = xTextDocument.getText();
178*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!" +
179*eba4d44aSLiu Zhe                 "Hello,world!Hello,world!");
180*eba4d44aSLiu Zhe         // create text cursor for selecting and formatting text
181*eba4d44aSLiu Zhe         XTextCursor xTextCursor = xText.createTextCursor();
182*eba4d44aSLiu Zhe         XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
183*eba4d44aSLiu Zhe         xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.TOP);
184*eba4d44aSLiu Zhe         //save to odt
185*eba4d44aSLiu Zhe         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
186*eba4d44aSLiu Zhe         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
187*eba4d44aSLiu Zhe         aStoreProperties_odt[0] = new PropertyValue();
188*eba4d44aSLiu Zhe         aStoreProperties_odt[1] = new PropertyValue();
189*eba4d44aSLiu Zhe         aStoreProperties_odt[0].Name = "Override";
190*eba4d44aSLiu Zhe         aStoreProperties_odt[0].Value = true;
191*eba4d44aSLiu Zhe         aStoreProperties_odt[1].Name = "FilterName";
192*eba4d44aSLiu Zhe         aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
193*eba4d44aSLiu Zhe         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
194*eba4d44aSLiu Zhe         //save to doc
195*eba4d44aSLiu Zhe         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
196*eba4d44aSLiu Zhe         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
197*eba4d44aSLiu Zhe         aStoreProperties_doc[0] = new PropertyValue();
198*eba4d44aSLiu Zhe         aStoreProperties_doc[1] = new PropertyValue();
199*eba4d44aSLiu Zhe         aStoreProperties_doc[0].Name = "Override";
200*eba4d44aSLiu Zhe         aStoreProperties_doc[0].Value = true;
201*eba4d44aSLiu Zhe         aStoreProperties_doc[1].Name = "FilterName";
202*eba4d44aSLiu Zhe         aStoreProperties_doc[1].Value = "MS Word 97";
203*eba4d44aSLiu Zhe         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
204*eba4d44aSLiu Zhe         app.closeDocument(xTextDocument);
205*eba4d44aSLiu Zhe 
206*eba4d44aSLiu Zhe         //reopen the document
207*eba4d44aSLiu Zhe         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
208*eba4d44aSLiu Zhe         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
209*eba4d44aSLiu Zhe         //verify paragraph text to text alignment
210*eba4d44aSLiu Zhe         assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.TOP,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment"));
211*eba4d44aSLiu Zhe 
212*eba4d44aSLiu Zhe         //reopen the document
213*eba4d44aSLiu Zhe         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
214*eba4d44aSLiu Zhe         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
215*eba4d44aSLiu Zhe         //verify paragraph text to text alignment
216*eba4d44aSLiu Zhe         assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.TOP,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment"));
217*eba4d44aSLiu Zhe     }
218*eba4d44aSLiu Zhe     @Test
219*eba4d44aSLiu Zhe     public void testTexttoTextAlignment_Automatic() throws Exception {
220*eba4d44aSLiu Zhe 
221*eba4d44aSLiu Zhe         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
222*eba4d44aSLiu Zhe         xText = xTextDocument.getText();
223*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!" +
224*eba4d44aSLiu Zhe                 "Hello,world!Hello,world!");
225*eba4d44aSLiu Zhe         // create text cursor for selecting and formatting text
226*eba4d44aSLiu Zhe         XTextCursor xTextCursor = xText.createTextCursor();
227*eba4d44aSLiu Zhe         XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
228*eba4d44aSLiu Zhe         xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.AUTOMATIC);
229*eba4d44aSLiu Zhe         //save to odt
230*eba4d44aSLiu Zhe         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
231*eba4d44aSLiu Zhe         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
232*eba4d44aSLiu Zhe         aStoreProperties_odt[0] = new PropertyValue();
233*eba4d44aSLiu Zhe         aStoreProperties_odt[1] = new PropertyValue();
234*eba4d44aSLiu Zhe         aStoreProperties_odt[0].Name = "Override";
235*eba4d44aSLiu Zhe         aStoreProperties_odt[0].Value = true;
236*eba4d44aSLiu Zhe         aStoreProperties_odt[1].Name = "FilterName";
237*eba4d44aSLiu Zhe         aStoreProperties_odt[1].Value = "StarOffice XML (Writer)";
238*eba4d44aSLiu Zhe         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
239*eba4d44aSLiu Zhe         //save to doc
240*eba4d44aSLiu Zhe         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
241*eba4d44aSLiu Zhe         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
242*eba4d44aSLiu Zhe         aStoreProperties_doc[0] = new PropertyValue();
243*eba4d44aSLiu Zhe         aStoreProperties_doc[1] = new PropertyValue();
244*eba4d44aSLiu Zhe         aStoreProperties_doc[0].Name = "Override";
245*eba4d44aSLiu Zhe         aStoreProperties_doc[0].Value = true;
246*eba4d44aSLiu Zhe         aStoreProperties_doc[1].Name = "FilterName";
247*eba4d44aSLiu Zhe         aStoreProperties_doc[1].Value = "MS Word 97";
248*eba4d44aSLiu Zhe         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
249*eba4d44aSLiu Zhe         app.closeDocument(xTextDocument);
250*eba4d44aSLiu Zhe 
251*eba4d44aSLiu Zhe         //reopen the document
252*eba4d44aSLiu Zhe         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
253*eba4d44aSLiu Zhe         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
254*eba4d44aSLiu Zhe         //verify paragraph text to text alignment
255*eba4d44aSLiu Zhe         assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.AUTOMATIC,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment"));
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 text to text alignment
261*eba4d44aSLiu Zhe         assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.AUTOMATIC,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment"));
262*eba4d44aSLiu Zhe     }
263*eba4d44aSLiu Zhe }
264