xref: /AOO41X/test/testuno/source/fvt/uno/sw/frame/FrameBorderSpacingtoContent.java (revision 54628ca40d27d15cc98fe861da7fff7e60c2f7d6)
1 package fvt.uno.sw.frame;
2 
3 import static org.junit.Assert.*;
4 
5 import org.junit.After;
6 import org.junit.Before;
7 import org.junit.Test;
8 import org.openoffice.test.common.Testspace;
9 import org.openoffice.test.uno.UnoApp;
10 
11 import testlib.uno.SWUtil;
12 
13 import com.sun.star.uno.UnoRuntime;
14 import com.sun.star.text.*;
15 import com.sun.star.lang.XMultiServiceFactory;
16 import com.sun.star.beans.XPropertySet;
17 import com.sun.star.container.XNameAccess;
18 
19 
20 public class FrameBorderSpacingtoContent {
21 
22     private static final UnoApp app = new UnoApp();
23     private XTextDocument xTextDocument=null;
24     private XMultiServiceFactory xWriterFactory=null;
25     private XText xText=null;
26     @Before
27     public void setUp() throws Exception {
28         app.start();
29     }
30 
31     @After
32     public void tearDown() throws Exception {
33         app.close();
34     }
35     @Test
36     public void testFrameBorderSpacingtoContent() throws Exception {
37         xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
38         xText=xTextDocument.getText();
39         XTextCursor xTextCursor = xText.createTextCursor();
40         // get internal service factory of the document
41         xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
42         // Create a new table from the document's factory
43         XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
44         xText.insertTextContent(xTextCursor,xTextFrame,false);
45         //set frame border spacing to content
46         XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTextFrame);
47         xCursorProps.setPropertyValue("LeftBorderDistance",499);
48         xCursorProps.setPropertyValue("RightBorderDistance",499);
49         xCursorProps.setPropertyValue("TopBorderDistance",499);
50         xCursorProps.setPropertyValue("BottomBorderDistance",499);
51         //reopen the document
52         XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app));
53         XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
54         XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
55         Object xTextFrame_obj_odt=xTextFrames_odt.getByName("Frame1");
56         XTextFrame xTextFrame_Assert_odt=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_odt);
57         XPropertySet xCursorProps_assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTextFrame_Assert_odt);
58         assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("LeftBorderDistance"));
59         assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("RightBorderDistance"));
60         assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("TopBorderDistance"));
61         assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("BottomBorderDistance"));
62 
63         //reopen the document
64         XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "MS Word 97",Testspace.getPath("output/test.doc"), app));
65         XTextFramesSupplier xTFS_doc = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_doc);
66         XNameAccess xTextFrames_doc = xTFS_doc.getTextFrames();
67         Object xTextFrame_obj_doc=xTextFrames_doc.getByName("Frame1");
68         XTextFrame xTextFrame_Assert_doc=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_doc);
69         XPropertySet xCursorProps_assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTextFrame_Assert_doc);
70         assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("LeftBorderDistance"));
71         assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("RightBorderDistance"));
72         assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("TopBorderDistance"));
73         assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("BottomBorderDistance"));
74     }
75 }
76 
77