Bug 47261 - SlideShow.removeSlide makes PPT corrupted
Summary: SlideShow.removeSlide makes PPT corrupted
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: unspecified
Hardware: PC All
: P1 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-25 06:33 UTC by Constantin
Modified: 2014-12-30 01:08 UTC (History)
0 users



Attachments
TestSlide.ppt (177.00 KB, application/octet-stream)
2009-05-25 06:35 UTC, Constantin
Details
Screenshot (412.16 KB, image/jpeg)
2009-05-25 06:37 UTC, Constantin
Details
Another PPT (366.50 KB, application/octet-stream)
2009-06-22 03:20 UTC, Constantin
Details
PowerPoint file (66.00 KB, application/octet-stream)
2009-10-08 04:04 UTC, Constantin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Constantin 2009-05-25 06:33:50 UTC
removeSlide method of SlideShow makes PPT corrupted.
Check code snippet below.
When I try to open TestSlide_Empty.ppt in MS Powerpoint 2003, I catch "PowerPoint was unable to display some og the text...". error. See full error text in attached screenshot.

Code snippet:

import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.usermodel.SlideShow;

public class POITest {

    public static void main(String[] args) throws Exception {
        
        SlideShow ppt = new SlideShow(new FileInputStream("TestSlide.ppt"));

        Slide[] slides = ppt.getSlides();

        for (int i = 0; i < slides.length; i++) {
          ppt.removeSlide(0);
        }
        
        FileOutputStream out = new FileOutputStream("TestSlide_Empty.ppt");
        ppt.write(out);
        out.close();

    }

}
Comment 1 Constantin 2009-05-25 06:35:29 UTC
Created attachment 23711 [details]
TestSlide.ppt
Comment 2 Constantin 2009-05-25 06:37:21 UTC
Created attachment 23712 [details]
Screenshot
Comment 3 David Fisher 2009-06-17 07:08:05 UTC
Is this error with POI-3.2 FINAL or on the current trunk?

Would you please describe your use case within your production.
Comment 4 Constantin 2009-06-17 07:14:21 UTC
(In reply to comment #3)
> Is this error with POI-3.2 FINAL or on the current trunk?
> 
> Would you please describe your use case within your production.

On trunk and on 3.2.
I use this method to remove slides.
Comment 5 Yegor Kozlov 2009-06-19 06:27:28 UTC
Should be fixed in r786501. PowerPoint wasn't happy to find orphan references to notes belonging to the deleted slide. 

P.S. PowerPoint 2007 silently ignored this bug, the alert was only in PowerPoint 2003 and older.

Yegor
Comment 6 Constantin 2009-06-22 03:20:22 UTC
Created attachment 23844 [details]
Another PPT

Thanks for quick feedback, Yegor,
but bug still here.
I have attached another PPT, that still causes error.
Could you check please?
Use the same code snippet.
Comment 7 Yegor Kozlov 2009-06-27 03:27:04 UTC
Should be fixed in r788948. There was a typo that prevented deletion of slide's notes. 

Regards,
Yegor
Comment 8 Constantin 2009-10-08 04:04:49 UTC
Created attachment 24364 [details]
PowerPoint file

Code snippet:

import java.io.FileInputStream;

import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.usermodel.SlideShow;

public class POITest {

    public static void main(String[] args) throws Exception {
        
        SlideShow ppt = new SlideShow(new FileInputStream("tt2.ppt"));

        Slide[] slides = ppt.getSlides();

        for (int i = 0; i < slides.length; i++) {
          ppt.removeSlide(0);
        }

        Slide newSlide = ppt.createSlide();

    }

}

This code generates following error:

Exception in thread "main" java.lang.IllegalStateException: The last child record of a Document should be EndDocument, but it was org.apache.poi.hslf.record.UnknownRecordPlaceholder@12d96f2
	at org.apache.poi.hslf.record.Document.addSlideListWithText(Document.java:179)
	at org.apache.poi.hslf.usermodel.SlideShow.createSlide(SlideShow.java:700)
	at POITest.main(POITest.java:19)

With removeSlide commented works ok.
tt2.ppt attached (file received from our customer)
Comment 9 Constantin 2009-10-08 04:05:53 UTC
comment #8
Comment 10 Yegor Kozlov 2010-02-14 17:09:22 UTC
Constantin,

Please don't abuse Bugzilla. Changing the priority of a bug to Blocker will not help us to fix it sooner. 
If you are really interested in fixing this bug - you are welcome to do a research and figure out which bits in the PPT format are broken. If you need a guidance, please ask, I will be happy to help.

Yegor
Comment 11 Andreas Beeker 2014-12-30 01:08:10 UTC
Fix applied with r1648458
Although saving a PPT without slides doesn't make sense, there was a problem with an optional RoundTripCustomTableStyles12Atom, which occured when all slides were removed and new slides created afterwards - this is fixed now.