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 34eba4d44aSLiu Zhe import com.sun.star.style.NumberingType; 35eba4d44aSLiu Zhe import com.sun.star.text.*; 36eba4d44aSLiu Zhe import com.sun.star.beans.*; 37eba4d44aSLiu Zhe import com.sun.star.container.XIndexAccess; 38eba4d44aSLiu Zhe import com.sun.star.container.XIndexReplace; 39eba4d44aSLiu Zhe import com.sun.star.frame.XStorable; 40eba4d44aSLiu Zhe import com.sun.star.lang.XMultiServiceFactory; 41eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime; 42eba4d44aSLiu Zhe 43eba4d44aSLiu Zhe public class ParagraphNumberingAndBullet_Numbering { 44eba4d44aSLiu Zhe private static final UnoApp app = new UnoApp(); 45eba4d44aSLiu Zhe XText xText = null; 46eba4d44aSLiu Zhe 47eba4d44aSLiu Zhe @Before setUp()48eba4d44aSLiu Zhe public void setUp() throws Exception { 49eba4d44aSLiu Zhe app.start(); 50eba4d44aSLiu Zhe 51eba4d44aSLiu Zhe } 52eba4d44aSLiu Zhe 53eba4d44aSLiu Zhe @After tearDown()54eba4d44aSLiu Zhe public void tearDown() throws Exception { 55eba4d44aSLiu Zhe app.close(); 56eba4d44aSLiu Zhe } 57eba4d44aSLiu Zhe /* 58eba4d44aSLiu Zhe * test paragraph background color 59eba4d44aSLiu Zhe * 1.new a text document 60eba4d44aSLiu Zhe * 2.insert some text 61eba4d44aSLiu Zhe * 3.set paragraph numbering and bullet with numbering 62eba4d44aSLiu Zhe * 4.save and close the document 63eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph numbering bullet 64eba4d44aSLiu Zhe */ 65eba4d44aSLiu Zhe @Test testNumberingBullet_ARABIC()66eba4d44aSLiu Zhe public void testNumberingBullet_ARABIC() throws Exception { 67eba4d44aSLiu Zhe 68eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 69eba4d44aSLiu Zhe xText = xTextDocument.getText(); 70eba4d44aSLiu 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!" + 71eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 72eba4d44aSLiu Zhe //create cursor to select paragraph and formating paragraph 73eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 74eba4d44aSLiu Zhe //create paragraph property set 75eba4d44aSLiu Zhe XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 76eba4d44aSLiu Zhe //create document service factory 77eba4d44aSLiu Zhe XMultiServiceFactory xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 78eba4d44aSLiu Zhe //set numbering character 79eba4d44aSLiu Zhe XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules")); 80eba4d44aSLiu Zhe PropertyValue[] propsRule = {new PropertyValue()}; 81eba4d44aSLiu Zhe propsRule[0].Name = "NumberingType"; 82eba4d44aSLiu Zhe propsRule[0].Value = NumberingType.ARABIC; 83eba4d44aSLiu Zhe XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule); 84eba4d44aSLiu Zhe xReplaceRule.replaceByIndex(0, propsRule); 85eba4d44aSLiu Zhe //set paragraph numbering and bullet character 86eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingRules", xNumRule); 87eba4d44aSLiu Zhe //save to odt 88eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 89eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 90eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 91eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 92eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 93eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 94eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 95eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 96eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 97eba4d44aSLiu Zhe //save to doc 98eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 99eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 100eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 101eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 102eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 103eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 104eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 105eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 106eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 107eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 108eba4d44aSLiu Zhe 109eba4d44aSLiu Zhe //reopen the document 110eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 111eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 112eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules")); 113eba4d44aSLiu Zhe XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt); 114eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0)); 115eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 116eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name); 117eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value); 118eba4d44aSLiu Zhe 119eba4d44aSLiu Zhe //reopen the document 120eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 121eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 122eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules")); 123eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0)); 124eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 125eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name); 126eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value); 127eba4d44aSLiu Zhe } 128eba4d44aSLiu Zhe @Test testNumberingBullet_ARABIC_Suffix()129eba4d44aSLiu Zhe public void testNumberingBullet_ARABIC_Suffix() throws Exception { 130eba4d44aSLiu Zhe 131eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 132eba4d44aSLiu Zhe xText = xTextDocument.getText(); 133eba4d44aSLiu 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!" + 134eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 135eba4d44aSLiu Zhe //create cursor to select paragraph and formating paragraph 136eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 137eba4d44aSLiu Zhe //create paragraph property set 138eba4d44aSLiu Zhe XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 139eba4d44aSLiu Zhe //create document service factory 140eba4d44aSLiu Zhe XMultiServiceFactory xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 141eba4d44aSLiu Zhe //set numbering character 142eba4d44aSLiu Zhe XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules")); 143eba4d44aSLiu Zhe PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()}; 144eba4d44aSLiu Zhe propsRule[0].Name = "NumberingType"; 145eba4d44aSLiu Zhe propsRule[0].Value = NumberingType.ARABIC; 146eba4d44aSLiu Zhe propsRule[1].Name = "Suffix"; 147eba4d44aSLiu Zhe propsRule[1].Value = ")"; 148eba4d44aSLiu Zhe XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule); 149eba4d44aSLiu Zhe xReplaceRule.replaceByIndex(0, propsRule); 150eba4d44aSLiu Zhe //set paragraph numbering and bullet character 151eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingRules", xNumRule); 152eba4d44aSLiu Zhe //save to odt 153eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 154eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 155eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 156eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 157eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 158eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 159eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 160eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 161eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 162eba4d44aSLiu Zhe //save to doc 163eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 164eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 165eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 166eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 167eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 168eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 169eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 170eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 171eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 172eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 173eba4d44aSLiu Zhe 174eba4d44aSLiu Zhe //reopen the document 175eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 176eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 177eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules")); 178eba4d44aSLiu Zhe XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt); 179eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0)); 180eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 181eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name); 182eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value); 183eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name); 184eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value); 185eba4d44aSLiu Zhe 186eba4d44aSLiu Zhe //reopen the document 187eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 188eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 189eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules")); 190eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0)); 191eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 192eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name); 193eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value); 194eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name); 195eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value); 196eba4d44aSLiu Zhe } 197eba4d44aSLiu Zhe @Test testNumberingBullet_ARABIC_Preffix_Suffix()198eba4d44aSLiu Zhe public void testNumberingBullet_ARABIC_Preffix_Suffix() throws Exception { 199eba4d44aSLiu Zhe 200eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 201eba4d44aSLiu Zhe xText = xTextDocument.getText(); 202eba4d44aSLiu 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!" + 203eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 204eba4d44aSLiu Zhe //create cursor to select paragraph and formating paragraph 205eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 206eba4d44aSLiu Zhe //create paragraph property set 207eba4d44aSLiu Zhe XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 208eba4d44aSLiu Zhe //create document service factory 209eba4d44aSLiu Zhe XMultiServiceFactory xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 210eba4d44aSLiu Zhe //set numbering character 211eba4d44aSLiu Zhe XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules")); 212eba4d44aSLiu Zhe PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue(),new PropertyValue()}; 213eba4d44aSLiu Zhe propsRule[0].Name = "NumberingType"; 214eba4d44aSLiu Zhe propsRule[0].Value = NumberingType.ARABIC; 215eba4d44aSLiu Zhe propsRule[1].Name = "Suffix"; 216eba4d44aSLiu Zhe propsRule[1].Value = ")"; 217eba4d44aSLiu Zhe propsRule[2].Name = "Prefix"; 218eba4d44aSLiu Zhe propsRule[2].Value = "("; 219eba4d44aSLiu Zhe XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule); 220eba4d44aSLiu Zhe xReplaceRule.replaceByIndex(0, propsRule); 221eba4d44aSLiu Zhe //set paragraph numbering and bullet character 222eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingRules", xNumRule); 223eba4d44aSLiu Zhe //save to odt 224eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 225eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 226eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 227eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 228eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 229eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 230eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 231eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 232eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 233eba4d44aSLiu Zhe //save to doc 234eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 235eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 236eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 237eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 238eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 239eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 240eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 241eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 242eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 243eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 244eba4d44aSLiu Zhe 245eba4d44aSLiu Zhe //reopen the document 246eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 247eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 248eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules")); 249eba4d44aSLiu Zhe XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt); 250eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0)); 251eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 252eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name); 253eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_odt[11].Value); 254eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name); 255eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value); 256eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Prefix",propsRule_assert_odt[2].Name); 257eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","(",propsRule_assert_odt[2].Value); 258eba4d44aSLiu Zhe 259eba4d44aSLiu Zhe //reopen the document 260eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 261eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 262eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules")); 263eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0)); 264eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 265eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name); 266eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.ARABIC,propsRule_assert_doc[11].Value); 267eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name); 268eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value); 269eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Prefix",propsRule_assert_odt[2].Name); 270eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","(",propsRule_assert_odt[2].Value); 271eba4d44aSLiu Zhe } 272eba4d44aSLiu Zhe @Test testNumberingBullet_ROMAN_LOWER()273eba4d44aSLiu Zhe public void testNumberingBullet_ROMAN_LOWER() throws Exception { 274eba4d44aSLiu Zhe 275eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 276eba4d44aSLiu Zhe xText = xTextDocument.getText(); 277eba4d44aSLiu 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!" + 278eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 279eba4d44aSLiu Zhe //create cursor to select paragraph and formating paragraph 280eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 281eba4d44aSLiu Zhe //create paragraph property set 282eba4d44aSLiu Zhe XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 283eba4d44aSLiu Zhe //create document service factory 284eba4d44aSLiu Zhe XMultiServiceFactory xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 285eba4d44aSLiu Zhe //set numbering character 286eba4d44aSLiu Zhe XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules")); 287eba4d44aSLiu Zhe PropertyValue[] propsRule = {new PropertyValue()}; 288eba4d44aSLiu Zhe propsRule[0].Name = "NumberingType"; 289eba4d44aSLiu Zhe propsRule[0].Value = NumberingType.ROMAN_LOWER; 290eba4d44aSLiu Zhe XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule); 291eba4d44aSLiu Zhe xReplaceRule.replaceByIndex(0, propsRule); 292eba4d44aSLiu Zhe //set paragraph numbering and bullet character 293eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingRules", xNumRule); 294eba4d44aSLiu Zhe //save to odt 295eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 296eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 297eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 298eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 299eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 300eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 301eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 302eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 303eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 304eba4d44aSLiu Zhe //save to doc 305eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 306eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 307eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 308eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 309eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 310eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 311eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 312eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 313eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 314eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 315eba4d44aSLiu Zhe 316eba4d44aSLiu Zhe //reopen the document 317eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 318eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 319eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules")); 320eba4d44aSLiu Zhe XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt); 321eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0)); 322eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 323eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name); 324eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.ROMAN_LOWER,propsRule_assert_odt[11].Value); 325eba4d44aSLiu Zhe 326eba4d44aSLiu Zhe //reopen the document 327eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 328eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 329eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules")); 330eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0)); 331eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 332eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name); 333eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.ROMAN_LOWER,propsRule_assert_doc[11].Value); 334eba4d44aSLiu Zhe } 335eba4d44aSLiu Zhe @Test testNumberingBullet_ROMAN_UPPER()336eba4d44aSLiu Zhe public void testNumberingBullet_ROMAN_UPPER() throws Exception { 337eba4d44aSLiu Zhe 338eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 339eba4d44aSLiu Zhe xText = xTextDocument.getText(); 340eba4d44aSLiu 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!" + 341eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 342eba4d44aSLiu Zhe //create cursor to select paragraph and formating paragraph 343eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 344eba4d44aSLiu Zhe //create paragraph property set 345eba4d44aSLiu Zhe XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 346eba4d44aSLiu Zhe //create document service factory 347eba4d44aSLiu Zhe XMultiServiceFactory xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 348eba4d44aSLiu Zhe //set numbering character 349eba4d44aSLiu Zhe XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules")); 350eba4d44aSLiu Zhe PropertyValue[] propsRule = {new PropertyValue()}; 351eba4d44aSLiu Zhe propsRule[0].Name = "NumberingType"; 352eba4d44aSLiu Zhe propsRule[0].Value = NumberingType.ROMAN_UPPER; 353eba4d44aSLiu Zhe XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule); 354eba4d44aSLiu Zhe xReplaceRule.replaceByIndex(0, propsRule); 355eba4d44aSLiu Zhe //set paragraph numbering and bullet character 356eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingRules", xNumRule); 357eba4d44aSLiu Zhe //save to odt 358eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 359eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 360eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 361eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 362eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 363eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 364eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 365eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 366eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 367eba4d44aSLiu Zhe //save to doc 368eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 369eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 370eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 371eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 372eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 373eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 374eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 375eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 376eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 377eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 378eba4d44aSLiu Zhe 379eba4d44aSLiu Zhe //reopen the document 380eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 381eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 382eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules")); 383eba4d44aSLiu Zhe XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt); 384eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0)); 385eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 386eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name); 387eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.ROMAN_UPPER,propsRule_assert_odt[11].Value); 388eba4d44aSLiu Zhe 389eba4d44aSLiu Zhe //reopen the document 390eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 391eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 392eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules")); 393eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0)); 394eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 395eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name); 396eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.ROMAN_UPPER,propsRule_assert_doc[11].Value); 397eba4d44aSLiu Zhe } 398eba4d44aSLiu Zhe @Test@Ignore("Bug #120826 - [testUNO patch]A,B,C numbering bullet will change to A,AA,AAA when save to doc.") testNumberingBullet_CHARS_UPPER_LETTER()399eba4d44aSLiu Zhe public void testNumberingBullet_CHARS_UPPER_LETTER() throws Exception { 400eba4d44aSLiu Zhe 401eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 402eba4d44aSLiu Zhe xText = xTextDocument.getText(); 403eba4d44aSLiu 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!" + 404eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 405eba4d44aSLiu Zhe //create cursor to select paragraph and formating paragraph 406eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 407eba4d44aSLiu Zhe //create paragraph property set 408eba4d44aSLiu Zhe XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 409eba4d44aSLiu Zhe //create document service factory 410eba4d44aSLiu Zhe XMultiServiceFactory xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 411eba4d44aSLiu Zhe //set numbering character 412eba4d44aSLiu Zhe XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules")); 413eba4d44aSLiu Zhe PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()}; 414eba4d44aSLiu Zhe propsRule[0].Name = "NumberingType"; 415eba4d44aSLiu Zhe propsRule[0].Value = NumberingType.CHARS_UPPER_LETTER; 416eba4d44aSLiu Zhe propsRule[1].Name = "Suffix"; 417eba4d44aSLiu Zhe propsRule[1].Value = ")"; 418eba4d44aSLiu Zhe XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule); 419eba4d44aSLiu Zhe xReplaceRule.replaceByIndex(0, propsRule); 420eba4d44aSLiu Zhe //set paragraph numbering and bullet character 421eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingRules", xNumRule); 422eba4d44aSLiu Zhe //save to odt 423eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 424eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 425eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 426eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 427eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 428eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 429eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 430eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 431eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 432eba4d44aSLiu Zhe //save to doc 433eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 434eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 435eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 436eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 437eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 438eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 439eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 440eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 441eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 442eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 443eba4d44aSLiu Zhe 444eba4d44aSLiu Zhe //reopen the document 445eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 446eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 447eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules")); 448eba4d44aSLiu Zhe XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt); 449eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0)); 450eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 451eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name); 452eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.CHARS_UPPER_LETTER,propsRule_assert_odt[11].Value); 453eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name); 454eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value); 455eba4d44aSLiu Zhe 456eba4d44aSLiu Zhe //reopen the document 457eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 458eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 459eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules")); 460eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0)); 461eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 462eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name); 463eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.CHARS_UPPER_LETTER,propsRule_assert_doc[11].Value); 464eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name); 465eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value); 466eba4d44aSLiu Zhe } 467eba4d44aSLiu Zhe @Test@Ignore("Bug #120826 - [testUNO patch]A,B,C numbering bullet will change to A,AA,AAA when save to doc.") testNumberingBullet_CHARS_LOWER_LETTER_Suffix()468eba4d44aSLiu Zhe public void testNumberingBullet_CHARS_LOWER_LETTER_Suffix() throws Exception { 469eba4d44aSLiu Zhe 470eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 471eba4d44aSLiu Zhe xText = xTextDocument.getText(); 472eba4d44aSLiu 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!" + 473eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 474eba4d44aSLiu Zhe //create cursor to select paragraph and formating paragraph 475eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 476eba4d44aSLiu Zhe //create paragraph property set 477eba4d44aSLiu Zhe XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 478eba4d44aSLiu Zhe //create document service factory 479eba4d44aSLiu Zhe XMultiServiceFactory xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 480eba4d44aSLiu Zhe //set numbering character 481eba4d44aSLiu Zhe XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules")); 482eba4d44aSLiu Zhe PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue()}; 483eba4d44aSLiu Zhe propsRule[0].Name = "NumberingType"; 484eba4d44aSLiu Zhe propsRule[0].Value = NumberingType.CHARS_LOWER_LETTER; 485eba4d44aSLiu Zhe propsRule[1].Name = "Suffix"; 486eba4d44aSLiu Zhe propsRule[1].Value = ")"; 487eba4d44aSLiu Zhe XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule); 488eba4d44aSLiu Zhe xReplaceRule.replaceByIndex(0, propsRule); 489eba4d44aSLiu Zhe //set paragraph numbering and bullet character 490eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingRules", xNumRule); 491eba4d44aSLiu Zhe //save to odt 492eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 493eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 494eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 495eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 496eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 497eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 498eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 499eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 500eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 501eba4d44aSLiu Zhe //save to doc 502eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 503eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 504eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 505eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 506eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 507eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 508eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 509eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 510eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 511eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 512eba4d44aSLiu Zhe 513eba4d44aSLiu Zhe //reopen the document 514eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 515eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 516eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules")); 517eba4d44aSLiu Zhe XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt); 518eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0)); 519eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 520eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name); 521eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_odt[11].Value); 522eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name); 523eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value); 524eba4d44aSLiu Zhe 525eba4d44aSLiu Zhe //reopen the document 526eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 527eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 528eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules")); 529eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0)); 530eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 531eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name); 532eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_doc[11].Value); 533eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name); 534eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value); 535eba4d44aSLiu Zhe } 536eba4d44aSLiu Zhe @Test@Ignore("Bug #120826 - [testUNO patch]A,B,C numbering bullet will change to A,AA,AAA when save to doc.") testNumberingBullet_CHARS_LOWER_LETTER_Suffix_Prefix()537eba4d44aSLiu Zhe public void testNumberingBullet_CHARS_LOWER_LETTER_Suffix_Prefix() throws Exception { 538eba4d44aSLiu Zhe 539eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 540eba4d44aSLiu Zhe xText = xTextDocument.getText(); 541eba4d44aSLiu 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!" + 542eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 543eba4d44aSLiu Zhe //create cursor to select paragraph and formating paragraph 544eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 545eba4d44aSLiu Zhe //create paragraph property set 546eba4d44aSLiu Zhe XPropertySet xTextProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 547eba4d44aSLiu Zhe //create document service factory 548eba4d44aSLiu Zhe XMultiServiceFactory xWriterFactory= (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); 549eba4d44aSLiu Zhe //set numbering character 550eba4d44aSLiu Zhe XIndexAccess xNumRule = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class,xWriterFactory.createInstance("com.sun.star.text.NumberingRules")); 551eba4d44aSLiu Zhe PropertyValue[] propsRule = {new PropertyValue(),new PropertyValue(),new PropertyValue()}; 552eba4d44aSLiu Zhe propsRule[0].Name = "NumberingType"; 553eba4d44aSLiu Zhe propsRule[0].Value = NumberingType.CHARS_LOWER_LETTER; 554eba4d44aSLiu Zhe propsRule[1].Name = "Suffix"; 555eba4d44aSLiu Zhe propsRule[1].Value = ")"; 556eba4d44aSLiu Zhe propsRule[2].Name = "Prefix"; 557eba4d44aSLiu Zhe propsRule[2].Value = "("; 558eba4d44aSLiu Zhe XIndexReplace xReplaceRule = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule); 559eba4d44aSLiu Zhe xReplaceRule.replaceByIndex(0, propsRule); 560eba4d44aSLiu Zhe //set paragraph numbering and bullet character 561eba4d44aSLiu Zhe xTextProps.setPropertyValue("NumberingRules", xNumRule); 562eba4d44aSLiu Zhe //save to odt 563eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 564eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 565eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 566eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 567eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 568eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 569eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 570eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "writer8"; 571eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 572eba4d44aSLiu Zhe //save to doc 573eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 574eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 575eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 576eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 577eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 578eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 579eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 580eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 581eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 582eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 583eba4d44aSLiu Zhe 584eba4d44aSLiu Zhe //reopen the document 585eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 586eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 587eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_odt = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_odt.getPropertyValue("NumberingRules")); 588eba4d44aSLiu Zhe XIndexReplace xReplaceRule_assert_odt = (XIndexReplace) UnoRuntime.queryInterface(XIndexReplace.class, xNumRule_assert_odt); 589eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_odt=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xReplaceRule_assert_odt.getByIndex(0)); 590eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 591eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_odt[11].Name); 592eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_odt[11].Value); 593eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Suffix",propsRule_assert_odt[3].Name); 594eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",")",propsRule_assert_odt[3].Value); 595eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Prefix",propsRule_assert_odt[2].Name); 596eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","(",propsRule_assert_odt[2].Value); 597eba4d44aSLiu Zhe 598eba4d44aSLiu Zhe //reopen the document 599eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 600eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 601eba4d44aSLiu Zhe XIndexAccess xNumRule_assert_doc = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xCursorProps_Assert_doc.getPropertyValue("NumberingRules")); 602eba4d44aSLiu Zhe PropertyValue[] propsRule_assert_doc=(PropertyValue[]) UnoRuntime.queryInterface(PropertyValue[].class,xNumRule_assert_doc.getByIndex(0)); 603eba4d44aSLiu Zhe //verify paragraph numbering and bullet alignment 604eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","NumberingType",propsRule_assert_doc[11].Name); 605eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",NumberingType.CHARS_LOWER_LETTER,propsRule_assert_doc[11].Value); 606eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Suffix",propsRule_assert_doc[3].Name); 607eba4d44aSLiu Zhe assertEquals("assert numbering and bullet",")",propsRule_assert_doc[3].Value); 608eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","Prefix",propsRule_assert_doc[2].Name); 609eba4d44aSLiu Zhe assertEquals("assert numbering and bullet","(",propsRule_assert_doc[2].Value); 610eba4d44aSLiu Zhe } 611eba4d44aSLiu Zhe } 612