1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski package fvt.uno.sw.paragraph; 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski import static org.junit.Assert.*; 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim Jagielski import org.junit.After; 27*b1cdbd2cSJim Jagielski import org.junit.Before; 28*b1cdbd2cSJim Jagielski import org.junit.Test; 29*b1cdbd2cSJim Jagielski import org.openoffice.test.common.FileUtil; 30*b1cdbd2cSJim Jagielski import org.openoffice.test.common.Testspace; 31*b1cdbd2cSJim Jagielski import org.openoffice.test.uno.UnoApp; 32*b1cdbd2cSJim Jagielski import com.sun.star.text.*; 33*b1cdbd2cSJim Jagielski import com.sun.star.beans.*; 34*b1cdbd2cSJim Jagielski import com.sun.star.frame.XStorable; 35*b1cdbd2cSJim Jagielski import com.sun.star.uno.UnoRuntime; 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim Jagielski public class ParagraphTexttoTextAlignment { 38*b1cdbd2cSJim Jagielski private static final UnoApp app = new UnoApp(); 39*b1cdbd2cSJim Jagielski XText xText = null; 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielski @Before setUp()42*b1cdbd2cSJim Jagielski public void setUp() throws Exception { 43*b1cdbd2cSJim Jagielski app.start(); 44*b1cdbd2cSJim Jagielski 45*b1cdbd2cSJim Jagielski } 46*b1cdbd2cSJim Jagielski 47*b1cdbd2cSJim Jagielski @After tearDown()48*b1cdbd2cSJim Jagielski public void tearDown() throws Exception { 49*b1cdbd2cSJim Jagielski app.close(); 50*b1cdbd2cSJim Jagielski } 51*b1cdbd2cSJim Jagielski /* 52*b1cdbd2cSJim Jagielski * test paragraph background color 53*b1cdbd2cSJim Jagielski * 1.new a text document 54*b1cdbd2cSJim Jagielski * 2.insert some text 55*b1cdbd2cSJim Jagielski * 3.set paragraph text to text alignment 56*b1cdbd2cSJim Jagielski * 4.save and close the document 57*b1cdbd2cSJim Jagielski * 5.reload the saved document and check the paragraph text to text alignment 58*b1cdbd2cSJim Jagielski */ 59*b1cdbd2cSJim Jagielski @Test testTexttoTextAlignment_Baseline()60*b1cdbd2cSJim Jagielski public void testTexttoTextAlignment_Baseline() throws Exception { 61*b1cdbd2cSJim Jagielski 62*b1cdbd2cSJim Jagielski XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 63*b1cdbd2cSJim Jagielski xText = xTextDocument.getText(); 64*b1cdbd2cSJim Jagielski 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!" + 65*b1cdbd2cSJim Jagielski "Hello,world!Hello,world!"); 66*b1cdbd2cSJim Jagielski // create text cursor for selecting and formatting text 67*b1cdbd2cSJim Jagielski XTextCursor xTextCursor = xText.createTextCursor(); 68*b1cdbd2cSJim Jagielski XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 69*b1cdbd2cSJim Jagielski xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.BASELINE); 70*b1cdbd2cSJim Jagielski //save to odt 71*b1cdbd2cSJim Jagielski XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 72*b1cdbd2cSJim Jagielski PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 73*b1cdbd2cSJim Jagielski aStoreProperties_odt[0] = new PropertyValue(); 74*b1cdbd2cSJim Jagielski aStoreProperties_odt[1] = new PropertyValue(); 75*b1cdbd2cSJim Jagielski aStoreProperties_odt[0].Name = "Override"; 76*b1cdbd2cSJim Jagielski aStoreProperties_odt[0].Value = true; 77*b1cdbd2cSJim Jagielski aStoreProperties_odt[1].Name = "FilterName"; 78*b1cdbd2cSJim Jagielski aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 79*b1cdbd2cSJim Jagielski xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 80*b1cdbd2cSJim Jagielski //save to doc 81*b1cdbd2cSJim Jagielski XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 82*b1cdbd2cSJim Jagielski PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 83*b1cdbd2cSJim Jagielski aStoreProperties_doc[0] = new PropertyValue(); 84*b1cdbd2cSJim Jagielski aStoreProperties_doc[1] = new PropertyValue(); 85*b1cdbd2cSJim Jagielski aStoreProperties_doc[0].Name = "Override"; 86*b1cdbd2cSJim Jagielski aStoreProperties_doc[0].Value = true; 87*b1cdbd2cSJim Jagielski aStoreProperties_doc[1].Name = "FilterName"; 88*b1cdbd2cSJim Jagielski aStoreProperties_doc[1].Value = "MS Word 97"; 89*b1cdbd2cSJim Jagielski xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 90*b1cdbd2cSJim Jagielski app.closeDocument(xTextDocument); 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski //reopen the document 93*b1cdbd2cSJim Jagielski XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 94*b1cdbd2cSJim Jagielski XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 95*b1cdbd2cSJim Jagielski //verify paragraph text to text alignment 96*b1cdbd2cSJim Jagielski assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BASELINE,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 97*b1cdbd2cSJim Jagielski 98*b1cdbd2cSJim Jagielski //reopen the document 99*b1cdbd2cSJim Jagielski XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 100*b1cdbd2cSJim Jagielski XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 101*b1cdbd2cSJim Jagielski //verify paragraph text to text alignment 102*b1cdbd2cSJim Jagielski assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BASELINE,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 103*b1cdbd2cSJim Jagielski } 104*b1cdbd2cSJim Jagielski @Test testTexttoTextAlignment_Bottom()105*b1cdbd2cSJim Jagielski public void testTexttoTextAlignment_Bottom() throws Exception { 106*b1cdbd2cSJim Jagielski 107*b1cdbd2cSJim Jagielski XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 108*b1cdbd2cSJim Jagielski xText = xTextDocument.getText(); 109*b1cdbd2cSJim Jagielski 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!" + 110*b1cdbd2cSJim Jagielski "Hello,world!Hello,world!"); 111*b1cdbd2cSJim Jagielski // create text cursor for selecting and formatting text 112*b1cdbd2cSJim Jagielski XTextCursor xTextCursor = xText.createTextCursor(); 113*b1cdbd2cSJim Jagielski XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 114*b1cdbd2cSJim Jagielski xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.BOTTOM); 115*b1cdbd2cSJim Jagielski //save to odt 116*b1cdbd2cSJim Jagielski XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 117*b1cdbd2cSJim Jagielski PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 118*b1cdbd2cSJim Jagielski aStoreProperties_odt[0] = new PropertyValue(); 119*b1cdbd2cSJim Jagielski aStoreProperties_odt[1] = new PropertyValue(); 120*b1cdbd2cSJim Jagielski aStoreProperties_odt[0].Name = "Override"; 121*b1cdbd2cSJim Jagielski aStoreProperties_odt[0].Value = true; 122*b1cdbd2cSJim Jagielski aStoreProperties_odt[1].Name = "FilterName"; 123*b1cdbd2cSJim Jagielski aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 124*b1cdbd2cSJim Jagielski xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 125*b1cdbd2cSJim Jagielski //save to doc 126*b1cdbd2cSJim Jagielski XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 127*b1cdbd2cSJim Jagielski PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 128*b1cdbd2cSJim Jagielski aStoreProperties_doc[0] = new PropertyValue(); 129*b1cdbd2cSJim Jagielski aStoreProperties_doc[1] = new PropertyValue(); 130*b1cdbd2cSJim Jagielski aStoreProperties_doc[0].Name = "Override"; 131*b1cdbd2cSJim Jagielski aStoreProperties_doc[0].Value = true; 132*b1cdbd2cSJim Jagielski aStoreProperties_doc[1].Name = "FilterName"; 133*b1cdbd2cSJim Jagielski aStoreProperties_doc[1].Value = "MS Word 97"; 134*b1cdbd2cSJim Jagielski xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 135*b1cdbd2cSJim Jagielski app.closeDocument(xTextDocument); 136*b1cdbd2cSJim Jagielski 137*b1cdbd2cSJim Jagielski //reopen the document 138*b1cdbd2cSJim Jagielski XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 139*b1cdbd2cSJim Jagielski XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 140*b1cdbd2cSJim Jagielski //verify paragraph text to text alignment 141*b1cdbd2cSJim Jagielski assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BOTTOM,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 142*b1cdbd2cSJim Jagielski 143*b1cdbd2cSJim Jagielski //reopen the document 144*b1cdbd2cSJim Jagielski XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 145*b1cdbd2cSJim Jagielski XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 146*b1cdbd2cSJim Jagielski //verify paragraph text to text alignment 147*b1cdbd2cSJim Jagielski assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.BOTTOM,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 148*b1cdbd2cSJim Jagielski } 149*b1cdbd2cSJim Jagielski @Test testTexttoTextAlignment_Center()150*b1cdbd2cSJim Jagielski public void testTexttoTextAlignment_Center() throws Exception { 151*b1cdbd2cSJim Jagielski 152*b1cdbd2cSJim Jagielski XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 153*b1cdbd2cSJim Jagielski xText = xTextDocument.getText(); 154*b1cdbd2cSJim Jagielski 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!" + 155*b1cdbd2cSJim Jagielski "Hello,world!Hello,world!"); 156*b1cdbd2cSJim Jagielski // create text cursor for selecting and formatting text 157*b1cdbd2cSJim Jagielski XTextCursor xTextCursor = xText.createTextCursor(); 158*b1cdbd2cSJim Jagielski XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 159*b1cdbd2cSJim Jagielski xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.CENTER); 160*b1cdbd2cSJim Jagielski //save to odt 161*b1cdbd2cSJim Jagielski XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 162*b1cdbd2cSJim Jagielski PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 163*b1cdbd2cSJim Jagielski aStoreProperties_odt[0] = new PropertyValue(); 164*b1cdbd2cSJim Jagielski aStoreProperties_odt[1] = new PropertyValue(); 165*b1cdbd2cSJim Jagielski aStoreProperties_odt[0].Name = "Override"; 166*b1cdbd2cSJim Jagielski aStoreProperties_odt[0].Value = true; 167*b1cdbd2cSJim Jagielski aStoreProperties_odt[1].Name = "FilterName"; 168*b1cdbd2cSJim Jagielski aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 169*b1cdbd2cSJim Jagielski xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 170*b1cdbd2cSJim Jagielski //save to doc 171*b1cdbd2cSJim Jagielski XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 172*b1cdbd2cSJim Jagielski PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 173*b1cdbd2cSJim Jagielski aStoreProperties_doc[0] = new PropertyValue(); 174*b1cdbd2cSJim Jagielski aStoreProperties_doc[1] = new PropertyValue(); 175*b1cdbd2cSJim Jagielski aStoreProperties_doc[0].Name = "Override"; 176*b1cdbd2cSJim Jagielski aStoreProperties_doc[0].Value = true; 177*b1cdbd2cSJim Jagielski aStoreProperties_doc[1].Name = "FilterName"; 178*b1cdbd2cSJim Jagielski aStoreProperties_doc[1].Value = "MS Word 97"; 179*b1cdbd2cSJim Jagielski xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 180*b1cdbd2cSJim Jagielski app.closeDocument(xTextDocument); 181*b1cdbd2cSJim Jagielski 182*b1cdbd2cSJim Jagielski //reopen the document 183*b1cdbd2cSJim Jagielski XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 184*b1cdbd2cSJim Jagielski XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 185*b1cdbd2cSJim Jagielski //verify paragraph text to text alignment 186*b1cdbd2cSJim Jagielski assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.CENTER,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 187*b1cdbd2cSJim Jagielski 188*b1cdbd2cSJim Jagielski //reopen the document 189*b1cdbd2cSJim Jagielski XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 190*b1cdbd2cSJim Jagielski XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 191*b1cdbd2cSJim Jagielski //verify paragraph text to text alignment 192*b1cdbd2cSJim Jagielski assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.CENTER,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 193*b1cdbd2cSJim Jagielski } 194*b1cdbd2cSJim Jagielski @Test testTexttoTextAlignment_Top()195*b1cdbd2cSJim Jagielski public void testTexttoTextAlignment_Top() throws Exception { 196*b1cdbd2cSJim Jagielski 197*b1cdbd2cSJim Jagielski XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 198*b1cdbd2cSJim Jagielski xText = xTextDocument.getText(); 199*b1cdbd2cSJim Jagielski 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!" + 200*b1cdbd2cSJim Jagielski "Hello,world!Hello,world!"); 201*b1cdbd2cSJim Jagielski // create text cursor for selecting and formatting text 202*b1cdbd2cSJim Jagielski XTextCursor xTextCursor = xText.createTextCursor(); 203*b1cdbd2cSJim Jagielski XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 204*b1cdbd2cSJim Jagielski xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.TOP); 205*b1cdbd2cSJim Jagielski //save to odt 206*b1cdbd2cSJim Jagielski XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 207*b1cdbd2cSJim Jagielski PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 208*b1cdbd2cSJim Jagielski aStoreProperties_odt[0] = new PropertyValue(); 209*b1cdbd2cSJim Jagielski aStoreProperties_odt[1] = new PropertyValue(); 210*b1cdbd2cSJim Jagielski aStoreProperties_odt[0].Name = "Override"; 211*b1cdbd2cSJim Jagielski aStoreProperties_odt[0].Value = true; 212*b1cdbd2cSJim Jagielski aStoreProperties_odt[1].Name = "FilterName"; 213*b1cdbd2cSJim Jagielski aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 214*b1cdbd2cSJim Jagielski xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 215*b1cdbd2cSJim Jagielski //save to doc 216*b1cdbd2cSJim Jagielski XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 217*b1cdbd2cSJim Jagielski PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 218*b1cdbd2cSJim Jagielski aStoreProperties_doc[0] = new PropertyValue(); 219*b1cdbd2cSJim Jagielski aStoreProperties_doc[1] = new PropertyValue(); 220*b1cdbd2cSJim Jagielski aStoreProperties_doc[0].Name = "Override"; 221*b1cdbd2cSJim Jagielski aStoreProperties_doc[0].Value = true; 222*b1cdbd2cSJim Jagielski aStoreProperties_doc[1].Name = "FilterName"; 223*b1cdbd2cSJim Jagielski aStoreProperties_doc[1].Value = "MS Word 97"; 224*b1cdbd2cSJim Jagielski xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 225*b1cdbd2cSJim Jagielski app.closeDocument(xTextDocument); 226*b1cdbd2cSJim Jagielski 227*b1cdbd2cSJim Jagielski //reopen the document 228*b1cdbd2cSJim Jagielski XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 229*b1cdbd2cSJim Jagielski XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 230*b1cdbd2cSJim Jagielski //verify paragraph text to text alignment 231*b1cdbd2cSJim Jagielski assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.TOP,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 232*b1cdbd2cSJim Jagielski 233*b1cdbd2cSJim Jagielski //reopen the document 234*b1cdbd2cSJim Jagielski XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 235*b1cdbd2cSJim Jagielski XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 236*b1cdbd2cSJim Jagielski //verify paragraph text to text alignment 237*b1cdbd2cSJim Jagielski assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.TOP,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 238*b1cdbd2cSJim Jagielski } 239*b1cdbd2cSJim Jagielski @Test testTexttoTextAlignment_Automatic()240*b1cdbd2cSJim Jagielski public void testTexttoTextAlignment_Automatic() throws Exception { 241*b1cdbd2cSJim Jagielski 242*b1cdbd2cSJim Jagielski XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 243*b1cdbd2cSJim Jagielski xText = xTextDocument.getText(); 244*b1cdbd2cSJim Jagielski 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!" + 245*b1cdbd2cSJim Jagielski "Hello,world!Hello,world!"); 246*b1cdbd2cSJim Jagielski // create text cursor for selecting and formatting text 247*b1cdbd2cSJim Jagielski XTextCursor xTextCursor = xText.createTextCursor(); 248*b1cdbd2cSJim Jagielski XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 249*b1cdbd2cSJim Jagielski xCursorProps.setPropertyValue("ParaVertAlignment",ParagraphVertAlign.AUTOMATIC); 250*b1cdbd2cSJim Jagielski //save to odt 251*b1cdbd2cSJim Jagielski XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 252*b1cdbd2cSJim Jagielski PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 253*b1cdbd2cSJim Jagielski aStoreProperties_odt[0] = new PropertyValue(); 254*b1cdbd2cSJim Jagielski aStoreProperties_odt[1] = new PropertyValue(); 255*b1cdbd2cSJim Jagielski aStoreProperties_odt[0].Name = "Override"; 256*b1cdbd2cSJim Jagielski aStoreProperties_odt[0].Value = true; 257*b1cdbd2cSJim Jagielski aStoreProperties_odt[1].Name = "FilterName"; 258*b1cdbd2cSJim Jagielski aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 259*b1cdbd2cSJim Jagielski xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 260*b1cdbd2cSJim Jagielski //save to doc 261*b1cdbd2cSJim Jagielski XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 262*b1cdbd2cSJim Jagielski PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 263*b1cdbd2cSJim Jagielski aStoreProperties_doc[0] = new PropertyValue(); 264*b1cdbd2cSJim Jagielski aStoreProperties_doc[1] = new PropertyValue(); 265*b1cdbd2cSJim Jagielski aStoreProperties_doc[0].Name = "Override"; 266*b1cdbd2cSJim Jagielski aStoreProperties_doc[0].Value = true; 267*b1cdbd2cSJim Jagielski aStoreProperties_doc[1].Name = "FilterName"; 268*b1cdbd2cSJim Jagielski aStoreProperties_doc[1].Value = "MS Word 97"; 269*b1cdbd2cSJim Jagielski xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 270*b1cdbd2cSJim Jagielski app.closeDocument(xTextDocument); 271*b1cdbd2cSJim Jagielski 272*b1cdbd2cSJim Jagielski //reopen the document 273*b1cdbd2cSJim Jagielski XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 274*b1cdbd2cSJim Jagielski XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 275*b1cdbd2cSJim Jagielski //verify paragraph text to text alignment 276*b1cdbd2cSJim Jagielski assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.AUTOMATIC,xCursorProps_Assert_odt.getPropertyValue("ParaVertAlignment")); 277*b1cdbd2cSJim Jagielski 278*b1cdbd2cSJim Jagielski //reopen the document 279*b1cdbd2cSJim Jagielski XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 280*b1cdbd2cSJim Jagielski XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 281*b1cdbd2cSJim Jagielski //verify paragraph text to text alignment 282*b1cdbd2cSJim Jagielski assertEquals("assert paragraph text to text alignment",ParagraphVertAlign.AUTOMATIC,xCursorProps_Assert_doc.getPropertyValue("ParaVertAlignment")); 283*b1cdbd2cSJim Jagielski } 284*b1cdbd2cSJim Jagielski } 285