1*07d7dbdcSHerbert Dürr /************************************************************** 2*07d7dbdcSHerbert Dürr * 3*07d7dbdcSHerbert Dürr * Licensed to the Apache Software Foundation (ASF) under one 4*07d7dbdcSHerbert Dürr * or more contributor license agreements. See the NOTICE file 5*07d7dbdcSHerbert Dürr * distributed with this work for additional information 6*07d7dbdcSHerbert Dürr * regarding copyright ownership. The ASF licenses this file 7*07d7dbdcSHerbert Dürr * to you under the Apache License, Version 2.0 (the 8*07d7dbdcSHerbert Dürr * "License"); you may not use this file except in compliance 9*07d7dbdcSHerbert Dürr * with the License. You may obtain a copy of the License at 10*07d7dbdcSHerbert Dürr * 11*07d7dbdcSHerbert Dürr * http://www.apache.org/licenses/LICENSE-2.0 12*07d7dbdcSHerbert Dürr * 13*07d7dbdcSHerbert Dürr * Unless required by applicable law or agreed to in writing, 14*07d7dbdcSHerbert Dürr * software distributed under the License is distributed on an 15*07d7dbdcSHerbert Dürr * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*07d7dbdcSHerbert Dürr * KIND, either express or implied. See the License for the 17*07d7dbdcSHerbert Dürr * specific language governing permissions and limitations 18*07d7dbdcSHerbert Dürr * under the License. 19*07d7dbdcSHerbert Dürr * 20*07d7dbdcSHerbert Dürr *************************************************************/ 21*07d7dbdcSHerbert Dürr 22eba4d44aSLiu Zhe package fvt.uno.sw.paragraph; 236194dbcdSLiu Zhe 246194dbcdSLiu Zhe import static org.junit.Assert.*; 256194dbcdSLiu Zhe 266194dbcdSLiu Zhe import org.junit.After; 276194dbcdSLiu Zhe import org.junit.Before; 286194dbcdSLiu Zhe import org.junit.Ignore; 296194dbcdSLiu Zhe import org.junit.Test; 306194dbcdSLiu Zhe import org.openoffice.test.common.FileUtil; 316194dbcdSLiu Zhe import org.openoffice.test.common.Testspace; 326194dbcdSLiu Zhe import org.openoffice.test.uno.UnoApp; 336194dbcdSLiu Zhe 346194dbcdSLiu Zhe import com.sun.star.table.BorderLine; 356194dbcdSLiu Zhe import com.sun.star.text.*; 366194dbcdSLiu Zhe import com.sun.star.beans.*; 376194dbcdSLiu Zhe import com.sun.star.frame.XStorable; 386194dbcdSLiu Zhe import com.sun.star.uno.UnoRuntime; 396194dbcdSLiu Zhe 406194dbcdSLiu Zhe public class ParagraphBorder { 416194dbcdSLiu Zhe private static final UnoApp app = new UnoApp(); 426194dbcdSLiu Zhe XText xText = null; 436194dbcdSLiu Zhe 446194dbcdSLiu Zhe @Before setUp()456194dbcdSLiu Zhe public void setUp() throws Exception { 466194dbcdSLiu Zhe app.start(); 476194dbcdSLiu Zhe 486194dbcdSLiu Zhe } 496194dbcdSLiu Zhe 506194dbcdSLiu Zhe @After tearDown()516194dbcdSLiu Zhe public void tearDown() throws Exception { 526194dbcdSLiu Zhe app.close(); 536194dbcdSLiu Zhe } 546194dbcdSLiu Zhe /* 556194dbcdSLiu Zhe * test paragraph background color 566194dbcdSLiu Zhe * 1.new a text document 576194dbcdSLiu Zhe * 2.insert some text 586194dbcdSLiu Zhe * 3.set paragraph border 596194dbcdSLiu Zhe * 4.save and close the document 606194dbcdSLiu Zhe * 5.reload the saved document and check the paragraph border 616194dbcdSLiu Zhe */ 62af986861SLiu Zhe @Test@Ignore("Bug #120694 - [testUNO patch]the paragraph border line style change when save to doc.") testParagraphBorderSetting()636194dbcdSLiu Zhe public void testParagraphBorderSetting() throws Exception { 646194dbcdSLiu Zhe 656194dbcdSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 666194dbcdSLiu Zhe xText = xTextDocument.getText(); 676194dbcdSLiu 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!" + 686194dbcdSLiu Zhe "Hello,world!Hello,world!"); 696194dbcdSLiu Zhe // create text cursor for selecting and formatting text 706194dbcdSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 716194dbcdSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 726194dbcdSLiu Zhe BorderLine[]borderLine=new BorderLine[] {new BorderLine(),new BorderLine(),new BorderLine(),new BorderLine()}; 736194dbcdSLiu Zhe borderLine[0].Color=0x00FF0000; 746194dbcdSLiu Zhe borderLine[0].InnerLineWidth=101; 756194dbcdSLiu Zhe borderLine[0].OuterLineWidth=19; 766194dbcdSLiu Zhe borderLine[0].LineDistance=100; 776194dbcdSLiu Zhe borderLine[1].Color =0x00FFFF00; 786194dbcdSLiu Zhe borderLine[1].InnerLineWidth=101; 796194dbcdSLiu Zhe borderLine[1].OuterLineWidth=19; 806194dbcdSLiu Zhe borderLine[1].LineDistance=101; 816194dbcdSLiu Zhe borderLine[2].Color =0x0000FF00; 826194dbcdSLiu Zhe borderLine[2].InnerLineWidth=150; 836194dbcdSLiu Zhe borderLine[2].OuterLineWidth=19; 846194dbcdSLiu Zhe borderLine[2].LineDistance=101; 856194dbcdSLiu Zhe borderLine[3].Color =0x0000FF00; 866194dbcdSLiu Zhe borderLine[3].InnerLineWidth=150; 876194dbcdSLiu Zhe borderLine[3].OuterLineWidth=19; 886194dbcdSLiu Zhe borderLine[3].LineDistance=101; 896194dbcdSLiu Zhe xCursorProps.setPropertyValue("LeftBorder", borderLine[0]); 906194dbcdSLiu Zhe xCursorProps.setPropertyValue("RightBorder", borderLine[1]); 916194dbcdSLiu Zhe xCursorProps.setPropertyValue("TopBorder", borderLine[2]); 926194dbcdSLiu Zhe xCursorProps.setPropertyValue("BottomBorder", borderLine[3]); 936194dbcdSLiu Zhe //save to odt 946194dbcdSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 956194dbcdSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 966194dbcdSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 976194dbcdSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 986194dbcdSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 996194dbcdSLiu Zhe aStoreProperties_odt[0].Value = true; 1006194dbcdSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 1016194dbcdSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 1026194dbcdSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 1036194dbcdSLiu Zhe //save to doc 1046194dbcdSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1056194dbcdSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 1066194dbcdSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 1076194dbcdSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 1086194dbcdSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 1096194dbcdSLiu Zhe aStoreProperties_doc[0].Value = true; 1106194dbcdSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 1116194dbcdSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 1126194dbcdSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 1136194dbcdSLiu Zhe app.closeDocument(xTextDocument); 1146194dbcdSLiu Zhe 1156194dbcdSLiu Zhe //reopen the document 1166194dbcdSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 1176194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 1186194dbcdSLiu Zhe //verify paragraph border 1196194dbcdSLiu Zhe Object borderLine_odt[]={xCursorProps_Assert_odt.getPropertyValue("LeftBorder"),xCursorProps_Assert_odt.getPropertyValue("RightBorder"),xCursorProps_Assert_odt.getPropertyValue("TopBorder"),xCursorProps_Assert_odt.getPropertyValue("BottomBorder")}; 1206194dbcdSLiu Zhe BorderLine leftborderLine_odt=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_odt[0]); 1216194dbcdSLiu Zhe assertEquals("assert paragraph left border",0x00FF0000,leftborderLine_odt.Color); 1226194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,leftborderLine_odt.InnerLineWidth); 1236194dbcdSLiu Zhe assertEquals("assert paragraph left border",19,leftborderLine_odt.OuterLineWidth); 1246194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,leftborderLine_odt.LineDistance); 1256194dbcdSLiu Zhe 1266194dbcdSLiu Zhe BorderLine rightborderLine_odt=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_odt[1]); 1276194dbcdSLiu Zhe assertEquals("assert paragraph left border",0x00FFFF00,rightborderLine_odt.Color); 1286194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,rightborderLine_odt.InnerLineWidth); 1296194dbcdSLiu Zhe assertEquals("assert paragraph left border",19,rightborderLine_odt.OuterLineWidth); 1306194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,rightborderLine_odt.LineDistance); 1316194dbcdSLiu Zhe 1326194dbcdSLiu Zhe BorderLine topborderLine_odt=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_odt[2]); 1336194dbcdSLiu Zhe assertEquals("assert paragraph left border",0x0000FF00,topborderLine_odt.Color); 1346194dbcdSLiu Zhe assertEquals("assert paragraph left border",150,topborderLine_odt.InnerLineWidth); 1356194dbcdSLiu Zhe assertEquals("assert paragraph left border",19,topborderLine_odt.OuterLineWidth); 1366194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,topborderLine_odt.LineDistance); 1376194dbcdSLiu Zhe 1386194dbcdSLiu Zhe BorderLine bottomtborderLine_odt=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_odt[3]); 1396194dbcdSLiu Zhe assertEquals("assert paragraph left border",0x0000FF00,bottomtborderLine_odt.Color); 1406194dbcdSLiu Zhe assertEquals("assert paragraph left border",150,bottomtborderLine_odt.InnerLineWidth); 1416194dbcdSLiu Zhe assertEquals("assert paragraph left border",19,bottomtborderLine_odt.OuterLineWidth); 1426194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,bottomtborderLine_odt.LineDistance); 1436194dbcdSLiu Zhe 1446194dbcdSLiu Zhe //reopen the document 1456194dbcdSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 1466194dbcdSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 1476194dbcdSLiu Zhe //verify paragraph border 1486194dbcdSLiu Zhe Object borderLine_doc[]={xCursorProps_Assert_doc.getPropertyValue("LeftBorder"),xCursorProps_Assert_doc.getPropertyValue("RightBorder"),xCursorProps_Assert_doc.getPropertyValue("TopBorder"),xCursorProps_Assert_doc.getPropertyValue("BottomBorder")}; 1496194dbcdSLiu Zhe BorderLine leftborderLine_doc=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_doc[0]); 1506194dbcdSLiu Zhe assertEquals("assert paragraph left border",0x00FF0000,leftborderLine_doc.Color); 1516194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,leftborderLine_doc.InnerLineWidth); 1526194dbcdSLiu Zhe assertEquals("assert paragraph left border",19,leftborderLine_doc.OuterLineWidth); 1536194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,leftborderLine_doc.LineDistance); 1546194dbcdSLiu Zhe 1556194dbcdSLiu Zhe BorderLine rightborderLine_doc=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_doc[1]); 1566194dbcdSLiu Zhe assertEquals("assert paragraph left border",0x00FFFF00,rightborderLine_doc.Color); 1576194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,rightborderLine_doc.InnerLineWidth); 1586194dbcdSLiu Zhe assertEquals("assert paragraph left border",19,rightborderLine_doc.OuterLineWidth); 1596194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,rightborderLine_doc.LineDistance); 1606194dbcdSLiu Zhe 1616194dbcdSLiu Zhe BorderLine topborderLine_doc=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_doc[2]); 1626194dbcdSLiu Zhe assertEquals("assert paragraph left border",0x0000FF00,topborderLine_doc.Color); 1636194dbcdSLiu Zhe assertEquals("assert paragraph left border",150,topborderLine_doc.InnerLineWidth); 1646194dbcdSLiu Zhe assertEquals("assert paragraph left border",19,topborderLine_doc.OuterLineWidth); 1656194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,topborderLine_doc.LineDistance); 1666194dbcdSLiu Zhe 1676194dbcdSLiu Zhe BorderLine bottomtborderLine_doc=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_doc[3]); 1686194dbcdSLiu Zhe assertEquals("assert paragraph left border",0x0000FF00,bottomtborderLine_doc.Color); 1696194dbcdSLiu Zhe assertEquals("assert paragraph left border",150,bottomtborderLine_doc.InnerLineWidth); 1706194dbcdSLiu Zhe assertEquals("assert paragraph left border",19,bottomtborderLine_doc.OuterLineWidth); 1716194dbcdSLiu Zhe assertEquals("assert paragraph left border",101,bottomtborderLine_doc.LineDistance); 1726194dbcdSLiu Zhe } 1736194dbcdSLiu Zhe } 174