1*07d7dbdcSHerbert Dürr /************************************************************** 2*07d7dbdcSHerbert Dürr * 3*07d7dbdcSHerbert Dürr * Licensed to the Apache Software Foundation (ASF) under one 4*07d7dbdcSHerbert Dürr * or more contributor license agreements. See the NOTICE file 5*07d7dbdcSHerbert Dürr * distributed with this work for additional information 6*07d7dbdcSHerbert Dürr * regarding copyright ownership. The ASF licenses this file 7*07d7dbdcSHerbert Dürr * to you under the Apache License, Version 2.0 (the 8*07d7dbdcSHerbert Dürr * "License"); you may not use this file except in compliance 9*07d7dbdcSHerbert Dürr * with the License. You may obtain a copy of the License at 10*07d7dbdcSHerbert Dürr * 11*07d7dbdcSHerbert Dürr * http://www.apache.org/licenses/LICENSE-2.0 12*07d7dbdcSHerbert Dürr * 13*07d7dbdcSHerbert Dürr * Unless required by applicable law or agreed to in writing, 14*07d7dbdcSHerbert Dürr * software distributed under the License is distributed on an 15*07d7dbdcSHerbert Dürr * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*07d7dbdcSHerbert Dürr * KIND, either express or implied. See the License for the 17*07d7dbdcSHerbert Dürr * specific language governing permissions and limitations 18*07d7dbdcSHerbert Dürr * under the License. 19*07d7dbdcSHerbert Dürr * 20*07d7dbdcSHerbert Dürr *************************************************************/ 21*07d7dbdcSHerbert Dürr 22eba4d44aSLiu Zhe package fvt.uno.sw.paragraph; 23eba4d44aSLiu Zhe 24eba4d44aSLiu Zhe import static org.junit.Assert.*; 25eba4d44aSLiu Zhe 26eba4d44aSLiu Zhe import org.junit.After; 27eba4d44aSLiu Zhe import org.junit.Before; 28eba4d44aSLiu Zhe import org.junit.Ignore; 29eba4d44aSLiu Zhe import org.junit.Test; 30eba4d44aSLiu Zhe import org.openoffice.test.common.FileUtil; 31eba4d44aSLiu Zhe import org.openoffice.test.common.Testspace; 32eba4d44aSLiu Zhe import org.openoffice.test.uno.UnoApp; 33eba4d44aSLiu Zhe 34eba4d44aSLiu Zhe import com.sun.star.table.BorderLine; 35eba4d44aSLiu Zhe import com.sun.star.text.*; 36eba4d44aSLiu Zhe import com.sun.star.beans.*; 37eba4d44aSLiu Zhe import com.sun.star.frame.XStorable; 38eba4d44aSLiu Zhe import com.sun.star.uno.UnoRuntime; 39eba4d44aSLiu Zhe 40eba4d44aSLiu Zhe public class ParagraphBorder { 41eba4d44aSLiu Zhe private static final UnoApp app = new UnoApp(); 42eba4d44aSLiu Zhe XText xText = null; 43eba4d44aSLiu Zhe 44eba4d44aSLiu Zhe @Before setUp()45eba4d44aSLiu Zhe public void setUp() throws Exception { 46eba4d44aSLiu Zhe app.start(); 47eba4d44aSLiu Zhe 48eba4d44aSLiu Zhe } 49eba4d44aSLiu Zhe 50eba4d44aSLiu Zhe @After tearDown()51eba4d44aSLiu Zhe public void tearDown() throws Exception { 52eba4d44aSLiu Zhe app.close(); 53eba4d44aSLiu Zhe } 54eba4d44aSLiu Zhe /* 55eba4d44aSLiu Zhe * test paragraph background color 56eba4d44aSLiu Zhe * 1.new a text document 57eba4d44aSLiu Zhe * 2.insert some text 58eba4d44aSLiu Zhe * 3.set paragraph border 59eba4d44aSLiu Zhe * 4.save and close the document 60eba4d44aSLiu Zhe * 5.reload the saved document and check the paragraph border 61eba4d44aSLiu Zhe */ 62eba4d44aSLiu Zhe @Test@Ignore("Bug #120694 - [testUNO patch]the paragraph border line style change when save to doc.") testParagraphBorderSetting()63eba4d44aSLiu Zhe public void testParagraphBorderSetting() throws Exception { 64eba4d44aSLiu Zhe 65eba4d44aSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 66eba4d44aSLiu Zhe xText = xTextDocument.getText(); 67eba4d44aSLiu 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!" + 68eba4d44aSLiu Zhe "Hello,world!Hello,world!"); 69eba4d44aSLiu Zhe // create text cursor for selecting and formatting text 70eba4d44aSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 71eba4d44aSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 72eba4d44aSLiu Zhe BorderLine[]borderLine=new BorderLine[] {new BorderLine(),new BorderLine(),new BorderLine(),new BorderLine()}; 73eba4d44aSLiu Zhe borderLine[0].Color=0x00FF0000; 74eba4d44aSLiu Zhe borderLine[0].InnerLineWidth=101; 75eba4d44aSLiu Zhe borderLine[0].OuterLineWidth=19; 76eba4d44aSLiu Zhe borderLine[0].LineDistance=100; 77eba4d44aSLiu Zhe borderLine[1].Color =0x00FFFF00; 78eba4d44aSLiu Zhe borderLine[1].InnerLineWidth=101; 79eba4d44aSLiu Zhe borderLine[1].OuterLineWidth=19; 80eba4d44aSLiu Zhe borderLine[1].LineDistance=101; 81eba4d44aSLiu Zhe borderLine[2].Color =0x0000FF00; 82eba4d44aSLiu Zhe borderLine[2].InnerLineWidth=150; 83eba4d44aSLiu Zhe borderLine[2].OuterLineWidth=19; 84eba4d44aSLiu Zhe borderLine[2].LineDistance=101; 85eba4d44aSLiu Zhe borderLine[3].Color =0x0000FF00; 86eba4d44aSLiu Zhe borderLine[3].InnerLineWidth=150; 87eba4d44aSLiu Zhe borderLine[3].OuterLineWidth=19; 88eba4d44aSLiu Zhe borderLine[3].LineDistance=101; 89eba4d44aSLiu Zhe xCursorProps.setPropertyValue("LeftBorder", borderLine[0]); 90eba4d44aSLiu Zhe xCursorProps.setPropertyValue("RightBorder", borderLine[1]); 91eba4d44aSLiu Zhe xCursorProps.setPropertyValue("TopBorder", borderLine[2]); 92eba4d44aSLiu Zhe xCursorProps.setPropertyValue("BottomBorder", borderLine[3]); 93eba4d44aSLiu Zhe //save to odt 94eba4d44aSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 95eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 96eba4d44aSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 97eba4d44aSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 98eba4d44aSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 99eba4d44aSLiu Zhe aStoreProperties_odt[0].Value = true; 100eba4d44aSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 101eba4d44aSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 102eba4d44aSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 103eba4d44aSLiu Zhe //save to doc 104eba4d44aSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 105eba4d44aSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 106eba4d44aSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 107eba4d44aSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 108eba4d44aSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 109eba4d44aSLiu Zhe aStoreProperties_doc[0].Value = true; 110eba4d44aSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 111eba4d44aSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 112eba4d44aSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 113eba4d44aSLiu Zhe app.closeDocument(xTextDocument); 114eba4d44aSLiu Zhe 115eba4d44aSLiu Zhe //reopen the document 116eba4d44aSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 117eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 118eba4d44aSLiu Zhe //verify paragraph border 119eba4d44aSLiu Zhe Object borderLine_odt[]={xCursorProps_Assert_odt.getPropertyValue("LeftBorder"),xCursorProps_Assert_odt.getPropertyValue("RightBorder"),xCursorProps_Assert_odt.getPropertyValue("TopBorder"),xCursorProps_Assert_odt.getPropertyValue("BottomBorder")}; 120eba4d44aSLiu Zhe BorderLine leftborderLine_odt=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_odt[0]); 121eba4d44aSLiu Zhe assertEquals("assert paragraph left border",0x00FF0000,leftborderLine_odt.Color); 122eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,leftborderLine_odt.InnerLineWidth); 123eba4d44aSLiu Zhe assertEquals("assert paragraph left border",19,leftborderLine_odt.OuterLineWidth); 124eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,leftborderLine_odt.LineDistance); 125eba4d44aSLiu Zhe 126eba4d44aSLiu Zhe BorderLine rightborderLine_odt=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_odt[1]); 127eba4d44aSLiu Zhe assertEquals("assert paragraph left border",0x00FFFF00,rightborderLine_odt.Color); 128eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,rightborderLine_odt.InnerLineWidth); 129eba4d44aSLiu Zhe assertEquals("assert paragraph left border",19,rightborderLine_odt.OuterLineWidth); 130eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,rightborderLine_odt.LineDistance); 131eba4d44aSLiu Zhe 132eba4d44aSLiu Zhe BorderLine topborderLine_odt=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_odt[2]); 133eba4d44aSLiu Zhe assertEquals("assert paragraph left border",0x0000FF00,topborderLine_odt.Color); 134eba4d44aSLiu Zhe assertEquals("assert paragraph left border",150,topborderLine_odt.InnerLineWidth); 135eba4d44aSLiu Zhe assertEquals("assert paragraph left border",19,topborderLine_odt.OuterLineWidth); 136eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,topborderLine_odt.LineDistance); 137eba4d44aSLiu Zhe 138eba4d44aSLiu Zhe BorderLine bottomtborderLine_odt=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_odt[3]); 139eba4d44aSLiu Zhe assertEquals("assert paragraph left border",0x0000FF00,bottomtborderLine_odt.Color); 140eba4d44aSLiu Zhe assertEquals("assert paragraph left border",150,bottomtborderLine_odt.InnerLineWidth); 141eba4d44aSLiu Zhe assertEquals("assert paragraph left border",19,bottomtborderLine_odt.OuterLineWidth); 142eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,bottomtborderLine_odt.LineDistance); 143eba4d44aSLiu Zhe 144eba4d44aSLiu Zhe //reopen the document 145eba4d44aSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 146eba4d44aSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 147eba4d44aSLiu Zhe //verify paragraph border 148eba4d44aSLiu Zhe Object borderLine_doc[]={xCursorProps_Assert_doc.getPropertyValue("LeftBorder"),xCursorProps_Assert_doc.getPropertyValue("RightBorder"),xCursorProps_Assert_doc.getPropertyValue("TopBorder"),xCursorProps_Assert_doc.getPropertyValue("BottomBorder")}; 149eba4d44aSLiu Zhe BorderLine leftborderLine_doc=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_doc[0]); 150eba4d44aSLiu Zhe assertEquals("assert paragraph left border",0x00FF0000,leftborderLine_doc.Color); 151eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,leftborderLine_doc.InnerLineWidth); 152eba4d44aSLiu Zhe assertEquals("assert paragraph left border",19,leftborderLine_doc.OuterLineWidth); 153eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,leftborderLine_doc.LineDistance); 154eba4d44aSLiu Zhe 155eba4d44aSLiu Zhe BorderLine rightborderLine_doc=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_doc[1]); 156eba4d44aSLiu Zhe assertEquals("assert paragraph left border",0x00FFFF00,rightborderLine_doc.Color); 157eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,rightborderLine_doc.InnerLineWidth); 158eba4d44aSLiu Zhe assertEquals("assert paragraph left border",19,rightborderLine_doc.OuterLineWidth); 159eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,rightborderLine_doc.LineDistance); 160eba4d44aSLiu Zhe 161eba4d44aSLiu Zhe BorderLine topborderLine_doc=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_doc[2]); 162eba4d44aSLiu Zhe assertEquals("assert paragraph left border",0x0000FF00,topborderLine_doc.Color); 163eba4d44aSLiu Zhe assertEquals("assert paragraph left border",150,topborderLine_doc.InnerLineWidth); 164eba4d44aSLiu Zhe assertEquals("assert paragraph left border",19,topborderLine_doc.OuterLineWidth); 165eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,topborderLine_doc.LineDistance); 166eba4d44aSLiu Zhe 167eba4d44aSLiu Zhe BorderLine bottomtborderLine_doc=(BorderLine)UnoRuntime.queryInterface(BorderLine.class,borderLine_doc[3]); 168eba4d44aSLiu Zhe assertEquals("assert paragraph left border",0x0000FF00,bottomtborderLine_doc.Color); 169eba4d44aSLiu Zhe assertEquals("assert paragraph left border",150,bottomtborderLine_doc.InnerLineWidth); 170eba4d44aSLiu Zhe assertEquals("assert paragraph left border",19,bottomtborderLine_doc.OuterLineWidth); 171eba4d44aSLiu Zhe assertEquals("assert paragraph left border",101,bottomtborderLine_doc.LineDistance); 172eba4d44aSLiu Zhe } 173eba4d44aSLiu Zhe } 174