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.Test; 29eba4d44aSLiu Zhe import org.openoffice.test.common.FileUtil; 30eba4d44aSLiu Zhe import org.openoffice.test.common.Testspace; 31eba4d44aSLiu Zhe import org.openoffice.test.uno.UnoApp; 32eba4d44aSLiu Zhe import com.sun.star.text.*; 33eba4d44aSLiu Zhe import com.sun.star.beans.*; 34eba4d44aSLiu Zhe import com.sun.star.frame.XStorable; 35eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime; 36eba4d44aSLiu Zhe 37eba4d44aSLiu Zhe public class ParagraphTexttoTextAlignment { 38eba4d44aSLiu Zhe private static final UnoApp app = new UnoApp(); 39eba4d44aSLiu Zhe XText xText = null; 40eba4d44aSLiu Zhe 41eba4d44aSLiu Zhe @Before setUp()42eba4d44aSLiu Zhe public void setUp() throws Exception { 43eba4d44aSLiu Zhe app.start(); 44eba4d44aSLiu Zhe 45eba4d44aSLiu Zhe } 46eba4d44aSLiu Zhe 47eba4d44aSLiu Zhe @After tearDown()48eba4d44aSLiu Zhe public void tearDown() throws Exception { 49eba4d44aSLiu Zhe app.close(); 50eba4d44aSLiu Zhe } 51eba4d44aSLiu Zhe /* 52eba4d44aSLiu Zhe * test paragraph background color 53eba4d44aSLiu Zhe * 1.new a text document 54eba4d44aSLiu Zhe * 2.insert some text 55eba4d44aSLiu Zhe * 3.set paragraph text to text alignment 56eba4d44aSLiu Zhe * 4.save and close the document 57eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph text to text alignment 58eba4d44aSLiu Zhe */ 59eba4d44aSLiu Zhe @Test testTexttoTextAlignment_Baseline()60eba4d44aSLiu Zhe public void testTexttoTextAlignment_Baseline() throws Exception { 61eba4d44aSLiu Zhe 62eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 63eba4d44aSLiu Zhe xText = xTextDocument.getText(); 64eba4d44aSLiu 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!" + 65eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 66eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 67eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 68eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 69eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.BASELINE); 70eba4d44aSLiu Zhe //save to odt 71eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 72eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 73eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 74eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 75eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 76eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 77eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 78eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 79eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 80eba4d44aSLiu Zhe //save to doc 81eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 82eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 83eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 84eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 85eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 86eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 87eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 88eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 89eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 90eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 91eba4d44aSLiu Zhe 92eba4d44aSLiu Zhe //reopen the document 93eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 94eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 95eba4d44aSLiu Zhe //verify paragraph text to text alignment 96eba4d44aSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BASELINE,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 97eba4d44aSLiu Zhe 98eba4d44aSLiu Zhe //reopen the document 99eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 100eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 101eba4d44aSLiu Zhe //verify paragraph text to text alignment 102eba4d44aSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BASELINE,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 103eba4d44aSLiu Zhe } 104eba4d44aSLiu Zhe @Test testTexttoTextAlignment_Bottom()105eba4d44aSLiu Zhe public void testTexttoTextAlignment_Bottom() throws Exception { 106eba4d44aSLiu Zhe 107eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 108eba4d44aSLiu Zhe xText = xTextDocument.getText(); 109eba4d44aSLiu 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!" + 110eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 111eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 112eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 113eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 114eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.BOTTOM); 115eba4d44aSLiu Zhe //save to odt 116eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 117eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 118eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 119eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 120eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 121eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 122eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 123eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 124eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 125eba4d44aSLiu Zhe //save to doc 126eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 127eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 128eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 129eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 130eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 131eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 132eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 133eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 134eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 135eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 136eba4d44aSLiu Zhe 137eba4d44aSLiu Zhe //reopen the document 138eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 139eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 140eba4d44aSLiu Zhe //verify paragraph text to text alignment 141eba4d44aSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BOTTOM,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 142eba4d44aSLiu Zhe 143eba4d44aSLiu Zhe //reopen the document 144eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 145eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 146eba4d44aSLiu Zhe //verify paragraph text to text alignment 147eba4d44aSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BOTTOM,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 148eba4d44aSLiu Zhe } 149eba4d44aSLiu Zhe @Test testTexttoTextAlignment_Center()150eba4d44aSLiu Zhe public void testTexttoTextAlignment_Center() throws Exception { 151eba4d44aSLiu Zhe 152eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 153eba4d44aSLiu Zhe xText = xTextDocument.getText(); 154eba4d44aSLiu 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!" + 155eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 156eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 157eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 158eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 159eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.CENTER); 160eba4d44aSLiu Zhe //save to odt 161eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 162eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 163eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 164eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 165eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 166eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 167eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 168eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 169eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 170eba4d44aSLiu Zhe //save to doc 171eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 172eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 173eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 174eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 175eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 176eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 177eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 178eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 179eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 180eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 181eba4d44aSLiu Zhe 182eba4d44aSLiu Zhe //reopen the document 183eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 184eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 185eba4d44aSLiu Zhe //verify paragraph text to text alignment 186eba4d44aSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.CENTER,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 187eba4d44aSLiu Zhe 188eba4d44aSLiu Zhe //reopen the document 189eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 190eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 191eba4d44aSLiu Zhe //verify paragraph text to text alignment 192eba4d44aSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.CENTER,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 193eba4d44aSLiu Zhe } 194eba4d44aSLiu Zhe @Test testTexttoTextAlignment_Top()195eba4d44aSLiu Zhe public void testTexttoTextAlignment_Top() throws Exception { 196eba4d44aSLiu Zhe 197eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 198eba4d44aSLiu Zhe xText = xTextDocument.getText(); 199eba4d44aSLiu 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!" + 200eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 201eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 202eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 203eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 204eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.TOP); 205eba4d44aSLiu Zhe //save to odt 206eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 207eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 208eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 209eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 210eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 211eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 212eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 213eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 214eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 215eba4d44aSLiu Zhe //save to doc 216eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 217eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 218eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 219eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 220eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 221eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 222eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 223eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 224eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 225eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 226eba4d44aSLiu Zhe 227eba4d44aSLiu Zhe //reopen the document 228eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 229eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 230eba4d44aSLiu Zhe //verify paragraph text to text alignment 231eba4d44aSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.TOP,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 232eba4d44aSLiu Zhe 233eba4d44aSLiu Zhe //reopen the document 234eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 235eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 236eba4d44aSLiu Zhe //verify paragraph text to text alignment 237eba4d44aSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.TOP,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 238eba4d44aSLiu Zhe } 239eba4d44aSLiu Zhe @Test testTexttoTextAlignment_Automatic()240eba4d44aSLiu Zhe public void testTexttoTextAlignment_Automatic() throws Exception { 241eba4d44aSLiu Zhe 242eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 243eba4d44aSLiu Zhe xText = xTextDocument.getText(); 244eba4d44aSLiu 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!" + 245eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 246eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 247eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 248eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 249eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.AUTOMATIC); 250eba4d44aSLiu Zhe //save to odt 251eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 252eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 253eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 254eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 255eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 256eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 257eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 258eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 259eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 260eba4d44aSLiu Zhe //save to doc 261eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 262eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 263eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 264eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 265eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 266eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 267eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 268eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 269eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 270eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 271eba4d44aSLiu Zhe 272eba4d44aSLiu Zhe //reopen the document 273eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 274eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 275eba4d44aSLiu Zhe //verify paragraph text to text alignment 276eba4d44aSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.AUTOMATIC,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 277eba4d44aSLiu Zhe 278eba4d44aSLiu Zhe //reopen the document 279eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 280eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 281eba4d44aSLiu Zhe //verify paragraph text to text alignment 282eba4d44aSLiu Zhe assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.AUTOMATIC,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 283eba4d44aSLiu Zhe } 284eba4d44aSLiu Zhe } 285