From 50625c7196300a94e06eb47bbdd6260775cc2804 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 12 Oct 2006 11:26:05 +0000 Subject: [PATCH] If we hit an unknown picture type, don't break completely - report an error but carry on without the picture git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@463202 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hslf/HSLFSlideShow.java | 13 +++++++++---- .../org/apache/poi/hslf/usermodel/PictureData.java | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java index 48121e0c14..0dce7cb568 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java @@ -271,10 +271,15 @@ public class HSLFSlideShow extends POIDocument byte[] imgdata = new byte[imgsize]; System.arraycopy(pictstream, pos, imgdata, 0, imgdata.length); - PictureData pict = PictureData.create(type - 0xF018); - pict.setRawData(imgdata); - pict.setOffset(offset); - p.add(pict); + try { + PictureData pict = PictureData.create(type - 0xF018); + pict.setRawData(imgdata); + pict.setOffset(offset); + p.add(pict); + } catch(IllegalArgumentException e) { + System.err.println("Problem reading picture: " + e + "\nYou document will probably become corrupted if you save it!"); + } + pos += imgsize; } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java index c8d6f02660..4b82e780de 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java @@ -175,7 +175,7 @@ public abstract class PictureData { pict = new PNG(); break; default: - throw new RuntimeException("Unsupported picture type: " + type); + throw new IllegalArgumentException("Unsupported picture type: " + type); } return pict; } -- 2.39.5