From 9968e86b14188b43920f0ef28f68559e3dadf7be Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Sun, 11 Feb 2018 20:39:18 +0000 Subject: #62096 - Add support for tabstops git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1823893 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/sl/usermodel/BaseTestSlideShow.java | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'src/testcases/org/apache') diff --git a/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java b/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java index e02260844a..47b886e174 100644 --- a/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java +++ b/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java @@ -21,18 +21,24 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; +import java.awt.Color; +import java.awt.geom.Rectangle2D; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.List; import org.apache.poi.POIDataSamples; import org.apache.poi.sl.usermodel.PictureData.PictureType; +import org.apache.poi.sl.usermodel.TabStop.TabStopType; import org.junit.Test; public abstract class BaseTestSlideShow { protected static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); public abstract SlideShow createSlideShow(); + + public abstract SlideShow reopen(SlideShow show); @Test public void addPicture_File() throws IOException { @@ -92,4 +98,63 @@ public abstract class BaseTestSlideShow { show.close(); } + + @Test + public void addTabStops() throws IOException { + try (final SlideShow show1 = createSlideShow()) { + // first set the TabStops in the Master sheet + final MasterSheet master1 = show1.getSlideMasters().get(0); + final AutoShape master1_as = (AutoShape)master1.getPlaceholder(Placeholder.BODY); + final TextParagraph master1_tp = master1_as.getTextParagraphs().get(0); + master1_tp.clearTabStops(); + int i1 = 0; + for (final TabStopType tst : TabStopType.values()) { + master1_tp.addTabStops(10+i1*10, tst); + i1++; + } + + // then set it on a normal slide + final Slide slide1 = show1.createSlide(); + final AutoShape slide1_as = slide1.createAutoShape(); + slide1_as.setText("abc"); + slide1_as.setAnchor(new Rectangle2D.Double(100,100,100,100)); + final TextParagraph slide1_tp = slide1_as.getTextParagraphs().get(0); + slide1_tp.getTextRuns().get(0).setFontColor(new Color(0x563412)); + slide1_tp.clearTabStops(); + int i2 = 0; + for (final TabStopType tst : TabStopType.values()) { + slide1_tp.addTabStops(15+i2*5, tst); + i2++; + } + + try (final SlideShow show2 = reopen(show1)) { + final MasterSheet master2 = show2.getSlideMasters().get(0); + final AutoShape master2_as = (AutoShape)master2.getPlaceholder(Placeholder.BODY); + final TextParagraph master2_tp = master2_as.getTextParagraphs().get(0); + final List master2_tabStops = master2_tp.getTabStops(); + assertNotNull(master2_tabStops); + int i3 = 0; + for (final TabStopType tst : TabStopType.values()) { + final TabStop ts = master2_tabStops.get(i3); + assertEquals(10+i3*10, ts.getPositionInPoints(), 0.0); + assertEquals(tst, ts.getType()); + i3++; + } + + + final Slide slide2 = show2.getSlides().get(0); + final AutoShape slide2_as = (AutoShape)slide2.getShapes().get(0); + final TextParagraph slide2_tp = slide2_as.getTextParagraphs().get(0); + final List slide2_tabStops = slide2_tp.getTabStops(); + assertNotNull(slide2_tabStops); + int i4 = 0; + for (final TabStopType tst : TabStopType.values()) { + final TabStop ts = slide2_tabStops.get(i4); + assertEquals(15+i4*5, ts.getPositionInPoints(), 0.0); + assertEquals(tst, ts.getType()); + i4++; + } + } + } + } } -- cgit v1.2.3