]> source.dussan.org Git - poi.git/commitdiff
If we hit an unknown picture type, don't break completely - report an error but carry...
authorNick Burch <nick@apache.org>
Thu, 12 Oct 2006 11:26:05 +0000 (11:26 +0000)
committerNick Burch <nick@apache.org>
Thu, 12 Oct 2006 11:26:05 +0000 (11:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@463202 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java

index 48121e0c1450df62c169267280b54a0604e0da9b..0dce7cb568bbf7b4fd08bf591af6b178c2c8779b 100644 (file)
@@ -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;
         }
 
index c8d6f0266056148e5621a73426c4e4872545e5c9..4b82e780ded30ad8b70263c9e00cb7e6244fa0c1 100644 (file)
@@ -175,7 +175,7 @@ public abstract class PictureData {
                 pict = new PNG();\r
                 break;\r
             default:\r
-                throw new RuntimeException("Unsupported picture type: " + type);\r
+                throw new IllegalArgumentException("Unsupported picture type: " + type);\r
         }\r
         return pict;\r
     }\r