From commits-return-11224-archive-asf-public=cust-asf.ponee.io@poi.apache.org Sun Feb 11 21:39:24 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 4D80318064E for ; Sun, 11 Feb 2018 21:39:24 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 3CDBF160C60; Sun, 11 Feb 2018 20:39:24 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5B059160C2E for ; Sun, 11 Feb 2018 21:39:23 +0100 (CET) Received: (qmail 67885 invoked by uid 500); 11 Feb 2018 20:39:22 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 67876 invoked by uid 99); 11 Feb 2018 20:39:22 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Feb 2018 20:39:22 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 03AC53A01DB for ; Sun, 11 Feb 2018 20:39:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1823893 [2/2] - in /poi: site/src/documentation/content/xdocs/ trunk/src/java/org/apache/poi/sl/usermodel/ trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/ trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/ trunk/src/scratchpad/sr... Date: Sun, 11 Feb 2018 20:39:19 -0000 To: commits@poi.apache.org From: kiwiwings@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20180211203921.03AC53A01DB@svn01-us-west.apache.org> Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java?rev=1823893&r1=1823892&r2=1823893&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java Sun Feb 11 20:39:18 2018 @@ -18,17 +18,17 @@ package org.apache.poi.hslf.record; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import java.io.ByteArrayOutputStream; +import java.util.List; -import junit.framework.TestCase; +import org.apache.poi.hslf.model.textproperties.HSLFTabStop; +import org.junit.Test; -/** - * Tests TextRulerAtom - * - * @author Yegor Kozlov - */ -public final class TestTextRulerAtom extends TestCase { +public final class TestTextRulerAtom { //from a real file private final byte[] data_1 = new byte[] { @@ -40,25 +40,27 @@ public final class TestTextRulerAtom ext private final byte[] data_2 = new byte[] { 0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00, - 0x10, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01 + 0x08, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01 }; + @Test public void testReadRuler() { TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length); assertEquals(ruler.getNumberOfLevels(), 0); assertEquals(ruler.getDefaultTabSize(), 0); - int[] tabStops = ruler.getTabStops(); - assertNull(tabStops); + List tabStops = ruler.getTabStops(); + assertNotNull(tabStops); - int[] textOffsets = ruler.getTextOffsets(); - assertArrayEquals(new int[]{226, 451, 903, 1129, 1526}, textOffsets); + Integer[] textOffsets = ruler.getTextOffsets(); + assertArrayEquals(new Integer[]{226, 451, 903, 1129, 1526}, textOffsets); - int[] bulletOffsets = ruler.getBulletOffsets(); - assertArrayEquals(new int[]{117, 345, 794, 1016, 1526}, bulletOffsets); + Integer[] bulletOffsets = ruler.getBulletOffsets(); + assertArrayEquals(new Integer[]{117, 345, 794, 1016, 1526}, bulletOffsets); } + @Test public void testWriteRuler() throws Exception { TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length); ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -68,6 +70,7 @@ public final class TestTextRulerAtom ext assertArrayEquals(result, data_1); } + @Test public void testRead2() throws Exception { TextRulerAtom ruler = TextRulerAtom.getParagraphInstance(); ruler.setParagraphIndent((short)249, (short)321); @@ -75,6 +78,6 @@ public final class TestTextRulerAtom ext ruler.writeOut(out); byte[] result = out.toByteArray(); - assertArrayEquals(result, data_2); + assertArrayEquals(data_2, result); } } Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestHSLFSlideShow.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestHSLFSlideShow.java?rev=1823893&r1=1823892&r2=1823893&view=diff ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestHSLFSlideShow.java (original) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestHSLFSlideShow.java Sun Feb 11 20:39:18 2018 @@ -17,8 +17,14 @@ package org.apache.poi.hslf.usermodel; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import org.apache.poi.sl.usermodel.BaseTestSlideShow; +import org.apache.poi.sl.usermodel.SlideShow; import org.junit.Test; public class TestHSLFSlideShow extends BaseTestSlideShow { @@ -32,4 +38,25 @@ public class TestHSLFSlideShow extends B public void dummy() { assertNotNull(createSlideShow()); } + + public SlideShow reopen(SlideShow show) { + return reopen((HSLFSlideShow)show); + } + + public static HSLFSlideShow reopen(HSLFSlideShow show) { + try { + BufAccessBAOS bos = new BufAccessBAOS(); + show.write(bos); + return new HSLFSlideShow(new ByteArrayInputStream(bos.getBuf())); + } catch (IOException e) { + fail(e.getMessage()); + return null; + } + } + + private static class BufAccessBAOS extends ByteArrayOutputStream { + public byte[] getBuf() { + return buf; + } + } } Modified: poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java?rev=1823893&r1=1823892&r2=1823893&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java (original) +++ poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java Sun Feb 11 20:39:18 2018 @@ -21,18 +21,24 @@ import static org.junit.Assert.assertNot 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++; + } + } + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org