107d7dbdcSHerbert Dürr /**************************************************************
207d7dbdcSHerbert Dürr  *
307d7dbdcSHerbert Dürr  * Licensed to the Apache Software Foundation (ASF) under one
407d7dbdcSHerbert Dürr  * or more contributor license agreements.  See the NOTICE file
507d7dbdcSHerbert Dürr  * distributed with this work for additional information
607d7dbdcSHerbert Dürr  * regarding copyright ownership.  The ASF licenses this file
707d7dbdcSHerbert Dürr  * to you under the Apache License, Version 2.0 (the
807d7dbdcSHerbert Dürr  * "License"); you may not use this file except in compliance
907d7dbdcSHerbert Dürr  * with the License.  You may obtain a copy of the License at
1007d7dbdcSHerbert Dürr  *
1107d7dbdcSHerbert Dürr  *   http://www.apache.org/licenses/LICENSE-2.0
1207d7dbdcSHerbert Dürr  *
1307d7dbdcSHerbert Dürr  * Unless required by applicable law or agreed to in writing,
1407d7dbdcSHerbert Dürr  * software distributed under the License is distributed on an
1507d7dbdcSHerbert Dürr  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1607d7dbdcSHerbert Dürr  * KIND, either express or implied.  See the License for the
1707d7dbdcSHerbert Dürr  * specific language governing permissions and limitations
1807d7dbdcSHerbert Dürr  * under the License.
1907d7dbdcSHerbert Dürr  *
2007d7dbdcSHerbert Dürr  *************************************************************/
2107d7dbdcSHerbert Dürr 
22eba4d44aSLiu Zhe package fvt.uno.sw.paragraph;
23294fe326SLiu Zhe 
24294fe326SLiu Zhe import static org.junit.Assert.*;
25294fe326SLiu Zhe 
26294fe326SLiu Zhe import org.junit.After;
27294fe326SLiu Zhe import org.junit.Before;
28294fe326SLiu Zhe import org.junit.Ignore;
29294fe326SLiu Zhe import org.junit.Test;
30294fe326SLiu Zhe import org.openoffice.test.common.FileUtil;
31294fe326SLiu Zhe import org.openoffice.test.common.Testspace;
32294fe326SLiu Zhe import org.openoffice.test.uno.UnoApp;
33294fe326SLiu Zhe 
34294fe326SLiu Zhe import com.sun.star.style.NumberingType;
35294fe326SLiu Zhe import com.sun.star.text.*;
36294fe326SLiu Zhe import com.sun.star.beans.*;
37294fe326SLiu Zhe import com.sun.star.container.XIndexAccess;
38294fe326SLiu Zhe import com.sun.star.container.XIndexReplace;
39294fe326SLiu Zhe import com.sun.star.frame.XStorable;
40294fe326SLiu Zhe import com.sun.star.lang.XMultiServiceFactory;
41294fe326SLiu Zhe import com.sun.star.uno.UnoRuntime;
42294fe326SLiu Zhe 
43294fe326SLiu Zhe public class ParagraphNumberingAndBullet_Numbering {
44294fe326SLiu Zhe 	private static final UnoApp app = new UnoApp();
45294fe326SLiu Zhe 	XText xText = null;
46294fe326SLiu Zhe 
47294fe326SLiu Zhe 	@Before
setUp()48294fe326SLiu Zhe 	public void setUp() throws Exception {
49294fe326SLiu Zhe 		app.start();
50294fe326SLiu Zhe 
51294fe326SLiu Zhe 	}
52294fe326SLiu Zhe 
53294fe326SLiu Zhe 	@After
tearDown()54294fe326SLiu Zhe 	public void tearDown() throws Exception {
55af986861SLiu Zhe 		app.close();
56294fe326SLiu Zhe 	}
57294fe326SLiu Zhe 	/*
58294fe326SLiu Zhe 	 * test paragraph background color
59294fe326SLiu Zhe 	 * 1.new a text document
60294fe326SLiu Zhe 	 * 2.insert some text
61294fe326SLiu Zhe 	 * 3.set paragraph numbering and bullet with numbering
62294fe326SLiu Zhe 	 * 4.save and close the document
63294fe326SLiu Zhe 	 * 5.reload the saved document and check the paragraph numbering bullet
64294fe326SLiu Zhe 	 */
65294fe326SLiu Zhe 	@Test
testNumberingBullet_ARABIC()66294fe326SLiu Zhe 	public void testNumberingBullet_ARABIC() throws Exception {
67294fe326SLiu Zhe 
68294fe326SLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
69294fe326SLiu Zhe 		xText = xTextDocument.getText();
70294fe326SLiu 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!" +
71294fe326SLiu Zhe 				"Hello,world!Hello,world!");
72*06fb39a1SJohn Bampton 		//create cursor to select paragraph and formatting paragraph
73294fe326SLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
74294fe326SLiu Zhe 		//create paragraph property set
75294fe326SLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
76294fe326SLiu Zhe 		//create document service factory
77294fe326SLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
78294fe326SLiu Zhe 		//set numbering character
79294fe326SLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
80294fe326SLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue()};
81294fe326SLiu Zhe 		propsRule[0].Name = "NumberingType";
82294fe326SLiu Zhe 		propsRule[0].Value = NumberingType.ARABIC;
83294fe326SLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
84294fe326SLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
85294fe326SLiu Zhe 		//set paragraph numbering and bullet character
86294fe326SLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
87294fe326SLiu Zhe 		//save to odt
88294fe326SLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
89294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
90294fe326SLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
91294fe326SLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
92294fe326SLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
93294fe326SLiu Zhe 		aStoreProperties_odt[0].Value = true;
94294fe326SLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
95294fe326SLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
96294fe326SLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
97294fe326SLiu Zhe 		//save to doc
98294fe326SLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
99294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
100294fe326SLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
101294fe326SLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
102294fe326SLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
103294fe326SLiu Zhe 		aStoreProperties_doc[0].Value = true;
104294fe326SLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
105294fe326SLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
106294fe326SLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
107294fe326SLiu Zhe 		app.closeDocument(xTextDocument);
108294fe326SLiu Zhe 
109294fe326SLiu Zhe 		//reopen the document
110294fe326SLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
111294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
112294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
113294fe326SLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
114294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
115294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
116294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
117294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value);
118294fe326SLiu Zhe 
119294fe326SLiu Zhe 		//reopen the document
120294fe326SLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
121294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
122294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
123294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
124294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
125294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
126294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value);
127294fe326SLiu Zhe 	}
128294fe326SLiu Zhe 	@Test
testNumberingBullet_ARABIC_Suffix()129294fe326SLiu Zhe 	public void testNumberingBullet_ARABIC_Suffix() throws Exception {
130294fe326SLiu Zhe 
131294fe326SLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
132294fe326SLiu Zhe 		xText = xTextDocument.getText();
133294fe326SLiu 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!" +
134294fe326SLiu Zhe 				"Hello,world!Hello,world!");
135*06fb39a1SJohn Bampton 		//create cursor to select paragraph and formatting paragraph
136294fe326SLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
137294fe326SLiu Zhe 		//create paragraph property set
138294fe326SLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
139294fe326SLiu Zhe 		//create document service factory
140294fe326SLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
141294fe326SLiu Zhe 		//set numbering character
142294fe326SLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
143294fe326SLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()};
144294fe326SLiu Zhe 		propsRule[0].Name = "NumberingType";
145294fe326SLiu Zhe 		propsRule[0].Value = NumberingType.ARABIC;
146294fe326SLiu Zhe 		propsRule[1].Name = "Suffix";
147294fe326SLiu Zhe 		propsRule[1].Value = ")";
148294fe326SLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
149294fe326SLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
150294fe326SLiu Zhe 		//set paragraph numbering and bullet character
151294fe326SLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
152294fe326SLiu Zhe 		//save to odt
153294fe326SLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
154294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
155294fe326SLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
156294fe326SLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
157294fe326SLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
158294fe326SLiu Zhe 		aStoreProperties_odt[0].Value = true;
159294fe326SLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
160294fe326SLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
161294fe326SLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
162294fe326SLiu Zhe 		//save to doc
163294fe326SLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
164294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
165294fe326SLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
166294fe326SLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
167294fe326SLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
168294fe326SLiu Zhe 		aStoreProperties_doc[0].Value = true;
169294fe326SLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
170294fe326SLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
171294fe326SLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
172294fe326SLiu Zhe 		app.closeDocument(xTextDocument);
173294fe326SLiu Zhe 
174294fe326SLiu Zhe 		//reopen the document
175294fe326SLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
176294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
177294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
178294fe326SLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
179294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
180294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
181294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
182294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value);
183294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name);
184294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value);
185294fe326SLiu Zhe 
186294fe326SLiu Zhe 		//reopen the document
187294fe326SLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
188294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
189294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
190294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
191294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
192294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
193294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value);
194294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name);
195294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value);
196294fe326SLiu Zhe 	}
197294fe326SLiu Zhe 	@Test
testNumberingBullet_ARABIC_Preffix_Suffix()198294fe326SLiu Zhe 	public void testNumberingBullet_ARABIC_Preffix_Suffix() throws Exception {
199294fe326SLiu Zhe 
200294fe326SLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
201294fe326SLiu Zhe 		xText = xTextDocument.getText();
202294fe326SLiu 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!" +
203294fe326SLiu Zhe 				"Hello,world!Hello,world!");
204*06fb39a1SJohn Bampton 		//create cursor to select paragraph and formatting paragraph
205294fe326SLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
206294fe326SLiu Zhe 		//create paragraph property set
207294fe326SLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
208294fe326SLiu Zhe 		//create document service factory
209294fe326SLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
210294fe326SLiu Zhe 		//set numbering character
211294fe326SLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
212294fe326SLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue(),new PropertyValue()};
213294fe326SLiu Zhe 		propsRule[0].Name = "NumberingType";
214294fe326SLiu Zhe 		propsRule[0].Value = NumberingType.ARABIC;
215294fe326SLiu Zhe 		propsRule[1].Name = "Suffix";
216294fe326SLiu Zhe 		propsRule[1].Value = ")";
217294fe326SLiu Zhe 		propsRule[2].Name = "Prefix";
218294fe326SLiu Zhe 		propsRule[2].Value = "(";
219294fe326SLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
220294fe326SLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
221294fe326SLiu Zhe 		//set paragraph numbering and bullet character
222294fe326SLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
223294fe326SLiu Zhe 		//save to odt
224294fe326SLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
225294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
226294fe326SLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
227294fe326SLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
228294fe326SLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
229294fe326SLiu Zhe 		aStoreProperties_odt[0].Value = true;
230294fe326SLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
231294fe326SLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
232294fe326SLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
233294fe326SLiu Zhe 		//save to doc
234294fe326SLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
235294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
236294fe326SLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
237294fe326SLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
238294fe326SLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
239294fe326SLiu Zhe 		aStoreProperties_doc[0].Value = true;
240294fe326SLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
241294fe326SLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
242294fe326SLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
243294fe326SLiu Zhe 		app.closeDocument(xTextDocument);
244294fe326SLiu Zhe 
245294fe326SLiu Zhe 		//reopen the document
246294fe326SLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
247294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
248294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
249294fe326SLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
250294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
251294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
252294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
253294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value);
254294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name);
255294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value);
256294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Prefix",propsRule_assert_odt[2].Name);
257294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","(",propsRule_assert_odt[2].Value);
258294fe326SLiu Zhe 
259294fe326SLiu Zhe 		//reopen the document
260294fe326SLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
261294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
262294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
263294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
264294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
265294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
266294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value);
267294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name);
268294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value);
269294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Prefix",propsRule_assert_odt[2].Name);
270294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","(",propsRule_assert_odt[2].Value);
271294fe326SLiu Zhe 	}
272294fe326SLiu Zhe 	@Test
testNumberingBullet_ROMAN_LOWER()273294fe326SLiu Zhe 	public void testNumberingBullet_ROMAN_LOWER() throws Exception {
274294fe326SLiu Zhe 
275294fe326SLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
276294fe326SLiu Zhe 		xText = xTextDocument.getText();
277294fe326SLiu 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!" +
278294fe326SLiu Zhe 				"Hello,world!Hello,world!");
279*06fb39a1SJohn Bampton 		//create cursor to select paragraph and formatting paragraph
280294fe326SLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
281294fe326SLiu Zhe 		//create paragraph property set
282294fe326SLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
283294fe326SLiu Zhe 		//create document service factory
284294fe326SLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
285294fe326SLiu Zhe 		//set numbering character
286294fe326SLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
287294fe326SLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue()};
288294fe326SLiu Zhe 		propsRule[0].Name = "NumberingType";
289294fe326SLiu Zhe 		propsRule[0].Value = NumberingType.ROMAN_LOWER;
290294fe326SLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
291294fe326SLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
292294fe326SLiu Zhe 		//set paragraph numbering and bullet character
293294fe326SLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
294294fe326SLiu Zhe 		//save to odt
295294fe326SLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
296294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
297294fe326SLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
298294fe326SLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
299294fe326SLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
300294fe326SLiu Zhe 		aStoreProperties_odt[0].Value = true;
301294fe326SLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
302294fe326SLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
303294fe326SLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
304294fe326SLiu Zhe 		//save to doc
305294fe326SLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
306294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
307294fe326SLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
308294fe326SLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
309294fe326SLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
310294fe326SLiu Zhe 		aStoreProperties_doc[0].Value = true;
311294fe326SLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
312294fe326SLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
313294fe326SLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
314294fe326SLiu Zhe 		app.closeDocument(xTextDocument);
315294fe326SLiu Zhe 
316294fe326SLiu Zhe 		//reopen the document
317294fe326SLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
318294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
319294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
320294fe326SLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
321294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
322294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
323294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
324294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ROMAN_LOWER,propsRule_assert_odt[11].Value);
325294fe326SLiu Zhe 
326294fe326SLiu Zhe 		//reopen the document
327294fe326SLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
328294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
329294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
330294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
331294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
332294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
333294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ROMAN_LOWER,propsRule_assert_doc[11].Value);
334294fe326SLiu Zhe 	}
335294fe326SLiu Zhe 	@Test
testNumberingBullet_ROMAN_UPPER()336294fe326SLiu Zhe 	public void testNumberingBullet_ROMAN_UPPER() throws Exception {
337294fe326SLiu Zhe 
338294fe326SLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
339294fe326SLiu Zhe 		xText = xTextDocument.getText();
340294fe326SLiu 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!" +
341294fe326SLiu Zhe 				"Hello,world!Hello,world!");
342*06fb39a1SJohn Bampton 		//create cursor to select paragraph and formatting paragraph
343294fe326SLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
344294fe326SLiu Zhe 		//create paragraph property set
345294fe326SLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
346294fe326SLiu Zhe 		//create document service factory
347294fe326SLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
348294fe326SLiu Zhe 		//set numbering character
349294fe326SLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
350294fe326SLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue()};
351294fe326SLiu Zhe 		propsRule[0].Name = "NumberingType";
352294fe326SLiu Zhe 		propsRule[0].Value = NumberingType.ROMAN_UPPER;
353294fe326SLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
354294fe326SLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
355294fe326SLiu Zhe 		//set paragraph numbering and bullet character
356294fe326SLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
357294fe326SLiu Zhe 		//save to odt
358294fe326SLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
359294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
360294fe326SLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
361294fe326SLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
362294fe326SLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
363294fe326SLiu Zhe 		aStoreProperties_odt[0].Value = true;
364294fe326SLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
365294fe326SLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
366294fe326SLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
367294fe326SLiu Zhe 		//save to doc
368294fe326SLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
369294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
370294fe326SLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
371294fe326SLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
372294fe326SLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
373294fe326SLiu Zhe 		aStoreProperties_doc[0].Value = true;
374294fe326SLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
375294fe326SLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
376294fe326SLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
377294fe326SLiu Zhe 		app.closeDocument(xTextDocument);
378294fe326SLiu Zhe 
379294fe326SLiu Zhe 		//reopen the document
380294fe326SLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
381294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
382294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
383294fe326SLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
384294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
385294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
386294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
387294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ROMAN_UPPER,propsRule_assert_odt[11].Value);
388294fe326SLiu Zhe 
389294fe326SLiu Zhe 		//reopen the document
390294fe326SLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
391294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
392294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
393294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
394294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
395294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
396294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ROMAN_UPPER,propsRule_assert_doc[11].Value);
397294fe326SLiu Zhe 	}
398af986861SLiu Zhe 	@Test@Ignore("Bug #120826 - [testUNO patch]A,B,C numbering bullet will change to A,AA,AAA when save to doc.")
testNumberingBullet_CHARS_UPPER_LETTER()399294fe326SLiu Zhe 	public void testNumberingBullet_CHARS_UPPER_LETTER() throws Exception {
400294fe326SLiu Zhe 
401294fe326SLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
402294fe326SLiu Zhe 		xText = xTextDocument.getText();
403294fe326SLiu 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!" +
404294fe326SLiu Zhe 				"Hello,world!Hello,world!");
405*06fb39a1SJohn Bampton 		//create cursor to select paragraph and formatting paragraph
406294fe326SLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
407294fe326SLiu Zhe 		//create paragraph property set
408294fe326SLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
409294fe326SLiu Zhe 		//create document service factory
410294fe326SLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
411294fe326SLiu Zhe 		//set numbering character
412294fe326SLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
413294fe326SLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()};
414294fe326SLiu Zhe 		propsRule[0].Name = "NumberingType";
415294fe326SLiu Zhe 		propsRule[0].Value = NumberingType.CHARS_UPPER_LETTER;
416294fe326SLiu Zhe 		propsRule[1].Name = "Suffix";
417294fe326SLiu Zhe 		propsRule[1].Value = ")";
418294fe326SLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
419294fe326SLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
420294fe326SLiu Zhe 		//set paragraph numbering and bullet character
421294fe326SLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
422294fe326SLiu Zhe 		//save to odt
423294fe326SLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
424294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
425294fe326SLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
426294fe326SLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
427294fe326SLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
428294fe326SLiu Zhe 		aStoreProperties_odt[0].Value = true;
429294fe326SLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
430294fe326SLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
431294fe326SLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
432294fe326SLiu Zhe 		//save to doc
433294fe326SLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
434294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
435294fe326SLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
436294fe326SLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
437294fe326SLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
438294fe326SLiu Zhe 		aStoreProperties_doc[0].Value = true;
439294fe326SLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
440294fe326SLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
441294fe326SLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
442294fe326SLiu Zhe 		app.closeDocument(xTextDocument);
443294fe326SLiu Zhe 
444294fe326SLiu Zhe 		//reopen the document
445294fe326SLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
446294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
447294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
448294fe326SLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
449294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
450294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
451294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
452294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.CHARS_UPPER_LETTER,propsRule_assert_odt[11].Value);
453294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name);
454294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value);
455294fe326SLiu Zhe 
456294fe326SLiu Zhe 		//reopen the document
457294fe326SLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
458294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
459294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
460294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
461294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
462294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
463294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.CHARS_UPPER_LETTER,propsRule_assert_doc[11].Value);
464294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name);
465294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value);
466294fe326SLiu Zhe 	}
467af986861SLiu Zhe 	@Test@Ignore("Bug #120826 - [testUNO patch]A,B,C numbering bullet will change to A,AA,AAA when save to doc.")
testNumberingBullet_CHARS_LOWER_LETTER_Suffix()468294fe326SLiu Zhe 	public void testNumberingBullet_CHARS_LOWER_LETTER_Suffix() throws Exception {
469294fe326SLiu Zhe 
470294fe326SLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
471294fe326SLiu Zhe 		xText = xTextDocument.getText();
472294fe326SLiu 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!" +
473294fe326SLiu Zhe 				"Hello,world!Hello,world!");
474*06fb39a1SJohn Bampton 		//create cursor to select paragraph and formatting paragraph
475294fe326SLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
476294fe326SLiu Zhe 		//create paragraph property set
477294fe326SLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
478294fe326SLiu Zhe 		//create document service factory
479294fe326SLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
480294fe326SLiu Zhe 		//set numbering character
481294fe326SLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
482294fe326SLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()};
483294fe326SLiu Zhe 		propsRule[0].Name = "NumberingType";
484294fe326SLiu Zhe 		propsRule[0].Value = NumberingType.CHARS_LOWER_LETTER;
485294fe326SLiu Zhe 		propsRule[1].Name = "Suffix";
486294fe326SLiu Zhe 		propsRule[1].Value = ")";
487294fe326SLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
488294fe326SLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
489294fe326SLiu Zhe 		//set paragraph numbering and bullet character
490294fe326SLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
491294fe326SLiu Zhe 		//save to odt
492294fe326SLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
493294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
494294fe326SLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
495294fe326SLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
496294fe326SLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
497294fe326SLiu Zhe 		aStoreProperties_odt[0].Value = true;
498294fe326SLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
499294fe326SLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
500294fe326SLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
501294fe326SLiu Zhe 		//save to doc
502294fe326SLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
503294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
504294fe326SLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
505294fe326SLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
506294fe326SLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
507294fe326SLiu Zhe 		aStoreProperties_doc[0].Value = true;
508294fe326SLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
509294fe326SLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
510294fe326SLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
511294fe326SLiu Zhe 		app.closeDocument(xTextDocument);
512294fe326SLiu Zhe 
513294fe326SLiu Zhe 		//reopen the document
514294fe326SLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
515294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
516294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
517294fe326SLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
518294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
519294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
520294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
521294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_odt[11].Value);
522294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name);
523294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value);
524294fe326SLiu Zhe 
525294fe326SLiu Zhe 		//reopen the document
526294fe326SLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
527294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
528294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
529294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
530294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
531294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
532294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_doc[11].Value);
533294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name);
534294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value);
535294fe326SLiu Zhe 	}
536af986861SLiu Zhe 	@Test@Ignore("Bug #120826 - [testUNO patch]A,B,C numbering bullet will change to A,AA,AAA when save to doc.")
testNumberingBullet_CHARS_LOWER_LETTER_Suffix_Prefix()537294fe326SLiu Zhe 	public void testNumberingBullet_CHARS_LOWER_LETTER_Suffix_Prefix() throws Exception {
538294fe326SLiu Zhe 
539294fe326SLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
540294fe326SLiu Zhe 		xText = xTextDocument.getText();
541294fe326SLiu 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!" +
542294fe326SLiu Zhe 				"Hello,world!Hello,world!");
543*06fb39a1SJohn Bampton 		//create cursor to select paragraph and formatting paragraph
544294fe326SLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
545294fe326SLiu Zhe 		//create paragraph property set
546294fe326SLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
547294fe326SLiu Zhe 		//create document service factory
548294fe326SLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
549294fe326SLiu Zhe 		//set numbering character
550294fe326SLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
551294fe326SLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue(),new PropertyValue()};
552294fe326SLiu Zhe 		propsRule[0].Name = "NumberingType";
553294fe326SLiu Zhe 		propsRule[0].Value = NumberingType.CHARS_LOWER_LETTER;
554294fe326SLiu Zhe 		propsRule[1].Name = "Suffix";
555294fe326SLiu Zhe 		propsRule[1].Value = ")";
556294fe326SLiu Zhe 		propsRule[2].Name = "Prefix";
557294fe326SLiu Zhe 		propsRule[2].Value = "(";
558294fe326SLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
559294fe326SLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
560294fe326SLiu Zhe 		//set paragraph numbering and bullet character
561294fe326SLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
562294fe326SLiu Zhe 		//save to odt
563294fe326SLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
564294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
565294fe326SLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
566294fe326SLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
567294fe326SLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
568294fe326SLiu Zhe 		aStoreProperties_odt[0].Value = true;
569294fe326SLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
570294fe326SLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
571294fe326SLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
572294fe326SLiu Zhe 		//save to doc
573294fe326SLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
574294fe326SLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
575294fe326SLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
576294fe326SLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
577294fe326SLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
578294fe326SLiu Zhe 		aStoreProperties_doc[0].Value = true;
579294fe326SLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
580294fe326SLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
581294fe326SLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
582294fe326SLiu Zhe 		app.closeDocument(xTextDocument);
583294fe326SLiu Zhe 
584294fe326SLiu Zhe 		//reopen the document
585294fe326SLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
586294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
587294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
588294fe326SLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
589294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
590294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
591294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
592294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_odt[11].Value);
593294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name);
594294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value);
595294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Prefix",propsRule_assert_odt[2].Name);
596294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","(",propsRule_assert_odt[2].Value);
597294fe326SLiu Zhe 
598294fe326SLiu Zhe 		//reopen the document
599294fe326SLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
600294fe326SLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
601294fe326SLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
602294fe326SLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
603294fe326SLiu Zhe 		//verify paragraph numbering and bullet alignment
604294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
605294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_doc[11].Value);
606294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name);
607294fe326SLiu Zhe 		assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value);
608294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","Prefix",propsRule_assert_doc[2].Name);
609294fe326SLiu Zhe 		assertEquals("assert numbering and bullet","(",propsRule_assert_doc[2].Value);
610294fe326SLiu Zhe 	}
611294fe326SLiu Zhe }
612