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.Test; 299f0ca99bSLiu Zhe import org.openoffice.test.common.FileUtil; 309f0ca99bSLiu Zhe import org.openoffice.test.common.Testspace; 319f0ca99bSLiu Zhe import org.openoffice.test.uno.UnoApp; 329f0ca99bSLiu Zhe import com.sun.star.text.*; 339f0ca99bSLiu Zhe import com.sun.star.beans.*; 349f0ca99bSLiu Zhe import com.sun.star.frame.XStorable; 359f0ca99bSLiu Zhe import com.sun.star.uno.UnoRuntime; 369f0ca99bSLiu Zhe 379f0ca99bSLiu Zhe public class ParagraphTexttoTextAlignment { 389f0ca99bSLiu Zhe private static final UnoApp app = new UnoApp(); 399f0ca99bSLiu Zhe XText xText = null; 409f0ca99bSLiu Zhe 419f0ca99bSLiu Zhe @Before setUp()429f0ca99bSLiu Zhe public void setUp() throws Exception { 439f0ca99bSLiu Zhe app.start(); 449f0ca99bSLiu Zhe 459f0ca99bSLiu Zhe } 469f0ca99bSLiu Zhe 479f0ca99bSLiu Zhe @After tearDown()489f0ca99bSLiu Zhe public void tearDown() throws Exception { 499f0ca99bSLiu Zhe app.close(); 509f0ca99bSLiu Zhe } 519f0ca99bSLiu Zhe /* 529f0ca99bSLiu Zhe * test paragraph background color 539f0ca99bSLiu Zhe * 1.new a text document 549f0ca99bSLiu Zhe * 2.insert some text 559f0ca99bSLiu Zhe * 3.set paragraph text to text alignment 569f0ca99bSLiu Zhe * 4.save and close the document 579f0ca99bSLiu Zhe * 5.reload the saved document and check the paragraph text to text alignment 589f0ca99bSLiu Zhe */ 599f0ca99bSLiu Zhe @Test testTexttoTextAlignment_Baseline()609f0ca99bSLiu Zhe public void testTexttoTextAlignment_Baseline() throws Exception { 619f0ca99bSLiu Zhe 629f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 639f0ca99bSLiu Zhe xText = xTextDocument.getText(); 649f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 659f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 669f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 679f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 689f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 699f0ca99bSLiu Zhe xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.BASELINE); 709f0ca99bSLiu Zhe //save to odt 719f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 729f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 739f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 749f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 759f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 769f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 779f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 789f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 799f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 809f0ca99bSLiu Zhe //save to doc 819f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 829f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 839f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 849f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 859f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 869f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 879f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 889f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 899f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 909f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 919f0ca99bSLiu Zhe 929f0ca99bSLiu Zhe //reopen the document 939f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 949f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 959f0ca99bSLiu Zhe //verify paragraph text to text alignment 969f0ca99bSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BASELINE,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 979f0ca99bSLiu Zhe 989f0ca99bSLiu Zhe //reopen the document 999f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 1009f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 1019f0ca99bSLiu Zhe //verify paragraph text to text alignment 1029f0ca99bSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BASELINE,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 1039f0ca99bSLiu Zhe } 1049f0ca99bSLiu Zhe @Test testTexttoTextAlignment_Bottom()1059f0ca99bSLiu Zhe public void testTexttoTextAlignment_Bottom() throws Exception { 1069f0ca99bSLiu Zhe 1079f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 1089f0ca99bSLiu Zhe xText = xTextDocument.getText(); 1099f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 1109f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 1119f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 1129f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 1139f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 1149f0ca99bSLiu Zhe xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.BOTTOM); 1159f0ca99bSLiu Zhe //save to odt 1169f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1179f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 1189f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 1199f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 1209f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 1219f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 1229f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 1239f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 1249f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 1259f0ca99bSLiu Zhe //save to doc 1269f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1279f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 1289f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 1299f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 1309f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 1319f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 1329f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 1339f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 1349f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 1359f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 1369f0ca99bSLiu Zhe 1379f0ca99bSLiu Zhe //reopen the document 1389f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 1399f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 1409f0ca99bSLiu Zhe //verify paragraph text to text alignment 1419f0ca99bSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BOTTOM,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 1429f0ca99bSLiu Zhe 1439f0ca99bSLiu Zhe //reopen the document 1449f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 1459f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 1469f0ca99bSLiu Zhe //verify paragraph text to text alignment 1479f0ca99bSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BOTTOM,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 1489f0ca99bSLiu Zhe } 1499f0ca99bSLiu Zhe @Test testTexttoTextAlignment_Center()1509f0ca99bSLiu Zhe public void testTexttoTextAlignment_Center() throws Exception { 1519f0ca99bSLiu Zhe 1529f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 1539f0ca99bSLiu Zhe xText = xTextDocument.getText(); 1549f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 1559f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 1569f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 1579f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 1589f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 1599f0ca99bSLiu Zhe xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.CENTER); 1609f0ca99bSLiu Zhe //save to odt 1619f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1629f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 1639f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 1649f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 1659f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 1669f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 1679f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 1689f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 1699f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 1709f0ca99bSLiu Zhe //save to doc 1719f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1729f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 1739f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 1749f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 1759f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 1769f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 1779f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 1789f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 1799f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 1809f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 1819f0ca99bSLiu Zhe 1829f0ca99bSLiu Zhe //reopen the document 1839f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 1849f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 1859f0ca99bSLiu Zhe //verify paragraph text to text alignment 1869f0ca99bSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.CENTER,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 1879f0ca99bSLiu Zhe 1889f0ca99bSLiu Zhe //reopen the document 1899f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 1909f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 1919f0ca99bSLiu Zhe //verify paragraph text to text alignment 1929f0ca99bSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.CENTER,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 1939f0ca99bSLiu Zhe } 1949f0ca99bSLiu Zhe @Test testTexttoTextAlignment_Top()1959f0ca99bSLiu Zhe public void testTexttoTextAlignment_Top() throws Exception { 1969f0ca99bSLiu Zhe 1979f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 1989f0ca99bSLiu Zhe xText = xTextDocument.getText(); 1999f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 2009f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 2019f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 2029f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 2039f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 2049f0ca99bSLiu Zhe xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.TOP); 2059f0ca99bSLiu Zhe //save to odt 2069f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2079f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 2089f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 2099f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 2109f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 2119f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 2129f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 2139f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 2149f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 2159f0ca99bSLiu Zhe //save to doc 2169f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2179f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 2189f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 2199f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 2209f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 2219f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 2229f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 2239f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 2249f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 2259f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 2269f0ca99bSLiu Zhe 2279f0ca99bSLiu Zhe //reopen the document 2289f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 2299f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 2309f0ca99bSLiu Zhe //verify paragraph text to text alignment 2319f0ca99bSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.TOP,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 2329f0ca99bSLiu Zhe 2339f0ca99bSLiu Zhe //reopen the document 2349f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 2359f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 2369f0ca99bSLiu Zhe //verify paragraph text to text alignment 2379f0ca99bSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.TOP,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 2389f0ca99bSLiu Zhe } 2399f0ca99bSLiu Zhe @Test testTexttoTextAlignment_Automatic()2409f0ca99bSLiu Zhe public void testTexttoTextAlignment_Automatic() throws Exception { 2419f0ca99bSLiu Zhe 2429f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 2439f0ca99bSLiu Zhe xText = xTextDocument.getText(); 2449f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 2459f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 2469f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 2479f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 2489f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 2499f0ca99bSLiu Zhe xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.AUTOMATIC); 2509f0ca99bSLiu Zhe //save to odt 2519f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2529f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 2539f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 2549f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 2559f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 2569f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 2579f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 2589f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 2599f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 2609f0ca99bSLiu Zhe //save to doc 2619f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2629f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 2639f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 2649f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 2659f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 2669f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 2679f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 2689f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 2699f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 2709f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 2719f0ca99bSLiu Zhe 2729f0ca99bSLiu Zhe //reopen the document 2739f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 2749f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 2759f0ca99bSLiu Zhe //verify paragraph text to text alignment 2769f0ca99bSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.AUTOMATIC,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 2779f0ca99bSLiu Zhe 2789f0ca99bSLiu Zhe //reopen the document 2799f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 2809f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 2819f0ca99bSLiu Zhe //verify paragraph text to text alignment 2829f0ca99bSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.AUTOMATIC,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 2839f0ca99bSLiu Zhe } 2849f0ca99bSLiu Zhe } 285