--- testuno/.externalToolBuilders/Classpath Builder.launch (revision 1412762) +++ testuno/.externalToolBuilders/Classpath Builder.launch (working copy) @@ -1,22 +1,22 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + --- testuno/source/fvt/uno/sw/bookmark/CheckBookmarks.java (revision 1412762) +++ testuno/source/fvt/uno/sw/bookmark/CheckBookmarks.java (working copy) @@ -57,7 +57,9 @@ XText xText = document.getText(); XTextCursor xTextCursor = xText.createTextCursor(); xTextCursor.setString("Contents"); - + /** + * insert bookmark into document + */ for (int i = 0; i < initBookmarkNames.length; i++) { xTextCursor.gotoEnd(false); XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, xTextCursor); @@ -77,7 +79,12 @@ public static void tearDownConnection() throws Exception { app.close(); } - + /** + * get bookmark content + * @param xBookmarks + * @return + * @throws Exception + */ private static String[] getBookmarkContents(XNameAccess xBookmarks) throws Exception { String[] bookmarkNames = xBookmarks.getElementNames(); String[] bookmarkContents = new String[bookmarkNames.length]; @@ -89,14 +96,20 @@ return bookmarkContents; } - + /** + * verify inserted bookmark by compare their name and content + * @throws Exception + */ @Test public void createBookmark() throws Exception { XNameAccess xBookmarks = ((XBookmarksSupplier)UnoRuntime.queryInterface(XBookmarksSupplier.class, document)).getBookmarks(); assertArrayEquals("Bookmark name list:", initBookmarkNames, xBookmarks.getElementNames()); assertArrayEquals("Bookmark content list:", initBookmarkContents, getBookmarkContents(xBookmarks)); } - + /** + * verify bookmark modify + * @throws Exception + */ @Test public void updateBookmarkContent() throws Exception { String[] expectedBookmarkNames= new String[]{"bookmark1", "bookmark2", "bookmark3"}; @@ -113,7 +126,10 @@ assertArrayEquals("Bookmark name list after updating some content:", expectedBookmarkNames, xBookmarks.getElementNames()); assertArrayEquals("Bookmark content list after updating some content:", expectedBookmarkContents, getBookmarkContents(xBookmarks)); } - + /** + * verify bookmark remove + * @throws Exception + */ @Test public void removeBookmark() throws Exception { String[] expectedBookmarkNames= new String[]{"bookmark2", "bookmark3"}; --- testuno/source/fvt/uno/sw/DocumentTest.java (revision 1412762) +++ testuno/source/fvt/uno/sw/DocumentTest.java (working copy) @@ -32,6 +32,8 @@ import org.openoffice.test.common.FileUtil; import org.openoffice.test.uno.UnoApp; +import testlib.uno.SWUtil; + import com.sun.star.text.XTextDocument; import com.sun.star.text.XTextCursor; import com.sun.star.text.XText; @@ -39,10 +41,7 @@ import com.sun.star.beans.PropertyValue; import com.sun.star.frame.*; import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.XCloseable; import com.sun.star.lang.XComponent; -import com.sun.star.container.XEnumerationAccess; -import com.sun.star.container.XEnumeration; public class DocumentTest { @@ -51,10 +50,7 @@ File temp = null; String workingFilePath = ""; String workingTemplatePath = ""; - - /** - * @throws java.lang.Exception - */ + @Before public void setUp() throws Exception { unoApp.start(); @@ -72,71 +68,39 @@ public void tearDown() throws Exception { unoApp.close(); } - - private XComponent newDocumentFromTemplate(String templatePath) throws Exception - { - XComponentLoader componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, unoApp.getDesktop()); - PropertyValue[] pros = new PropertyValue[1]; - pros[0] = new PropertyValue(); - pros[0].Name = "AsTemplate"; - pros[0].Value = new Boolean(true); - - XComponent component = componentLoader.loadComponentFromURL(FileUtil.getUrl(workingTemplatePath), "_blank", 0,pros); - return component; - } - - /** - * test close document + * test new document and close document * @throws Exception */ @Test - public void testCloseDocument() throws Exception + public void testNewAndCloseDocument() throws Exception { XComponent component = unoApp.newDocument("swriter"); - unoApp.closeDocument(component); - XModel xModel = unoApp.getDesktop().getCurrentFrame().getController().getModel(); - Assert.assertTrue("Document has been closed.",xModel==null); - } - - /** - * test new document - * @throws Exception - */ - @Test - public void testNewDocument() throws Exception - { - XComponentLoader componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, unoApp.getDesktop()); - XComponent component = componentLoader.loadComponentFromURL("private:factory/" + "swriter", "_blank", 0, new PropertyValue[0]); textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component); XTitle xTitle = (XTitle)UnoRuntime.queryInterface(XTitle.class, textDocument); String title = xTitle.getTitle(); Assert.assertEquals("New Document title start with \"Untitled\"",true, title.startsWith("Untitled")); - unoApp.closeDocument(textDocument); - } - + unoApp.closeDocument(component); + XModel xModel = unoApp.getDesktop().getCurrentFrame().getController().getModel(); + Assert.assertTrue("Document has been closed.",xModel==null); + } /** * test new document from template * @throws Exception */ @Test public void testNewDocumentFromTemplate() throws Exception - { - XComponent component = this.newDocumentFromTemplate(workingTemplatePath); + { + XComponent component = SWUtil.newDocumentFromTemplate(workingTemplatePath,unoApp); textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component); + XTitle xTitle = (XTitle)UnoRuntime.queryInterface(XTitle.class, textDocument); XText xText = textDocument.getText(); - XTitle xTitle = (XTitle)UnoRuntime.queryInterface(XTitle.class, textDocument); - xText = textDocument.getText(); XTextCursor xTextCursor = xText.createTextCursor(); xTextCursor.gotoEnd(true); XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); - String paraStyle = (String)xPropertySet.getPropertyValue("ParaStyleName"); - - Assert.assertEquals("new document from template, heading style in template is remained. ", "Heading 1", paraStyle); - + String paraStyle = (String)xPropertySet.getPropertyValue("ParaStyleName"); + Assert.assertEquals("new document from template, heading style in template is remained. ", "Heading 1", paraStyle); Assert.assertEquals("new document from template, title start with \"Untitled\".", true, xTitle.getTitle().startsWith("Untitled")); - - unoApp.closeDocument(textDocument); } /** @@ -151,23 +115,17 @@ XText xText = textDocument.getText(); XTextCursor xTextCursor = xText.createTextCursor(); xTextCursor.gotoEnd(true); - XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); - - xPropertySet.setPropertyValue("ParaStyleName", "Heading 1"); - - XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, component); - xStorable.store(); - unoApp.closeDocument(textDocument); - + XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); + xPropertySet.setPropertyValue("ParaStyleName", "Heading 1"); + SWUtil.save(textDocument); + unoApp.closeDocument(textDocument); component = unoApp.loadDocument(workingFilePath); textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component); xText = textDocument.getText(); xTextCursor = xText.createTextCursor(); xTextCursor.gotoEnd(true); - xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); - + xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); Assert.assertEquals("Modify plain text to heading 1 style. ", "Heading 1", (String)xPropertySet.getPropertyValue("ParaStyleName")); - unoApp.closeDocument(textDocument); } /** @@ -186,21 +144,8 @@ xPropertySet.setPropertyValue("ParaStyleName", "Heading 1"); xText.insertString(xTextCursor, "test Save odt as doc.", false); - - XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, component); - PropertyValue[] storeProps = new PropertyValue[2]; - - storeProps[0] = new PropertyValue(); - storeProps[0].Name = "Overwrite"; - storeProps[0].Value = new Boolean(true); - - storeProps[1] = new PropertyValue(); - storeProps[1].Name = "FilterName"; - storeProps[1].Value = "MS Word 97"; - - xStorable.storeAsURL(FileUtil.getUrl(saveAsFile), storeProps); + SWUtil.saveAsDoc(textDocument, FileUtil.getUrl(saveAsFile)); Assert.assertTrue("Save odt document as doc the file exist: " + saveAsFile.getAbsolutePath(), saveAsFile.exists()); - unoApp.closeDocument(textDocument); } /** @@ -232,8 +177,6 @@ xStorable.storeToURL(FileUtil.getUrl(saveAsFile), storeProps); Assert.assertTrue("Export document as PDF.", saveAsFile.exists()); - - unoApp.closeDocument(textDocument); } /** @@ -270,19 +213,8 @@ storeProps[2].Value=new Boolean(true); xStorable.storeToURL(FileUtil.getUrl(saveAsFile), storeProps); - unoApp.closeDocument(textDocument); - - component = this.newDocumentFromTemplate(saveAsFile.getAbsolutePath()); - textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component); - XTitle xTitle = (XTitle)UnoRuntime.queryInterface(XTitle.class, textDocument); - xText = textDocument.getText(); - xTextCursor = xText.createTextCursor(); - xTextCursor.gotoEnd(true); - xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); - String paraStyle = (String)xPropertySet.getPropertyValue("ParaStyleName"); - Assert.assertEquals("Save document as template, heading style is remained. ", "Heading 1", paraStyle); - Assert.assertEquals("Save document as template, title start with \"Untitled\".", true, xTitle.getTitle().startsWith("Untitled")); - unoApp.closeDocument(textDocument); + unoApp.closeDocument(textDocument); + Assert.assertTrue("Export document as ott.", saveAsFile.exists()); } } --- testuno/source/fvt/uno/sw/frame/FrameAnchorType.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FrameAnchorType.java (working copy) @@ -0,0 +1,77 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; +@RunWith(value = Parameterized.class) +public class FrameAnchorType { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + private com.sun.star.text.TextContentAnchorType FrameAnchorType; + public FrameAnchorType(com.sun.star.text.TextContentAnchorType FrameAnchorType){ + this.FrameAnchorType=FrameAnchorType; + } + @Parameters + public static Collection data(){ + Object[][] params = new Object[][]{ + {com.sun.star.text.TextContentAnchorType.AS_CHARACTER}, + {com.sun.star.text.TextContentAnchorType.AT_CHARACTER}, + {com.sun.star.text.TextContentAnchorType.AT_PAGE}, + {com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH}, + }; + return Arrays.asList(params); + } + @Before + public void setUp() throws Exception { + app.start(); + } + @After + public void tearDown() throws Exception { + app.close(); + } + + @Test + public void testFrameAnchorType() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame1 = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame1,false); + XPropertySet xTextFrameProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame1); + xTextFrameProps1.setPropertyValue("AnchorType",FrameAnchorType); + //reopen the document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, SWUtil.saveTo_Override_reload(xTextDocument,"writer8", Testspace.getPath("output/test.odt"),app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + XTextFrame xTextFrame_Assert1=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrames_odt.getByName("Frame1")); + XPropertySet xTextFrameProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert1); + assertEquals("assert shadow anchor type",FrameAnchorType,xTextFrameProps_assert1.getPropertyValue("AnchorType")); + } +} --- testuno/source/fvt/uno/sw/frame/FrameBackColor.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FrameBackColor.java (working copy) @@ -0,0 +1,68 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; + +public class FrameBackColor { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.close(); + } + + @Test + public void testFrameBackColor() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame,false); + XPropertySet xFrameProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame); + xFrameProps.setPropertyValue("BackColor",0x0000FF00); + //reopen the document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + Object xTextFrame_obj_odt=xTextFrames_odt.getByName("Frame1"); + XTextFrame xTextFrame_Assert_odt=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_odt); + XPropertySet xFrameProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert_odt); + assertEquals("verify Frame background color",0x0000FF00,xFrameProps_assert_odt.getPropertyValue("BackColor")); + + //reopen the document + XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "MS Word 97",Testspace.getPath("output/test.doc"), app)); + XTextFramesSupplier xTFS_doc = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_doc); + XNameAccess xTextFrames_doc = xTFS_doc.getTextFrames(); + Object xTextFrame_obj_doc=xTextFrames_doc.getByName("Frame1"); + XTextFrame xTextFrame_Assert_doc=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_doc); + XPropertySet xFrameProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert_doc); + assertEquals("verify frame background color",0x0000FF00,xFrameProps_assert_doc.getPropertyValue("BackColor")); + } +} --- testuno/source/fvt/uno/sw/frame/FrameBackGraphic.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FrameBackGraphic.java (working copy) @@ -0,0 +1,95 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.openoffice.test.common.FileUtil; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.GraphicLocation; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; +import testlib.uno.SWUtil; +@RunWith(value = Parameterized.class) +public class FrameBackGraphic { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + private int backGraphicLocation; + private String graphicURL=null; + private String graphicName=null; + public FrameBackGraphic(String graphicURL,String graphicName,int backGraphicLocation){ + this.graphicURL=graphicURL; + this.graphicName=graphicName; + this.backGraphicLocation = backGraphicLocation; + } + @Parameters + public static Collection data(){ + Object[][] params = new Object[][]{ + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",1}, + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",2}, + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",3}, + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",4}, + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",5}, + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",6}, + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",7}, + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",8}, + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",9}, + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",10}, + {FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",11} + }; + return Arrays.asList(params); + } + + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.close(); + } + @Test + public void testFrameBackGraphic() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new Frame from the document's factory + XTextFrame xTextFrame1 = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame1,false); + XPropertySet xFrameProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame1); + xFrameProps1.setPropertyValue("BackGraphicURL",graphicURL); + xFrameProps1.setPropertyValue("BackGraphicFilter",graphicName); + xFrameProps1.setPropertyValue("BackGraphicLocation",backGraphicLocation); + XTextDocument xTextDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class,xTextDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + Object xFrame_obj1=xTextFrames_odt.getByName("Frame1"); + XTextFrame xFrame_Assert1=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xFrame_obj1); + XPropertySet xFrameProps1_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xFrame_Assert1); + GraphicLocation graphiclocation=(GraphicLocation)xFrameProps1_assert.getPropertyValue("BackGraphicLocation"); + assertEquals("verify Frame backgraphic location",backGraphicLocation,graphiclocation.getValue()); + assertEquals("verify Frame backgraphic fileter",graphicName,xFrameProps1_assert.getPropertyValue("BackGraphicFilter")); + assertEquals("verify Frame backgraphic URL",graphicURL,xFrameProps1_assert.getPropertyValue("BackGraphicURL")); + } +} --- testuno/source/fvt/uno/sw/frame/FrameBorder.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FrameBorder.java (working copy) @@ -0,0 +1,98 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.BorderLine; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; + +public class FrameBorder { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.close(); + } + + @Test + public void testInsertFrame() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame,false); + XPropertySet xTextFramerops = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame); + //set frame border + BorderLine[]borderLine=new BorderLine[] {new BorderLine(),new BorderLine(),new BorderLine(),new BorderLine()}; + borderLine[0].Color=0x00FF0000; + borderLine[0].InnerLineWidth=101; + borderLine[0].OuterLineWidth=19; + borderLine[0].LineDistance=100; + borderLine[1].Color =0x00FFFF00; + borderLine[1].InnerLineWidth=101; + borderLine[1].OuterLineWidth=19; + borderLine[1].LineDistance=101; + borderLine[2].Color =0x0000FF00; + borderLine[2].InnerLineWidth=150; + borderLine[2].OuterLineWidth=19; + borderLine[2].LineDistance=101; + borderLine[3].Color =0x0000FF00; + borderLine[3].InnerLineWidth=150; + borderLine[3].OuterLineWidth=19; + borderLine[3].LineDistance=101; + xTextFramerops.setPropertyValue("LeftBorder", borderLine[0]); + xTextFramerops.setPropertyValue("RightBorder", borderLine[1]); + xTextFramerops.setPropertyValue("TopBorder", borderLine[2]); + xTextFramerops.setPropertyValue("BottomBorder", borderLine[3]); + //reopen the document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, SWUtil.saveTo_Override_reload(xTextDocument,"writer8", Testspace.getPath("output/test.odt"),app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + XPropertySet xFrameProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrames_odt.getByName("Frame1")); + BorderLine LeftBorder_Assert_odt=(BorderLine) UnoRuntime.queryInterface(BorderLine.class, xFrameProps_Assert_odt.getPropertyValue("LeftBorder")); + assertEquals("assert topline color as setting",0x00FF0000,LeftBorder_Assert_odt.Color); + assertEquals("assert topline innerline width as setting",101,LeftBorder_Assert_odt.InnerLineWidth); + assertEquals("assert topline outerlinewidth as setting",19,LeftBorder_Assert_odt.OuterLineWidth); + assertEquals("assert topline linedistance as setting",101,LeftBorder_Assert_odt.LineDistance); + BorderLine RightBorder_Assert_odt=(BorderLine) UnoRuntime.queryInterface(BorderLine.class, xFrameProps_Assert_odt.getPropertyValue("RightBorder")); + assertEquals("assert bottomline color as setting",0x00FFFF00,RightBorder_Assert_odt.Color); + assertEquals("assert bottomline innerline width as setting",101,RightBorder_Assert_odt.InnerLineWidth); + assertEquals("assert bottomline outerlinewidth as setting",19,RightBorder_Assert_odt.OuterLineWidth); + assertEquals("assert bottomline linedistance as setting",101,RightBorder_Assert_odt.LineDistance); + BorderLine TopBorder_Assert_odt=(BorderLine) UnoRuntime.queryInterface(BorderLine.class, xFrameProps_Assert_odt.getPropertyValue("TopBorder")); + assertEquals("assert leftline color as setting",0x0000FF00,TopBorder_Assert_odt.Color); + assertEquals("assert leftline innerline width as setting",150,TopBorder_Assert_odt.InnerLineWidth); + assertEquals("assert leftline outerlinewidth as setting",19,TopBorder_Assert_odt.OuterLineWidth); + assertEquals("assert leftline linedistance as setting",101,TopBorder_Assert_odt.LineDistance); + BorderLine BottomBorder_Assert_odt=(BorderLine) UnoRuntime.queryInterface(BorderLine.class, xFrameProps_Assert_odt.getPropertyValue("BottomBorder")); + assertEquals("assert rightline color as setting",0x0000FF00,BottomBorder_Assert_odt.Color); + assertEquals("assert rightline linedistance as setting",101,BottomBorder_Assert_odt.LineDistance); + assertEquals("assert rightline innerline width as setting",150,BottomBorder_Assert_odt.InnerLineWidth); + assertEquals("assert rightline outerlinewidth as setting",19,BottomBorder_Assert_odt.OuterLineWidth); + } +} --- testuno/source/fvt/uno/sw/frame/FrameBorderSpacingtoContent.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FrameBorderSpacingtoContent.java (working copy) @@ -0,0 +1,76 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.text.*; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; + + +public class FrameBorderSpacingtoContent { + + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.close(); + } + @Test + public void testFrameBorderSpacingtoContent() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame,false); + //set frame border spacing to content + XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTextFrame); + xCursorProps.setPropertyValue("LeftBorderDistance",499); + xCursorProps.setPropertyValue("RightBorderDistance",499); + xCursorProps.setPropertyValue("TopBorderDistance",499); + xCursorProps.setPropertyValue("BottomBorderDistance",499); + //reopen the document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + Object xTextFrame_obj_odt=xTextFrames_odt.getByName("Frame1"); + XTextFrame xTextFrame_Assert_odt=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_odt); + XPropertySet xCursorProps_assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTextFrame_Assert_odt); + assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("LeftBorderDistance")); + assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("RightBorderDistance")); + assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("TopBorderDistance")); + assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("BottomBorderDistance")); + + //reopen the document + XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "MS Word 97",Testspace.getPath("output/test.doc"), app)); + XTextFramesSupplier xTFS_doc = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_doc); + XNameAccess xTextFrames_doc = xTFS_doc.getTextFrames(); + Object xTextFrame_obj_doc=xTextFrames_doc.getByName("Frame1"); + XTextFrame xTextFrame_Assert_doc=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_doc); + XPropertySet xCursorProps_assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTextFrame_Assert_doc); + assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("LeftBorderDistance")); + assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("RightBorderDistance")); + assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("TopBorderDistance")); + assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("BottomBorderDistance")); + } +} + --- testuno/source/fvt/uno/sw/frame/FrameDescription.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FrameDescription.java (working copy) @@ -0,0 +1,65 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; + +public class FrameDescription { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.closeDocument(xTextDocument); + } + @AfterClass + public static void tearDownConnection() throws Exception { + app.close(); + } + + @Test + public void testFrameDescription() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame,false); + XPropertySet xTextFrameProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame); + xTextFrameProps.setPropertyValue("Title", "Frame"); + xTextFrameProps.setPropertyValue("Description", "Test Frame"); + + //save and reopen the document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + XPropertySet xTextFrameProps_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrames_odt.getByName("Frame1")); + assertEquals("Test Frame title","Frame", xTextFrameProps_odt.getPropertyValue("Title")); + assertEquals("Test Frame description","Test Frame", xTextFrameProps_odt.getPropertyValue("Description")); + } +} --- testuno/source/fvt/uno/sw/frame/FrameHyperlink.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FrameHyperlink.java (working copy) @@ -0,0 +1,68 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; + +public class FrameHyperlink { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.closeDocument(xTextDocument); + } + @AfterClass + public static void tearDownConnection() throws Exception { + app.close(); + } + + @Test + public void testFrameHyperlink() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame,false); + XPropertySet xTextFrameProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame); + xTextFrameProps.setPropertyValue("HyperLinkURL","http://www.google.com.hk/"); + xTextFrameProps.setPropertyValue("HyperLinkTarget","google"); + xTextFrameProps.setPropertyValue("HyperLinkName","FrameHyperlinkToGoogle"); + + //save and reopen the document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + XTextFrame xTextFrame_Assert=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrames_odt.getByName("Frame1")); + XPropertySet xTextFrameProps_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert); + assertEquals("assert Frame hyperlink url","http://www.google.com.hk/", xTextFrameProps_assert.getPropertyValue("HyperLinkURL")); + assertEquals("assert Frame hyperlink target","google", xTextFrameProps_assert.getPropertyValue("HyperLinkTarget")); + assertEquals("assert Frame hyperlink name", "FrameHyperlinkToGoogle",xTextFrameProps_assert.getPropertyValue("HyperLinkName")); + } +} --- testuno/source/fvt/uno/sw/frame/FramePosition.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FramePosition.java (working copy) @@ -0,0 +1,93 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; +@RunWith(value = Parameterized.class) +public class FramePosition { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + private short HoriOrient; + private short HoriOrientRelation; + private short VertOrient; + private short VertOrientRelation; + public FramePosition(short HoriOrient,short HoriOrientRelation,short VertOrient,short VertOrientRelation){ + this.HoriOrient=HoriOrient; + this.HoriOrientRelation = HoriOrientRelation; + this.VertOrient=VertOrient; + this.VertOrientRelation = VertOrientRelation; + } + @Parameters + public static Collection data(){ + Object[][] params = new Object[][]{ + {(short)0,(short)0,(short)0,(short)0}, + {(short)1,(short)1,(short)1,(short)1}, + {(short)2,(short)2,(short)2,(short)2}, + {(short)3,(short)3,(short)3,(short)2}, + {(short)0,(short)4,(short)2,(short)0}, + {(short)1,(short)5,(short)2,(short)2}, + }; + return Arrays.asList(params); + } + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.close(); + } + + @Test + public void testFramePosition() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame,false); + XPropertySet xFrameProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame); + xFrameProps.setPropertyValue("HoriOrient", HoriOrient); + xFrameProps.setPropertyValue("HoriOrientRelation", HoriOrientRelation); + xFrameProps.setPropertyValue("VertOrient", VertOrient); + xFrameProps.setPropertyValue("VertOrientRelation", VertOrientRelation); + + //reopen the odt document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + Object xTextFrame_obj_odt=xTextFrames_odt.getByName("Frame1"); + XTextFrame xTextFrame_Assert_odt=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_odt); + XPropertySet xFramProps_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert_odt); + assertEquals("verify Frame position",HoriOrient,xFramProps_odt.getPropertyValue("HoriOrient")); + assertEquals("verify Frame position",HoriOrientRelation,xFramProps_odt.getPropertyValue("HoriOrientRelation")); + assertEquals("verify Frame position",VertOrient,xFramProps_odt.getPropertyValue("VertOrient")); + assertEquals("verify Frame position",VertOrientRelation,xFramProps_odt.getPropertyValue("VertOrientRelation")); + } +} --- testuno/source/fvt/uno/sw/frame/FrameShadow.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FrameShadow.java (working copy) @@ -0,0 +1,93 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.ShadowFormat; +import com.sun.star.table.ShadowLocation; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; +@RunWith(value = Parameterized.class) +public class FrameShadow { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + private int shadowColor; + private short shadowWidth; + private ShadowLocation shadowLocation; + public FrameShadow(ShadowLocation shadowLocation,short shadowWidth,int shadowColor){ + this.shadowLocation=shadowLocation; + this.shadowWidth=shadowWidth; + this.shadowColor=shadowColor; + } + @Parameters + public static Collection data(){ + Object[][] params = new Object[][]{ + {ShadowLocation.NONE,(short)0,0}, + {ShadowLocation.TOP_LEFT,(short)101,0x00FF00FF}, + {ShadowLocation.TOP_RIGHT,(short)101,0x00FF00FF}, + {ShadowLocation.BOTTOM_LEFT,(short)101,0x00FF00FF}, + {ShadowLocation.BOTTOM_RIGHT,(short)101,0x00FF00FF}, + }; + return Arrays.asList(params); + } + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.close(); + } + + @Test + public void testFrameShadow() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame1 = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame1,false); + XPropertySet xTextFrameProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame1); + ShadowFormat shadowFormat=new ShadowFormat(); + shadowFormat.Color=shadowColor; + shadowFormat.Location=shadowLocation; + shadowFormat.ShadowWidth=shadowWidth; + xTextFrameProps1.setPropertyValue("ShadowFormat",shadowFormat); + //reopen the document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, SWUtil.saveTo_Override_reload(xTextDocument,"writer8", Testspace.getPath("output/test.odt"),app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + XTextFrame xTextFrame_Assert1=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrames_odt.getByName("Frame1")); + XPropertySet xTextFrameProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert1); + ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTextFrameProps_assert1.getPropertyValue("ShadowFormat")); + assertEquals("assert shadow color",shadowColor,shadowFormat_Assert1.Color); + assertEquals("assert shadow location",shadowLocation,shadowFormat_Assert1.Location); + assertEquals("assert shadow width",shadowWidth,shadowFormat_Assert1.ShadowWidth); + } +} --- testuno/source/fvt/uno/sw/frame/FrameSize.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FrameSize.java (working copy) @@ -0,0 +1,82 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; + +import com.sun.star.awt.Size; +import com.sun.star.container.XNameAccess; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; + +public class FrameSize { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.closeDocument(xTextDocument); + } + @AfterClass + public static void tearDownConnection() throws Exception { + app.close(); + } + + @Test + public void testFrameSize() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame,false); + // Access the XShape interface of the TextFrame + XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xTextFrame); + // Set the size of the new Text Frame using the XShape's 'setSize' method + Size aSize = new Size(); + aSize.Height = 41; + aSize.Width = 15000; + xShape.setSize(aSize); + + //reopen the odt document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + Object xTextFrame_obj_odt=xTextFrames_odt.getByName("Frame1"); + XTextFrame xTextFrame_Assert_odt=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_odt); + XShape xShape_odt = (XShape) UnoRuntime.queryInterface(XShape.class, xTextFrame_Assert_odt); + assertEquals("verify Frame height size",41,xShape_odt.getSize().Height); + assertEquals("verify Frame width size",15000,xShape_odt.getSize().Width); + + //reopen the doc document + XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "MS Word 97",Testspace.getPath("output/test.doc"), app)); + XTextFramesSupplier xTFS_doc = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_doc); + XNameAccess xTextFrames_doc = xTFS_doc.getTextFrames(); + Object xTextFrame_obj_doc=xTextFrames_doc.getByName("Frame1"); + XTextFrame xTextFrame_Assert_doc=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_doc); + XShape xShape_doc = (XShape) UnoRuntime.queryInterface(XShape.class, xTextFrame_Assert_doc); + assertEquals("verify Frame height size",788,xShape_doc.getSize().Height); + assertEquals("verify Frame width size",14998,xShape_doc.getSize().Width); + } +} --- testuno/source/fvt/uno/sw/frame/FrameWrapType.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/FrameWrapType.java (working copy) @@ -0,0 +1,86 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.WrapTextMode; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; +@RunWith(value = Parameterized.class) +public class FrameWrapType { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + private int FrameWrapType; + public FrameWrapType(int FrameWrapType){ + this.FrameWrapType=FrameWrapType; + } + /* + * 0:NONE + * 1:THROUGHT + * 2:PARALLEL + * 3:DYNAMIC + * 4:LEFT + * 5:RIGHT + */ + @Parameters + public static Collection data(){ + Object[][] params = new Object[][]{ + {0},{1},{2},{3},{4},{5}, + }; + return Arrays.asList(params); + } + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.close(); + } + + @Test + public void testFrameAnchorType() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame1 = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame1,false); + XPropertySet xTextFrameProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame1); + xTextFrameProps1.setPropertyValue("Surround",FrameWrapType); + //reopen the document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, SWUtil.saveTo_Override_reload(xTextDocument,"writer8", Testspace.getPath("output/test.odt"),app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + XTextFrame xTextFrame_Assert1=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrames_odt.getByName("Frame1")); + XPropertySet xTextFrameProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert1); + WrapTextMode surrond=(WrapTextMode)UnoRuntime.queryInterface(WrapTextMode.class,xTextFrameProps_assert1.getPropertyValue("Surround")); + assertEquals("assert frame wrap type",FrameWrapType,surrond.getValue()); + } +} --- testuno/source/fvt/uno/sw/frame/InsertFrame.java (revision 0) +++ testuno/source/fvt/uno/sw/frame/InsertFrame.java (working copy) @@ -0,0 +1,64 @@ +package fvt.uno.sw.frame; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.SWUtil; + +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; + +public class InsertFrame { + private static final UnoApp app = new UnoApp(); + private XTextDocument xTextDocument=null; + private XMultiServiceFactory xWriterFactory=null; + private XText xText=null; + @Before + public void setUp() throws Exception { + app.start(); + } + + @After + public void tearDown() throws Exception { + app.closeDocument(xTextDocument); + } + @AfterClass + public static void tearDownConnection() throws Exception { + app.close(); + } + + @Test + public void testInsertFrame() throws Exception { + xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter")); + xText=xTextDocument.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + // get internal service factory of the document + xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); + // Create a new table from the document's factory + XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame")); + xText.insertTextContent(xTextCursor,xTextFrame,false); + + //save and reopen the document + XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app)); + XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt); + XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames(); + assertTrue("Has text frame named Frame1", xTextFrames_odt.hasByName("Frame1")); + //save and reopen the document + XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "MS Word 97",Testspace.getPath("output/test.doc"), app)); + XTextFramesSupplier xTFS_doc = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_doc); + XNameAccess xTextFrames_doc = xTFS_doc.getTextFrames(); + assertTrue("Has text frame named Frame1", xTextFrames_doc.hasByName("Frame1")); + } +} --- testuno/source/testlib/uno/SWUtil.java (revision 1412762) +++ testuno/source/testlib/uno/SWUtil.java (working copy) @@ -21,6 +21,7 @@ package testlib.uno; +import org.openoffice.test.common.FileUtil; import org.openoffice.test.uno.UnoApp; import com.sun.star.beans.PropertyValue; @@ -42,6 +43,7 @@ import com.sun.star.text.XTextContent; import com.sun.star.text.XTextCursor; import com.sun.star.text.XTextDocument; +import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XModel; import com.sun.star.frame.XController; import com.sun.star.uno.UnoRuntime; @@ -229,4 +231,31 @@ XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStyle); xStyleProps.setPropertyValue (propertyName.toString(), propertyValue); } + + public static XTextDocument saveTo_Override_reload(XTextDocument xTextDocument,String filtervalue, String url,UnoApp app) throws Exception { + XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); + PropertyValue[] aStoreProperties = new PropertyValue[2]; + aStoreProperties[0] = new PropertyValue(); + aStoreProperties[1] = new PropertyValue(); + aStoreProperties[0].Name = "Override"; + aStoreProperties[0].Value = true; + aStoreProperties[1].Name = "FilterName"; + aStoreProperties[1].Value = filtervalue; + xStorable_odt.storeToURL(FileUtil.getUrl(url), aStoreProperties); + //reopen the document + return (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(url)); + } + /** + * create document from template + */ + public static XComponent newDocumentFromTemplate(String templatePath,UnoApp unoApp) throws Exception + { + XComponentLoader componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, unoApp.getDesktop()); + PropertyValue[] pros = new PropertyValue[1]; + pros[0] = new PropertyValue(); + pros[0].Name = "AsTemplate"; + pros[0].Value = new Boolean(true); + XComponent component = componentLoader.loadComponentFromURL(FileUtil.getUrl(templatePath), "_blank", 0,pros); + return component; + } }