You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Jim Talbut <jt...@spudsoft.co.uk> on 2011/12/07 20:43:55 UTC

HSLF: addPictures/Fills not working correctly

Hi,

If org.apache.poi.hslf.model.TestBackground.testBackgroundPicture is 
modified to write to a file, instead of a byte array:
         //serialize and read again
         // ByteArrayOutputStream out = new ByteArrayOutputStream();
         FileOutputStream out = new FileOutputStream( 
"C:\\Temp\\TestBackground.ppt" );
         ppt.write(out);
         out.close();

         // ppt = new SlideShow(new HSLFSlideShow(new 
ByteArrayInputStream(out.toByteArray())));
         ppt = new SlideShow(new HSLFSlideShow(new FileInputStream( 
"C:\\Temp\\TestBackground.ppt" )));
         Slide[] slides = ppt.getSlides();

The resultant PPT file does not have any images in it when loaded in 
PowerPoint (just disappointing red crosses and unhelpful error messages).
The test itself passes, so it looks like the test is invalid/incomplete.

Bug 46288 looks relevant, but is ancient.

Anyone any idea what's wrong?

Thanks

Jim


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: HSLF: addPictures/Fills not working correctly

Posted by Jim Talbut <jt...@spudsoft.co.uk>.
Patch submitted to https://issues.apache.org/bugzilla/show_bug.cgi?id=46288

Whilst the two changes I made to the tag and the hash make the document 
consistent with other PPTs they don't seem to be necessary so I haven't 
included them in the patch.

Jim

On 08/12/2011 18:07, Jim Talbut wrote:
> Oh wow, I think I've found it!!
>
> Two changes I made first, don't know if they are vital or not:
> 1. Change the tag in the picture header to 0xFF as per 
> http://msdn.microsoft.com/en-us/library/dd947487%28v=office.12%29.aspx
> 2. Change the hash in the picture header to MD4, not MD5.
>
> And the thing that made it work:
> Change the ref count in the BSE record to 1 (done with a hex editor so 
> far).
>
> More investigation needed, but got to cook the dinner now!
>
> Jim
>
> On 08/12/2011 14:49, Jim Talbut wrote:
>> I've been trying to work out why the backgrounds aren't working, but 
>> not getting very far :(
>>
>> I've create a simple test that create a PPT file with a single slide 
>> with the tomcat image as a background - which then fails to show up 
>> in PowerPoint.
>> That file is only 17KB.
>> If I then use PowerPoint to change the background image the file 
>> balloons to 200KB, which I think is down to it resizing the image and 
>> storing that.
>>
>> I've then been dumping out as much of the structure of the file as I 
>> can try to make sense of.
>> The only significant difference seems to be that PowerPoint add an 
>> EscherTertiaryOptRecord to the background, and POI has fill.rectright 
>> and fill.rectbottom properties.
>>
>> If anyone more knowledgeable could take a look I'd be happy to make 
>> all this available.
>>
>> Jim
>>
>>
>>
>>
>> On 07/12/2011 19:43, Jim Talbut wrote:
>>> Hi,
>>>
>>> If org.apache.poi.hslf.model.TestBackground.testBackgroundPicture is 
>>> modified to write to a file, instead of a byte array:
>>>         //serialize and read again
>>>         // ByteArrayOutputStream out = new ByteArrayOutputStream();
>>>         FileOutputStream out = new FileOutputStream( 
>>> "C:\\Temp\\TestBackground.ppt" );
>>>         ppt.write(out);
>>>         out.close();
>>>
>>>         // ppt = new SlideShow(new HSLFSlideShow(new 
>>> ByteArrayInputStream(out.toByteArray())));
>>>         ppt = new SlideShow(new HSLFSlideShow(new FileInputStream( 
>>> "C:\\Temp\\TestBackground.ppt" )));
>>>         Slide[] slides = ppt.getSlides();
>>>
>>> The resultant PPT file does not have any images in it when loaded in 
>>> PowerPoint (just disappointing red crosses and unhelpful error 
>>> messages).
>>> The test itself passes, so it looks like the test is 
>>> invalid/incomplete.
>>>
>>> Bug 46288 looks relevant, but is ancient.
>>>
>>> Anyone any idea what's wrong?
>>>
>>> Thanks
>>>
>>> Jim
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>>> For additional commands, e-mail: user-help@poi.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: HSLF: addPictures/Fills not working correctly

Posted by Jim Talbut <jt...@spudsoft.co.uk>.
Oh wow, I think I've found it!!

Two changes I made first, don't know if they are vital or not:
1. Change the tag in the picture header to 0xFF as per 
http://msdn.microsoft.com/en-us/library/dd947487%28v=office.12%29.aspx
2. Change the hash in the picture header to MD4, not MD5.

And the thing that made it work:
Change the ref count in the BSE record to 1 (done with a hex editor so far).

More investigation needed, but got to cook the dinner now!

Jim

On 08/12/2011 14:49, Jim Talbut wrote:
> I've been trying to work out why the backgrounds aren't working, but 
> not getting very far :(
>
> I've create a simple test that create a PPT file with a single slide 
> with the tomcat image as a background - which then fails to show up in 
> PowerPoint.
> That file is only 17KB.
> If I then use PowerPoint to change the background image the file 
> balloons to 200KB, which I think is down to it resizing the image and 
> storing that.
>
> I've then been dumping out as much of the structure of the file as I 
> can try to make sense of.
> The only significant difference seems to be that PowerPoint add an 
> EscherTertiaryOptRecord to the background, and POI has fill.rectright 
> and fill.rectbottom properties.
>
> If anyone more knowledgeable could take a look I'd be happy to make 
> all this available.
>
> Jim
>
>
>
>
> On 07/12/2011 19:43, Jim Talbut wrote:
>> Hi,
>>
>> If org.apache.poi.hslf.model.TestBackground.testBackgroundPicture is 
>> modified to write to a file, instead of a byte array:
>>         //serialize and read again
>>         // ByteArrayOutputStream out = new ByteArrayOutputStream();
>>         FileOutputStream out = new FileOutputStream( 
>> "C:\\Temp\\TestBackground.ppt" );
>>         ppt.write(out);
>>         out.close();
>>
>>         // ppt = new SlideShow(new HSLFSlideShow(new 
>> ByteArrayInputStream(out.toByteArray())));
>>         ppt = new SlideShow(new HSLFSlideShow(new FileInputStream( 
>> "C:\\Temp\\TestBackground.ppt" )));
>>         Slide[] slides = ppt.getSlides();
>>
>> The resultant PPT file does not have any images in it when loaded in 
>> PowerPoint (just disappointing red crosses and unhelpful error 
>> messages).
>> The test itself passes, so it looks like the test is invalid/incomplete.
>>
>> Bug 46288 looks relevant, but is ancient.
>>
>> Anyone any idea what's wrong?
>>
>> Thanks
>>
>> Jim
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: HSLF: addPictures/Fills not working correctly

Posted by Jim Talbut <jt...@spudsoft.co.uk>.
I've been trying to work out why the backgrounds aren't working, but not 
getting very far :(

I've create a simple test that create a PPT file with a single slide 
with the tomcat image as a background - which then fails to show up in 
PowerPoint.
That file is only 17KB.
If I then use PowerPoint to change the background image the file 
balloons to 200KB, which I think is down to it resizing the image and 
storing that.

I've then been dumping out as much of the structure of the file as I can 
try to make sense of.
The only significant difference seems to be that PowerPoint add an 
EscherTertiaryOptRecord to the background, and POI has fill.rectright 
and fill.rectbottom properties.

If anyone more knowledgeable could take a look I'd be happy to make all 
this available.

Jim




On 07/12/2011 19:43, Jim Talbut wrote:
> Hi,
>
> If org.apache.poi.hslf.model.TestBackground.testBackgroundPicture is 
> modified to write to a file, instead of a byte array:
>         //serialize and read again
>         // ByteArrayOutputStream out = new ByteArrayOutputStream();
>         FileOutputStream out = new FileOutputStream( 
> "C:\\Temp\\TestBackground.ppt" );
>         ppt.write(out);
>         out.close();
>
>         // ppt = new SlideShow(new HSLFSlideShow(new 
> ByteArrayInputStream(out.toByteArray())));
>         ppt = new SlideShow(new HSLFSlideShow(new FileInputStream( 
> "C:\\Temp\\TestBackground.ppt" )));
>         Slide[] slides = ppt.getSlides();
>
> The resultant PPT file does not have any images in it when loaded in 
> PowerPoint (just disappointing red crosses and unhelpful error messages).
> The test itself passes, so it looks like the test is invalid/incomplete.
>
> Bug 46288 looks relevant, but is ancient.
>
> Anyone any idea what's wrong?
>
> Thanks
>
> Jim
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org