--- source/testcase/uno/sd/CustomAnimation.java (revision 1379333) +++ source/testcase/uno/sd/CustomAnimation.java (working copy) @@ -1,280 +0,0 @@ -package testcase.uno.sd; - -import junit.framework.Assert; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openoffice.test.common.FileUtil; -import org.openoffice.test.common.Testspace; -import org.openoffice.test.uno.UnoApp; - -import testlib.uno.ShapeUtil; - -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; -import com.sun.star.container.XIndexContainer; -import com.sun.star.container.XNameContainer; -import com.sun.star.container.XNamed; -import com.sun.star.drawing.XDrawPage; -import com.sun.star.drawing.XDrawPages; -import com.sun.star.drawing.XDrawPagesSupplier; -import com.sun.star.drawing.XShape; -import com.sun.star.drawing.XShapes; -import com.sun.star.frame.XStorable; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.presentation.AnimationEffect; -import com.sun.star.presentation.XCustomPresentationSupplier; -import com.sun.star.presentation.XPresentation; -import com.sun.star.presentation.XPresentationSupplier; -import com.sun.star.table.XCell; -import com.sun.star.text.ControlCharacter; -import com.sun.star.text.XText; -import com.sun.star.text.XTextCursor; -import com.sun.star.text.XTextRange; -import com.sun.star.uno.UnoRuntime; - -public class CustomAnimation { - XPresentationSupplier sdDocument = null; - XPresentation pre = null; - XComponent precomp = null; - XComponent impressDocument = null; - XComponent reLoadFile = null; - XDrawPagesSupplier drawsupplier = null; - XDrawPages drawpages = null; - - String filePath = null; - - UnoApp unoApp = new UnoApp(); - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - unoApp.start(); - createDocumentAndSlide(); - } - - @After - public void tearDown() throws Exception { - unoApp.closeDocument(impressDocument); - unoApp.closeDocument(reLoadFile); - unoApp.close(); - } - - @Test - public void testShapeAnimation() throws Exception { - - XShapes xShapes = null; - XPropertySet xShapePropSet[] = new XPropertySet[23]; - - drawpages.insertNewByIndex(0); - - String aNameArray[] = { "Page 1", "Page 2", "Page 3", "Page 4", - "Page 5", "Page 6", "Page 7", "Page 8", "Page 9", "Page 10", - "Page 11", "Page 12", "Page 13", "Page 14", "Page 15", - "Page 16", "Page 17", "Page 18", "Page 19", "Page 20", - "Page 21", "Page 22", "Page 23", }; - AnimationEffect AnimationEffectArray[] = { - AnimationEffect.NONE, - AnimationEffect.FADE_FROM_LEFT, - AnimationEffect.FADE_FROM_TOP, - AnimationEffect.FADE_FROM_RIGHT, - AnimationEffect.FADE_FROM_BOTTOM, - AnimationEffect.FADE_TO_CENTER, - AnimationEffect.FADE_FROM_CENTER, - AnimationEffect.MOVE_FROM_LEFT, - AnimationEffect.MOVE_FROM_TOP, - AnimationEffect.MOVE_FROM_RIGHT, - AnimationEffect.MOVE_FROM_BOTTOM, - AnimationEffect.VERTICAL_STRIPES, - AnimationEffect.HORIZONTAL_STRIPES, - AnimationEffect.CLOCKWISE, - AnimationEffect.COUNTERCLOCKWISE, - AnimationEffect.FADE_FROM_UPPERLEFT, - AnimationEffect.FADE_FROM_UPPERRIGHT, - AnimationEffect.FADE_FROM_LOWERLEFT, - AnimationEffect.FADE_FROM_LOWERRIGHT, - AnimationEffect.CLOSE_VERTICAL, - AnimationEffect.CLOSE_HORIZONTAL, - AnimationEffect.OPEN_VERTICAL, - AnimationEffect.OPEN_HORIZONTAL, - AnimationEffect.PATH, -/* AnimationEffect.MOVE_TO_LEFT, - AnimationEffect.MOVE_TO_TOP, - AnimationEffect.MOVE_TO_RIGHT, - AnimationEffect.MOVE_TO_BOTTOM, - AnimationEffect.SPIRALIN_LEFT, - AnimationEffect.SPIRALIN_RIGHT, - AnimationEffect.SPIRALOUT_LEFT, - AnimationEffect.SPIRALOUT_RIGHT, - AnimationEffect.DISSOLVE, - AnimationEffect.WAVYLINE_FROM_LEFT, - AnimationEffect.RANDOM, - AnimationEffect.VERTICAL_LINES, - AnimationEffect.LASER_FROM_LEFT, - AnimationEffect.APPEAR, - AnimationEffect.HIDE, - AnimationEffect.MOVE_FROM_UPPERLEFT, - AnimationEffect.VERTICAL_CHECKERBOARD, - AnimationEffect.HORIZONTAL_ROTATE, - AnimationEffect.VERTICAL_STRETCH, - AnimationEffect.ZOOM_IN, - AnimationEffect.ZOOM_OUT_FROM_LEFT, */ - }; - - // insert pages - while (drawpages.getCount() < aNameArray.length) - drawpages.insertNewByIndex(0); - - // add text shape to each page - for (int i = 0; i < aNameArray.length; i++) { - XDrawPage xDrawPage = (XDrawPage) UnoRuntime.queryInterface( - XDrawPage.class, drawpages.getByIndex(i)); - XNamed xPageName = (XNamed) UnoRuntime.queryInterface(XNamed.class, - xDrawPage); - xPageName.setName(aNameArray[i]); - - xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, - drawpages.getByIndex(i)); - - // create a rectangle that is placed on the top left of the page - xShapePropSet[i] = ShapeUtil.createAndInsertShape(impressDocument, - xShapes, new Point(1000, 1000), new Size(5000, 5000), - "com.sun.star.drawing.RectangleShape"); - } - - for (int i = 0; i < aNameArray.length; i++) { - // set an object animation for each slide - xShapePropSet[i] - .setPropertyValue("Effect", AnimationEffectArray[i]); - } - - // If this property and the property DimPrevious are both true, the shape is hidden on the next click after the AnimationEffect has finished. - xShapePropSet[1].setPropertyValue("DimHide", new Boolean(false)); - // If true, this shape is painted using DimColor on the next click after finishing the AnimationEffect. - xShapePropSet[1].setPropertyValue("DimPrevious", new Boolean(true)); - // his color is used to paint the shape on the next click after the animation effect has finished - xShapePropSet[1].setPropertyValue("DimColor", new Integer(0xff0000)); - // the sound file specified in Sound is played while the animation effect is executed - xShapePropSet[1].setPropertyValue("SoundOn", new Boolean(false)); - // the sound specified in the Sound property of this shape is played completely - xShapePropSet[1].setPropertyValue("PlayFull", new Boolean(false)); - - saveAndLoadSlide(); - - for (int i = 0; i < aNameArray.length; i++) { - // assert if Shape Animation is set - Assert.assertEquals( - "Text Animation Effect is AnimationEffectArray[]", - AnimationEffectArray[i], - xShapePropSet[i].getPropertyValue("Effect")); - } - // assert if DimHide is false - Assert.assertEquals("Shape Animation DimHide is false", Boolean.FALSE, - xShapePropSet[1].getPropertyValue("DimHide")); - // assert if DimPrevious is true - Assert.assertEquals("Shape Animation DimPrevious is true", - Boolean.TRUE, xShapePropSet[1].getPropertyValue("DimPrevious")); - // assert if DimColor is red - Assert.assertEquals("Shape Animation DimColor is Red", 0xff0000, - xShapePropSet[1].getPropertyValue("DimColor")); - // assert the sound file specified in Sound don't play while the - // animation effect is executed. - Assert.assertEquals("Shape SoundOn is false", Boolean.FALSE, - xShapePropSet[1].getPropertyValue("SoundOn")); - // assert the sound specified in the Sound property of this shape is - // played completely - Assert.assertEquals("Shape PlayFull is false", Boolean.FALSE, - xShapePropSet[1].getPropertyValue("PlayFull")); - - } - - public XPropertySet addPortion(XShape xShape, String sText, - boolean bNewParagraph) - throws com.sun.star.lang.IllegalArgumentException { - XText xText = (XText) UnoRuntime.queryInterface(XText.class, xShape); - - XTextCursor xTextCursor = xText.createTextCursor(); - xTextCursor.gotoEnd(false); - if (bNewParagraph == true) { - xText.insertControlCharacter(xTextCursor, - ControlCharacter.PARAGRAPH_BREAK, false); - xTextCursor.gotoEnd(false); - } - XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface( - XTextRange.class, xTextCursor); - xTextRange.setString(sText); - xTextCursor.gotoEnd(true); - XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, xText); - return xPropSet; - } - - /** - * create a new presentation document and insert a new slide. - * - * @throws Exception - */ - public void createDocumentAndSlide() throws Exception { - impressDocument = (XComponent) UnoRuntime.queryInterface( - XComponent.class, unoApp.newDocument("simpress")); - drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface( - XDrawPagesSupplier.class, impressDocument); - drawpages = drawsupplier.getDrawPages(); - - sdDocument = (XPresentationSupplier) UnoRuntime.queryInterface( - XPresentationSupplier.class, impressDocument); - pre = sdDocument.getPresentation(); - } - - /** - * Save presentation and reLoad the slide. - * - * @param no - * @return void - * @throws Exception - */ - public void saveAndLoadSlide() throws Exception { - reLoadFile = saveAndReloadDoc(impressDocument, - "StarOffice XML (Impress)", "odp"); - drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface( - XDrawPagesSupplier.class, reLoadFile); - drawpages = drawsupplier.getDrawPages(); - - sdDocument = (XPresentationSupplier) UnoRuntime.queryInterface( - XPresentationSupplier.class, reLoadFile); - pre = sdDocument.getPresentation(); - } - - /** - * save and reload Presentation document. - * - * @param presentationDocument - * @param sFilter - * @param sExtension - * @return - * @throws Exception - */ - private XComponent saveAndReloadDoc(XComponent presentationDocument, - String sFilter, String sExtension) throws Exception { - filePath = Testspace.getPath("tmp/shapeanimation." + sExtension); - 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 = sFilter; - XStorable xStorable = (XStorable) UnoRuntime.queryInterface( - XStorable.class, presentationDocument); - xStorable.storeToURL(FileUtil.getUrl(filePath), aStoreProperties); - - return UnoRuntime.queryInterface(XComponent.class, - unoApp.loadDocument(filePath)); - } -} --- source/testcase/uno/sd/ParagraphStyle.java (revision 1379333) +++ source/testcase/uno/sd/ParagraphStyle.java (working copy) @@ -1,201 +0,0 @@ -package testcase.uno.sd; - -import junit.framework.Assert; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openoffice.test.common.FileUtil; -import org.openoffice.test.common.Testspace; -import org.openoffice.test.uno.UnoApp; - -import testlib.uno.PageUtil; -import testlib.uno.ShapeUtil; - -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; -import com.sun.star.drawing.TextFitToSizeType; -import com.sun.star.drawing.XDrawPage; -import com.sun.star.drawing.XDrawPages; -import com.sun.star.drawing.XDrawPagesSupplier; -import com.sun.star.drawing.XShape; -import com.sun.star.drawing.XShapes; -import com.sun.star.frame.XStorable; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.presentation.XPresentation; -import com.sun.star.presentation.XPresentationSupplier; -import com.sun.star.style.LineSpacing; -import com.sun.star.style.LineSpacingMode; -import com.sun.star.style.ParagraphAdjust; -import com.sun.star.text.ControlCharacter; -import com.sun.star.text.XText; -import com.sun.star.text.XTextCursor; -import com.sun.star.text.XTextRange; -import com.sun.star.uno.UnoRuntime; - -public class ParagraphStyle { - XPresentationSupplier sdDocument = null; - XPresentation pre = null; - XComponent precomp = null; - XComponent impressDocument = null; - XComponent reLoadFile = null; - XDrawPagesSupplier drawsupplier = null; - XDrawPages drawpages = null; - XShapes xShapes = null; - XDrawPage xpage = null; - String filePath=null; - - UnoApp unoApp = new UnoApp(); - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - unoApp.start(); - createDocumentAndSlide(); - } - - @After - public void tearDown() throws Exception { - unoApp.closeDocument(impressDocument); - unoApp.closeDocument(reLoadFile); - unoApp.close(); - } - - @Test - public void ParaStyle() throws Exception { - Point po = new Point(5000, 5000); - xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage); - // create the shape - XShape xRectangle = ShapeUtil.createShape(impressDocument, po, new Size(21000, 12500), "com.sun.star.drawing.RectangleShape"); - xShapes.add(xRectangle); - XPropertySet xShapePropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xRectangle); - // TextFitToSize - xShapePropSet.setPropertyValue("TextFitToSize", TextFitToSizeType.PROPORTIONAL); - - XPropertySet xTextPropSet1 = addPortion(xRectangle, "New text paragraph", true); - xTextPropSet1.setPropertyValue("ParaAdjust", ParagraphAdjust.CENTER); - - //Line Spacing - LineSpacing xLineSpacing = new LineSpacing(LineSpacingMode.LEADING, (short)1); - xTextPropSet1.setPropertyValue("ParaLineSpacing", xLineSpacing); - - //left, right, top and bottom margin - xTextPropSet1.setPropertyValue("ParaLeftMargin", 1000); - xTextPropSet1.setPropertyValue("ParaRightMargin", 1000); - xTextPropSet1.setPropertyValue("ParaTopMargin", 1000); - xTextPropSet1.setPropertyValue("ParaBottomMargin", 1000); - - XPropertySet xTextPropSet2 = addPortion(xRectangle, "And another text paragraph", true); - xTextPropSet2.setPropertyValue("CharColor", new Integer(0xff0000)); - - xRectangle = saveAndLoadShape(1, 0); - - - Assert.assertEquals("Paragraph Left Margin is 1000",1000, xTextPropSet1.getPropertyValue("ParaLeftMargin")); - Assert.assertEquals("Paragraph Right Margin is 1000", 1000,xTextPropSet1.getPropertyValue("ParaRightMargin")); - Assert.assertEquals("Paragraph Top Margin is 1000",1000, xTextPropSet1.getPropertyValue("ParaTopMargin") ); - Assert.assertEquals("Paragraph Bottom Margin is 1000 ",1000, xTextPropSet1.getPropertyValue("ParaBottomMargin")); - Assert.assertEquals("Text Color is red",0xff0000,xTextPropSet2.getPropertyValue("CharColor")); - - } - - - public static XShape createShape(XComponent xComponent, int x, int y, - int width, int height, String sShapeType) - throws java.lang.Exception { - // query the document for the document-internal service factory - XMultiServiceFactory xFactory = (XMultiServiceFactory) UnoRuntime - .queryInterface(XMultiServiceFactory.class, xComponent); - - // get the given Shape service from the factory - Object xObj = xFactory.createInstance(sShapeType); - Point aPos = new Point(x, y); - Size aSize = new Size(width, height); - - // use its XShape interface to determine position and size before - // insertion - XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xObj); - xShape.setPosition(aPos); - xShape.setSize(aSize); - return xShape; - } - - public static XPropertySet addPortion(XShape xShape, String sText, boolean bNewParagraph) - throws com.sun.star.lang.IllegalArgumentException { - XText xText = (XText)UnoRuntime.queryInterface(XText.class, xShape); - XTextCursor xTextCursor = xText.createTextCursor(); - xTextCursor.gotoEnd(false); - if (bNewParagraph) { - xText.insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false); - xTextCursor.gotoEnd(false); - } - XTextRange xTextRange = (XTextRange)UnoRuntime.queryInterface(XTextRange.class, xTextCursor); - xTextRange.setString(sText); - xTextCursor.gotoEnd(true); - XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextRange); - return xPropSet; - } - - /** - * create a new presentation document and insert a new slide. - * - * @throws Exception - */ - public void createDocumentAndSlide() throws Exception { - impressDocument = (XComponent) UnoRuntime.queryInterface( - XComponent.class, unoApp.newDocument("simpress")); - drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface( - XDrawPagesSupplier.class, impressDocument); - drawpages = drawsupplier.getDrawPages(); - drawpages.insertNewByIndex(1); - xpage = PageUtil.getDrawPageByIndex(impressDocument, 1); - } - - /** - * Save presentation and reLoad the presentation and shape in it. - * - * @param po - * @param shapeType - * @return - * @throws Exception - */ - public XShape saveAndLoadShape(int pageIndex, int shapeIndex) throws Exception { - reLoadFile = saveAndReloadDoc(impressDocument, - "impress8", "odp"); - xShapes=ShapeUtil.getShapes(reLoadFile, pageIndex); - return (XShape) UnoRuntime.queryInterface(XShape.class, xShapes.getByIndex(shapeIndex)); - } - - /** - * save and reload Presentation document. - * - * @param presentationDocument - * @param sFilter - * @param sExtension - * @return - * @throws Exception - */ - private XComponent saveAndReloadDoc(XComponent presentationDocument, - String sFilter, String sExtension) throws Exception { - filePath = Testspace.getPath("tmp/paragraphstyle." - + sExtension); - 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 = sFilter; - XStorable xStorable = (XStorable) UnoRuntime.queryInterface( - XStorable.class, presentationDocument); - xStorable.storeToURL(FileUtil.getUrl(filePath), aStoreProperties); - - return UnoRuntime.queryInterface(XComponent.class, - unoApp.loadDocument(filePath)); - } -} --- source/testcase/uno/sd/paragraph/ParagraphStyle.java (revision 0) +++ source/testcase/uno/sd/paragraph/ParagraphStyle.java (working copy) @@ -1,4 +1,4 @@ -package testcase.uno.sd; +package testcase.uno.sd.paragraph; import junit.framework.Assert; --- source/testcase/uno/sd/slidesshow/CustomShow.java (revision 0) +++ source/testcase/uno/sd/slidesshow/CustomShow.java (working copy) @@ -1,4 +1,4 @@ -package testcase.uno.sd; +package testcase.uno.sd.slidesshow; import junit.framework.Assert; --- source/testcase/uno/sd/CustomShow.java (revision 1379333) +++ source/testcase/uno/sd/CustomShow.java (working copy) @@ -1,205 +0,0 @@ -package testcase.uno.sd; - -import junit.framework.Assert; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openoffice.test.common.FileUtil; -import org.openoffice.test.common.Testspace; -import org.openoffice.test.uno.UnoApp; - -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; -import com.sun.star.container.XIndexContainer; -import com.sun.star.container.XNameContainer; -import com.sun.star.container.XNamed; -import com.sun.star.drawing.XDrawPage; -import com.sun.star.drawing.XDrawPages; -import com.sun.star.drawing.XDrawPagesSupplier; -import com.sun.star.drawing.XShape; -import com.sun.star.drawing.XShapes; -import com.sun.star.frame.XStorable; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.presentation.XCustomPresentationSupplier; -import com.sun.star.presentation.XPresentation; -import com.sun.star.presentation.XPresentationSupplier; -import com.sun.star.uno.UnoRuntime; - -import testlib.uno.ShapeUtil; - -public class CustomShow { - XPresentationSupplier sdDocument = null; - XPresentation pre = null; - XComponent precomp = null; - XComponent impressDocument = null; - XComponent reLoadFile = null; - XDrawPagesSupplier drawsupplier = null; - XDrawPages drawpages = null; - - String filePath = null; - - UnoApp unoApp = new UnoApp(); - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - unoApp.start(); - createDocumentAndSlide(); - } - - @After - public void tearDown() throws Exception { - unoApp.closeDocument(impressDocument); - unoApp.closeDocument(reLoadFile); - unoApp.close(); - } - - @Test - public void testCustomShow() throws Exception { - - String aNameArray[] = { "Page 1", "Page 2", "Page 3", "Page 4", "Page 5"}; - - //insert five pages - while (drawpages.getCount() < aNameArray.length) - drawpages.insertNewByIndex(0); - - //add text shape to each page - for (int i = 0; i < aNameArray.length; i++) { - XDrawPage xDrawPage = (XDrawPage) UnoRuntime.queryInterface( - XDrawPage.class, drawpages.getByIndex(i)); - XNamed xPageName = (XNamed) UnoRuntime.queryInterface(XNamed.class, - xDrawPage); - xPageName.setName(aNameArray[i]); - - XShape xTextObj = ShapeUtil.createShape(impressDocument, new Point( - 10000, 9000), new Size(10000, 5000), - "com.sun.star.drawing.TextShape"); - XShapes xShapes = (XShapes) UnoRuntime.queryInterface( - XShapes.class, xDrawPage); - xShapes.add(xTextObj); - ShapeUtil.addPortion(xTextObj, aNameArray[i], true); - } - - - //create two custom shows - //one will play slide 3 to 5 and is named "Part" - //the other one will play slide 1 t0 5 and is named "All" - XCustomPresentationSupplier xCustPresSupplier = (XCustomPresentationSupplier) UnoRuntime - .queryInterface(XCustomPresentationSupplier.class, impressDocument); - - - // the following container is a container for further container which - // includes the list of pages that are to play within a custom show - XNameContainer xNameContainer = xCustPresSupplier - .getCustomPresentations(); - XSingleServiceFactory xFactory = (XSingleServiceFactory) UnoRuntime - .queryInterface(XSingleServiceFactory.class, xNameContainer); - - Object xObj; - XIndexContainer xContainer; - - //instantiate an IndexContainer that will take a list of draw pages for - //the first custom show - xObj = xFactory.createInstance(); - xContainer = (XIndexContainer) UnoRuntime.queryInterface( - XIndexContainer.class, xObj); - for (int i = 3; i < 5; i++) - xContainer.insertByIndex(xContainer.getCount(), - drawpages.getByIndex(i)); - xNameContainer.insertByName("Part", xContainer); - - - //instantiate an IndexContainer that will take a list of draw page for - //the second custom show - xObj = xFactory.createInstance(); - xContainer = (XIndexContainer) UnoRuntime.queryInterface( - XIndexContainer.class, xObj); - for (int i = 1; i < 5; i++) - xContainer.insertByIndex(xContainer.getCount(), - drawpages.getByIndex(i)); - xNameContainer.insertByName("All", xContainer); - - - //set which custom show is to used - XPresentationSupplier xPresSupplier = (XPresentationSupplier) UnoRuntime - .queryInterface(XPresentationSupplier.class, impressDocument); - XPresentation xPresentation = xPresSupplier.getPresentation(); - XPropertySet xPresPropSet = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, xPresentation); - xPresPropSet.setPropertyValue("CustomShow", "Part"); - - saveAndLoadSlide(); - - //assert if custom show is set - Assert.assertEquals("Set Part as CustomSHow", xPresPropSet.getPropertyValue("CustomShow"), "Part"); - } - - /** - * create a new presentation document and insert a new slide. - * - * @throws Exception - */ - public void createDocumentAndSlide() throws Exception { - impressDocument = (XComponent) UnoRuntime.queryInterface( - XComponent.class, unoApp.newDocument("simpress")); - drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface( - XDrawPagesSupplier.class, impressDocument); - drawpages = drawsupplier.getDrawPages(); - - sdDocument = (XPresentationSupplier) UnoRuntime.queryInterface( - XPresentationSupplier.class, impressDocument); - pre = sdDocument.getPresentation(); - } - - /** - * Save presentation and reLoad the slide. - * - * @param no - * @return void - * @throws Exception - */ - public void saveAndLoadSlide() throws Exception { - reLoadFile = saveAndReloadDoc(impressDocument, - "StarOffice XML (Impress)", "odp"); - drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface( - XDrawPagesSupplier.class, reLoadFile); - drawpages = drawsupplier.getDrawPages(); - - sdDocument = (XPresentationSupplier) UnoRuntime.queryInterface( - XPresentationSupplier.class, reLoadFile); - pre = sdDocument.getPresentation(); - } - - /** - * save and reload Presentation document. - * - * @param presentationDocument - * @param sFilter - * @param sExtension - * @return - * @throws Exception - */ - private XComponent saveAndReloadDoc(XComponent presentationDocument, - String sFilter, String sExtension) throws Exception { - filePath = Testspace.getPath("tmp/customshow." + sExtension); - 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 = sFilter; - XStorable xStorable = (XStorable) UnoRuntime.queryInterface( - XStorable.class, presentationDocument); - xStorable.storeToURL(FileUtil.getUrl(filePath), aStoreProperties); - - return UnoRuntime.queryInterface(XComponent.class, - unoApp.loadDocument(filePath)); - } -} --- source/testcase/uno/sd/slidesshow/SlideShow.java (revision 0) +++ source/testcase/uno/sd/slidesshow/SlideShow.java (working copy) @@ -1,4 +1,4 @@ -package testcase.uno.sd; +package testcase.uno.sd.slidesshow; import junit.framework.Assert; --- source/testcase/uno/sd/SlideShow.java (revision 1379333) +++ source/testcase/uno/sd/SlideShow.java (working copy) @@ -1,170 +0,0 @@ -package testcase.uno.sd; - -import junit.framework.Assert; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openoffice.test.common.FileUtil; -import org.openoffice.test.common.Testspace; -import org.openoffice.test.uno.UnoApp; - -import testlib.uno.PageUtil; -import testlib.uno.ShapeUtil; - -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; -import com.sun.star.drawing.XDrawPage; -import com.sun.star.drawing.XDrawPages; -import com.sun.star.drawing.XDrawPagesSupplier; -import com.sun.star.drawing.XShape; -import com.sun.star.drawing.XShapes; -import com.sun.star.frame.XStorable; -import com.sun.star.lang.XComponent; -import com.sun.star.presentation.XPresentation; -import com.sun.star.presentation.XPresentationSupplier; -import com.sun.star.uno.UnoRuntime; - -public class SlideShow { - XPresentationSupplier sdDocument = null; - XPresentation pre = null; - XComponent precomp = null; - XComponent impressDocument = null; - XComponent reLoadFile = null; - XDrawPagesSupplier drawsupplier = null; - XDrawPages drawpages = null; - - String filePath = null; - - UnoApp unoApp = new UnoApp(); - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - unoApp.start(); - createDocumentAndSlide(); - } - - @After - public void tearDown() throws Exception { - unoApp.closeDocument(impressDocument); - unoApp.closeDocument(reLoadFile); - unoApp.close(); - } - - @Test - public void testSlideShow() throws Exception { - Point po = new Point(5000, 5000); - - XDrawPage xPage1 = createSlide(0); - XShapes xShapes1 = (XShapes) UnoRuntime.queryInterface(XShapes.class, - xPage1); - XShape xRectangle1 = ShapeUtil.createShape(impressDocument, po, - new Size(21000, 12500), "com.sun.star.drawing.RectangleShape"); - xShapes1.add(xRectangle1); - ShapeUtil.addPortion(xRectangle1, "Page1", false); - - XDrawPage xPage2 = createSlide(1); - XShapes xShapes2 = (XShapes) UnoRuntime.queryInterface(XShapes.class, - xPage2); - XShape xRectangle2 = ShapeUtil.createShape(impressDocument, po, - new Size(21000, 12500), "com.sun.star.drawing.RectangleShape"); - xShapes2.add(xRectangle2); - ShapeUtil.addPortion(xRectangle2, "Page2", false); - - XDrawPage xPage3 = createSlide(2); - XShapes xShapes3 = (XShapes) UnoRuntime.queryInterface(XShapes.class, - xPage3); - XShape xRectangle3 = ShapeUtil.createShape(impressDocument, po, - new Size(21000, 12500), "com.sun.star.drawing.RectangleShape"); - xShapes3.add(xRectangle3); - ShapeUtil.addPortion(xRectangle3, "Page3", false); - - XPropertySet xPresPropSet = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, pre); - xPresPropSet.setPropertyValue("IsEndless", Boolean.FALSE); - xPresPropSet.setPropertyValue("IsFullScreen", Boolean.TRUE); - xPresPropSet.setPropertyValue("Pause", new Integer(0)); - - saveAndLoadSlide(); - - Assert.assertEquals("IsEndless set to false", - xPresPropSet.getPropertyValue("IsEndless"), Boolean.FALSE); - Assert.assertEquals("IsFullScreen set to true", - xPresPropSet.getPropertyValue("IsFullScreen"), Boolean.TRUE); - Assert.assertEquals("Pause set to 0", - xPresPropSet.getPropertyValue("Pause"), 0); - } - - public XDrawPage createSlide(int index) throws Exception { - drawpages.insertNewByIndex(index); - XDrawPage xPage = PageUtil.getDrawPageByIndex(impressDocument, index); - return xPage; - } - - /** - * create a new presentation document and insert a new slide. - * - * @throws Exception - */ - public void createDocumentAndSlide() throws Exception { - impressDocument = (XComponent) UnoRuntime.queryInterface( - XComponent.class, unoApp.newDocument("simpress")); - drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface( - XDrawPagesSupplier.class, impressDocument); - drawpages = drawsupplier.getDrawPages(); - sdDocument = (XPresentationSupplier) UnoRuntime.queryInterface( - XPresentationSupplier.class, impressDocument); - pre = sdDocument.getPresentation(); - } - - /** - * Save presentation and reLoad the slide. - * - * @param no - * @return void - * @throws Exception - */ - public void saveAndLoadSlide() throws Exception { - reLoadFile = saveAndReloadDoc(impressDocument, - "StarOffice XML (Impress)", "odp"); - drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface( - XDrawPagesSupplier.class, reLoadFile); - drawpages = drawsupplier.getDrawPages(); - - sdDocument = (XPresentationSupplier) UnoRuntime.queryInterface( - XPresentationSupplier.class, reLoadFile); - pre = sdDocument.getPresentation(); - } - - /** - * save and reload Presentation document. - * - * @param presentationDocument - * @param sFilter - * @param sExtension - * @return - * @throws Exception - */ - private XComponent saveAndReloadDoc(XComponent presentationDocument, - String sFilter, String sExtension) throws Exception { - filePath = Testspace.getPath("tmp/slideshow." + sExtension); - 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 = sFilter; - XStorable xStorable = (XStorable) UnoRuntime.queryInterface( - XStorable.class, presentationDocument); - xStorable.storeToURL(FileUtil.getUrl(filePath), aStoreProperties); - - return UnoRuntime.queryInterface(XComponent.class, - unoApp.loadDocument(filePath)); - } -} --- source/testcase/uno/sd/ParagraphTextProperty.java (revision 1379333) +++ source/testcase/uno/sd/ParagraphTextProperty.java (working copy) @@ -1,168 +0,0 @@ -package testcase.uno.sd; - -import junit.framework.Assert; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openoffice.test.common.FileUtil; -import org.openoffice.test.common.Testspace; -import org.openoffice.test.uno.UnoApp; - -import testlib.uno.PageUtil; -import testlib.uno.ShapeUtil; - -import com.sun.star.awt.Point; -import com.sun.star.awt.Size; -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; -import com.sun.star.drawing.TextFitToSizeType; -import com.sun.star.drawing.XDrawPage; -import com.sun.star.drawing.XDrawPages; -import com.sun.star.drawing.XDrawPagesSupplier; -import com.sun.star.drawing.XShape; -import com.sun.star.drawing.XShapes; -import com.sun.star.frame.XStorable; -import com.sun.star.lang.XComponent; - -import com.sun.star.presentation.XPresentation; -import com.sun.star.presentation.XPresentationSupplier; - -import com.sun.star.text.ControlCharacter; -import com.sun.star.text.XText; -import com.sun.star.text.XTextCursor; -import com.sun.star.text.XTextRange; -import com.sun.star.uno.UnoRuntime; - -public class ParagraphTextProperty { - XPresentationSupplier sdDocument = null; - XPresentation pre = null; - XComponent precomp = null; - XComponent impressDocument = null; - XComponent reLoadFile = null; - XDrawPagesSupplier drawsupplier = null; - XDrawPages drawpages = null; - XShapes xShapes = null; - XDrawPage xpage = null; - String filePath=null; - - UnoApp unoApp = new UnoApp(); - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - unoApp.start(); - createDocumentAndSlide(); - } - - @After - public void tearDown() throws Exception { - unoApp.closeDocument(impressDocument); - unoApp.closeDocument(reLoadFile); - unoApp.close(); - } - - @Test - public void testParagraphPropertyShape() throws Exception { - Point po = new Point(5000, 5000); - xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage); - // create the shape - XShape xRectangle = ShapeUtil.createShape(impressDocument, po, new Size(21000, 12500), "com.sun.star.drawing.RectangleShape"); - xShapes.add(xRectangle); - - XPropertySet xShapePropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xRectangle); - // TextFitToSize - xShapePropSet.setPropertyValue("TextFitToSize", TextFitToSizeType.PROPORTIONAL); - // border size - xShapePropSet.setPropertyValue("TextLeftDistance", new Integer(2500)); - xShapePropSet.setPropertyValue("TextRightDistance", new Integer(2500)); - xShapePropSet.setPropertyValue("TextUpperDistance", new Integer(2500)); - xShapePropSet.setPropertyValue("TextLowerDistance", new Integer(2500)); - XPropertySet xTextPropSet = addPortion(xRectangle, "using TextFitToSize", false); - xTextPropSet = addPortion(xRectangle, "and a Border distance of 2,5 cm", true); - - xRectangle = saveAndLoadShape(1,0); - - Assert.assertEquals("TextLeftDistance is 2500", 2500, xShapePropSet.getPropertyValue("TextLeftDistance")); - Assert.assertEquals("TextRightDistance is 2500", 2500, xShapePropSet.getPropertyValue("TextRightDistance")); - Assert.assertEquals("TextUpperDistance is 2500", 2500, xShapePropSet.getPropertyValue("TextUpperDistance")); - Assert.assertEquals("TextLowerDistance is 2500", 2500, xShapePropSet.getPropertyValue("TextLowerDistance")); - - } - - public static XPropertySet addPortion(XShape xShape, String sText, boolean bNewParagraph) - throws com.sun.star.lang.IllegalArgumentException { - XText xText = (XText)UnoRuntime.queryInterface(XText.class, xShape); - XTextCursor xTextCursor = xText.createTextCursor(); - xTextCursor.gotoEnd(false); - if (bNewParagraph) { - xText.insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false); - xTextCursor.gotoEnd(false); - } - XTextRange xTextRange = (XTextRange)UnoRuntime.queryInterface(XTextRange.class, xTextCursor); - xTextRange.setString(sText); - xTextCursor.gotoEnd(true); - XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextRange); - return xPropSet; - } - - /** - * create a new presentation document and insert a new slide. - * - * @throws Exception - */ - public void createDocumentAndSlide() throws Exception { - impressDocument = (XComponent) UnoRuntime.queryInterface( - XComponent.class, unoApp.newDocument("simpress")); - drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface( - XDrawPagesSupplier.class, impressDocument); - drawpages = drawsupplier.getDrawPages(); - drawpages.insertNewByIndex(1); - xpage = PageUtil.getDrawPageByIndex(impressDocument, 1); - } - - /** - * Save presentation and reLoad the presentation and shape in it. - * - * @param po - * @param shapeType - * @return - * @throws Exception - */ - public XShape saveAndLoadShape(int pageIndex, int shapeIndex) throws Exception { - reLoadFile = saveAndReloadDoc(impressDocument, - "impress8", "odp"); - xShapes=ShapeUtil.getShapes(reLoadFile, pageIndex); - return (XShape) UnoRuntime.queryInterface(XShape.class, xShapes.getByIndex(shapeIndex)); - } - - /** - * save and reload Presentation document. - * - * @param presentationDocument - * @param sFilter - * @param sExtension - * @return - * @throws Exception - */ - private XComponent saveAndReloadDoc(XComponent presentationDocument, - String sFilter, String sExtension) throws Exception { - filePath = Testspace.getPath("tmp/paragraphtextproperty." - + sExtension); - 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 = sFilter; - XStorable xStorable = (XStorable) UnoRuntime.queryInterface( - XStorable.class, presentationDocument); - xStorable.storeToURL(FileUtil.getUrl(filePath), aStoreProperties); - - return UnoRuntime.queryInterface(XComponent.class, - unoApp.loadDocument(filePath)); - } -} --- source/testcase/uno/sd/paragraph/ParagraphTextProperty.java (revision 0) +++ source/testcase/uno/sd/paragraph/ParagraphTextProperty.java (working copy) @@ -1,4 +1,4 @@ -package testcase.uno.sd; +package testcase.uno.sd.paragraph; import junit.framework.Assert; --- source/testcase/uno/sd/animation/CustomAnimation.java (revision 0) +++ source/testcase/uno/sd/animation/CustomAnimation.java (working copy) @@ -1,4 +1,4 @@ -package testcase.uno.sd; +package testcase.uno.sd.animation; import junit.framework.Assert; --- source/testcase/uno/sd/animation/TextAnimation.java (revision 0) +++ source/testcase/uno/sd/animation/TextAnimation.java (revision 0) @@ -0,0 +1,183 @@ +package testcase.uno.sd.animation; + +import junit.framework.Assert; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openoffice.test.common.FileUtil; +import org.openoffice.test.common.Testspace; +import org.openoffice.test.uno.UnoApp; + +import testlib.uno.ShapeUtil; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexContainer; +import com.sun.star.container.XNameContainer; +import com.sun.star.container.XNamed; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.presentation.AnimationEffect; +import com.sun.star.presentation.XCustomPresentationSupplier; +import com.sun.star.presentation.XPresentation; +import com.sun.star.presentation.XPresentationSupplier; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.UnoRuntime; + +public class TextAnimation { + XPresentationSupplier sdDocument = null; + XPresentation pre = null; + XComponent precomp = null; + XComponent impressDocument = null; + XComponent reLoadFile = null; + XDrawPagesSupplier drawsupplier = null; + XDrawPages drawpages = null; + + String filePath = null; + + UnoApp unoApp = new UnoApp(); + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + unoApp.start(); + createDocumentAndSlide(); + } + + @After + public void tearDown() throws Exception { + unoApp.closeDocument(impressDocument); + unoApp.closeDocument(reLoadFile); + unoApp.close(); + } + + @Test + public void testTextAnimation() throws Exception { + + XShapes xShapes; + XPropertySet xShapePropSet; + Point po = new Point(5000, 5000); + + // create pages, so that three are available + drawpages.insertNewByIndex(0); + // get the shape container for page one + xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, + drawpages.getByIndex(0)); + // create a rectangle that is placed on the top left of the page + XShape xRectangle = ShapeUtil.createShape(impressDocument, po, + new Size(21000, 12500), "com.sun.star.drawing.RectangleShape"); + xShapes.add(xRectangle); + + XPropertySet xTextPropSet = addPortion(xRectangle, "Text Animation", + false); + + xTextPropSet.setPropertyValue("TextEffect", + AnimationEffect.MOVE_FROM_RIGHT); + + saveAndLoadSlide(); + + // assert if Text Animation is set + Assert.assertEquals("Text Animation Effect is MOVE_FROM_RIGHT", + AnimationEffect.MOVE_FROM_RIGHT, + xTextPropSet.getPropertyValue("TextEffect")); + + } + + public XPropertySet addPortion(XShape xShape, String sText, + boolean bNewParagraph) + throws com.sun.star.lang.IllegalArgumentException { + XText xText = (XText) UnoRuntime.queryInterface(XText.class, xShape); + + XTextCursor xTextCursor = xText.createTextCursor(); + xTextCursor.gotoEnd(false); + if (bNewParagraph == true) { + xText.insertControlCharacter(xTextCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + xTextCursor.gotoEnd(false); + } + XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface( + XTextRange.class, xTextCursor); + xTextRange.setString(sText); + xTextCursor.gotoEnd(true); + XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, xText); + return xPropSet; + } + + /** + * create a new presentation document and insert a new slide. + * + * @throws Exception + */ + public void createDocumentAndSlide() throws Exception { + impressDocument = (XComponent) UnoRuntime.queryInterface( + XComponent.class, unoApp.newDocument("simpress")); + drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface( + XDrawPagesSupplier.class, impressDocument); + drawpages = drawsupplier.getDrawPages(); + + sdDocument = (XPresentationSupplier) UnoRuntime.queryInterface( + XPresentationSupplier.class, impressDocument); + pre = sdDocument.getPresentation(); + } + + /** + * Save presentation and reLoad the slide. + * + * @param no + * @return void + * @throws Exception + */ + public void saveAndLoadSlide() throws Exception { + reLoadFile = saveAndReloadDoc(impressDocument, + "StarOffice XML (Impress)", "odp"); + drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface( + XDrawPagesSupplier.class, reLoadFile); + drawpages = drawsupplier.getDrawPages(); + + sdDocument = (XPresentationSupplier) UnoRuntime.queryInterface( + XPresentationSupplier.class, reLoadFile); + pre = sdDocument.getPresentation(); + } + + /** + * save and reload Presentation document. + * + * @param presentationDocument + * @param sFilter + * @param sExtension + * @return + * @throws Exception + */ + private XComponent saveAndReloadDoc(XComponent presentationDocument, + String sFilter, String sExtension) throws Exception { + filePath = Testspace.getPath("tmp/customshow." + sExtension); + 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 = sFilter; + XStorable xStorable = (XStorable) UnoRuntime.queryInterface( + XStorable.class, presentationDocument); + xStorable.storeToURL(FileUtil.getUrl(filePath), aStoreProperties); + + return UnoRuntime.queryInterface(XComponent.class, + unoApp.loadDocument(filePath)); + } +}