From e2bc07e9d19565b4c7ed818eb1295704a9ff2a80 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Mon, 16 Nov 2015 23:56:19 +0000 Subject: [PATCH] #55955 - Filling an existing ppt table stopped working with 3.9 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1714715 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hslf/usermodel/TestTable.java | 75 +++++++++++++++++-- 1 file changed, 67 insertions(+), 8 deletions(-) diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java index d32114a7f..7a917fafd 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java @@ -26,6 +26,9 @@ import static org.junit.Assert.assertTrue; import java.awt.Color; import java.awt.Rectangle; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.util.List; import org.apache.poi.POIDataSamples; @@ -41,7 +44,7 @@ public class TestTable { private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); @Test - public void moveTable() throws Exception { + public void moveTable() throws IOException { HSLFSlideShow ppt = new HSLFSlideShow(); HSLFSlide slide = ppt.createSlide(); int rows = 3, cols = 5; @@ -52,26 +55,28 @@ public class TestTable { c.setText("r"+row+"c"+col); } } - + new DrawTableShape(table).setAllBorders(1.0, Color.black, StrokeStyle.LineDash.DASH_DOT); - + table.setAnchor(new Rectangle(100, 100, 400, 400)); - + Rectangle rectExp = new Rectangle(420,367,80,133); Rectangle rectAct = table.getCell(rows-1, cols-1).getAnchor(); assertEquals(rectExp, rectAct); + ppt.close(); } - + @Test - public void testTable() throws Exception { + public void testTable() throws IOException { HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("54111.ppt")); assertTrue("No Exceptions while reading file", true); List slides = ppt.getSlides(); assertEquals(1, slides.size()); checkSlide(slides.get(0)); + ppt.close(); } - + private void checkSlide(final HSLFSlide s) { List> textRuns = s.getTextParagraphs(); assertEquals(2, textRuns.size()); @@ -82,7 +87,7 @@ public class TestTable { assertFalse(textRun.getTextParagraph().isBullet()); assertEquals("Dummy text", HSLFTextParagraph.getRawText(textRuns.get(1))); - + List shapes = s.getShapes(); assertNotNull(shapes); assertEquals(3, shapes.size()); @@ -97,4 +102,58 @@ public class TestTable { } } } + + @Test + public void testAddText() throws IOException { + HSLFSlideShow ppt1 = new HSLFSlideShow(); + HSLFSlide slide = ppt1.createSlide(); + HSLFTable tab = slide.createTable(4, 5); + + int rows = tab.getNumberOfRows(); + int cols = tab.getNumberOfColumns(); + for (int row=0; row