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