1*07d7dbdcSHerbert Dürr /**************************************************************
2*07d7dbdcSHerbert Dürr  *
3*07d7dbdcSHerbert Dürr  * Licensed to the Apache Software Foundation (ASF) under one
4*07d7dbdcSHerbert Dürr  * or more contributor license agreements.  See the NOTICE file
5*07d7dbdcSHerbert Dürr  * distributed with this work for additional information
6*07d7dbdcSHerbert Dürr  * regarding copyright ownership.  The ASF licenses this file
7*07d7dbdcSHerbert Dürr  * to you under the Apache License, Version 2.0 (the
8*07d7dbdcSHerbert Dürr  * "License"); you may not use this file except in compliance
9*07d7dbdcSHerbert Dürr  * with the License.  You may obtain a copy of the License at
10*07d7dbdcSHerbert Dürr  *
11*07d7dbdcSHerbert Dürr  *   http://www.apache.org/licenses/LICENSE-2.0
12*07d7dbdcSHerbert Dürr  *
13*07d7dbdcSHerbert Dürr  * Unless required by applicable law or agreed to in writing,
14*07d7dbdcSHerbert Dürr  * software distributed under the License is distributed on an
15*07d7dbdcSHerbert Dürr  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*07d7dbdcSHerbert Dürr  * KIND, either express or implied.  See the License for the
17*07d7dbdcSHerbert Dürr  * specific language governing permissions and limitations
18*07d7dbdcSHerbert Dürr  * under the License.
19*07d7dbdcSHerbert Dürr  *
20*07d7dbdcSHerbert Dürr  *************************************************************/
21*07d7dbdcSHerbert Dürr 
22eba4d44aSLiu Zhe package fvt.uno.sw.paragraph;
234a089d9bSLiu Zhe 
244a089d9bSLiu Zhe import static org.junit.Assert.*;
254a089d9bSLiu Zhe 
264a089d9bSLiu Zhe import org.junit.After;
274a089d9bSLiu Zhe import org.junit.Before;
284a089d9bSLiu Zhe import org.junit.Test;
294a089d9bSLiu Zhe import org.openoffice.test.common.FileUtil;
304a089d9bSLiu Zhe import org.openoffice.test.common.Testspace;
314a089d9bSLiu Zhe import org.openoffice.test.uno.UnoApp;
324a089d9bSLiu Zhe 
334a089d9bSLiu Zhe import com.sun.star.style.NumberingType;
344a089d9bSLiu Zhe import com.sun.star.text.*;
354a089d9bSLiu Zhe import com.sun.star.beans.*;
364a089d9bSLiu Zhe import com.sun.star.container.XIndexAccess;
374a089d9bSLiu Zhe import com.sun.star.container.XIndexReplace;
384a089d9bSLiu Zhe import com.sun.star.frame.XStorable;
394a089d9bSLiu Zhe import com.sun.star.lang.XMultiServiceFactory;
404a089d9bSLiu Zhe import com.sun.star.uno.UnoRuntime;
414a089d9bSLiu Zhe 
424a089d9bSLiu Zhe public class ParagraphNumberingAndBulletAlignment {
434a089d9bSLiu Zhe 	private static final UnoApp app = new UnoApp();
444a089d9bSLiu Zhe 	XText xText = null;
454a089d9bSLiu Zhe 
464a089d9bSLiu Zhe 	@Before
setUp()474a089d9bSLiu Zhe 	public void setUp() throws Exception {
484a089d9bSLiu Zhe 		app.start();
494a089d9bSLiu Zhe 
504a089d9bSLiu Zhe 	}
514a089d9bSLiu Zhe 
524a089d9bSLiu Zhe 	@After
tearDown()534a089d9bSLiu Zhe 	public void tearDown() throws Exception {
544a089d9bSLiu Zhe 		app.close();
554a089d9bSLiu Zhe 	}
564a089d9bSLiu Zhe 	/*
574a089d9bSLiu Zhe 	 * test paragraph background color
584a089d9bSLiu Zhe 	 * 1.new a text document
594a089d9bSLiu Zhe 	 * 2.insert some text
604a089d9bSLiu Zhe 	 * 3.set paragraph numbering alignment
614a089d9bSLiu Zhe 	 * 4.save and close the document
624a089d9bSLiu Zhe 	 * 5.reload the saved document and check the paragraph numbering alignment
634a089d9bSLiu Zhe 	 */
644a089d9bSLiu Zhe 	@Test
testNumberingBulletAlign_Right()654a089d9bSLiu Zhe 	public void testNumberingBulletAlign_Right() throws Exception {
664a089d9bSLiu Zhe 
674a089d9bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
684a089d9bSLiu Zhe 		xText = xTextDocument.getText();
694a089d9bSLiu Zhe 		xText.setString("we are Chinese,they are American.\nwe are all living in one earth!\nHello,world!Hello,world!Hello,world!\nHello,world!Hello,world!Hello,world!" +
704a089d9bSLiu Zhe 				"Hello,world!Hello,world!");
714a089d9bSLiu Zhe 		//create cursor to select paragraph and formating paragraph
724a089d9bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
734a089d9bSLiu Zhe 		//create paragraph property set
744a089d9bSLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
754a089d9bSLiu Zhe 		//create document service factory
764a089d9bSLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
774a089d9bSLiu Zhe 		//set numbering character
784a089d9bSLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
794a089d9bSLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()};
804a089d9bSLiu Zhe 		propsRule[1].Name = "NumberingType";
814a089d9bSLiu Zhe 		propsRule[1].Value = NumberingType.ARABIC;
824a089d9bSLiu Zhe 		propsRule[0].Name = "Adjust";
834a089d9bSLiu Zhe 		propsRule[0].Value = HoriOrientation.RIGHT;
844a089d9bSLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
854a089d9bSLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
864a089d9bSLiu Zhe 		//set paragraph numbering and bullet character
874a089d9bSLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
884a089d9bSLiu Zhe 		//save to odt
894a089d9bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
904a089d9bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
914a089d9bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
924a089d9bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
934a089d9bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
944a089d9bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
954a089d9bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
964a089d9bSLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
974a089d9bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
984a089d9bSLiu Zhe 		//save to doc
994a089d9bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
1004a089d9bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
1014a089d9bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
1024a089d9bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
1034a089d9bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
1044a089d9bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
1054a089d9bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
1064a089d9bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
1074a089d9bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
1084a089d9bSLiu Zhe 		app.closeDocument(xTextDocument);
1094a089d9bSLiu Zhe 
1104a089d9bSLiu Zhe 		//reopen the document
1114a089d9bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
1124a089d9bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
1134a089d9bSLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
1144a089d9bSLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
1154a089d9bSLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
1164a089d9bSLiu Zhe 		//verify paragraph numbering and bullet alignment
1174a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","Adjust",propsRule_assert_odt[0].Name);
1184a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",HoriOrientation.RIGHT,propsRule_assert_odt[0].Value);
1194a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
1204a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value);
1214a089d9bSLiu Zhe 
1224a089d9bSLiu Zhe 		//reopen the document
1234a089d9bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
1244a089d9bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
1254a089d9bSLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
1264a089d9bSLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
1274a089d9bSLiu Zhe 		//verify paragraph numbering and bullet alignment
1284a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","Adjust",propsRule_assert_doc[0].Name);
1294a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",HoriOrientation.RIGHT,propsRule_assert_doc[0].Value);
1304a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
1314a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value);
1324a089d9bSLiu Zhe 	}
1334a089d9bSLiu Zhe 	@Test
testNumberingBulletAlign_Left()1344a089d9bSLiu Zhe 	public void testNumberingBulletAlign_Left() throws Exception {
1354a089d9bSLiu Zhe 
1364a089d9bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
1374a089d9bSLiu Zhe 		xText = xTextDocument.getText();
1384a089d9bSLiu Zhe 		xText.setString("we are Chinese,they are American.\nwe are all living in one earth!\nHello,world!Hello,world!Hello,world!\nHello,world!Hello,world!Hello,world!" +
1394a089d9bSLiu Zhe 				"Hello,world!Hello,world!");
1404a089d9bSLiu Zhe 		//create cursor to select paragraph and formating paragraph
1414a089d9bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
1424a089d9bSLiu Zhe 		//create paragraph property set
1434a089d9bSLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
1444a089d9bSLiu Zhe 		//create document service factory
1454a089d9bSLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
1464a089d9bSLiu Zhe 		//set numbering character
1474a089d9bSLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
1484a089d9bSLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()};
1494a089d9bSLiu Zhe 		propsRule[1].Name = "NumberingType";
1504a089d9bSLiu Zhe 		propsRule[1].Value = NumberingType.ARABIC;
1514a089d9bSLiu Zhe 		propsRule[0].Name = "Adjust";
1524a089d9bSLiu Zhe 		propsRule[0].Value = HoriOrientation.LEFT;
1534a089d9bSLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
1544a089d9bSLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
1554a089d9bSLiu Zhe 		//set paragraph numbering and bullet character
1564a089d9bSLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
1574a089d9bSLiu Zhe 		//save to odt
1584a089d9bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
1594a089d9bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
1604a089d9bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
1614a089d9bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
1624a089d9bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
1634a089d9bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
1644a089d9bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
1654a089d9bSLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
1664a089d9bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
1674a089d9bSLiu Zhe 		//save to doc
1684a089d9bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
1694a089d9bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
1704a089d9bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
1714a089d9bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
1724a089d9bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
1734a089d9bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
1744a089d9bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
1754a089d9bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
1764a089d9bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
1774a089d9bSLiu Zhe 		app.closeDocument(xTextDocument);
1784a089d9bSLiu Zhe 
1794a089d9bSLiu Zhe 		//reopen the document
1804a089d9bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
1814a089d9bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
1824a089d9bSLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
1834a089d9bSLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
1844a089d9bSLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
1854a089d9bSLiu Zhe 		//verify paragraph numbering and bullet alignment
1864a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","Adjust",propsRule_assert_odt[0].Name);
1874a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",HoriOrientation.LEFT,propsRule_assert_odt[0].Value);
1884a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
1894a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value);
1904a089d9bSLiu Zhe 
1914a089d9bSLiu Zhe 		//reopen the document
1924a089d9bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
1934a089d9bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
1944a089d9bSLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
1954a089d9bSLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
1964a089d9bSLiu Zhe 		//verify paragraph numbering and bullet alignment
1974a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","Adjust",propsRule_assert_doc[0].Name);
1984a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",HoriOrientation.LEFT,propsRule_assert_doc[0].Value);
1994a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
2004a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value);
2014a089d9bSLiu Zhe 	}
2024a089d9bSLiu Zhe 	@Test
testNumberingBulletAlign_Center()2034a089d9bSLiu Zhe 	public void testNumberingBulletAlign_Center() throws Exception {
2044a089d9bSLiu Zhe 
2054a089d9bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
2064a089d9bSLiu Zhe 		xText = xTextDocument.getText();
2074a089d9bSLiu Zhe 		xText.setString("we are Chinese,they are American.\nwe are all living in one earth!\nHello,world!Hello,world!Hello,world!\nHello,world!Hello,world!Hello,world!" +
2084a089d9bSLiu Zhe 				"Hello,world!Hello,world!");
2094a089d9bSLiu Zhe 		//create cursor to select paragraph and formating paragraph
2104a089d9bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
2114a089d9bSLiu Zhe 		//create paragraph property set
2124a089d9bSLiu Zhe 		XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
2134a089d9bSLiu Zhe 		//create document service factory
2144a089d9bSLiu Zhe 		XMultiServiceFactory  xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
2154a089d9bSLiu Zhe 		//set numbering character
2164a089d9bSLiu Zhe 		XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules"));
2174a089d9bSLiu Zhe 		PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()};
2184a089d9bSLiu Zhe 		propsRule[1].Name = "NumberingType";
2194a089d9bSLiu Zhe 		propsRule[1].Value = NumberingType.ARABIC;
2204a089d9bSLiu Zhe 		propsRule[0].Name = "Adjust";
2214a089d9bSLiu Zhe 		propsRule[0].Value = HoriOrientation.CENTER;
2224a089d9bSLiu Zhe 		XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule);
2234a089d9bSLiu Zhe 		xReplaceRule.replaceByIndex(0, propsRule);
2244a089d9bSLiu Zhe 		//set paragraph numbering and bullet character
2254a089d9bSLiu Zhe 		xTextProps.setPropertyValue("NumberingRules", xNumRule);
2264a089d9bSLiu Zhe 		//save to odt
2274a089d9bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
2284a089d9bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
2294a089d9bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
2304a089d9bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
2314a089d9bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
2324a089d9bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
2334a089d9bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
2344a089d9bSLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
2354a089d9bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
2364a089d9bSLiu Zhe 		//save to doc
2374a089d9bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
2384a089d9bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
2394a089d9bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
2404a089d9bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
2414a089d9bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
2424a089d9bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
2434a089d9bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
2444a089d9bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
2454a089d9bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
2464a089d9bSLiu Zhe 		app.closeDocument(xTextDocument);
2474a089d9bSLiu Zhe 
2484a089d9bSLiu Zhe 		//reopen the document
2494a089d9bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
2504a089d9bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
2514a089d9bSLiu Zhe 		XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules"));
2524a089d9bSLiu Zhe 		XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt);
2534a089d9bSLiu Zhe 		PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0));
2544a089d9bSLiu Zhe 		//verify paragraph numbering and bullet alignment
2554a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","Adjust",propsRule_assert_odt[0].Name);
2564a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",HoriOrientation.CENTER,propsRule_assert_odt[0].Value);
2574a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name);
2584a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value);
2594a089d9bSLiu Zhe 
2604a089d9bSLiu Zhe 		//reopen the document
2614a089d9bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
2624a089d9bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
2634a089d9bSLiu Zhe 		XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules"));
2644a089d9bSLiu Zhe 		PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0));
2654a089d9bSLiu Zhe 		//verify paragraph numbering and bullet alignment
2664a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","Adjust",propsRule_assert_doc[0].Name);
2674a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",HoriOrientation.CENTER,propsRule_assert_doc[0].Value);
2684a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name);
2694a089d9bSLiu Zhe 		assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value);
2704a089d9bSLiu Zhe 	}
2714a089d9bSLiu Zhe }
272