Bug 46122 - Problem doing PPT2PNG
Summary: Problem doing PPT2PNG
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.2-dev
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-10-29 11:43 UTC by Enrique Peña
Modified: 2008-11-03 09:57 UTC (History)
0 users

The .ppt file that causes all this mess (22.50 KB, application/vnd.)
2008-10-29 11:43 UTC, Enrique Peña

Note You need to log in before you can comment on or make changes to this bug.
Description Enrique Peña 2008-10-29 11:43:27 UTC
Created attachment 22790 [details]
The .ppt file that causes all this mess

Hello I'm currently using Apache POI HSLF to convert in application to convert flowchart Powerpoint files (.ppt) into .png image files. It works ok, normally, without arrows usually, but I found a new crash while converting a .ppt file.
I have no idea why this is happening.

The sentence that throws NullPointerException is:
/* Code Start */
FileInputStream is = new FileInputStream("greenpe.ppt");
SlideShow ppt = new SlideShow (is);
Dimension pgsize = ppt.getPageSize();
Slide[] slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) { 
   BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB);
   Graphics2D graphics = img.createGraphics();
   graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
   graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
   graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
   graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));

   Slide s = slide[i];
   try   {	
   } catch (NullPointerException e) {
/* Code Finish */

This is the stack trace:
StackTrace: java.lang.NullPointerException
	at org.apache.poi.hslf.model.Picture.getEscherBSERecord(Picture.java:200)
	at org.apache.poi.hslf.model.Picture.getPictureData(Picture.java:180)
	at org.apache.poi.hslf.model.Picture.draw(Picture.java:265)
	at org.apache.poi.hslf.model.ShapeGroup.draw(ShapeGroup.java:280)
	at org.apache.poi.hslf.model.Slide.draw(Slide.java:431)
	at ... (...MyComponent.java:381)

Any idea? Thanks
Comment 1 Yegor Kozlov 2008-11-03 09:57:47 UTC
Fixed in r710114

One of the shapes has type=Picture but the reference to picture data is invalid. I fixed Picture.draw to skip rendering of such "invalid" pictures.