1*07d7dbdcSHerbert Dürr /************************************************************** 2*07d7dbdcSHerbert Dürr * 3*07d7dbdcSHerbert Dürr * Licensed to the Apache Software Foundation (ASF) under one 4*07d7dbdcSHerbert Dürr * or more contributor license agreements. See the NOTICE file 5*07d7dbdcSHerbert Dürr * distributed with this work for additional information 6*07d7dbdcSHerbert Dürr * regarding copyright ownership. The ASF licenses this file 7*07d7dbdcSHerbert Dürr * to you under the Apache License, Version 2.0 (the 8*07d7dbdcSHerbert Dürr * "License"); you may not use this file except in compliance 9*07d7dbdcSHerbert Dürr * with the License. You may obtain a copy of the License at 10*07d7dbdcSHerbert Dürr * 11*07d7dbdcSHerbert Dürr * http://www.apache.org/licenses/LICENSE-2.0 12*07d7dbdcSHerbert Dürr * 13*07d7dbdcSHerbert Dürr * Unless required by applicable law or agreed to in writing, 14*07d7dbdcSHerbert Dürr * software distributed under the License is distributed on an 15*07d7dbdcSHerbert Dürr * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*07d7dbdcSHerbert Dürr * KIND, either express or implied. See the License for the 17*07d7dbdcSHerbert Dürr * specific language governing permissions and limitations 18*07d7dbdcSHerbert Dürr * under the License. 19*07d7dbdcSHerbert Dürr * 20*07d7dbdcSHerbert Dürr *************************************************************/ 21*07d7dbdcSHerbert Dürr 22eba4d44aSLiu Zhe package fvt.uno.sw.paragraph; 23eba4d44aSLiu Zhe 24eba4d44aSLiu Zhe import static org.junit.Assert.*; 25eba4d44aSLiu Zhe 26eba4d44aSLiu Zhe import org.junit.After; 27eba4d44aSLiu Zhe import org.junit.Before; 28eba4d44aSLiu Zhe import org.junit.Ignore; 29eba4d44aSLiu Zhe import org.junit.Test; 30eba4d44aSLiu Zhe import org.openoffice.test.common.FileUtil; 31eba4d44aSLiu Zhe import org.openoffice.test.common.Testspace; 32eba4d44aSLiu Zhe import org.openoffice.test.uno.UnoApp; 33eba4d44aSLiu Zhe //import org.openoffice.test.vcl.Tester.*; 34eba4d44aSLiu Zhe import com.sun.star.text.*; 35eba4d44aSLiu Zhe import com.sun.star.beans.*; 36eba4d44aSLiu Zhe import com.sun.star.frame.XStorable; 37eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime; 38eba4d44aSLiu Zhe import com.sun.star.style.*; 39eba4d44aSLiu Zhe 40eba4d44aSLiu Zhe public class ParagraphLineSpacing { 41eba4d44aSLiu Zhe private static final UnoApp app = new UnoApp(); 42eba4d44aSLiu Zhe XText xText = null; 43eba4d44aSLiu Zhe 44eba4d44aSLiu Zhe @Before setUp()45eba4d44aSLiu Zhe public void setUp() throws Exception { 46eba4d44aSLiu Zhe app.start(); 47eba4d44aSLiu Zhe 48eba4d44aSLiu Zhe } 49eba4d44aSLiu Zhe 50eba4d44aSLiu Zhe @After tearDown()51eba4d44aSLiu Zhe public void tearDown() throws Exception { 52eba4d44aSLiu Zhe app.close(); 53eba4d44aSLiu Zhe } 54eba4d44aSLiu Zhe /* 55eba4d44aSLiu Zhe * test paragraph line spacing is fix 56eba4d44aSLiu Zhe * 1.new a text document 57eba4d44aSLiu Zhe * 2.insert some text 58eba4d44aSLiu Zhe * 3.set paragraph line spacing is fix 59eba4d44aSLiu Zhe * 4.save and close the document 60eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 61eba4d44aSLiu Zhe */ 62eba4d44aSLiu Zhe @Test testParagraphLineSpacingFix()63eba4d44aSLiu Zhe public void testParagraphLineSpacingFix() throws Exception { 64eba4d44aSLiu Zhe 65eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 66eba4d44aSLiu Zhe xText = xTextDocument.getText(); 67eba4d44aSLiu 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!" + 68eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 69eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 70eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 71eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 72eba4d44aSLiu Zhe //set paragraph line spacing 73eba4d44aSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 74eba4d44aSLiu Zhe lineSpacing.Mode = LineSpacingMode.FIX; 75eba4d44aSLiu Zhe lineSpacing.Height = 5000; 76eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 77eba4d44aSLiu Zhe //save to odt 78eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 79eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 80eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 81eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 82eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 83eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 84eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 85eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 86eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 87eba4d44aSLiu Zhe //save to doc 88eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 89eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 90eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 91eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 92eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 93eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 94eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 95eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 96eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 97eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 98eba4d44aSLiu Zhe 99eba4d44aSLiu Zhe //reopen the document and assert paragraph line spacing 100eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 101eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 102eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 103eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.FIX,paraLineSpacing_assert_odt.Mode); 104eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_odt.Height); 105eba4d44aSLiu Zhe 106eba4d44aSLiu Zhe //reopen the document and assert paragraph line spacing 107eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 108eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 109eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 110eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.FIX,paraLineSpacing_assert_doc.Mode); 111eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_doc.Height); 112eba4d44aSLiu Zhe } 113eba4d44aSLiu Zhe /* 114eba4d44aSLiu Zhe * test paragraph line spacing is leading 115eba4d44aSLiu Zhe * 1.new a text document 116eba4d44aSLiu Zhe * 2.insert some text 117eba4d44aSLiu Zhe * 3.set paragraph line spacing is leading 118eba4d44aSLiu Zhe * 4.save and close the document 119eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 120eba4d44aSLiu Zhe */ 121eba4d44aSLiu Zhe @Test@Ignore("Bug #120647 - [testUNO patch]line spacing leading setting change to at least when save to doc") testParagraphLineSpacingLeading()122eba4d44aSLiu Zhe public void testParagraphLineSpacingLeading() throws Exception { 123eba4d44aSLiu Zhe 124eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 125eba4d44aSLiu Zhe xText = xTextDocument.getText(); 126eba4d44aSLiu 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!" + 127eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 128eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 129eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 130eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 131eba4d44aSLiu Zhe //set paragraph line spacing 132eba4d44aSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 133eba4d44aSLiu Zhe lineSpacing.Mode = LineSpacingMode.LEADING; 134eba4d44aSLiu Zhe lineSpacing.Height = 5000; 135eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 136eba4d44aSLiu Zhe //save to odt 137eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 138eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 139eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 140eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 141eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 142eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 143eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 144eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 145eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 146eba4d44aSLiu Zhe //save to doc 147eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 148eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 149eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 150eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 151eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 152eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 153eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 154eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 155eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 156eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 157eba4d44aSLiu Zhe 158eba4d44aSLiu Zhe //reopen the document 159eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 160eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 161eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 162eba4d44aSLiu Zhe //verify paragraph line spacing property 163eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.LEADING,paraLineSpacing_assert_odt.Mode); 164eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_odt.Height); 165eba4d44aSLiu Zhe 166eba4d44aSLiu Zhe //reopen the document 167eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 168eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 169eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 170eba4d44aSLiu Zhe //verify paragraph line spacing property 171eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.LEADING,paraLineSpacing_assert_doc.Mode); 172eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_doc.Height); 173eba4d44aSLiu Zhe } 174eba4d44aSLiu Zhe /* 175eba4d44aSLiu Zhe * test paragraph line spacing is minimum 176eba4d44aSLiu Zhe * 1.new a text document 177eba4d44aSLiu Zhe * 2.insert some text 178eba4d44aSLiu Zhe * 3.set paragraph line spacing is minimum 179eba4d44aSLiu Zhe * 4.save and close the document 180eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 181eba4d44aSLiu Zhe */ 182eba4d44aSLiu Zhe @Test testParagraphLineSpacingMinimum()183eba4d44aSLiu Zhe public void testParagraphLineSpacingMinimum() throws Exception { 184eba4d44aSLiu Zhe 185eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 186eba4d44aSLiu Zhe xText = xTextDocument.getText(); 187eba4d44aSLiu 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!" + 188eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 189eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 190eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 191eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 192eba4d44aSLiu Zhe //set paragraph line spacing 193eba4d44aSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 194eba4d44aSLiu Zhe lineSpacing.Mode = LineSpacingMode.MINIMUM; 195eba4d44aSLiu Zhe lineSpacing.Height = 5000; 196eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 197eba4d44aSLiu Zhe //save to odt 198eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 199eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 200eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 201eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 202eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 203eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 204eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 205eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 206eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 207eba4d44aSLiu Zhe //save to doc 208eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 209eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 210eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 211eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 212eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 213eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 214eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 215eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 216eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 217eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 218eba4d44aSLiu Zhe 219eba4d44aSLiu Zhe //reopen the document 220eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 221eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 222eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 223eba4d44aSLiu Zhe //verify paragraph line spacing property 224eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.MINIMUM,paraLineSpacing_assert_odt.Mode); 225eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_odt.Height); 226eba4d44aSLiu Zhe 227eba4d44aSLiu Zhe //reopen the document 228eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 229eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 230eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 231eba4d44aSLiu Zhe //verify paragraph line spacing property 232eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",LineSpacingMode.MINIMUM,paraLineSpacing_assert_doc.Mode); 233eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is fix",5001,paraLineSpacing_assert_doc.Height); 234eba4d44aSLiu Zhe } 235eba4d44aSLiu Zhe /* 236eba4d44aSLiu Zhe * test paragraph line spacing is prop 237eba4d44aSLiu Zhe * 1.new a text document 238eba4d44aSLiu Zhe * 2.insert some text 239eba4d44aSLiu Zhe * 3.set paragraph alignment is prop 240eba4d44aSLiu Zhe * 4.save and close the document 241eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 242eba4d44aSLiu Zhe */ 243eba4d44aSLiu Zhe @Test testParagraphLineSpacingProp()244eba4d44aSLiu Zhe public void testParagraphLineSpacingProp() throws Exception { 245eba4d44aSLiu Zhe 246eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 247eba4d44aSLiu Zhe xText = xTextDocument.getText(); 248eba4d44aSLiu 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!" + 249eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 250eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 251eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 252eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 253eba4d44aSLiu Zhe //set paragraph line spacing 254eba4d44aSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 255eba4d44aSLiu Zhe lineSpacing.Mode = LineSpacingMode.PROP; 256eba4d44aSLiu Zhe lineSpacing.Height = 150; 257eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 258eba4d44aSLiu Zhe //save to odt 259eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 260eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 261eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 262eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 263eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 264eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 265eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 266eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 267eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 268eba4d44aSLiu Zhe //save to doc 269eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 270eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 271eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 272eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 273eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 274eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 275eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 276eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 277eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 278eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 279eba4d44aSLiu Zhe 280eba4d44aSLiu Zhe //reopen the document 281eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 282eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 283eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 284eba4d44aSLiu Zhe //verify paragraph line spacing property 285eba4d44aSLiu Zhe assertEquals("assert line spacing is prop",LineSpacingMode.PROP,paraLineSpacing_assert_odt.Mode); 286eba4d44aSLiu Zhe assertEquals("assert line spacing height is 150",150,paraLineSpacing_assert_odt.Height); 287eba4d44aSLiu Zhe 288eba4d44aSLiu Zhe //reopen the document 289eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 290eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 291eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 292eba4d44aSLiu Zhe //verify paragraph line spacing property 293eba4d44aSLiu Zhe assertEquals("assert line spacing is prop",LineSpacingMode.PROP,paraLineSpacing_assert_doc.Mode); 294eba4d44aSLiu Zhe assertEquals("assert line spacing height is 150",150,paraLineSpacing_assert_doc.Height); 295eba4d44aSLiu Zhe } 296eba4d44aSLiu Zhe /* 297eba4d44aSLiu Zhe * test paragraph line spacing is single 298eba4d44aSLiu Zhe * 1.new a text document 299eba4d44aSLiu Zhe * 2.insert some text 300eba4d44aSLiu Zhe * 3.set paragraph line spacing is single 301eba4d44aSLiu Zhe * 4.save and close the document 302eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 303eba4d44aSLiu Zhe */ 304eba4d44aSLiu Zhe @Test@Ignore("Bug #120649 - [testUNO patch]single line spacing change to at least of 0.07 when save to doc") testParagraphLineSpacingSingle()305eba4d44aSLiu Zhe public void testParagraphLineSpacingSingle() throws Exception { 306eba4d44aSLiu Zhe 307eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 308eba4d44aSLiu Zhe xText = xTextDocument.getText(); 309eba4d44aSLiu 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!" + 310eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 311eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 312eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 313eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 314eba4d44aSLiu Zhe //set paragraph line spacing 315eba4d44aSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 316eba4d44aSLiu Zhe lineSpacing.Height = 100; 317eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 318eba4d44aSLiu Zhe //save to odt 319eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 320eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 321eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 322eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 323eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 324eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 325eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 326eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 327eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 328eba4d44aSLiu Zhe //save to doc 329eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 330eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 331eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 332eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 333eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 334eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 335eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 336eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 337eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 338eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 339eba4d44aSLiu Zhe 340eba4d44aSLiu Zhe //reopen the document 341eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 342eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 343eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 344eba4d44aSLiu Zhe //verify paragraph line spacing property 345eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is single",100,paraLineSpacing_assert_odt.Height); 346eba4d44aSLiu Zhe 347eba4d44aSLiu Zhe //reopen the document 348eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 349eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 350eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 351eba4d44aSLiu Zhe //verify paragraph line spacing property 352eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is single",100,paraLineSpacing_assert_doc.Height); 353eba4d44aSLiu Zhe } 354eba4d44aSLiu Zhe /* 355eba4d44aSLiu Zhe * test paragraph line spacing is double 356eba4d44aSLiu Zhe * 1.new a text document 357eba4d44aSLiu Zhe * 2.insert some text 358eba4d44aSLiu Zhe * 3.set paragraph line spacing is double 359eba4d44aSLiu Zhe * 4.save and close the document 360eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 361eba4d44aSLiu Zhe */ 362eba4d44aSLiu Zhe @Test testParagraphLineSpacingDouble()363eba4d44aSLiu Zhe public void testParagraphLineSpacingDouble() throws Exception { 364eba4d44aSLiu Zhe 365eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 366eba4d44aSLiu Zhe xText = xTextDocument.getText(); 367eba4d44aSLiu 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!" + 368eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 369eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 370eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 371eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 372eba4d44aSLiu Zhe //set paragraph line spacing 373eba4d44aSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 374eba4d44aSLiu Zhe lineSpacing.Height = 200; 375eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 376eba4d44aSLiu Zhe //save to odt 377eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 378eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 379eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 380eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 381eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 382eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 383eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 384eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 385eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 386eba4d44aSLiu Zhe //save to doc 387eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 388eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 389eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 390eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 391eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 392eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 393eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 394eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 395eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 396eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 397eba4d44aSLiu Zhe 398eba4d44aSLiu Zhe //reopen the document and assert line spacing 399eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 400eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 401eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 402eba4d44aSLiu Zhe //verify paragraph line spacing property 403eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is single",200,paraLineSpacing_assert_odt.Height); 404eba4d44aSLiu Zhe 405eba4d44aSLiu Zhe //reopen the document and assert line spacing 406eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 407eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 408eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 409eba4d44aSLiu Zhe //verify paragraph line spacing property 410eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is single",200,paraLineSpacing_assert_doc.Height); 411eba4d44aSLiu Zhe } 412eba4d44aSLiu Zhe /* 413eba4d44aSLiu Zhe * test paragraph line spacing is 1.5line 414eba4d44aSLiu Zhe * 1.new a text document 415eba4d44aSLiu Zhe * 2.insert some text 416eba4d44aSLiu Zhe * 3.set paragraph line spacing is 1.5line 417eba4d44aSLiu Zhe * 4.save and close the document 418eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph line spacing 419eba4d44aSLiu Zhe */ 420eba4d44aSLiu Zhe @Test testParagraphLineSpacingUserDefine()421eba4d44aSLiu Zhe public void testParagraphLineSpacingUserDefine() throws Exception { 422eba4d44aSLiu Zhe 423eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 424eba4d44aSLiu Zhe xText = xTextDocument.getText(); 425eba4d44aSLiu 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!" + 426eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 427eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 428eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 429eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 430eba4d44aSLiu Zhe //set paragraph line spacing 431eba4d44aSLiu Zhe LineSpacing lineSpacing = new LineSpacing(); 432eba4d44aSLiu Zhe lineSpacing.Height = 150; 433eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaLineSpacing",lineSpacing); 434eba4d44aSLiu Zhe //save to odt 435eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 436eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 437eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 438eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 439eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 440eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 441eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 442eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 443eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 444eba4d44aSLiu Zhe //save to doc 445eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 446eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 447eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 448eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 449eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 450eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 451eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 452eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 453eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 454eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 455eba4d44aSLiu Zhe 456eba4d44aSLiu Zhe //reopen the document 457eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 458eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_odt.getText().createTextCursor()); 459eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_odt=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_odt.getPropertyValue("ParaLineSpacing")); 460eba4d44aSLiu Zhe //verify paragraph line spacing property 461eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is single",150,paraLineSpacing_assert_odt.Height); 462eba4d44aSLiu Zhe 463eba4d44aSLiu Zhe //reopen the document 464eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 465eba4d44aSLiu Zhe XPropertySet xCursorProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,assertDocument_doc.getText().createTextCursor()); 466eba4d44aSLiu Zhe LineSpacing paraLineSpacing_assert_doc=(LineSpacing) UnoRuntime.queryInterface(LineSpacing.class, xCursorProps_assert_doc.getPropertyValue("ParaLineSpacing")); 467eba4d44aSLiu Zhe //verify paragraph line spacing property 468eba4d44aSLiu Zhe assertEquals("assert first paragraph line spacing is single",150,paraLineSpacing_assert_doc.Height); 469eba4d44aSLiu Zhe } 470eba4d44aSLiu Zhe } 471