Bug 41176 - Figure out what (if anything) we can do for PPT files where the first SlideListWithTexts has slides and masters
Summary: Figure out what (if anything) we can do for PPT files where the first SlideLi...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.0-dev
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-14 03:48 UTC by Nick Burch
Modified: 2007-01-09 10:53 UTC (History)
0 users



Attachments
This file causes the exception (195.50 KB, application/octet-stream)
2006-12-24 06:30 UTC, Eitan
Details
ppt with title master (10.00 KB, application/vnd.ms-powerpoint)
2007-01-09 05:38 UTC, Yegor Kozlov
Details
Improved SlideShow.buildSlidesAndNotes (27.68 KB, patch)
2007-01-09 05:39 UTC, Yegor Kozlov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Burch 2006-12-14 03:48:11 UTC
I've discovered that some PPT files (eg data/PictureTypeZero.ppt in SVN) have a
really crazy first SlideListWithText

In theory, there should be 2 or 3 of these. The first with MainMasters, the
second with Slides, and the optional third with Notes. However, on files like
these, the first one contains both MainMasters and Slides!

I've updated the code to throw a CorruptPowerPointFileException on these docs
(previously we had a class cast exception), but we need to figure out what (if
anything) we can do for them.
Comment 1 Eitan 2006-12-24 06:30:37 UTC
Created attachment 19303 [details]
This file causes the exception

As requested - here is an example file that causes HSLF to throw the exception
Comment 2 Yegor Kozlov 2007-01-09 05:37:11 UTC
Nick,

This is quite normal. The error happens when the first SLWT has a link to Title
Matster.

How to reproduce:
 - open PowerPoint and create a presentation
 - Menu view/slide master
 - Menu Insert/ New Title Master. After it you should have two masters: a slide
master and a title master.
 - save.
 - Try to open it in HSLF and get the error.
I attached a sample file.

PowerPoint supports two types of slide masters: 

 * Slide Master. The data is in MainMaster container
 * Title Master. The data is in Slide container. Weird? I think so.
I don't know why pages with title layout use different master. I guess if it is
missing the normal MainMaster 
is used but I didn't research it yet.

I think your code in SlideShow.buildSlidesAndNotes has extra checks that can be
ommitted. 
Just keep in mind, whatever you find in the fist SLWT it is about masters.
 For now we handle only references to MainMasters. Later we will add support for
Title, Note and other masters.
I won't be surprised if we have references to other exotic containers in the
first SLWT.

See how I changed SlideShow.buildSlidesAndNotes.

Regards,
Yegor
Comment 3 Yegor Kozlov 2007-01-09 05:38:15 UTC
Created attachment 19380 [details]
ppt with title master
Comment 4 Yegor Kozlov 2007-01-09 05:39:34 UTC
Created attachment 19381 [details]
Improved SlideShow.buildSlidesAndNotes
Comment 5 Nick Burch 2007-01-09 05:41:30 UTC
So, if a PPT file has the first SLWT with
  MainMaster
  Slide
  ....
and the second SLWT with
  Slide
  Slide

Then all's fine, we ignore (for now) anything other than MainMaster in the first
SLWT, and grab the slides from the second one?

If we have a ppt with
  MainMaster
  Slide
  ....
and no second SLWT, we throw a CorruptPowerPointException?
Comment 6 Yegor Kozlov 2007-01-09 05:50:58 UTC
>>Then all's fine, we ignore (for now) anything other than MainMaster in the first
>>SLWT, and grab the slides from the second one?

Yes. We always read master info from the first SLWT and slides from the second
one. Just ignore what we don't support.

>>If we have a ppt with
>>  MainMaster
>>  Slide
>>  ....
>>and no second SLWT, we throw a CorruptPowerPointException?

Yes. There MUST be two SLWTs. If either is missing it means the ppt is corrupted
(or MS guys put another level of complexity into it :)). 

Yegor
Comment 7 Nick Burch 2007-01-09 10:53:54 UTC
OK, based on your findings (thanks for those!), I've applied your patch, and
then tidied the code up a little more (and made a few variables have more
sensible names)

Hopefully this scheme will be a good starting position for supporting future
kinds of masters.

I haven't got anything to throw CorruptPowerPoint in the case of not enough
SLWTs, do you think we should have that check?