From aad955d3bfa210d7d146663e64d6d8b68b7843c9 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Sun, 25 Nov 2018 23:01:54 +0000 Subject: [PATCH] Fix exception for old powerpoint documents without the usual stream name git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1847442 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/TestAllFiles.java | 1 + .../poi/xslf/usermodel/TestPPTX2PNG.java | 2 +- .../poi/hslf/record/CurrentUserAtom.java | 4 +++- .../poi/hslf/usermodel/HSLFSlideShow.java | 1 + .../poi/hslf/usermodel/HSLFSlideShowImpl.java | 19 +++++++++++++----- .../{keyframes.ppt => keyframes.pptx} | Bin 6 files changed, 20 insertions(+), 7 deletions(-) rename test-data/slideshow/{keyframes.ppt => keyframes.pptx} (100%) diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/TestAllFiles.java index 61c47b9e88..40f19f9c85 100644 --- a/src/integrationtest/org/apache/poi/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/TestAllFiles.java @@ -289,6 +289,7 @@ public class TestAllFiles { "document/Bug50955.doc", "document/57843.doc", "slideshow/PPT95.ppt", + "slideshow/pp40only.ppt", "slideshow/Divino_Revelado.pptx", "openxml4j/OPCCompliance_CoreProperties_DCTermsNamespaceLimitedUseFAIL.docx", "openxml4j/OPCCompliance_CoreProperties_DoNotUseCompatibilityMarkupFAIL.docx", diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java index 6e27599729..199a9f6286 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java @@ -47,7 +47,7 @@ public class TestPPTX2PNG { private static final POIDataSamples samples = POIDataSamples.getSlideShowInstance(); private static final File basedir = null; private static final String files = - "53446.ppt, alterman_security.ppt, alterman_security.pptx, KEY02.pptx, themes.pptx, backgrounds.pptx, layouts.pptx, sample.pptx, shapes.pptx, 54880_chinese.ppt, keyframes.ppt"; + "53446.ppt, alterman_security.ppt, alterman_security.pptx, KEY02.pptx, themes.pptx, backgrounds.pptx, layouts.pptx, sample.pptx, shapes.pptx, 54880_chinese.ppt, keyframes.pptx"; diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java index cedfbb0470..26ba59d2c6 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java @@ -20,6 +20,8 @@ package org.apache.poi.hslf.record; +import static org.apache.poi.hslf.usermodel.HSLFSlideShow.PP95_DOCUMENT; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -143,7 +145,7 @@ public class CurrentUserAtom // See how long it is. If it's under 28 bytes long, we can't // read it if(_contents.length < 28) { - boolean isPP95 = dir.hasEntry("PP40"); + boolean isPP95 = dir.hasEntry(PP95_DOCUMENT); // PPT95 has 4 byte size, then data if (!isPP95 && _contents.length >= 4) { int size = LittleEndian.getInt(_contents); diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java index ecc360e135..2f0a116d68 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java @@ -71,6 +71,7 @@ public final class HSLFSlideShow implements SlideShow