ASF Bugzilla – Attachment 20788 Details for
Bug 43323
Cannot add Picture to ShapeGroup
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Unit Test case
TestShapeGroup.java (text/plain), 3.22 KB, created by
Danno Ferrin
on 2007-09-10 09:37:54 UTC
(
hide
)
Description:
Unit Test case
Filename:
MIME Type:
Creator:
Danno Ferrin
Created:
2007-09-10 09:37:54 UTC
Size:
3.22 KB
patch
obsolete
>package org.apache.poi.hslf.model; > >import junit.framework.TestCase; >import org.apache.poi.hslf.HSLFSlideShow; >import org.apache.poi.hslf.usermodel.SlideShow; > >import java.io.ByteArrayInputStream; >import java.io.ByteArrayOutputStream; >import java.io.File; > >public class TestShapeGroup extends TestCase { > > protected File cwd; > > public void setUp() throws Exception { > cwd = new File(System.getProperty("HSLF.testdata.path")); > } > > public void testSimpleGroup() throws Exception { > SlideShow ppt = new SlideShow(); > > Slide slide = ppt.createSlide(); > > //slide.addTitle().setText("ShapeGroup tester"); > > ShapeGroup group = new ShapeGroup(); > java.awt.Rectangle groupRectangle = new java.awt.Rectangle(1,1,500,500); > group.setAnchor(groupRectangle); > slide.addShape(group); > > // create one of each appropriate SimpleShape and add it > AutoShape ellipse = new AutoShape(ShapeTypes.Ellipse, group); > java.awt.Rectangle ellipseAnchor = new java.awt.Rectangle(320, 154, 55, 111); > ellipse.setAnchor(ellipseAnchor); > group.addShape(ellipse); > > Line line = new Line(group); > java.awt.Rectangle lineAnchor = new java.awt.Rectangle(100, 200, 50, 60); > line.setAnchor(lineAnchor); > group.addShape(line); > > File img = new File(cwd, "tomcat.png"); > int idx = ppt.addPicture(img, Picture.PNG); > Picture pict = new Picture(idx, group); > java.awt.Rectangle pictAnchor = new java.awt.Rectangle(200, 100, 130, 92); > group.addShape(pict); > > TextBox txtbox = new TextBox(group); > txtbox.setText("Hello, World!"); > java.awt.Rectangle txtAnchor = new java.awt.Rectangle(100, 100, 300, 100); > txtbox.setAnchor(txtAnchor); > group.addShape(txtbox); > > > // Serialize and read again > ByteArrayOutputStream out = new ByteArrayOutputStream(); > ppt.write(out); > out.close(); > > ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); > slide = ppt.getSlides()[0]; > > Shape[] shape = slide.getShapes(); > for (int i = 0; i < shape.length; i++) { > System.out.println(shape[i].getClass().getName()); > System.out.println(shape[i].getAnchor()); > } > > assertEquals(1, shape.length); > assertTrue(shape[0] instanceof ShapeGroup); > assertEquals(groupRectangle, shape[0].getAnchor()); > > group = (ShapeGroup) shape[0]; > shape = group.getShapes(); > for (int i = 0; i < shape.length; i++) { > System.out.println(shape[i].getClass().getName()); > System.out.println(shape[i].getAnchor()); > } > assertEquals(4, shape.length); > > assertTrue(shape[0] instanceof AutoShape); > //assertEquals(ellipseAnchor, shape[0].getAnchor()); > > assertTrue(shape[1] instanceof Line); > //assertEquals(lineAnchor, shape[1].getAnchor()); > > assertTrue(shape[2] instanceof Picture); > //assertEquals(pictAnchor, shape[2].getAnchor()); > > assertTrue(shape[3] instanceof TextBox); > //assertEquals(txtAnchor, shape[3].getAnchor()); > > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 43323
:
20778
| 20788