From e94b5e52f1969378e5b55659c2ebc15a047f6457 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Wed, 22 Feb 2012 13:23:31 +0000 Subject: [PATCH] Bugzilla 52599 - avoid duplicate text when rendering slides in HSLF git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1292273 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../src/org/apache/poi/hslf/model/Slide.java | 1 + .../org/apache/poi/hslf/model/TextRun.java | 2 +- .../apache/poi/hslf/model/TestTextShape.java | 22 +++++++++++++++++- test-data/slideshow/52599.ppt | Bin 0 -> 13312 bytes 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 test-data/slideshow/52599.ppt diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 99cb798d00..d2367da522 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 52599 - avoid duplicate text when rendering slides in HSLF 52598 - respect slide background when rendering slides in HSLF 51731 - fixed painting shape outlines in HSLF 52701 - fixed seting vertical alignment for XSLFTableCell diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java b/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java index 7822d8cd11..0decdaa448 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java @@ -91,6 +91,7 @@ public final class Slide extends Sheet for(int k=0; k<_otherRuns.length; i++, k++) { _runs[i] = _otherRuns[k]; _runs[i].setSheet(this); + _runs[i].setIndex(-1); // runs found in PPDrawing are not linked with SlideListWithTexts } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java b/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java index 65c4459d17..5eb3930638 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java @@ -48,7 +48,7 @@ public final class TextRun private SlideShow slideShow; private Sheet _sheet; private int shapeId; - private int slwtIndex; //position in the owning SlideListWithText + private int slwtIndex = -1; //position in the owning SlideListWithText /** * all text run records that follow TextHeaderAtom. * (there can be misc InteractiveInfo, TxInteractiveInfo and other records) diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java index 7285f5120a..48b6df54a6 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java @@ -47,7 +47,7 @@ public final class TestTextShape extends TestCase { assertNotNull(shape.getEscherTextboxWrapper()); assertEquals("", shape.getText()); assertSame(run, shape.createTextRun()); - + assertEquals(-1, run.getIndex()); } public void testCreateTextBox(){ @@ -195,4 +195,24 @@ public final class TestTextShape extends TestCase { assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01); assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01); } + + public void test52599() throws IOException { + SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("52599.ppt")); + + Slide slide = ppt.getSlides()[0]; + Shape[] sh = slide.getShapes(); + assertEquals(3, sh.length); + + TextShape sh0 = (TextShape)sh[0]; + assertEquals(null, sh0.getText()); + assertEquals(null, sh0.getTextRun()); + + TextShape sh1 = (TextShape)sh[1]; + assertEquals(null, sh1.getText()); + assertEquals(null, sh1.getTextRun()); + + TextShape sh2 = (TextShape)sh[2]; + assertEquals("this box should be shown just once", sh2.getText()); + assertEquals(-1, sh2.getTextRun().getIndex()); + } } diff --git a/test-data/slideshow/52599.ppt b/test-data/slideshow/52599.ppt new file mode 100644 index 0000000000000000000000000000000000000000..a1c2e8d06b42e4be1028e050069ce4ac3a9a605b GIT binary patch literal 13312 zcmeHN4RBP|6+Z914M||*TL>V6g$JTR7Qta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