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.table.ShadowFormat; 35eba4d44aSLiu Zhe import com.sun.star.table.ShadowLocation; 36eba4d44aSLiu Zhe import com.sun.star.text.*; 37eba4d44aSLiu Zhe import com.sun.star.beans.*; 38eba4d44aSLiu Zhe import com.sun.star.frame.XStorable; 39eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime; 40eba4d44aSLiu Zhe 41eba4d44aSLiu Zhe public class ParagraphShadow { 42eba4d44aSLiu Zhe private static final UnoApp app = new UnoApp(); 43eba4d44aSLiu Zhe XText xText = null; 44eba4d44aSLiu Zhe 45eba4d44aSLiu Zhe @Before setUp()46eba4d44aSLiu Zhe public void setUp() throws Exception { 47eba4d44aSLiu Zhe app.start(); 48eba4d44aSLiu Zhe 49eba4d44aSLiu Zhe } 50eba4d44aSLiu Zhe 51eba4d44aSLiu Zhe @After tearDown()52eba4d44aSLiu Zhe public void tearDown() throws Exception { 53eba4d44aSLiu Zhe app.close(); 54eba4d44aSLiu Zhe } 55eba4d44aSLiu Zhe /* 56eba4d44aSLiu Zhe * test paragraph background color 57eba4d44aSLiu Zhe * 1.new a text document 58eba4d44aSLiu Zhe * 2.insert some text 59eba4d44aSLiu Zhe * 3.set paragraph shadow 60eba4d44aSLiu Zhe * 4.save and close the document 61eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph shadow 62eba4d44aSLiu Zhe */ 63eba4d44aSLiu Zhe @Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.") testParagraphShadow_BottomRight()64eba4d44aSLiu Zhe public void testParagraphShadow_BottomRight() throws Exception { 65eba4d44aSLiu Zhe 66eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 67eba4d44aSLiu Zhe xText = xTextDocument.getText(); 68eba4d44aSLiu 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!" + 69eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 70eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 71eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 72eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 73eba4d44aSLiu Zhe //set paragraph background color 74eba4d44aSLiu Zhe ShadowFormat shadowFormat=new ShadowFormat(); 75eba4d44aSLiu Zhe shadowFormat.Location=ShadowLocation.BOTTOM_RIGHT; 76eba4d44aSLiu Zhe shadowFormat.ShadowWidth=101; 77eba4d44aSLiu Zhe shadowFormat.Color=0x00FF00FF; 78eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat); 79eba4d44aSLiu Zhe //save to odt 80eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 81eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 82eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 83eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 84eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 85eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 86eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 87eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 88eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 89eba4d44aSLiu Zhe //save to doc 90eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 91eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 92eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 93eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 94eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 95eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 96eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 97eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 98eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 99eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 100eba4d44aSLiu Zhe 101eba4d44aSLiu Zhe //reopen the document 102eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 103eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 104eba4d44aSLiu Zhe //verify paragraph background color 105eba4d44aSLiu Zhe ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat")); 106eba4d44aSLiu Zhe assertEquals("assert shadow location",ShadowLocation.BOTTOM_RIGHT,shadowFormat_Assert1.Location); 107eba4d44aSLiu Zhe assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth); 108eba4d44aSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color); 109eba4d44aSLiu Zhe 110eba4d44aSLiu Zhe //reopen the document 111eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 112eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 113eba4d44aSLiu Zhe //verify paragraph background color 114eba4d44aSLiu Zhe ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat")); 115eba4d44aSLiu Zhe assertEquals("assert shadow location",ShadowLocation.BOTTOM_RIGHT,shadowFormat_Assert2.Location); 116eba4d44aSLiu Zhe assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth); 117eba4d44aSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color); 118eba4d44aSLiu Zhe } 119eba4d44aSLiu Zhe @Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.") testParagraphShadow_BottomLeft()120eba4d44aSLiu Zhe public void testParagraphShadow_BottomLeft() throws Exception { 121eba4d44aSLiu Zhe 122eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 123eba4d44aSLiu Zhe xText = xTextDocument.getText(); 124eba4d44aSLiu 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!" + 125eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 126eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 127eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 128eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 129eba4d44aSLiu Zhe //set paragraph background color 130eba4d44aSLiu Zhe ShadowFormat shadowFormat=new ShadowFormat(); 131eba4d44aSLiu Zhe shadowFormat.Location=ShadowLocation.BOTTOM_LEFT; 132eba4d44aSLiu Zhe shadowFormat.ShadowWidth=101; 133eba4d44aSLiu Zhe shadowFormat.Color=0x00FF00FF; 134eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat); 135eba4d44aSLiu Zhe //save to odt 136eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 137eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 138eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 139eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 140eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 141eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 142eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 143eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 144eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 145eba4d44aSLiu Zhe //save to doc 146eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 147eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 148eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 149eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 150eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 151eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 152eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 153eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 154eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 155eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 156eba4d44aSLiu Zhe 157eba4d44aSLiu Zhe //reopen the document 158eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 159eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 160eba4d44aSLiu Zhe //verify paragraph background color 161eba4d44aSLiu Zhe ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat")); 162eba4d44aSLiu Zhe assertEquals("assert shadow location",ShadowLocation.BOTTOM_LEFT,shadowFormat_Assert1.Location); 163eba4d44aSLiu Zhe assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth); 164eba4d44aSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color); 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 //verify paragraph background color 170eba4d44aSLiu Zhe ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat")); 171eba4d44aSLiu Zhe assertEquals("assert shadow location",ShadowLocation.BOTTOM_LEFT,shadowFormat_Assert2.Location); 172eba4d44aSLiu Zhe assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth); 173eba4d44aSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color); 174eba4d44aSLiu Zhe } 175eba4d44aSLiu Zhe @Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.") testParagraphShadow_TopLeft()176eba4d44aSLiu Zhe public void testParagraphShadow_TopLeft() throws Exception { 177eba4d44aSLiu Zhe 178eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 179eba4d44aSLiu Zhe xText = xTextDocument.getText(); 180eba4d44aSLiu 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!" + 181eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 182eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 183eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 184eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 185eba4d44aSLiu Zhe //set paragraph background color 186eba4d44aSLiu Zhe ShadowFormat shadowFormat=new ShadowFormat(); 187eba4d44aSLiu Zhe shadowFormat.Location=ShadowLocation.TOP_LEFT; 188eba4d44aSLiu Zhe shadowFormat.ShadowWidth=101; 189eba4d44aSLiu Zhe shadowFormat.Color=0x00FF00FF; 190eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat); 191eba4d44aSLiu Zhe //save to odt 192eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 193eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 194eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 195eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 196eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 197eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 198eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 199eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 200eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 201eba4d44aSLiu Zhe //save to doc 202eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 203eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 204eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 205eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 206eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 207eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 208eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 209eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 210eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 211eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 212eba4d44aSLiu Zhe 213eba4d44aSLiu Zhe //reopen the document 214eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 215eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 216eba4d44aSLiu Zhe //verify paragraph background color 217eba4d44aSLiu Zhe ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat")); 218eba4d44aSLiu Zhe assertEquals("assert shadow location",ShadowLocation.TOP_LEFT,shadowFormat_Assert1.Location); 219eba4d44aSLiu Zhe assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth); 220eba4d44aSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color); 221eba4d44aSLiu Zhe 222eba4d44aSLiu Zhe //reopen the document 223eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 224eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 225eba4d44aSLiu Zhe //verify paragraph background color 226eba4d44aSLiu Zhe ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat")); 227eba4d44aSLiu Zhe assertEquals("assert shadow location",ShadowLocation.TOP_LEFT,shadowFormat_Assert2.Location); 228eba4d44aSLiu Zhe assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth); 229eba4d44aSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color); 230eba4d44aSLiu Zhe } 231eba4d44aSLiu Zhe @Test@Ignore("Bug #120697 - [testUNO patch]paragraph shadow effect lost when save to doc.") testParagraphShadow_TopRight()232eba4d44aSLiu Zhe public void testParagraphShadow_TopRight() throws Exception { 233eba4d44aSLiu Zhe 234eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 235eba4d44aSLiu Zhe xText = xTextDocument.getText(); 236eba4d44aSLiu 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!" + 237eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 238eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 239eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 240eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 241eba4d44aSLiu Zhe //set paragraph background color 242eba4d44aSLiu Zhe ShadowFormat shadowFormat=new ShadowFormat(); 243eba4d44aSLiu Zhe shadowFormat.Location=ShadowLocation.TOP_RIGHT; 244eba4d44aSLiu Zhe shadowFormat.ShadowWidth=101; 245eba4d44aSLiu Zhe shadowFormat.Color=0x00FF00FF; 246eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat); 247eba4d44aSLiu Zhe //save to odt 248eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 249eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 250eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 251eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 252eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 253eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 254eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 255eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 256eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 257eba4d44aSLiu Zhe //save to doc 258eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 259eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 260eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 261eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 262eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 263eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 264eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 265eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 266eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 267eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 268eba4d44aSLiu Zhe 269eba4d44aSLiu Zhe //reopen the document 270eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 271eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 272eba4d44aSLiu Zhe //verify paragraph background color 273eba4d44aSLiu Zhe ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat")); 274eba4d44aSLiu Zhe assertEquals("assert shadow location",ShadowLocation.TOP_RIGHT,shadowFormat_Assert1.Location); 275eba4d44aSLiu Zhe assertEquals("assert shadow width",101,shadowFormat_Assert1.ShadowWidth); 276eba4d44aSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert1.Color); 277eba4d44aSLiu Zhe 278eba4d44aSLiu Zhe //reopen the document 279eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 280eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 281eba4d44aSLiu Zhe //verify paragraph background color 282eba4d44aSLiu Zhe ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat")); 283eba4d44aSLiu Zhe assertEquals("assert shadow location",ShadowLocation.TOP_RIGHT,shadowFormat_Assert2.Location); 284eba4d44aSLiu Zhe assertEquals("assert shadow width",100,shadowFormat_Assert2.ShadowWidth); 285eba4d44aSLiu Zhe assertEquals("assert shadow color",0x00FF00FF,shadowFormat_Assert2.Color); 286eba4d44aSLiu Zhe } 287eba4d44aSLiu Zhe @Test testParagraphShadow_None()288eba4d44aSLiu Zhe public void testParagraphShadow_None() throws Exception { 289eba4d44aSLiu Zhe 290eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 291eba4d44aSLiu Zhe xText = xTextDocument.getText(); 292eba4d44aSLiu 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!" + 293eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 294eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 295eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 296eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 297eba4d44aSLiu Zhe //set paragraph background color 298eba4d44aSLiu Zhe ShadowFormat shadowFormat=new ShadowFormat(); 299eba4d44aSLiu Zhe shadowFormat.Location=ShadowLocation.NONE; 300eba4d44aSLiu Zhe shadowFormat.ShadowWidth=101; 301eba4d44aSLiu Zhe shadowFormat.Color=0x00FF00FF; 302eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaShadowFormat",shadowFormat); 303eba4d44aSLiu Zhe //save to odt 304eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 305eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 306eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 307eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 308eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 309eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 310eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 311eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 312eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 313eba4d44aSLiu Zhe //save to doc 314eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 315eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 316eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 317eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 318eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 319eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 320eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 321eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 322eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 323eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 324eba4d44aSLiu Zhe 325eba4d44aSLiu Zhe //reopen the document 326eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 327eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 328eba4d44aSLiu Zhe //verify paragraph background color 329eba4d44aSLiu Zhe ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_odt.getPropertyValue("ParaShadowFormat")); 330eba4d44aSLiu Zhe assertEquals("assert shadow location",ShadowLocation.NONE,shadowFormat_Assert1.Location); 331eba4d44aSLiu Zhe 332eba4d44aSLiu Zhe //reopen the document 333eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 334eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 335eba4d44aSLiu Zhe //verify paragraph background color 336eba4d44aSLiu Zhe ShadowFormat shadowFormat_Assert2=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xCursorProps_Assert_doc.getPropertyValue("ParaShadowFormat")); 337eba4d44aSLiu Zhe assertEquals("assert shadow location",ShadowLocation.NONE,shadowFormat_Assert2.Location); 338eba4d44aSLiu Zhe } 339eba4d44aSLiu Zhe } 340