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;
239f0ca99bSLiu Zhe 
249f0ca99bSLiu Zhe import static org.junit.Assert.*;
259f0ca99bSLiu Zhe 
269f0ca99bSLiu Zhe import org.junit.After;
279f0ca99bSLiu Zhe import org.junit.Before;
289f0ca99bSLiu Zhe import org.junit.Ignore;
299f0ca99bSLiu Zhe import org.junit.Test;
309f0ca99bSLiu Zhe import org.openoffice.test.common.FileUtil;
319f0ca99bSLiu Zhe import org.openoffice.test.common.Testspace;
329f0ca99bSLiu Zhe import org.openoffice.test.uno.UnoApp;
339f0ca99bSLiu Zhe 
349f0ca99bSLiu Zhe import com.sun.star.style.TabAlign;
359f0ca99bSLiu Zhe import com.sun.star.style.TabStop;
369f0ca99bSLiu Zhe import com.sun.star.text.*;
379f0ca99bSLiu Zhe import com.sun.star.beans.*;
389f0ca99bSLiu Zhe import com.sun.star.frame.XStorable;
399f0ca99bSLiu Zhe import com.sun.star.uno.UnoRuntime;
409f0ca99bSLiu Zhe 
419f0ca99bSLiu Zhe public class ParagraphTabs {
429f0ca99bSLiu Zhe 	private static final UnoApp app = new UnoApp();
439f0ca99bSLiu Zhe 	XText xText = null;
449f0ca99bSLiu Zhe 
459f0ca99bSLiu Zhe 	@Before
setUp()469f0ca99bSLiu Zhe 	public void setUp() throws Exception {
479f0ca99bSLiu Zhe 		app.start();
489f0ca99bSLiu Zhe 
499f0ca99bSLiu Zhe 	}
509f0ca99bSLiu Zhe 
519f0ca99bSLiu Zhe 	@After
tearDown()529f0ca99bSLiu Zhe 	public void tearDown() throws Exception {
539f0ca99bSLiu Zhe 		app.close();
549f0ca99bSLiu Zhe 	}
559f0ca99bSLiu Zhe 	@Test
ParagraphTabs_Center()569f0ca99bSLiu Zhe 	public void ParagraphTabs_Center() throws Exception {
579f0ca99bSLiu Zhe 
589f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
599f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
609f0ca99bSLiu Zhe 		xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!");
619f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
629f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
639f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
649f0ca99bSLiu Zhe 		//paraTabStops.
659f0ca99bSLiu Zhe 		TabStop[] tabStop=new TabStop[1];
669f0ca99bSLiu Zhe 		tabStop[0]=new TabStop();
679f0ca99bSLiu Zhe 		tabStop[0].Position=5001;
689f0ca99bSLiu Zhe 		tabStop[0].Alignment=TabAlign.CENTER;
699f0ca99bSLiu Zhe 		tabStop[0].FillChar='_';
709f0ca99bSLiu Zhe 		//set paragraph tab stops
719f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("ParaTabStops",tabStop);
729f0ca99bSLiu Zhe 		//save to odt
739f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
749f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
759f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
769f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
779f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
789f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
799f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
809f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
819f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
829f0ca99bSLiu Zhe 		//save to doc
839f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
849f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
859f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
869f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
879f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
889f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
899f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
909f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
919f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
929f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
939f0ca99bSLiu Zhe 
949f0ca99bSLiu Zhe 		//reopen the document
959f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
969f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
979f0ca99bSLiu Zhe 		Object paraTabs_obj_odt=xCursorProps_Assert_odt.getPropertyValue("ParaTabStops");
989f0ca99bSLiu Zhe 		TabStop[] paraTabs_assert_odt=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, paraTabs_obj_odt);
999f0ca99bSLiu Zhe 		//verify paragraph tabs
1009f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",TabAlign.CENTER,paraTabs_assert_odt[0].Alignment);
1019f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'_',paraTabs_assert_odt[0].FillChar);
1029f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",5001,paraTabs_assert_odt[0].Position);
1039f0ca99bSLiu Zhe 
1049f0ca99bSLiu Zhe 		//reopen the document
1059f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
1069f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
1079f0ca99bSLiu Zhe 		TabStop[] paraTabs_assert_doc=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, xCursorProps_Assert_doc.getPropertyValue("ParaTabStops"));
1089f0ca99bSLiu Zhe 		//verify paragraph tabs
1099f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",TabAlign.CENTER,paraTabs_assert_doc[0].Alignment);
1109f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'_',paraTabs_assert_doc[0].FillChar);
1119f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",5001,paraTabs_assert_doc[0].Position);
1129f0ca99bSLiu Zhe 	}
1139f0ca99bSLiu Zhe 	@Test
ParagraphTabs_Left()1149f0ca99bSLiu Zhe 	public void ParagraphTabs_Left() throws Exception {
1159f0ca99bSLiu Zhe 
1169f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
1179f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
1189f0ca99bSLiu Zhe 		xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!");
1199f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
1209f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
1219f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
1229f0ca99bSLiu Zhe 		//paraTabStops.
1239f0ca99bSLiu Zhe 		TabStop[] tabStop=new TabStop[1];
1249f0ca99bSLiu Zhe 		tabStop[0]=new TabStop();
1259f0ca99bSLiu Zhe 		tabStop[0].Position=5001;
1269f0ca99bSLiu Zhe 		tabStop[0].Alignment=TabAlign.LEFT;
1279f0ca99bSLiu Zhe 		tabStop[0].FillChar='.';
1289f0ca99bSLiu Zhe 		//set paragraph tab stops
1299f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("ParaTabStops",tabStop);
1309f0ca99bSLiu Zhe 		//save to odt
1319f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
1329f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
1339f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
1349f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
1359f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
1369f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
1379f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
1389f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
1399f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
1409f0ca99bSLiu Zhe 		//save to doc
1419f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
1429f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
1439f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
1449f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
1459f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
1469f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
1479f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
1489f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
1499f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
1509f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
1519f0ca99bSLiu Zhe 
1529f0ca99bSLiu Zhe 		//reopen the document
1539f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
1549f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
1559f0ca99bSLiu Zhe 		Object paraTabs_obj_odt=xCursorProps_Assert_odt.getPropertyValue("ParaTabStops");
1569f0ca99bSLiu Zhe 		TabStop[] paraTabs_assert_odt=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, paraTabs_obj_odt);
1579f0ca99bSLiu Zhe 		//verify paragraph tabs
1589f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",TabAlign.LEFT,paraTabs_assert_odt[0].Alignment);
1599f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'.',paraTabs_assert_odt[0].FillChar);
1609f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",5001,paraTabs_assert_odt[0].Position);
1619f0ca99bSLiu Zhe 
1629f0ca99bSLiu Zhe 		//reopen the document
1639f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
1649f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
1659f0ca99bSLiu Zhe 		TabStop[] paraTabs_assert_doc=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, xCursorProps_Assert_doc.getPropertyValue("ParaTabStops"));
1669f0ca99bSLiu Zhe 		//verify paragraph tabs
1679f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",TabAlign.LEFT,paraTabs_assert_doc[0].Alignment);
1689f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'.',paraTabs_assert_doc[0].FillChar);
1699f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",5001,paraTabs_assert_doc[0].Position);
1709f0ca99bSLiu Zhe 	}
1719f0ca99bSLiu Zhe 	@Test
ParagraphTabs_Right()1729f0ca99bSLiu Zhe 	public void ParagraphTabs_Right() throws Exception {
1739f0ca99bSLiu Zhe 
1749f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
1759f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
1769f0ca99bSLiu Zhe 		xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!");
1779f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
1789f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
1799f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
1809f0ca99bSLiu Zhe 		//paraTabStops.
1819f0ca99bSLiu Zhe 		TabStop[] tabStop=new TabStop[1];
1829f0ca99bSLiu Zhe 		tabStop[0]=new TabStop();
1839f0ca99bSLiu Zhe 		tabStop[0].Position=5001;
1849f0ca99bSLiu Zhe 		tabStop[0].Alignment=TabAlign.RIGHT;
1859f0ca99bSLiu Zhe 		tabStop[0].FillChar='-';
1869f0ca99bSLiu Zhe 		//set paragraph tab stops
1879f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("ParaTabStops",tabStop);
1889f0ca99bSLiu Zhe 		//save to odt
1899f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
1909f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
1919f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
1929f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
1939f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
1949f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
1959f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
1969f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
1979f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
1989f0ca99bSLiu Zhe 		//save to doc
1999f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
2009f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
2019f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
2029f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
2039f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
2049f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
2059f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
2069f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
2079f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
2089f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
2099f0ca99bSLiu Zhe 
2109f0ca99bSLiu Zhe 		//reopen the document
2119f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
2129f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
2139f0ca99bSLiu Zhe 		Object paraTabs_obj_odt=xCursorProps_Assert_odt.getPropertyValue("ParaTabStops");
2149f0ca99bSLiu Zhe 		TabStop[] paraTabs_assert_odt=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, paraTabs_obj_odt);
2159f0ca99bSLiu Zhe 		//verify paragraph tabs
2169f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",TabAlign.RIGHT,paraTabs_assert_odt[0].Alignment);
2179f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'-',paraTabs_assert_odt[0].FillChar);
2189f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",5001,paraTabs_assert_odt[0].Position);
2199f0ca99bSLiu Zhe 
2209f0ca99bSLiu Zhe 		//reopen the document
2219f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
2229f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
2239f0ca99bSLiu Zhe 		TabStop[] paraTabs_assert_doc=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, xCursorProps_Assert_doc.getPropertyValue("ParaTabStops"));
2249f0ca99bSLiu Zhe 		//verify paragraph tabs
2259f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",TabAlign.RIGHT,paraTabs_assert_doc[0].Alignment);
2269f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'-',paraTabs_assert_doc[0].FillChar);
2279f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",5001,paraTabs_assert_doc[0].Position);
2289f0ca99bSLiu Zhe 	}
2299f0ca99bSLiu Zhe 	@Test
ParagraphTabs_Decimal()2309f0ca99bSLiu Zhe 	public void ParagraphTabs_Decimal() throws Exception {
2319f0ca99bSLiu Zhe 
2329f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
2339f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
2349f0ca99bSLiu Zhe 		xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!");
2359f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
2369f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
2379f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
2389f0ca99bSLiu Zhe 		//paraTabStops.
2399f0ca99bSLiu Zhe 		TabStop[] tabStop=new TabStop[1];
2409f0ca99bSLiu Zhe 		tabStop[0]=new TabStop();
2419f0ca99bSLiu Zhe 		tabStop[0].Position=5001;
2429f0ca99bSLiu Zhe 		tabStop[0].Alignment=TabAlign.DECIMAL;
2439f0ca99bSLiu Zhe 		tabStop[0].DecimalChar='.';
2449f0ca99bSLiu Zhe 		tabStop[0].FillChar='-';
2459f0ca99bSLiu Zhe 		//set paragraph tab stops
2469f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("ParaTabStops",tabStop);
2479f0ca99bSLiu Zhe 		//save to odt
2489f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
2499f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
2509f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
2519f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
2529f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
2539f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
2549f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
2559f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
2569f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
2579f0ca99bSLiu Zhe 		//save to doc
2589f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
2599f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
2609f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
2619f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
2629f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
2639f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
2649f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
2659f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
2669f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
2679f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
2689f0ca99bSLiu Zhe 
2699f0ca99bSLiu Zhe 		//reopen the document
2709f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
2719f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
2729f0ca99bSLiu Zhe 		Object paraTabs_obj_odt=xCursorProps_Assert_odt.getPropertyValue("ParaTabStops");
2739f0ca99bSLiu Zhe 		TabStop[] paraTabs_assert_odt=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, paraTabs_obj_odt);
2749f0ca99bSLiu Zhe 		//verify paragraph tabs
2759f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",TabAlign.DECIMAL,paraTabs_assert_odt[0].Alignment);
2769f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'-',paraTabs_assert_odt[0].FillChar);
2779f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",5001,paraTabs_assert_odt[0].Position);
2789f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'.',paraTabs_assert_odt[0].DecimalChar);
2799f0ca99bSLiu Zhe 
2809f0ca99bSLiu Zhe 		//reopen the document
2819f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
2829f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
2839f0ca99bSLiu Zhe 		TabStop[] paraTabs_assert_doc=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, xCursorProps_Assert_doc.getPropertyValue("ParaTabStops"));
2849f0ca99bSLiu Zhe 		//verify paragraph tabs
2859f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",TabAlign.DECIMAL,paraTabs_assert_doc[0].Alignment);
2869f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'-',paraTabs_assert_doc[0].FillChar);
2879f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",5001,paraTabs_assert_doc[0].Position);
2889f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'.',paraTabs_assert_doc[0].DecimalChar);
2899f0ca99bSLiu Zhe 	}
290af986861SLiu Zhe 	@Test@Ignore("Bug #120748 - [testUNO patch]the tabstops character of paragraph change to default when save to doc.")
ParagraphTabs_Decimal_UserDefineCharacter()2919f0ca99bSLiu Zhe 	public void ParagraphTabs_Decimal_UserDefineCharacter() throws Exception {
2929f0ca99bSLiu Zhe 
2939f0ca99bSLiu Zhe 		XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document
2949f0ca99bSLiu Zhe 		xText = xTextDocument.getText();
2959f0ca99bSLiu Zhe 		xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!");
2969f0ca99bSLiu Zhe 		// create text cursor for selecting and formatting text
2979f0ca99bSLiu Zhe 		XTextCursor xTextCursor = xText.createTextCursor();
2989f0ca99bSLiu Zhe 		XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
2999f0ca99bSLiu Zhe 		//paraTabStops.
3009f0ca99bSLiu Zhe 		TabStop[] tabStop=new TabStop[1];
3019f0ca99bSLiu Zhe 		tabStop[0]=new TabStop();
3029f0ca99bSLiu Zhe 		tabStop[0].Position=5001;
3039f0ca99bSLiu Zhe 		tabStop[0].Alignment=TabAlign.DECIMAL;
3049f0ca99bSLiu Zhe 		tabStop[0].DecimalChar='@';
3059f0ca99bSLiu Zhe 		tabStop[0].FillChar='%';
3069f0ca99bSLiu Zhe 		//set paragraph tab stops
3079f0ca99bSLiu Zhe 		xCursorProps.setPropertyValue("ParaTabStops",tabStop);
3089f0ca99bSLiu Zhe 		//save to odt
3099f0ca99bSLiu Zhe 		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
3109f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_odt = new PropertyValue[2];
3119f0ca99bSLiu Zhe 		aStoreProperties_odt[0] = new PropertyValue();
3129f0ca99bSLiu Zhe 		aStoreProperties_odt[1] = new PropertyValue();
3139f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Name = "Override";
3149f0ca99bSLiu Zhe 		aStoreProperties_odt[0].Value = true;
3159f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Name = "FilterName";
3169f0ca99bSLiu Zhe 		aStoreProperties_odt[1].Value = "writer8";
3179f0ca99bSLiu Zhe 		xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt);
3189f0ca99bSLiu Zhe 		//save to doc
3199f0ca99bSLiu Zhe 		XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
3209f0ca99bSLiu Zhe 		PropertyValue[] aStoreProperties_doc = new PropertyValue[2];
3219f0ca99bSLiu Zhe 		aStoreProperties_doc[0] = new PropertyValue();
3229f0ca99bSLiu Zhe 		aStoreProperties_doc[1] = new PropertyValue();
3239f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Name = "Override";
3249f0ca99bSLiu Zhe 		aStoreProperties_doc[0].Value = true;
3259f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Name = "FilterName";
3269f0ca99bSLiu Zhe 		aStoreProperties_doc[1].Value = "MS Word 97";
3279f0ca99bSLiu Zhe 		xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc);
3289f0ca99bSLiu Zhe 		app.closeDocument(xTextDocument);
3299f0ca99bSLiu Zhe 
3309f0ca99bSLiu Zhe 		//reopen the document
3319f0ca99bSLiu Zhe 		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt")));
3329f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor());
3339f0ca99bSLiu Zhe 		Object paraTabs_obj_odt=xCursorProps_Assert_odt.getPropertyValue("ParaTabStops");
3349f0ca99bSLiu Zhe 		TabStop[] paraTabs_assert_odt=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, paraTabs_obj_odt);
3359f0ca99bSLiu Zhe 		//verify paragraph tabs
3369f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",TabAlign.DECIMAL,paraTabs_assert_odt[0].Alignment);
3379f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'%',paraTabs_assert_odt[0].FillChar);
3389f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",5001,paraTabs_assert_odt[0].Position);
3399f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'@',paraTabs_assert_odt[0].DecimalChar);
3409f0ca99bSLiu Zhe 
3419f0ca99bSLiu Zhe 		//reopen the document
3429f0ca99bSLiu Zhe 		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc")));
3439f0ca99bSLiu Zhe 		XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor());
3449f0ca99bSLiu Zhe 		TabStop[] paraTabs_assert_doc=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, xCursorProps_Assert_doc.getPropertyValue("ParaTabStops"));
3459f0ca99bSLiu Zhe 		//verify paragraph tabs
3469f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",TabAlign.DECIMAL,paraTabs_assert_doc[0].Alignment);
3479f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'%',paraTabs_assert_doc[0].FillChar);
3489f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",5001,paraTabs_assert_doc[0].Position);
3499f0ca99bSLiu Zhe 		assertEquals("assert paragraph tab setting",'@',paraTabs_assert_doc[0].DecimalChar);
3509f0ca99bSLiu Zhe 	}
3519f0ca99bSLiu Zhe }
352