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; 236194dbcdSLiu Zhe 246194dbcdSLiu Zhe import static org.junit.Assert.*; 256194dbcdSLiu Zhe 266194dbcdSLiu Zhe import org.junit.After; 276194dbcdSLiu Zhe import org.junit.Before; 286194dbcdSLiu Zhe import org.junit.Ignore; 296194dbcdSLiu Zhe import org.junit.Test; 306194dbcdSLiu Zhe import org.openoffice.test.common.FileUtil; 316194dbcdSLiu Zhe import org.openoffice.test.common.Testspace; 326194dbcdSLiu Zhe import org.openoffice.test.uno.UnoApp; 336194dbcdSLiu Zhe 346194dbcdSLiu Zhe import com.sun.star.table.ShadowFormat; 356194dbcdSLiu Zhe import com.sun.star.table.ShadowLocation; 366194dbcdSLiu Zhe import com.sun.star.text.*; 376194dbcdSLiu Zhe import com.sun.star.beans.*; 386194dbcdSLiu Zhe import com.sun.star.frame.XStorable; 396194dbcdSLiu Zhe import com.sun.star.uno.UnoRuntime; 406194dbcdSLiu Zhe 416194dbcdSLiu Zhe public class ParagraphShadow { 426194dbcdSLiu Zhe private static final UnoApp app = new UnoApp(); 436194dbcdSLiu Zhe XText xText = null; 446194dbcdSLiu Zhe 456194dbcdSLiu Zhe @Before setUp()466194dbcdSLiu Zhe public void setUp() throws Exception { 476194dbcdSLiu Zhe app.start(); 486194dbcdSLiu Zhe 496194dbcdSLiu Zhe } 506194dbcdSLiu Zhe 516194dbcdSLiu Zhe @After tearDown()526194dbcdSLiu Zhe public void tearDown() throws Exception { 536194dbcdSLiu Zhe app.close(); 546194dbcdSLiu Zhe } 556194dbcdSLiu Zhe /* 566194dbcdSLiu Zhe * test paragraph background color 576194dbcdSLiu Zhe * 1.new a text document 586194dbcdSLiu Zhe * 2.insert some text 596194dbcdSLiu Zhe * 3.set paragraph shadow 606194dbcdSLiu Zhe * 4.save and close the document 616194dbcdSLiu Zhe * 5.reload the saved document and check the paragraph shadow 626194dbcdSLiu Zhe */ 63af986861SLiu Zhe @Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.") testParagraphShadow_BottomRight()646194dbcdSLiu Zhe public void testParagraphShadow_BottomRight() throws Exception { 656194dbcdSLiu Zhe 666194dbcdSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 676194dbcdSLiu Zhe xText = xTextDocument.getText(); 686194dbcdSLiu 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!" + 696194dbcdSLiu Zhe "Hello,world!Hello,world!"); 706194dbcdSLiu Zhe // create text cursor for selecting and formatting text 716194dbcdSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 726194dbcdSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 736194dbcdSLiu Zhe //set paragraph background color 746194dbcdSLiu Zhe ShadowFormat shadowFormat=new ShadowFormat(); 756194dbcdSLiu Zhe shadowFormat.Location=ShadowLocation.BOTTOM_RIGHT; 766194dbcdSLiu Zhe shadowFormat.ShadowWidth=101; 776194dbcdSLiu Zhe shadowFormat.Color=0x00FF00FF; 786194dbcdSLiu Zhe xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat); 796194dbcdSLiu Zhe //save to odt 806194dbcdSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 816194dbcdSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 826194dbcdSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 836194dbcdSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 846194dbcdSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 856194dbcdSLiu Zhe aStoreProperties_odt[0].Value = true; 866194dbcdSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 876194dbcdSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 886194dbcdSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 896194dbcdSLiu Zhe //save to doc 906194dbcdSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 916194dbcdSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 926194dbcdSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 936194dbcdSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 946194dbcdSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 956194dbcdSLiu Zhe aStoreProperties_doc[0].Value = true; 966194dbcdSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 976194dbcdSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 986194dbcdSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 996194dbcdSLiu Zhe app.closeDocument(xTextDocument); 1006194dbcdSLiu Zhe 1016194dbcdSLiu Zhe //reopen the document 1026194dbcdSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 1036194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 1046194dbcdSLiu Zhe //verify paragraph background color 1056194dbcdSLiu Zhe ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat")); 1066194dbcdSLiu Zhe assertEquals("assert shadow location",ShadowLocation.BOTTOM_RIGHT,shadowFormat_Assert1.Location); 1076194dbcdSLiu Zhe assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth); 1086194dbcdSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color); 1096194dbcdSLiu Zhe 1106194dbcdSLiu Zhe //reopen the document 1116194dbcdSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 1126194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 1136194dbcdSLiu Zhe //verify paragraph background color 1146194dbcdSLiu Zhe ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat")); 1156194dbcdSLiu Zhe assertEquals("assert shadow location",ShadowLocation.BOTTOM_RIGHT,shadowFormat_Assert2.Location); 1166194dbcdSLiu Zhe assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth); 1176194dbcdSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color); 1186194dbcdSLiu Zhe } 119af986861SLiu Zhe @Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.") testParagraphShadow_BottomLeft()1206194dbcdSLiu Zhe public void testParagraphShadow_BottomLeft() throws Exception { 1216194dbcdSLiu Zhe 1226194dbcdSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 1236194dbcdSLiu Zhe xText = xTextDocument.getText(); 1246194dbcdSLiu 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!" + 1256194dbcdSLiu Zhe "Hello,world!Hello,world!"); 1266194dbcdSLiu Zhe // create text cursor for selecting and formatting text 1276194dbcdSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 1286194dbcdSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 1296194dbcdSLiu Zhe //set paragraph background color 1306194dbcdSLiu Zhe ShadowFormat shadowFormat=new ShadowFormat(); 1316194dbcdSLiu Zhe shadowFormat.Location=ShadowLocation.BOTTOM_LEFT; 1326194dbcdSLiu Zhe shadowFormat.ShadowWidth=101; 1336194dbcdSLiu Zhe shadowFormat.Color=0x00FF00FF; 1346194dbcdSLiu Zhe xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat); 1356194dbcdSLiu Zhe //save to odt 1366194dbcdSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1376194dbcdSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 1386194dbcdSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 1396194dbcdSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 1406194dbcdSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 1416194dbcdSLiu Zhe aStoreProperties_odt[0].Value = true; 1426194dbcdSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 1436194dbcdSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 1446194dbcdSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 1456194dbcdSLiu Zhe //save to doc 1466194dbcdSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1476194dbcdSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 1486194dbcdSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 1496194dbcdSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 1506194dbcdSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 1516194dbcdSLiu Zhe aStoreProperties_doc[0].Value = true; 1526194dbcdSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 1536194dbcdSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 1546194dbcdSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 1556194dbcdSLiu Zhe app.closeDocument(xTextDocument); 1566194dbcdSLiu Zhe 1576194dbcdSLiu Zhe //reopen the document 1586194dbcdSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 1596194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 1606194dbcdSLiu Zhe //verify paragraph background color 1616194dbcdSLiu Zhe ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat")); 1626194dbcdSLiu Zhe assertEquals("assert shadow location",ShadowLocation.BOTTOM_LEFT,shadowFormat_Assert1.Location); 1636194dbcdSLiu Zhe assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth); 1646194dbcdSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color); 1656194dbcdSLiu Zhe 1666194dbcdSLiu Zhe //reopen the document 1676194dbcdSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 1686194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 1696194dbcdSLiu Zhe //verify paragraph background color 1706194dbcdSLiu Zhe ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat")); 1716194dbcdSLiu Zhe assertEquals("assert shadow location",ShadowLocation.BOTTOM_LEFT,shadowFormat_Assert2.Location); 1726194dbcdSLiu Zhe assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth); 1736194dbcdSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color); 1746194dbcdSLiu Zhe } 175af986861SLiu Zhe @Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.") testParagraphShadow_TopLeft()1766194dbcdSLiu Zhe public void testParagraphShadow_TopLeft() throws Exception { 1776194dbcdSLiu Zhe 1786194dbcdSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 1796194dbcdSLiu Zhe xText = xTextDocument.getText(); 1806194dbcdSLiu 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!" + 1816194dbcdSLiu Zhe "Hello,world!Hello,world!"); 1826194dbcdSLiu Zhe // create text cursor for selecting and formatting text 1836194dbcdSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 1846194dbcdSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 1856194dbcdSLiu Zhe //set paragraph background color 1866194dbcdSLiu Zhe ShadowFormat shadowFormat=new ShadowFormat(); 1876194dbcdSLiu Zhe shadowFormat.Location=ShadowLocation.TOP_LEFT; 1886194dbcdSLiu Zhe shadowFormat.ShadowWidth=101; 1896194dbcdSLiu Zhe shadowFormat.Color=0x00FF00FF; 1906194dbcdSLiu Zhe xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat); 1916194dbcdSLiu Zhe //save to odt 1926194dbcdSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1936194dbcdSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 1946194dbcdSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 1956194dbcdSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 1966194dbcdSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 1976194dbcdSLiu Zhe aStoreProperties_odt[0].Value = true; 1986194dbcdSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 1996194dbcdSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 2006194dbcdSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 2016194dbcdSLiu Zhe //save to doc 2026194dbcdSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2036194dbcdSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 2046194dbcdSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 2056194dbcdSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 2066194dbcdSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 2076194dbcdSLiu Zhe aStoreProperties_doc[0].Value = true; 2086194dbcdSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 2096194dbcdSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 2106194dbcdSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 2116194dbcdSLiu Zhe app.closeDocument(xTextDocument); 2126194dbcdSLiu Zhe 2136194dbcdSLiu Zhe //reopen the document 2146194dbcdSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 2156194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 2166194dbcdSLiu Zhe //verify paragraph background color 2176194dbcdSLiu Zhe ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat")); 2186194dbcdSLiu Zhe assertEquals("assert shadow location",ShadowLocation.TOP_LEFT,shadowFormat_Assert1.Location); 2196194dbcdSLiu Zhe assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth); 2206194dbcdSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color); 2216194dbcdSLiu Zhe 2226194dbcdSLiu Zhe //reopen the document 2236194dbcdSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 2246194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 2256194dbcdSLiu Zhe //verify paragraph background color 2266194dbcdSLiu Zhe ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat")); 2276194dbcdSLiu Zhe assertEquals("assert shadow location",ShadowLocation.TOP_LEFT,shadowFormat_Assert2.Location); 2286194dbcdSLiu Zhe assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth); 2296194dbcdSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color); 2306194dbcdSLiu Zhe } 231af986861SLiu Zhe @Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.") testParagraphShadow_TopRight()2326194dbcdSLiu Zhe public void testParagraphShadow_TopRight() throws Exception { 2336194dbcdSLiu Zhe 2346194dbcdSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 2356194dbcdSLiu Zhe xText = xTextDocument.getText(); 2366194dbcdSLiu 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!" + 2376194dbcdSLiu Zhe "Hello,world!Hello,world!"); 2386194dbcdSLiu Zhe // create text cursor for selecting and formatting text 2396194dbcdSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 2406194dbcdSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 2416194dbcdSLiu Zhe //set paragraph background color 2426194dbcdSLiu Zhe ShadowFormat shadowFormat=new ShadowFormat(); 2436194dbcdSLiu Zhe shadowFormat.Location=ShadowLocation.TOP_RIGHT; 2446194dbcdSLiu Zhe shadowFormat.ShadowWidth=101; 2456194dbcdSLiu Zhe shadowFormat.Color=0x00FF00FF; 2466194dbcdSLiu Zhe xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat); 2476194dbcdSLiu Zhe //save to odt 2486194dbcdSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2496194dbcdSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 2506194dbcdSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 2516194dbcdSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 2526194dbcdSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 2536194dbcdSLiu Zhe aStoreProperties_odt[0].Value = true; 2546194dbcdSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 2556194dbcdSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 2566194dbcdSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 2576194dbcdSLiu Zhe //save to doc 2586194dbcdSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2596194dbcdSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 2606194dbcdSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 2616194dbcdSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 2626194dbcdSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 2636194dbcdSLiu Zhe aStoreProperties_doc[0].Value = true; 2646194dbcdSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 2656194dbcdSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 2666194dbcdSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 2676194dbcdSLiu Zhe app.closeDocument(xTextDocument); 2686194dbcdSLiu Zhe 2696194dbcdSLiu Zhe //reopen the document 2706194dbcdSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 2716194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 2726194dbcdSLiu Zhe //verify paragraph background color 2736194dbcdSLiu Zhe ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat")); 2746194dbcdSLiu Zhe assertEquals("assert shadow location",ShadowLocation.TOP_RIGHT,shadowFormat_Assert1.Location); 2756194dbcdSLiu Zhe assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth); 2766194dbcdSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color); 2776194dbcdSLiu Zhe 2786194dbcdSLiu Zhe //reopen the document 2796194dbcdSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 2806194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 2816194dbcdSLiu Zhe //verify paragraph background color 2826194dbcdSLiu Zhe ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat")); 2836194dbcdSLiu Zhe assertEquals("assert shadow location",ShadowLocation.TOP_RIGHT,shadowFormat_Assert2.Location); 2846194dbcdSLiu Zhe assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth); 2856194dbcdSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color); 2866194dbcdSLiu Zhe } 2876194dbcdSLiu Zhe @Test testParagraphShadow_None()2886194dbcdSLiu Zhe public void testParagraphShadow_None() throws Exception { 2896194dbcdSLiu Zhe 2906194dbcdSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 2916194dbcdSLiu Zhe xText = xTextDocument.getText(); 2926194dbcdSLiu 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!" + 2936194dbcdSLiu Zhe "Hello,world!Hello,world!"); 2946194dbcdSLiu Zhe // create text cursor for selecting and formatting text 2956194dbcdSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 2966194dbcdSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 2976194dbcdSLiu Zhe //set paragraph background color 2986194dbcdSLiu Zhe ShadowFormat shadowFormat=new ShadowFormat(); 2996194dbcdSLiu Zhe shadowFormat.Location=ShadowLocation.NONE; 3006194dbcdSLiu Zhe shadowFormat.ShadowWidth=101; 3016194dbcdSLiu Zhe shadowFormat.Color=0x00FF00FF; 3026194dbcdSLiu Zhe xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat); 3036194dbcdSLiu Zhe //save to odt 3046194dbcdSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 3056194dbcdSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 3066194dbcdSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 3076194dbcdSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 3086194dbcdSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 3096194dbcdSLiu Zhe aStoreProperties_odt[0].Value = true; 3106194dbcdSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 3116194dbcdSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 3126194dbcdSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 3136194dbcdSLiu Zhe //save to doc 3146194dbcdSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 3156194dbcdSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 3166194dbcdSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 3176194dbcdSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 3186194dbcdSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 3196194dbcdSLiu Zhe aStoreProperties_doc[0].Value = true; 3206194dbcdSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 3216194dbcdSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 3226194dbcdSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 3236194dbcdSLiu Zhe app.closeDocument(xTextDocument); 3246194dbcdSLiu Zhe 3256194dbcdSLiu Zhe //reopen the document 3266194dbcdSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 3276194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 3286194dbcdSLiu Zhe //verify paragraph background color 3296194dbcdSLiu Zhe ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat")); 3306194dbcdSLiu Zhe assertEquals("assert shadow location",ShadowLocation.NONE,shadowFormat_Assert1.Location); 3316194dbcdSLiu Zhe 3326194dbcdSLiu Zhe //reopen the document 3336194dbcdSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 3346194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 3356194dbcdSLiu Zhe //verify paragraph background color 3366194dbcdSLiu Zhe ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat")); 3376194dbcdSLiu Zhe assertEquals("assert shadow location",ShadowLocation.NONE,shadowFormat_Assert2.Location); 3386194dbcdSLiu Zhe } 3396194dbcdSLiu Zhe } 340