Summary: | offset of new pictures is sometimes wrong | ||
---|---|---|---|
Product: | POI | Reporter: | David <erwin94> |
Component: | HSLF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 3.2-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Linux | ||
Attachments: | patch that fixes the problem for me. |
Description
David
2009-01-29 08:52:31 UTC
Created attachment 23193 [details]
patch that fixes the problem for me.
Can you attach a problem ppt file with removed images? The suggested fix looks good but I don't want to commit it without a unit test. Thanks, Yegor Sorry, I am having trouble reproducing this problem on a new ppt file. The one that causes problems for me I cannot submit because of company policy, but this happened before on several files, so this does not seem to be an isolated incident. I will try again to reproduce the problem when I have more time (in about a week or so). bye, David. I suspect it can be reproduced with PictureTypeZero.ppt or PictureLengthZero.ppt from our collection of test files: http://svn.apache.org/repos/asf/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/ Can check it and post sample code that causes the problem? These two files contain invalid images, the first one contains images with unknown type=0, the second one contains images with zero length, i.e. only header and no data. Yegor You are correct, PictureLengthZero.ppt exposes the problem. Simply adding any picture, like the following code does, should result in an invalid image in the resulting ppt: SlideShow ppt = new SlideShow( new ByteArrayInputStream( readFile( args[ 0 ] ) ) ); int index = ppt.addPicture( readFile( args[ 1 ] ), Picture.PNG ); Picture picture = new Picture( index ); ppt.getSlides()[0].addShape( picture ); ByteArrayOutputStream result = new ByteArrayOutputStream(); ppt.write( result ); FileOutputStream os = new FileOutputStream( "output.ppt" ); os.write( result.toByteArray() ); os.close(); readFile is a simple function that returns the bytes contained in a file. After applying the patch this works for me. bye, David. |