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; 23eba4d44aSLiu Zhe 24eba4d44aSLiu Zhe import static org.junit.Assert.*; 25eba4d44aSLiu Zhe 26eba4d44aSLiu Zhe import org.junit.After; 27eba4d44aSLiu Zhe import org.junit.Before; 28eba4d44aSLiu Zhe import org.junit.Ignore; 29eba4d44aSLiu Zhe import org.junit.Test; 30eba4d44aSLiu Zhe import org.openoffice.test.common.FileUtil; 31eba4d44aSLiu Zhe import org.openoffice.test.common.Testspace; 32eba4d44aSLiu Zhe import org.openoffice.test.uno.UnoApp; 33eba4d44aSLiu Zhe 34eba4d44aSLiu Zhe import com.sun.star.style.TabAlign; 35eba4d44aSLiu Zhe import com.sun.star.style.TabStop; 36eba4d44aSLiu Zhe import com.sun.star.text.*; 37eba4d44aSLiu Zhe import com.sun.star.beans.*; 38eba4d44aSLiu Zhe import com.sun.star.frame.XStorable; 39eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime; 40eba4d44aSLiu Zhe 41eba4d44aSLiu Zhe public class ParagraphTabs { 42eba4d44aSLiu Zhe private static final UnoApp app = new UnoApp(); 43eba4d44aSLiu Zhe XText xText = null; 44eba4d44aSLiu Zhe 45eba4d44aSLiu Zhe @Before setUp()46eba4d44aSLiu Zhe public void setUp() throws Exception { 47eba4d44aSLiu Zhe app.start(); 48eba4d44aSLiu Zhe 49eba4d44aSLiu Zhe } 50eba4d44aSLiu Zhe 51eba4d44aSLiu Zhe @After tearDown()52eba4d44aSLiu Zhe public void tearDown() throws Exception { 53eba4d44aSLiu Zhe app.close(); 54eba4d44aSLiu Zhe } 55eba4d44aSLiu Zhe @Test ParagraphTabs_Center()56eba4d44aSLiu Zhe public void ParagraphTabs_Center() throws Exception { 57eba4d44aSLiu Zhe 58eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 59eba4d44aSLiu Zhe xText = xTextDocument.getText(); 60eba4d44aSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!"); 61eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 62eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 63eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 64eba4d44aSLiu Zhe //paraTabStops. 65eba4d44aSLiu Zhe TabStop[] tabStop=new TabStop[1]; 66eba4d44aSLiu Zhe tabStop[0]=new TabStop(); 67eba4d44aSLiu Zhe tabStop[0].Position=5001; 68eba4d44aSLiu Zhe tabStop[0].Alignment=TabAlign.CENTER; 69eba4d44aSLiu Zhe tabStop[0].FillChar='_'; 70eba4d44aSLiu Zhe //set paragraph tab stops 71eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaTabStops",tabStop); 72eba4d44aSLiu Zhe //save to odt 73eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 74eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 75eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 76eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 77eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 78eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 79eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 80eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 81eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 82eba4d44aSLiu Zhe //save to doc 83eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 84eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 85eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 86eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 87eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 88eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 89eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 90eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 91eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 92eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 93eba4d44aSLiu Zhe 94eba4d44aSLiu Zhe //reopen the document 95eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 96eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 97eba4d44aSLiu Zhe Object paraTabs_obj_odt=xCursorProps_Assert_odt.getPropertyValue("ParaTabStops"); 98eba4d44aSLiu Zhe TabStop[] paraTabs_assert_odt=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, paraTabs_obj_odt); 99eba4d44aSLiu Zhe //verify paragraph tabs 100eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",TabAlign.CENTER,paraTabs_assert_odt[0].Alignment); 101eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'_',paraTabs_assert_odt[0].FillChar); 102eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",5001,paraTabs_assert_odt[0].Position); 103eba4d44aSLiu Zhe 104eba4d44aSLiu Zhe //reopen the document 105eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 106eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 107eba4d44aSLiu Zhe TabStop[] paraTabs_assert_doc=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, xCursorProps_Assert_doc.getPropertyValue("ParaTabStops")); 108eba4d44aSLiu Zhe //verify paragraph tabs 109eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",TabAlign.CENTER,paraTabs_assert_doc[0].Alignment); 110eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'_',paraTabs_assert_doc[0].FillChar); 111eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",5001,paraTabs_assert_doc[0].Position); 112eba4d44aSLiu Zhe } 113eba4d44aSLiu Zhe @Test ParagraphTabs_Left()114eba4d44aSLiu Zhe public void ParagraphTabs_Left() throws Exception { 115eba4d44aSLiu Zhe 116eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 117eba4d44aSLiu Zhe xText = xTextDocument.getText(); 118eba4d44aSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!"); 119eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 120eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 121eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 122eba4d44aSLiu Zhe //paraTabStops. 123eba4d44aSLiu Zhe TabStop[] tabStop=new TabStop[1]; 124eba4d44aSLiu Zhe tabStop[0]=new TabStop(); 125eba4d44aSLiu Zhe tabStop[0].Position=5001; 126eba4d44aSLiu Zhe tabStop[0].Alignment=TabAlign.LEFT; 127eba4d44aSLiu Zhe tabStop[0].FillChar='.'; 128eba4d44aSLiu Zhe //set paragraph tab stops 129eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaTabStops",tabStop); 130eba4d44aSLiu Zhe //save to odt 131eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 132eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 133eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 134eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 135eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 136eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 137eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 138eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 139eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 140eba4d44aSLiu Zhe //save to doc 141eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 142eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 143eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 144eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 145eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 146eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 147eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 148eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 149eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 150eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 151eba4d44aSLiu Zhe 152eba4d44aSLiu Zhe //reopen the document 153eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 154eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 155eba4d44aSLiu Zhe Object paraTabs_obj_odt=xCursorProps_Assert_odt.getPropertyValue("ParaTabStops"); 156eba4d44aSLiu Zhe TabStop[] paraTabs_assert_odt=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, paraTabs_obj_odt); 157eba4d44aSLiu Zhe //verify paragraph tabs 158eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",TabAlign.LEFT,paraTabs_assert_odt[0].Alignment); 159eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'.',paraTabs_assert_odt[0].FillChar); 160eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",5001,paraTabs_assert_odt[0].Position); 161eba4d44aSLiu Zhe 162eba4d44aSLiu Zhe //reopen the document 163eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 164eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 165eba4d44aSLiu Zhe TabStop[] paraTabs_assert_doc=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, xCursorProps_Assert_doc.getPropertyValue("ParaTabStops")); 166eba4d44aSLiu Zhe //verify paragraph tabs 167eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",TabAlign.LEFT,paraTabs_assert_doc[0].Alignment); 168eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'.',paraTabs_assert_doc[0].FillChar); 169eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",5001,paraTabs_assert_doc[0].Position); 170eba4d44aSLiu Zhe } 171eba4d44aSLiu Zhe @Test ParagraphTabs_Right()172eba4d44aSLiu Zhe public void ParagraphTabs_Right() throws Exception { 173eba4d44aSLiu Zhe 174eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 175eba4d44aSLiu Zhe xText = xTextDocument.getText(); 176eba4d44aSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!"); 177eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 178eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 179eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 180eba4d44aSLiu Zhe //paraTabStops. 181eba4d44aSLiu Zhe TabStop[] tabStop=new TabStop[1]; 182eba4d44aSLiu Zhe tabStop[0]=new TabStop(); 183eba4d44aSLiu Zhe tabStop[0].Position=5001; 184eba4d44aSLiu Zhe tabStop[0].Alignment=TabAlign.RIGHT; 185eba4d44aSLiu Zhe tabStop[0].FillChar='-'; 186eba4d44aSLiu Zhe //set paragraph tab stops 187eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaTabStops",tabStop); 188eba4d44aSLiu Zhe //save to odt 189eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 190eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 191eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 192eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 193eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 194eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 195eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 196eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 197eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 198eba4d44aSLiu Zhe //save to doc 199eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 200eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 201eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 202eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 203eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 204eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 205eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 206eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 207eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 208eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 209eba4d44aSLiu Zhe 210eba4d44aSLiu Zhe //reopen the document 211eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 212eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 213eba4d44aSLiu Zhe Object paraTabs_obj_odt=xCursorProps_Assert_odt.getPropertyValue("ParaTabStops"); 214eba4d44aSLiu Zhe TabStop[] paraTabs_assert_odt=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, paraTabs_obj_odt); 215eba4d44aSLiu Zhe //verify paragraph tabs 216eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",TabAlign.RIGHT,paraTabs_assert_odt[0].Alignment); 217eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'-',paraTabs_assert_odt[0].FillChar); 218eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",5001,paraTabs_assert_odt[0].Position); 219eba4d44aSLiu Zhe 220eba4d44aSLiu Zhe //reopen the document 221eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 222eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 223eba4d44aSLiu Zhe TabStop[] paraTabs_assert_doc=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, xCursorProps_Assert_doc.getPropertyValue("ParaTabStops")); 224eba4d44aSLiu Zhe //verify paragraph tabs 225eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",TabAlign.RIGHT,paraTabs_assert_doc[0].Alignment); 226eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'-',paraTabs_assert_doc[0].FillChar); 227eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",5001,paraTabs_assert_doc[0].Position); 228eba4d44aSLiu Zhe } 229eba4d44aSLiu Zhe @Test ParagraphTabs_Decimal()230eba4d44aSLiu Zhe public void ParagraphTabs_Decimal() throws Exception { 231eba4d44aSLiu Zhe 232eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 233eba4d44aSLiu Zhe xText = xTextDocument.getText(); 234eba4d44aSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!"); 235eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 236eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 237eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 238eba4d44aSLiu Zhe //paraTabStops. 239eba4d44aSLiu Zhe TabStop[] tabStop=new TabStop[1]; 240eba4d44aSLiu Zhe tabStop[0]=new TabStop(); 241eba4d44aSLiu Zhe tabStop[0].Position=5001; 242eba4d44aSLiu Zhe tabStop[0].Alignment=TabAlign.DECIMAL; 243eba4d44aSLiu Zhe tabStop[0].DecimalChar='.'; 244eba4d44aSLiu Zhe tabStop[0].FillChar='-'; 245eba4d44aSLiu Zhe //set paragraph tab stops 246eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaTabStops",tabStop); 247eba4d44aSLiu Zhe //save to odt 248eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 249eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 250eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 251eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 252eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 253eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 254eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 255eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 256eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 257eba4d44aSLiu Zhe //save to doc 258eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 259eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 260eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 261eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 262eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 263eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 264eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 265eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 266eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 267eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 268eba4d44aSLiu Zhe 269eba4d44aSLiu Zhe //reopen the document 270eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 271eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 272eba4d44aSLiu Zhe Object paraTabs_obj_odt=xCursorProps_Assert_odt.getPropertyValue("ParaTabStops"); 273eba4d44aSLiu Zhe TabStop[] paraTabs_assert_odt=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, paraTabs_obj_odt); 274eba4d44aSLiu Zhe //verify paragraph tabs 275eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",TabAlign.DECIMAL,paraTabs_assert_odt[0].Alignment); 276eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'-',paraTabs_assert_odt[0].FillChar); 277eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",5001,paraTabs_assert_odt[0].Position); 278eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'.',paraTabs_assert_odt[0].DecimalChar); 279eba4d44aSLiu Zhe 280eba4d44aSLiu Zhe //reopen the document 281eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 282eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 283eba4d44aSLiu Zhe TabStop[] paraTabs_assert_doc=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, xCursorProps_Assert_doc.getPropertyValue("ParaTabStops")); 284eba4d44aSLiu Zhe //verify paragraph tabs 285eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",TabAlign.DECIMAL,paraTabs_assert_doc[0].Alignment); 286eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'-',paraTabs_assert_doc[0].FillChar); 287eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",5001,paraTabs_assert_doc[0].Position); 288eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'.',paraTabs_assert_doc[0].DecimalChar); 289eba4d44aSLiu Zhe } 290eba4d44aSLiu Zhe @Test@Ignore("Bug #120748 - [testUNO patch]the tabstops character of paragraph change to default when save to doc.") ParagraphTabs_Decimal_UserDefineCharacter()291eba4d44aSLiu Zhe public void ParagraphTabs_Decimal_UserDefineCharacter() throws Exception { 292eba4d44aSLiu Zhe 293eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 294eba4d44aSLiu Zhe xText = xTextDocument.getText(); 295eba4d44aSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!"); 296eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 297eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 298eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 299eba4d44aSLiu Zhe //paraTabStops. 300eba4d44aSLiu Zhe TabStop[] tabStop=new TabStop[1]; 301eba4d44aSLiu Zhe tabStop[0]=new TabStop(); 302eba4d44aSLiu Zhe tabStop[0].Position=5001; 303eba4d44aSLiu Zhe tabStop[0].Alignment=TabAlign.DECIMAL; 304eba4d44aSLiu Zhe tabStop[0].DecimalChar='@'; 305eba4d44aSLiu Zhe tabStop[0].FillChar='%'; 306eba4d44aSLiu Zhe //set paragraph tab stops 307eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaTabStops",tabStop); 308eba4d44aSLiu Zhe //save to odt 309eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 310eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 311eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 312eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 313eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 314eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 315eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 316eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 317eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 318eba4d44aSLiu Zhe //save to doc 319eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 320eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 321eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 322eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 323eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 324eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 325eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 326eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 327eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 328eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 329eba4d44aSLiu Zhe 330eba4d44aSLiu Zhe //reopen the document 331eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 332eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 333eba4d44aSLiu Zhe Object paraTabs_obj_odt=xCursorProps_Assert_odt.getPropertyValue("ParaTabStops"); 334eba4d44aSLiu Zhe TabStop[] paraTabs_assert_odt=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, paraTabs_obj_odt); 335eba4d44aSLiu Zhe //verify paragraph tabs 336eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",TabAlign.DECIMAL,paraTabs_assert_odt[0].Alignment); 337eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'%',paraTabs_assert_odt[0].FillChar); 338eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",5001,paraTabs_assert_odt[0].Position); 339eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'@',paraTabs_assert_odt[0].DecimalChar); 340eba4d44aSLiu Zhe 341eba4d44aSLiu Zhe //reopen the document 342eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 343eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 344eba4d44aSLiu Zhe TabStop[] paraTabs_assert_doc=(TabStop[]) UnoRuntime.queryInterface(TabStop[].class, xCursorProps_Assert_doc.getPropertyValue("ParaTabStops")); 345eba4d44aSLiu Zhe //verify paragraph tabs 346eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",TabAlign.DECIMAL,paraTabs_assert_doc[0].Alignment); 347eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'%',paraTabs_assert_doc[0].FillChar); 348eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",5001,paraTabs_assert_doc[0].Position); 349eba4d44aSLiu Zhe assertEquals("assert paragraph tab setting",'@',paraTabs_assert_doc[0].DecimalChar); 350eba4d44aSLiu Zhe } 351eba4d44aSLiu Zhe } 352