xref: /trunk/test/testuno/source/fvt/uno/sw/paragraph/ParagraphNumberingAndBullet_Numbering.java (revision a7b613a6af1cb6c17f72fb50272cb23f0021e01b)
1 package fvt.uno.sw.paragraph;
2 
3 import static org.junit.Assert.*;
4 
5 import org.junit.After;
6 import org.junit.Before;
7 import org.junit.Ignore;
8 import org.junit.Test;
9 import org.openoffice.test.common.FileUtil;
10 import org.openoffice.test.common.Testspace;
11 import org.openoffice.test.uno.UnoApp;
12 
13 import com.sun.star.style.NumberingType;
14 import com.sun.star.text.*;
15 import com.sun.star.beans.*;
16 import com.sun.star.container.XIndexAccess;
17 import com.sun.star.container.XIndexReplace;
18 import com.sun.star.frame.XStorable;
19 import com.sun.star.lang.XMultiServiceFactory;
20 import com.sun.star.uno.UnoRuntime;
21 
22 public class ParagraphNumberingAndBullet_Numbering {
23     private static final UnoApp app = new UnoApp();
24     XText xText = null;
25 
26     @Before
27     public void setUp() throws Exception {
28         app.start();
29 
30     }
31 
32     @After
33     public void tearDown() throws Exception {
34         app.close();
35     }
36     /*
37      * test paragraph background color
38      * 1.new a text document
39      * 2.insert some text
40      * 3.set paragraph numbering and bullet with numbering
41      * 4.save and close the document
42      * 5.reload the saved document and check the paragraph numbering bullet
43      */
44     @Test
45     public void testNumberingBullet_ARABIC() throws Exception {
46 
47         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
48         xText = xTextDocument.getText();
49         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!" +
50                 "Hello,world!Hello,world!");
51         //create cursor to select paragraph and formating paragraph
52         XTextCursor xTextCursor = xText.createTextCursor();
53         //create paragraph property set
54         XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
55         //create document service factory
56         XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
57         //set numbering character
58         XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
59         PropertyValue[] propsRule = {new PropertyValue()};
60         propsRule[0].Name = "NumberingType";
61         propsRule[0].Value = NumberingType.ARABIC;
62         XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
63         xReplaceRule.replaceByIndex(0, propsRule);
64         //set paragraph numbering and bullet character
65         xTextProps.setPropertyValue("NumberingRules", xNumRule);
66         //save to odt
67         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
68         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
69         aStoreProperties_odt[0] = new PropertyValue();
70         aStoreProperties_odt[1] = new PropertyValue();
71         aStoreProperties_odt[0].Name = "Override";
72         aStoreProperties_odt[0].Value = true;
73         aStoreProperties_odt[1].Name = "FilterName";
74         aStoreProperties_odt[1].Value = "writer8";
75         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
76         //save to doc
77         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
78         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
79         aStoreProperties_doc[0] = new PropertyValue();
80         aStoreProperties_doc[1] = new PropertyValue();
81         aStoreProperties_doc[0].Name = "Override";
82         aStoreProperties_doc[0].Value = true;
83         aStoreProperties_doc[1].Name = "FilterName";
84         aStoreProperties_doc[1].Value = "MS Word 97";
85         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
86         app.closeDocument(xTextDocument);
87 
88         //reopen the document
89         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
90         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
91         XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
92         XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
93         PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
94         //verify paragraph numbering and bullet alignment
95         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
96         assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value);
97 
98         //reopen the document
99         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
100         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
101         XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
102         PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
103         //verify paragraph numbering and bullet alignment
104         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
105         assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value);
106     }
107     @Test
108     public void testNumberingBullet_ARABIC_Suffix() throws Exception {
109 
110         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
111         xText = xTextDocument.getText();
112         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!" +
113                 "Hello,world!Hello,world!");
114         //create cursor to select paragraph and formating paragraph
115         XTextCursor xTextCursor = xText.createTextCursor();
116         //create paragraph property set
117         XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
118         //create document service factory
119         XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
120         //set numbering character
121         XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
122         PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()};
123         propsRule[0].Name = "NumberingType";
124         propsRule[0].Value = NumberingType.ARABIC;
125         propsRule[1].Name = "Suffix";
126         propsRule[1].Value = ")";
127         XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
128         xReplaceRule.replaceByIndex(0, propsRule);
129         //set paragraph numbering and bullet character
130         xTextProps.setPropertyValue("NumberingRules", xNumRule);
131         //save to odt
132         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
133         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
134         aStoreProperties_odt[0] = new PropertyValue();
135         aStoreProperties_odt[1] = new PropertyValue();
136         aStoreProperties_odt[0].Name = "Override";
137         aStoreProperties_odt[0].Value = true;
138         aStoreProperties_odt[1].Name = "FilterName";
139         aStoreProperties_odt[1].Value = "writer8";
140         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
141         //save to doc
142         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
143         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
144         aStoreProperties_doc[0] = new PropertyValue();
145         aStoreProperties_doc[1] = new PropertyValue();
146         aStoreProperties_doc[0].Name = "Override";
147         aStoreProperties_doc[0].Value = true;
148         aStoreProperties_doc[1].Name = "FilterName";
149         aStoreProperties_doc[1].Value = "MS Word 97";
150         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
151         app.closeDocument(xTextDocument);
152 
153         //reopen the document
154         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
155         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
156         XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
157         XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
158         PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
159         //verify paragraph numbering and bullet alignment
160         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
161         assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value);
162         assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name);
163         assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value);
164 
165         //reopen the document
166         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
167         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
168         XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
169         PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
170         //verify paragraph numbering and bullet alignment
171         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
172         assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value);
173         assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name);
174         assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value);
175     }
176     @Test
177     public void testNumberingBullet_ARABIC_Preffix_Suffix() throws Exception {
178 
179         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
180         xText = xTextDocument.getText();
181         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!" +
182                 "Hello,world!Hello,world!");
183         //create cursor to select paragraph and formating paragraph
184         XTextCursor xTextCursor = xText.createTextCursor();
185         //create paragraph property set
186         XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
187         //create document service factory
188         XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
189         //set numbering character
190         XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
191         PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue(),new PropertyValue()};
192         propsRule[0].Name = "NumberingType";
193         propsRule[0].Value = NumberingType.ARABIC;
194         propsRule[1].Name = "Suffix";
195         propsRule[1].Value = ")";
196         propsRule[2].Name = "Prefix";
197         propsRule[2].Value = "(";
198         XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
199         xReplaceRule.replaceByIndex(0, propsRule);
200         //set paragraph numbering and bullet character
201         xTextProps.setPropertyValue("NumberingRules", xNumRule);
202         //save to odt
203         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
204         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
205         aStoreProperties_odt[0] = new PropertyValue();
206         aStoreProperties_odt[1] = new PropertyValue();
207         aStoreProperties_odt[0].Name = "Override";
208         aStoreProperties_odt[0].Value = true;
209         aStoreProperties_odt[1].Name = "FilterName";
210         aStoreProperties_odt[1].Value = "writer8";
211         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
212         //save to doc
213         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
214         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
215         aStoreProperties_doc[0] = new PropertyValue();
216         aStoreProperties_doc[1] = new PropertyValue();
217         aStoreProperties_doc[0].Name = "Override";
218         aStoreProperties_doc[0].Value = true;
219         aStoreProperties_doc[1].Name = "FilterName";
220         aStoreProperties_doc[1].Value = "MS Word 97";
221         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
222         app.closeDocument(xTextDocument);
223 
224         //reopen the document
225         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
226         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
227         XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
228         XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
229         PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
230         //verify paragraph numbering and bullet alignment
231         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
232         assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value);
233         assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name);
234         assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value);
235         assertEquals("assert numbering and bullet","Prefix",propsRule_assert_odt[2].Name);
236         assertEquals("assert numbering and bullet","(",propsRule_assert_odt[2].Value);
237 
238         //reopen the document
239         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
240         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
241         XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
242         PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
243         //verify paragraph numbering and bullet alignment
244         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
245         assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value);
246         assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name);
247         assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value);
248         assertEquals("assert numbering and bullet","Prefix",propsRule_assert_odt[2].Name);
249         assertEquals("assert numbering and bullet","(",propsRule_assert_odt[2].Value);
250     }
251     @Test
252     public void testNumberingBullet_ROMAN_LOWER() throws Exception {
253 
254         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
255         xText = xTextDocument.getText();
256         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!" +
257                 "Hello,world!Hello,world!");
258         //create cursor to select paragraph and formating paragraph
259         XTextCursor xTextCursor = xText.createTextCursor();
260         //create paragraph property set
261         XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
262         //create document service factory
263         XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
264         //set numbering character
265         XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
266         PropertyValue[] propsRule = {new PropertyValue()};
267         propsRule[0].Name = "NumberingType";
268         propsRule[0].Value = NumberingType.ROMAN_LOWER;
269         XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
270         xReplaceRule.replaceByIndex(0, propsRule);
271         //set paragraph numbering and bullet character
272         xTextProps.setPropertyValue("NumberingRules", xNumRule);
273         //save to odt
274         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
275         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
276         aStoreProperties_odt[0] = new PropertyValue();
277         aStoreProperties_odt[1] = new PropertyValue();
278         aStoreProperties_odt[0].Name = "Override";
279         aStoreProperties_odt[0].Value = true;
280         aStoreProperties_odt[1].Name = "FilterName";
281         aStoreProperties_odt[1].Value = "writer8";
282         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
283         //save to doc
284         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
285         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
286         aStoreProperties_doc[0] = new PropertyValue();
287         aStoreProperties_doc[1] = new PropertyValue();
288         aStoreProperties_doc[0].Name = "Override";
289         aStoreProperties_doc[0].Value = true;
290         aStoreProperties_doc[1].Name = "FilterName";
291         aStoreProperties_doc[1].Value = "MS Word 97";
292         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
293         app.closeDocument(xTextDocument);
294 
295         //reopen the document
296         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
297         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
298         XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
299         XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
300         PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
301         //verify paragraph numbering and bullet alignment
302         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
303         assertEquals("assert numbering and bullet",NumberingType.ROMAN_LOWER,propsRule_assert_odt[11].Value);
304 
305         //reopen the document
306         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
307         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
308         XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
309         PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
310         //verify paragraph numbering and bullet alignment
311         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
312         assertEquals("assert numbering and bullet",NumberingType.ROMAN_LOWER,propsRule_assert_doc[11].Value);
313     }
314     @Test
315     public void testNumberingBullet_ROMAN_UPPER() throws Exception {
316 
317         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
318         xText = xTextDocument.getText();
319         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!" +
320                 "Hello,world!Hello,world!");
321         //create cursor to select paragraph and formating paragraph
322         XTextCursor xTextCursor = xText.createTextCursor();
323         //create paragraph property set
324         XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
325         //create document service factory
326         XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
327         //set numbering character
328         XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
329         PropertyValue[] propsRule = {new PropertyValue()};
330         propsRule[0].Name = "NumberingType";
331         propsRule[0].Value = NumberingType.ROMAN_UPPER;
332         XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
333         xReplaceRule.replaceByIndex(0, propsRule);
334         //set paragraph numbering and bullet character
335         xTextProps.setPropertyValue("NumberingRules", xNumRule);
336         //save to odt
337         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
338         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
339         aStoreProperties_odt[0] = new PropertyValue();
340         aStoreProperties_odt[1] = new PropertyValue();
341         aStoreProperties_odt[0].Name = "Override";
342         aStoreProperties_odt[0].Value = true;
343         aStoreProperties_odt[1].Name = "FilterName";
344         aStoreProperties_odt[1].Value = "writer8";
345         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
346         //save to doc
347         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
348         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
349         aStoreProperties_doc[0] = new PropertyValue();
350         aStoreProperties_doc[1] = new PropertyValue();
351         aStoreProperties_doc[0].Name = "Override";
352         aStoreProperties_doc[0].Value = true;
353         aStoreProperties_doc[1].Name = "FilterName";
354         aStoreProperties_doc[1].Value = "MS Word 97";
355         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
356         app.closeDocument(xTextDocument);
357 
358         //reopen the document
359         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
360         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
361         XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
362         XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
363         PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
364         //verify paragraph numbering and bullet alignment
365         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
366         assertEquals("assert numbering and bullet",NumberingType.ROMAN_UPPER,propsRule_assert_odt[11].Value);
367 
368         //reopen the document
369         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
370         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
371         XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
372         PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
373         //verify paragraph numbering and bullet alignment
374         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
375         assertEquals("assert numbering and bullet",NumberingType.ROMAN_UPPER,propsRule_assert_doc[11].Value);
376     }
377     @Test@Ignore("Bug #120826 - [testUNO patch]A,B,C numbering bullet will change to A,AA,AAA when save to doc.")
378     public void testNumberingBullet_CHARS_UPPER_LETTER() throws Exception {
379 
380         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
381         xText = xTextDocument.getText();
382         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!" +
383                 "Hello,world!Hello,world!");
384         //create cursor to select paragraph and formating paragraph
385         XTextCursor xTextCursor = xText.createTextCursor();
386         //create paragraph property set
387         XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
388         //create document service factory
389         XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
390         //set numbering character
391         XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
392         PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()};
393         propsRule[0].Name = "NumberingType";
394         propsRule[0].Value = NumberingType.CHARS_UPPER_LETTER;
395         propsRule[1].Name = "Suffix";
396         propsRule[1].Value = ")";
397         XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
398         xReplaceRule.replaceByIndex(0, propsRule);
399         //set paragraph numbering and bullet character
400         xTextProps.setPropertyValue("NumberingRules", xNumRule);
401         //save to odt
402         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
403         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
404         aStoreProperties_odt[0] = new PropertyValue();
405         aStoreProperties_odt[1] = new PropertyValue();
406         aStoreProperties_odt[0].Name = "Override";
407         aStoreProperties_odt[0].Value = true;
408         aStoreProperties_odt[1].Name = "FilterName";
409         aStoreProperties_odt[1].Value = "writer8";
410         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
411         //save to doc
412         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
413         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
414         aStoreProperties_doc[0] = new PropertyValue();
415         aStoreProperties_doc[1] = new PropertyValue();
416         aStoreProperties_doc[0].Name = "Override";
417         aStoreProperties_doc[0].Value = true;
418         aStoreProperties_doc[1].Name = "FilterName";
419         aStoreProperties_doc[1].Value = "MS Word 97";
420         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
421         app.closeDocument(xTextDocument);
422 
423         //reopen the document
424         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
425         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
426         XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
427         XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
428         PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
429         //verify paragraph numbering and bullet alignment
430         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
431         assertEquals("assert numbering and bullet",NumberingType.CHARS_UPPER_LETTER,propsRule_assert_odt[11].Value);
432         assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name);
433         assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value);
434 
435         //reopen the document
436         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
437         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
438         XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
439         PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
440         //verify paragraph numbering and bullet alignment
441         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
442         assertEquals("assert numbering and bullet",NumberingType.CHARS_UPPER_LETTER,propsRule_assert_doc[11].Value);
443         assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name);
444         assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value);
445     }
446     @Test@Ignore("Bug #120826 - [testUNO patch]A,B,C numbering bullet will change to A,AA,AAA when save to doc.")
447     public void testNumberingBullet_CHARS_LOWER_LETTER_Suffix() throws Exception {
448 
449         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
450         xText = xTextDocument.getText();
451         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!" +
452                 "Hello,world!Hello,world!");
453         //create cursor to select paragraph and formating paragraph
454         XTextCursor xTextCursor = xText.createTextCursor();
455         //create paragraph property set
456         XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
457         //create document service factory
458         XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
459         //set numbering character
460         XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
461         PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()};
462         propsRule[0].Name = "NumberingType";
463         propsRule[0].Value = NumberingType.CHARS_LOWER_LETTER;
464         propsRule[1].Name = "Suffix";
465         propsRule[1].Value = ")";
466         XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
467         xReplaceRule.replaceByIndex(0, propsRule);
468         //set paragraph numbering and bullet character
469         xTextProps.setPropertyValue("NumberingRules", xNumRule);
470         //save to odt
471         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
472         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
473         aStoreProperties_odt[0] = new PropertyValue();
474         aStoreProperties_odt[1] = new PropertyValue();
475         aStoreProperties_odt[0].Name = "Override";
476         aStoreProperties_odt[0].Value = true;
477         aStoreProperties_odt[1].Name = "FilterName";
478         aStoreProperties_odt[1].Value = "writer8";
479         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
480         //save to doc
481         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
482         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
483         aStoreProperties_doc[0] = new PropertyValue();
484         aStoreProperties_doc[1] = new PropertyValue();
485         aStoreProperties_doc[0].Name = "Override";
486         aStoreProperties_doc[0].Value = true;
487         aStoreProperties_doc[1].Name = "FilterName";
488         aStoreProperties_doc[1].Value = "MS Word 97";
489         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
490         app.closeDocument(xTextDocument);
491 
492         //reopen the document
493         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
494         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
495         XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
496         XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
497         PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
498         //verify paragraph numbering and bullet alignment
499         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
500         assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_odt[11].Value);
501         assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name);
502         assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value);
503 
504         //reopen the document
505         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
506         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
507         XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
508         PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
509         //verify paragraph numbering and bullet alignment
510         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
511         assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_doc[11].Value);
512         assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name);
513         assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value);
514     }
515     @Test@Ignore("Bug #120826 - [testUNO patch]A,B,C numbering bullet will change to A,AA,AAA when save to doc.")
516     public void testNumberingBullet_CHARS_LOWER_LETTER_Suffix_Prefix() throws Exception {
517 
518         XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
519         xText = xTextDocument.getText();
520         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!" +
521                 "Hello,world!Hello,world!");
522         //create cursor to select paragraph and formating paragraph
523         XTextCursor xTextCursor = xText.createTextCursor();
524         //create paragraph property set
525         XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
526         //create document service factory
527         XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
528         //set numbering character
529         XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
530         PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue(),new PropertyValue()};
531         propsRule[0].Name = "NumberingType";
532         propsRule[0].Value = NumberingType.CHARS_LOWER_LETTER;
533         propsRule[1].Name = "Suffix";
534         propsRule[1].Value = ")";
535         propsRule[2].Name = "Prefix";
536         propsRule[2].Value = "(";
537         XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
538         xReplaceRule.replaceByIndex(0, propsRule);
539         //set paragraph numbering and bullet character
540         xTextProps.setPropertyValue("NumberingRules", xNumRule);
541         //save to odt
542         XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
543         PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
544         aStoreProperties_odt[0] = new PropertyValue();
545         aStoreProperties_odt[1] = new PropertyValue();
546         aStoreProperties_odt[0].Name = "Override";
547         aStoreProperties_odt[0].Value = true;
548         aStoreProperties_odt[1].Name = "FilterName";
549         aStoreProperties_odt[1].Value = "writer8";
550         xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
551         //save to doc
552         XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
553         PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
554         aStoreProperties_doc[0] = new PropertyValue();
555         aStoreProperties_doc[1] = new PropertyValue();
556         aStoreProperties_doc[0].Name = "Override";
557         aStoreProperties_doc[0].Value = true;
558         aStoreProperties_doc[1].Name = "FilterName";
559         aStoreProperties_doc[1].Value = "MS Word 97";
560         xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
561         app.closeDocument(xTextDocument);
562 
563         //reopen the document
564         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
565         XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
566         XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
567         XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
568         PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
569         //verify paragraph numbering and bullet alignment
570         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
571         assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_odt[11].Value);
572         assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name);
573         assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value);
574         assertEquals("assert numbering and bullet","Prefix",propsRule_assert_odt[2].Name);
575         assertEquals("assert numbering and bullet","(",propsRule_assert_odt[2].Value);
576 
577         //reopen the document
578         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
579         XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
580         XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
581         PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
582         //verify paragraph numbering and bullet alignment
583         assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
584         assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_doc[11].Value);
585         assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name);
586         assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value);
587         assertEquals("assert numbering and bullet","Prefix",propsRule_assert_doc[2].Name);
588         assertEquals("assert numbering and bullet","(",propsRule_assert_doc[2].Value);
589     }
590 }
591