1*07d7dbdcSHerbert Dürr /************************************************************** 2*07d7dbdcSHerbert Dürr * 3*07d7dbdcSHerbert Dürr * Licensed to the Apache Software Foundation (ASF) under one 4*07d7dbdcSHerbert Dürr * or more contributor license agreements. See the NOTICE file 5*07d7dbdcSHerbert Dürr * distributed with this work for additional information 6*07d7dbdcSHerbert Dürr * regarding copyright ownership. The ASF licenses this file 7*07d7dbdcSHerbert Dürr * to you under the Apache License, Version 2.0 (the 8*07d7dbdcSHerbert Dürr * "License"); you may not use this file except in compliance 9*07d7dbdcSHerbert Dürr * with the License. You may obtain a copy of the License at 10*07d7dbdcSHerbert Dürr * 11*07d7dbdcSHerbert Dürr * http://www.apache.org/licenses/LICENSE-2.0 12*07d7dbdcSHerbert Dürr * 13*07d7dbdcSHerbert Dürr * Unless required by applicable law or agreed to in writing, 14*07d7dbdcSHerbert Dürr * software distributed under the License is distributed on an 15*07d7dbdcSHerbert Dürr * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*07d7dbdcSHerbert Dürr * KIND, either express or implied. See the License for the 17*07d7dbdcSHerbert Dürr * specific language governing permissions and limitations 18*07d7dbdcSHerbert Dürr * under the License. 19*07d7dbdcSHerbert Dürr * 20*07d7dbdcSHerbert Dürr *************************************************************/ 21*07d7dbdcSHerbert Dürr 22eba4d44aSLiu Zhe package fvt.uno.sw.paragraph; 23eba4d44aSLiu Zhe 24eba4d44aSLiu Zhe import static org.junit.Assert.*; 25eba4d44aSLiu Zhe 26eba4d44aSLiu Zhe import org.junit.After; 27eba4d44aSLiu Zhe import org.junit.Before; 28eba4d44aSLiu Zhe import org.junit.Ignore; 29eba4d44aSLiu Zhe import org.junit.Test; 30eba4d44aSLiu Zhe import org.openoffice.test.common.FileUtil; 31eba4d44aSLiu Zhe import org.openoffice.test.common.Testspace; 32eba4d44aSLiu Zhe import org.openoffice.test.uno.UnoApp; 33eba4d44aSLiu Zhe import com.sun.star.text.*; 34eba4d44aSLiu Zhe import com.sun.star.beans.*; 35eba4d44aSLiu Zhe import com.sun.star.frame.XStorable; 36eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime; 37eba4d44aSLiu Zhe 38eba4d44aSLiu Zhe public class ParagraphBackGraphic { 39eba4d44aSLiu Zhe private static final UnoApp app = new UnoApp(); 40eba4d44aSLiu Zhe XText xText = null; 41eba4d44aSLiu Zhe 42eba4d44aSLiu Zhe @Before setUp()43eba4d44aSLiu Zhe public void setUp() throws Exception { 44eba4d44aSLiu Zhe app.start(); 45eba4d44aSLiu Zhe 46eba4d44aSLiu Zhe } 47eba4d44aSLiu Zhe 48eba4d44aSLiu Zhe @After tearDown()49eba4d44aSLiu Zhe public void tearDown() throws Exception { 50eba4d44aSLiu Zhe app.close(); 51eba4d44aSLiu Zhe } 52eba4d44aSLiu Zhe /* 53eba4d44aSLiu Zhe * test paragraph background graphic 54eba4d44aSLiu Zhe * 1.new a text document 55eba4d44aSLiu Zhe * 2.insert some text 56eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is left bottom 57eba4d44aSLiu Zhe * 4.save and close the document 58eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 59eba4d44aSLiu Zhe */ 60eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_LeftBottom()61eba4d44aSLiu Zhe public void testParagraphBackGraphic_LeftBottom() throws Exception { 62eba4d44aSLiu Zhe 63eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 64eba4d44aSLiu Zhe xText = xTextDocument.getText(); 65eba4d44aSLiu 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!" + 66eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 67eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 68eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 69eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 70eba4d44aSLiu Zhe //set paragraph background color 71eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 72eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 73eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_BOTTOM); 74eba4d44aSLiu Zhe //save to odt 75eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 76eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 77eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 78eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 79eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 80eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 81eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 82eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 83eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 84eba4d44aSLiu Zhe //save to doc 85eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 86eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 87eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 88eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 89eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 90eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 91eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 92eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 93eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 94eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 95eba4d44aSLiu Zhe 96eba4d44aSLiu Zhe //reopen the document 97eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 98eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 99eba4d44aSLiu Zhe //verify paragraph background graphic 100eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_BOTTOM,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 101eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 102eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 103eba4d44aSLiu Zhe 104eba4d44aSLiu Zhe //reopen the document 105eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 106eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 107eba4d44aSLiu Zhe //verify paragraph background graphic 108eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_BOTTOM,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 109eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 110eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 111eba4d44aSLiu Zhe } 112eba4d44aSLiu Zhe /* 113eba4d44aSLiu Zhe * test paragraph background graphic 114eba4d44aSLiu Zhe * 1.new a text document 115eba4d44aSLiu Zhe * 2.insert some text 116eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is left middle 117eba4d44aSLiu Zhe * 4.save and close the document 118eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 119eba4d44aSLiu Zhe */ 120eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_LeftMiddle()121eba4d44aSLiu Zhe public void testParagraphBackGraphic_LeftMiddle() throws Exception { 122eba4d44aSLiu Zhe 123eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 124eba4d44aSLiu Zhe xText = xTextDocument.getText(); 125eba4d44aSLiu 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!" + 126eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 127eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 128eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 129eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 130eba4d44aSLiu Zhe //set paragraph background color 131eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 132eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 133eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_MIDDLE); 134eba4d44aSLiu Zhe //save to odt 135eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 136eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 137eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 138eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 139eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 140eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 141eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 142eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 143eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 144eba4d44aSLiu Zhe //save to doc 145eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 146eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 147eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 148eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 149eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 150eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 151eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 152eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 153eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 154eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 155eba4d44aSLiu Zhe 156eba4d44aSLiu Zhe //reopen the document 157eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 158eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 159eba4d44aSLiu Zhe //verify paragraph background graphic 160eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_MIDDLE,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 161eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 162eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 163eba4d44aSLiu Zhe 164eba4d44aSLiu Zhe //reopen the document 165eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 166eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 167eba4d44aSLiu Zhe //verify paragraph background graphic 168eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_MIDDLE,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 169eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 170eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 171eba4d44aSLiu Zhe } 172eba4d44aSLiu Zhe /* 173eba4d44aSLiu Zhe * test paragraph background graphic 174eba4d44aSLiu Zhe * 1.new a text document 175eba4d44aSLiu Zhe * 2.insert some text 176eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is left top 177eba4d44aSLiu Zhe * 4.save and close the document 178eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 179eba4d44aSLiu Zhe */ 180eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_LeftTop()181eba4d44aSLiu Zhe public void testParagraphBackGraphic_LeftTop() throws Exception { 182eba4d44aSLiu Zhe 183eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 184eba4d44aSLiu Zhe xText = xTextDocument.getText(); 185eba4d44aSLiu 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!" + 186eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 187eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 188eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 189eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 190eba4d44aSLiu Zhe //set paragraph background color 191eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 192eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 193eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.LEFT_TOP); 194eba4d44aSLiu Zhe //save to odt 195eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 196eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 197eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 198eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 199eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 200eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 201eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 202eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 203eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 204eba4d44aSLiu Zhe //save to doc 205eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 206eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 207eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 208eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 209eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 210eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 211eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 212eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 213eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 214eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 215eba4d44aSLiu Zhe 216eba4d44aSLiu Zhe //reopen the document 217eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 218eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 219eba4d44aSLiu Zhe //verify paragraph background graphic 220eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_TOP,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 221eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 222eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 223eba4d44aSLiu Zhe 224eba4d44aSLiu Zhe //reopen the document 225eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 226eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 227eba4d44aSLiu Zhe //verify paragraph background graphic 228eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.LEFT_TOP,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 229eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 230eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 231eba4d44aSLiu Zhe } 232eba4d44aSLiu Zhe /* 233eba4d44aSLiu Zhe * test paragraph background graphic 234eba4d44aSLiu Zhe * 1.new a text document 235eba4d44aSLiu Zhe * 2.insert some text 236eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is middle bottom 237eba4d44aSLiu Zhe * 4.save and close the document 238eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 239eba4d44aSLiu Zhe */ 240eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_MiddleBottom()241eba4d44aSLiu Zhe public void testParagraphBackGraphic_MiddleBottom() throws Exception { 242eba4d44aSLiu Zhe 243eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 244eba4d44aSLiu Zhe xText = xTextDocument.getText(); 245eba4d44aSLiu 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!" + 246eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 247eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 248eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 249eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 250eba4d44aSLiu Zhe //set paragraph background color 251eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 252eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 253eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_BOTTOM); 254eba4d44aSLiu Zhe //save to odt 255eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 256eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 257eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 258eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 259eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 260eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 261eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 262eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 263eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 264eba4d44aSLiu Zhe //save to doc 265eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 266eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 267eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 268eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 269eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 270eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 271eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 272eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 273eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 274eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 275eba4d44aSLiu Zhe 276eba4d44aSLiu Zhe //reopen the document 277eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 278eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 279eba4d44aSLiu Zhe //verify paragraph background graphic 280eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_BOTTOM,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 281eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 282eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 283eba4d44aSLiu Zhe 284eba4d44aSLiu Zhe //reopen the document 285eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 286eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 287eba4d44aSLiu Zhe //verify paragraph background graphic 288eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_BOTTOM,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 289eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 290eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 291eba4d44aSLiu Zhe } 292eba4d44aSLiu Zhe /* 293eba4d44aSLiu Zhe * test paragraph background graphic 294eba4d44aSLiu Zhe * 1.new a text document 295eba4d44aSLiu Zhe * 2.insert some text 296eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is middle middle 297eba4d44aSLiu Zhe * 4.save and close the document 298eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 299eba4d44aSLiu Zhe */ 300eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_MiddleMiddle()301eba4d44aSLiu Zhe public void testParagraphBackGraphic_MiddleMiddle() throws Exception { 302eba4d44aSLiu Zhe 303eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 304eba4d44aSLiu Zhe xText = xTextDocument.getText(); 305eba4d44aSLiu 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!" + 306eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 307eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 308eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 309eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 310eba4d44aSLiu Zhe //set paragraph background color 311eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 312eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 313eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_MIDDLE); 314eba4d44aSLiu Zhe //save to odt 315eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 316eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 317eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 318eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 319eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 320eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 321eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 322eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 323eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 324eba4d44aSLiu Zhe //save to doc 325eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 326eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 327eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 328eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 329eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 330eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 331eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 332eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 333eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 334eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 335eba4d44aSLiu Zhe 336eba4d44aSLiu Zhe //reopen the document 337eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 338eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 339eba4d44aSLiu Zhe //verify paragraph background graphic 340eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_MIDDLE,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 341eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 342eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 343eba4d44aSLiu Zhe 344eba4d44aSLiu Zhe //reopen the document 345eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 346eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 347eba4d44aSLiu Zhe //verify paragraph background graphic 348eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_MIDDLE,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 349eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 350eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 351eba4d44aSLiu Zhe } 352eba4d44aSLiu Zhe /* 353eba4d44aSLiu Zhe * test paragraph background graphic 354eba4d44aSLiu Zhe * 1.new a text document 355eba4d44aSLiu Zhe * 2.insert some text 356eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is middle top 357eba4d44aSLiu Zhe * 4.save and close the document 358eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 359eba4d44aSLiu Zhe */ 360eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_MiddleTop()361eba4d44aSLiu Zhe public void testParagraphBackGraphic_MiddleTop() throws Exception { 362eba4d44aSLiu Zhe 363eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 364eba4d44aSLiu Zhe xText = xTextDocument.getText(); 365eba4d44aSLiu 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!" + 366eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 367eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 368eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 369eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 370eba4d44aSLiu Zhe //set paragraph background color 371eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 372eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 373eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.MIDDLE_TOP); 374eba4d44aSLiu Zhe //save and reload text document 375eba4d44aSLiu Zhe //save to odt 376eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 377eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 378eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 379eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 380eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 381eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 382eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 383eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 384eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 385eba4d44aSLiu Zhe //save to doc 386eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 387eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 388eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 389eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 390eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 391eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 392eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 393eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 394eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 395eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 396eba4d44aSLiu Zhe 397eba4d44aSLiu Zhe //reopen the document 398eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 399eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 400eba4d44aSLiu Zhe //verify paragraph background graphic 401eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_TOP,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 402eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 403eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 404eba4d44aSLiu Zhe 405eba4d44aSLiu Zhe //reopen the document 406eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 407eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 408eba4d44aSLiu Zhe //verify paragraph background graphic 409eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.MIDDLE_TOP,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 410eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 411eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 412eba4d44aSLiu Zhe } 413eba4d44aSLiu Zhe /* 414eba4d44aSLiu Zhe * test paragraph background graphic 415eba4d44aSLiu Zhe * 1.new a text document 416eba4d44aSLiu Zhe * 2.insert some text 417eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is right bottom 418eba4d44aSLiu Zhe * 4.save and close the document 419eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 420eba4d44aSLiu Zhe */ 421eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_RightBottom()422eba4d44aSLiu Zhe public void testParagraphBackGraphic_RightBottom() throws Exception { 423eba4d44aSLiu Zhe 424eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 425eba4d44aSLiu Zhe xText = xTextDocument.getText(); 426eba4d44aSLiu 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!" + 427eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 428eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 429eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 430eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 431eba4d44aSLiu Zhe //set paragraph background color 432eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 433eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 434eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_BOTTOM); 435eba4d44aSLiu Zhe //save to odt 436eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 437eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 438eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 439eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 440eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 441eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 442eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 443eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 444eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 445eba4d44aSLiu Zhe //save to doc 446eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 447eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 448eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 449eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 450eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 451eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 452eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 453eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 454eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 455eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 456eba4d44aSLiu Zhe 457eba4d44aSLiu Zhe //reopen the document 458eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 459eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 460eba4d44aSLiu Zhe //verify paragraph background graphic 461eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_BOTTOM,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 462eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 463eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 464eba4d44aSLiu Zhe 465eba4d44aSLiu Zhe //reopen the document 466eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 467eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 468eba4d44aSLiu Zhe //verify paragraph background graphic 469eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_BOTTOM,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 470eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 471eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 472eba4d44aSLiu Zhe } 473eba4d44aSLiu Zhe /* 474eba4d44aSLiu Zhe * test paragraph background graphic 475eba4d44aSLiu Zhe * 1.new a text document 476eba4d44aSLiu Zhe * 2.insert some text 477eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is right middle 478eba4d44aSLiu Zhe * 4.save and close the document 479eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 480eba4d44aSLiu Zhe */ 481eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_RightMiddle()482eba4d44aSLiu Zhe public void testParagraphBackGraphic_RightMiddle() throws Exception { 483eba4d44aSLiu Zhe 484eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 485eba4d44aSLiu Zhe xText = xTextDocument.getText(); 486eba4d44aSLiu 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!" + 487eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 488eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 489eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 490eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 491eba4d44aSLiu Zhe //set paragraph background color 492eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 493eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 494eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_MIDDLE); 495eba4d44aSLiu Zhe //save to odt 496eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 497eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 498eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 499eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 500eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 501eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 502eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 503eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 504eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 505eba4d44aSLiu Zhe //save to doc 506eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 507eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 508eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 509eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 510eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 511eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 512eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 513eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 514eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 515eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 516eba4d44aSLiu Zhe 517eba4d44aSLiu Zhe //reopen the document 518eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 519eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 520eba4d44aSLiu Zhe //verify paragraph background graphic 521eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_MIDDLE,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 522eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 523eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 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 //verify paragraph background graphic 529eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_MIDDLE,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 530eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 531eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 532eba4d44aSLiu Zhe } 533eba4d44aSLiu Zhe /* 534eba4d44aSLiu Zhe * test paragraph background graphic 535eba4d44aSLiu Zhe * 1.new a text document 536eba4d44aSLiu Zhe * 2.insert some text 537eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is right top 538eba4d44aSLiu Zhe * 4.save and close the document 539eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 540eba4d44aSLiu Zhe */ 541eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_RightTop()542eba4d44aSLiu Zhe public void testParagraphBackGraphic_RightTop() throws Exception { 543eba4d44aSLiu Zhe 544eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 545eba4d44aSLiu Zhe xText = xTextDocument.getText(); 546eba4d44aSLiu 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!" + 547eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 548eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 549eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 550eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 551eba4d44aSLiu Zhe //set paragraph background color 552eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 553eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 554eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.RIGHT_TOP); 555eba4d44aSLiu Zhe //save to odt 556eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 557eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 558eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 559eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 560eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 561eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 562eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 563eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 564eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 565eba4d44aSLiu Zhe //save to doc 566eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 567eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 568eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 569eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 570eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 571eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 572eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 573eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 574eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 575eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 576eba4d44aSLiu Zhe 577eba4d44aSLiu Zhe //reopen the document 578eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 579eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 580eba4d44aSLiu Zhe //verify paragraph background graphic 581eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_TOP,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 582eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 583eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 584eba4d44aSLiu Zhe 585eba4d44aSLiu Zhe //reopen the document 586eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 587eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 588eba4d44aSLiu Zhe //verify paragraph background graphic 589eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.RIGHT_TOP,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 590eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 591eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 592eba4d44aSLiu Zhe } 593eba4d44aSLiu Zhe /* 594eba4d44aSLiu Zhe * test paragraph background graphic 595eba4d44aSLiu Zhe * 1.new a text document 596eba4d44aSLiu Zhe * 2.insert some text 597eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is area 598eba4d44aSLiu Zhe * 4.save and close the document 599eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 600eba4d44aSLiu Zhe */ 601eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_Area()602eba4d44aSLiu Zhe public void testParagraphBackGraphic_Area() throws Exception { 603eba4d44aSLiu Zhe 604eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 605eba4d44aSLiu Zhe xText = xTextDocument.getText(); 606eba4d44aSLiu 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!" + 607eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 608eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 609eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 610eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 611eba4d44aSLiu Zhe //set paragraph background color 612eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 613eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 614eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.AREA); 615eba4d44aSLiu Zhe //save to odt 616eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 617eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 618eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 619eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 620eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 621eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 622eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 623eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 624eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 625eba4d44aSLiu Zhe //save to doc 626eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 627eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 628eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 629eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 630eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 631eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 632eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 633eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 634eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 635eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 636eba4d44aSLiu Zhe 637eba4d44aSLiu Zhe //reopen the document 638eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 639eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 640eba4d44aSLiu Zhe //verify paragraph background graphic 641eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.AREA,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 642eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 643eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 644eba4d44aSLiu Zhe 645eba4d44aSLiu Zhe //reopen the document 646eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 647eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 648eba4d44aSLiu Zhe //verify paragraph background graphic 649eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.AREA,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 650eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 651eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 652eba4d44aSLiu Zhe } 653eba4d44aSLiu Zhe /* 654eba4d44aSLiu Zhe * test paragraph background graphic 655eba4d44aSLiu Zhe * 1.new a text document 656eba4d44aSLiu Zhe * 2.insert some text 657eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is titled 658eba4d44aSLiu Zhe * 4.save and close the document 659eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 660eba4d44aSLiu Zhe */ 661eba4d44aSLiu Zhe @Test@Ignore("Bug #120638 - [testUNO patch]graphic background lost when save to doc") testParagraphBackGraphic_Titled()662eba4d44aSLiu Zhe public void testParagraphBackGraphic_Titled() throws Exception { 663eba4d44aSLiu Zhe 664eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 665eba4d44aSLiu Zhe xText = xTextDocument.getText(); 666eba4d44aSLiu 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!" + 667eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 668eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 669eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 670eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 671eba4d44aSLiu Zhe //set paragraph background color 672eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicURL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg"))); 673eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicFilter","draw_jpg_Export"); 674eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.TILED); 675eba4d44aSLiu Zhe //save to odt 676eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 677eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 678eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 679eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 680eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 681eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 682eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 683eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 684eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 685eba4d44aSLiu Zhe //save to doc 686eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 687eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 688eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 689eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 690eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 691eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 692eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 693eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 694eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 695eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 696eba4d44aSLiu Zhe 697eba4d44aSLiu Zhe //reopen the document 698eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 699eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 700eba4d44aSLiu Zhe //verify paragraph background graphic 701eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.TILED,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 702eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicFilter")); 703eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/sw/paragraphtable/Desert.jpg")),xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicURL")); 704eba4d44aSLiu Zhe 705eba4d44aSLiu Zhe //reopen the document 706eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 707eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 708eba4d44aSLiu Zhe //verify paragraph background graphic 709eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.TILED,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 710eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic fileter","draw_jpg_Export",xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicFilter")); 711eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic URL",FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicURL")); 712eba4d44aSLiu Zhe } 713eba4d44aSLiu Zhe /* 714eba4d44aSLiu Zhe * test paragraph background graphic 715eba4d44aSLiu Zhe * 1.new a text document 716eba4d44aSLiu Zhe * 2.insert some text 717eba4d44aSLiu Zhe * 3.set paragraph background with graphic and graphic location is none 718eba4d44aSLiu Zhe * 4.save and close the document 719eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph background graphic 720eba4d44aSLiu Zhe */ 721eba4d44aSLiu Zhe @Test testParagraphBackGraphic_Nonne()722eba4d44aSLiu Zhe public void testParagraphBackGraphic_Nonne() throws Exception { 723eba4d44aSLiu Zhe 724eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 725eba4d44aSLiu Zhe xText = xTextDocument.getText(); 726eba4d44aSLiu 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!" + 727eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 728eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 729eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 730eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 731eba4d44aSLiu Zhe //set paragraph background color 732eba4d44aSLiu Zhe xCursorProps.setPropertyValue("ParaBackGraphicLocation",com.sun.star.style.GraphicLocation.NONE); 733eba4d44aSLiu Zhe //save to odt 734eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 735eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 736eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 737eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 738eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 739eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 740eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 741eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 742eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 743eba4d44aSLiu Zhe //save to doc 744eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 745eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 746eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 747eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 748eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 749eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 750eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 751eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 752eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 753eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 754eba4d44aSLiu Zhe 755eba4d44aSLiu Zhe //reopen the document 756eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 757eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 758eba4d44aSLiu Zhe //verify paragraph background graphic 759eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.NONE,xCursorProps_Assert_odt.getPropertyValue("ParaBackGraphicLocation")); 760eba4d44aSLiu Zhe 761eba4d44aSLiu Zhe //reopen the document 762eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 763eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 764eba4d44aSLiu Zhe //verify paragraph background graphic 765eba4d44aSLiu Zhe assertEquals("verify paragraph backgraphic location",com.sun.star.style.GraphicLocation.NONE,xCursorProps_Assert_doc.getPropertyValue("ParaBackGraphicLocation")); 766eba4d44aSLiu Zhe 767eba4d44aSLiu Zhe } 768eba4d44aSLiu Zhe } 769