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