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
This commit is contained in:
Nick Burch 2006-10-12 11:26:05 +00:00
parent ccc494626e
commit 353eafdd29
2 changed files with 10 additions and 5 deletions

View File

@ -271,10 +271,15 @@ public class HSLFSlideShow extends POIDocument
byte[] imgdata = new byte[imgsize];
System.arraycopy(pictstream, pos, imgdata, 0, imgdata.length);
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;
}

View File

@ -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;
}