You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/11/21 16:54:01 UTC
svn commit: r1715540 [2/2] - in /poi/trunk:
src/examples/src/org/apache/poi/hslf/examples/
src/java/org/apache/poi/sl/draw/ src/java/org/apache/poi/sl/usermodel/
src/java/org/apache/poi/util/ src/ooxml/java/org/apache/poi/xslf/usermodel/
src/ooxml/test...
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=1715540&r1=1715539&r2=1715540&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Sat Nov 21 15:54:01 2015
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertTru
import java.awt.Color;
import java.awt.Dimension;
-import java.awt.Rectangle;
+import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -49,7 +49,6 @@ import org.apache.poi.hslf.usermodel.HSL
import org.apache.poi.hslf.usermodel.HSLFSimpleShape;
import org.apache.poi.hslf.usermodel.HSLFSlide;
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
-import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl;
import org.apache.poi.hslf.usermodel.HSLFTextBox;
import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
import org.apache.poi.hslf.usermodel.HSLFTextRun;
@@ -84,7 +83,7 @@ public final class TestShapes {
}
@Test
- public void graphics() throws Exception {
+ public void graphics() throws IOException {
HSLFSlide slide = ppt.createSlide();
HSLFLine line = new HSLFLine();
@@ -96,7 +95,7 @@ public final class TestShapes {
slide.addShape(line);
HSLFAutoShape ellipse = new HSLFAutoShape(ShapeType.ELLIPSE);
- java.awt.Rectangle ellipseAnchor = new Rectangle(320, 154, 55, 111);
+ Rectangle2D ellipseAnchor = new Rectangle2D.Double(320, 154, 55, 111);
ellipse.setAnchor(ellipseAnchor);
ellipse.setLineWidth(2);
ellipse.setLineDash(LineDash.SOLID);
@@ -110,10 +109,10 @@ public final class TestShapes {
//read ppt from byte array
- ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
- assertEquals(1, ppt.getSlides().size());
+ HSLFSlideShow ppt2 = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
+ assertEquals(1, ppt2.getSlides().size());
- slide = ppt.getSlides().get(0);
+ slide = ppt2.getSlides().get(0);
List<HSLFShape> shape = slide.getShapes();
assertEquals(2, shape.size());
@@ -122,6 +121,8 @@ public final class TestShapes {
assertTrue(shape.get(1) instanceof HSLFAutoShape); //group shape
assertEquals(ellipseAnchor, shape.get(1).getAnchor()); //group shape
+
+ ppt2.close();
}
/**
@@ -129,7 +130,7 @@ public final class TestShapes {
* @throws Exception
*/
@Test
- public void textBoxRead() throws Exception {
+ public void textBoxRead() throws IOException {
ppt = new HSLFSlideShow(_slTests.openResourceAsStream("with_textbox.ppt"));
HSLFSlide sl = ppt.getSlides().get(0);
for (HSLFShape sh : sl.getShapes()) {
@@ -161,7 +162,7 @@ public final class TestShapes {
@SuppressWarnings("unused")
@Test
- public void testParagraphs() throws Exception {
+ public void testParagraphs() throws IOException {
HSLFSlideShow ss = new HSLFSlideShow();
HSLFSlide slide = ss.createSlide();
HSLFTextBox shape = new HSLFTextBox();
@@ -175,7 +176,7 @@ public final class TestShapes {
p2r2.setStrikethrough(true);
// run 3 has same text properties as run 2 and will be merged when saving
HSLFTextRun p2r3 = shape.appendText("para 2 run 3.", false);
- shape.setAnchor(new Rectangle(100,100,100,10));
+ shape.setAnchor(new Rectangle2D.Double(100,100,100,10));
slide.addShape(shape);
shape.resizeToFitText();
@@ -207,7 +208,7 @@ public final class TestShapes {
* and set some of the style attributes
*/
@Test
- public void textBoxWriteBytes() throws Exception {
+ public void textBoxWriteBytes() throws IOException {
ppt = new HSLFSlideShow();
HSLFSlide sl = ppt.createSlide();
HSLFTextRun rt;
@@ -241,8 +242,8 @@ public final class TestShapes {
ppt.write(out);
out.close();
- ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
- sl = ppt.getSlides().get(0);
+ HSLFSlideShow ppt2 = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
+ sl = ppt2.getSlides().get(0);
txtbox = (HSLFTextBox)sl.getShapes().get(0);
rt = txtbox.getTextParagraphs().get(0).getTextRuns().get(0);
@@ -255,6 +256,8 @@ public final class TestShapes {
assertFalse(rt.isUnderlined());
assertEquals("Arial", rt.getFontFamily());
assertTrue(sameColor(Color.red, rt.getFontColor()));
+
+ ppt2.close();
}
/**
@@ -276,7 +279,7 @@ public final class TestShapes {
* it must be the same as returned by Slide.getTextRuns().
*/
@Test
- public void textBoxSet() throws Exception {
+ public void textBoxSet() throws IOException {
textBoxSet("with_textbox.ppt");
textBoxSet("basic_test_ppt_file.ppt");
textBoxSet("next_test_ppt_file.ppt");
@@ -285,7 +288,7 @@ public final class TestShapes {
textBoxSet("incorrect_slide_order.ppt");
}
- private void textBoxSet(String filename) throws Exception {
+ private void textBoxSet(String filename) throws IOException {
HSLFSlideShow ss = new HSLFSlideShow(_slTests.openResourceAsStream(filename));
for (HSLFSlide sld : ss.getSlides()) {
ArrayList<String> lst1 = new ArrayList<String>();
@@ -311,13 +314,14 @@ public final class TestShapes {
assertTrue(lst1.containsAll(lst2));
assertTrue(lst2.containsAll(lst1));
}
+ ss.close();
}
/**
* Test adding shapes to <code>ShapeGroup</code>
*/
@Test
- public void shapeGroup() throws Exception {
+ public void shapeGroup() throws IOException {
HSLFSlideShow ss = new HSLFSlideShow();
HSLFSlide slide = ss.createSlide();
@@ -325,22 +329,23 @@ public final class TestShapes {
HSLFGroupShape group = new HSLFGroupShape();
- group.setAnchor(new Rectangle(0, 0, (int)pgsize.getWidth(), (int)pgsize.getHeight()));
+ group.setAnchor(new Rectangle2D.Double(0, 0, pgsize.getWidth(), pgsize.getHeight()));
slide.addShape(group);
HSLFPictureData data = ss.addPicture(_slTests.readFile("clock.jpg"), PictureType.JPEG);
HSLFPictureShape pict = new HSLFPictureShape(data, group);
- pict.setAnchor(new Rectangle(0, 0, 200, 200));
+ pict.setAnchor(new Rectangle2D.Double(0, 0, 200, 200));
group.addShape(pict);
HSLFLine line = new HSLFLine(group);
- line.setAnchor(new Rectangle(300, 300, 500, 0));
+ line.setAnchor(new Rectangle2D.Double(300, 300, 500, 0));
group.addShape(line);
//serialize and read again.
ByteArrayOutputStream out = new ByteArrayOutputStream();
ss.write(out);
out.close();
+ ss.close();
ByteArrayInputStream is = new ByteArrayInputStream(out.toByteArray());
ss = new HSLFSlideShow(is);
@@ -359,10 +364,12 @@ public final class TestShapes {
assertTrue(grshape.get(1) instanceof HSLFLine);
pict = (HSLFPictureShape)grshape.get(0);
- assertEquals(new Rectangle(0, 0, 200, 200), pict.getAnchor());
+ assertEquals(new Rectangle2D.Double(0, 0, 200, 200), pict.getAnchor());
line = (HSLFLine)grshape.get(1);
- assertEquals(new Rectangle(300, 300, 500, 0), line.getAnchor());
+ assertEquals(new Rectangle2D.Double(300, 300, 500, 0), line.getAnchor());
+
+ ss.close();
}
/**
@@ -387,10 +394,12 @@ public final class TestShapes {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ss.write(out);
out.close();
+ ss.close();
ss = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
sl = ss.getSlides().get(0);
assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().size());
+ ss.close();
}
@Test
@@ -409,7 +418,7 @@ public final class TestShapes {
}
@Test
- public void shapeId() {
+ public void shapeId() throws IOException {
HSLFSlideShow ss = new HSLFSlideShow();
HSLFSlide slide = ss.createSlide();
HSLFShape shape = null;
@@ -456,6 +465,7 @@ public final class TestShapes {
slide.addShape(shape);
}
assertEquals(numClusters + 1, dgg.getNumIdClusters());
+ ss.close();
}
@Test
@@ -482,5 +492,7 @@ public final class TestShapes {
assertEquals("Border width is 5 pt", sh4.getText());
assertEquals(Color.black, sh4.getLineColor());
assertEquals(5.0, sh4.getLineWidth(), 0);
+
+ ss.close();
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java?rev=1715540&r1=1715539&r2=1715540&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java Sat Nov 21 15:54:01 2015
@@ -25,6 +25,7 @@ import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.util.List;
import org.apache.poi.POIDataSamples;
@@ -42,8 +43,6 @@ import org.junit.Test;
/**
* Test <code>Table</code> object.
- *
- * @author Yegor Kozlov
*/
public final class TestTable {
private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
@@ -52,7 +51,7 @@ public final class TestTable {
* Test that ShapeFactory works properly and returns <code>Table</code>
*/
@Test
- public void testShapeFactory() throws Exception {
+ public void testShapeFactory() throws IOException {
HSLFSlideShow ppt = new HSLFSlideShow();
HSLFSlide slide = ppt.createSlide();
@@ -72,20 +71,22 @@ public final class TestTable {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ppt.write(out);
out.close();
-
+ ppt.close();
+
ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
slide = ppt.getSlides().get(0);
assertTrue(slide.getShapes().get(0) instanceof HSLFTable);
HSLFTable tbl3 = (HSLFTable)slide.getShapes().get(0);
assertEquals(tbl.getNumberOfColumns(), tbl3.getNumberOfColumns());
assertEquals(tbl.getNumberOfRows(), tbl3.getNumberOfRows());
+ ppt.close();
}
/**
* Error constructing Table when rownum=1
*/
@Test
- public void test45889(){
+ public void test45889() throws IOException {
HSLFSlideShow ppt = new HSLFSlideShow();
HSLFSlide slide = ppt.createSlide();
List<HSLFShape> shapes;
@@ -101,24 +102,25 @@ public final class TestTable {
assertEquals(tbl1.getNumberOfColumns(), tbl2.getNumberOfColumns());
assertEquals(tbl1.getNumberOfRows(), tbl2.getNumberOfRows());
+ ppt.close();
}
- @Test
- public void testIllegalCOnstruction(){
+ @Test(expected=IllegalArgumentException.class)
+ public void testIllegalRowCnstruction() throws IOException {
HSLFSlideShow ppt = new HSLFSlideShow();
HSLFSlide slide = ppt.createSlide();
- try {
- slide.createTable(0, 5);
- fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
- } catch (IllegalArgumentException e){
-
- }
- try {
- slide.createTable(5, 0);
- fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
- } catch (IllegalArgumentException e){
+ slide.createTable(0, 5);
+ fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
+ ppt.close();
+ }
- }
+ @Test(expected=IllegalArgumentException.class)
+ public void testIllegalColConstruction() throws IOException {
+ HSLFSlideShow ppt = new HSLFSlideShow();
+ HSLFSlide slide = ppt.createSlide();
+ slide.createTable(5, 0);
+ fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
+ ppt.close();
}
/**
@@ -126,7 +128,7 @@ public final class TestTable {
* when the table is positioned with its top at -1
*/
@Test
- public void test57820() throws Exception {
+ public void test57820() throws IOException {
SlideShow<?,?> ppt = new HSLFSlideShow(_slTests.openResourceAsStream("bug57820-initTableNullRefrenceException.ppt"));
List<? extends Slide<?,?>> slides = ppt.getSlides();
@@ -143,7 +145,8 @@ public final class TestTable {
}
assertNotNull(tbl);
-
assertEquals(-1, tbl.getAnchor().getY(), 0);
+
+ ppt.close();
}
}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java?rev=1715540&r1=1715539&r2=1715540&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java Sat Nov 21 15:54:01 2015
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertNot
import static org.junit.Assert.assertTrue;
import java.awt.Color;
-import java.awt.Rectangle;
+import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -58,10 +58,10 @@ public class TestTable {
new DrawTableShape(table).setAllBorders(1.0, Color.black, StrokeStyle.LineDash.DASH_DOT);
- table.setAnchor(new Rectangle(100, 100, 400, 400));
+ table.setAnchor(new Rectangle2D.Double(100, 100, 400, 400));
- Rectangle rectExp = new Rectangle(420,367,80,133);
- Rectangle rectAct = table.getCell(rows-1, cols-1).getAnchor();
+ Rectangle2D rectExp = new Rectangle2D.Double(420,366.625,80,133.375);
+ Rectangle2D rectAct = table.getCell(rows-1, cols-1).getAnchor();
assertEquals(rectExp, rectAct);
ppt.close();
}
Modified: poi/trunk/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java?rev=1715540&r1=1715539&r2=1715540&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java Sat Nov 21 15:54:01 2015
@@ -22,8 +22,8 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.awt.Rectangle;
import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
@@ -38,7 +38,7 @@ public class TestPresetGeometries {
for(String name : shapes.keySet()) {
CustomGeometry geom = shapes.get(name);
- Context ctx = new Context(geom, new Rectangle(0, 0, 100, 100), new IAdjustableShape() {
+ Context ctx = new Context(geom, new Rectangle2D.Double(0, 0, 100, 100), new IAdjustableShape() {
public Guide getAdjustValue(String presetName) {
return null;
}
Added: poi/trunk/test-data/slideshow/table_test.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/table_test.ppt?rev=1715540&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/slideshow/table_test.ppt
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: poi/trunk/test-data/slideshow/table_test.pptx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/table_test.pptx?rev=1715540&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/slideshow/table_test.pptx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org