Bug 39096 - bug: adding new slides fails
Summary: bug: adding new slides fails
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: unspecified
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-24 16:10 UTC by Yegor Kozlov
Modified: 2006-03-26 12:08 UTC (History)
0 users



Attachments
test case (3.13 KB, application/octet-stream)
2006-03-24 16:12 UTC, Yegor Kozlov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yegor Kozlov 2006-03-24 16:10:41 UTC
Nick,

Something is wrong with adding new slides.
Operation works only if you add the first slide to an empty presentation.

I attached the test cases.

(1) This is the only case when it works. 

    public void testAddSlides1() throws Exception {
        SlideShow ppt = new SlideShow();
        assertTrue(ppt.getSlides().length == 0);
        ppt.createSlide();
        assertTrue(ppt.getSlides().length == 1);

        //serialize and read again
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ppt.write(out);
        out.close();

        ppt = new SlideShow(new HSLFSlideShow(new
ByteArrayInputStream(out.toByteArray())));
        assertTrue(ppt.getSlides().length == 1);
    }




(2)  The same as above but add 2 slides. The ppt is silently serialized but
if you open it looks corrupted. Also number of slides is wrong.

    public void testAddSlides2() throws Exception {
        SlideShow ppt = new SlideShow(new HSLFSlideShow(dirname + "/empty.ppt"));
        assertTrue(ppt.getSlides().length == 0);
        ppt.createSlide();
        assertTrue(ppt.getSlides().length == 1);
        ppt.createSlide();
        assertTrue(ppt.getSlides().length == 2);

        //serialize and read again
         ByteArrayOutputStream out = new ByteArrayOutputStream();
        ppt.write(out);
        out.close();

        ppt = new SlideShow(new HSLFSlideShow(new
ByteArrayInputStream(out.toByteArray())));
        assertTrue(ppt.getSlides().length == 2);
    }

(3) 
 Adding slides to a ppt fails on serialization. Any tricks with PersistPtrHolder
required? 

    public void testAddSlides3() throws Exception {
        SlideShow ppt = new SlideShow(new HSLFSlideShow(dirname +
"/basic_test_ppt_file.ppt"));
        assertTrue(ppt.getSlides().length == 2);
        ppt.createSlide();
        assertTrue(ppt.getSlides().length == 3);

        //serialize and read again
         ByteArrayOutputStream out = new ByteArrayOutputStream();
        ppt.write(out);
        out.close();

        ppt = new SlideShow(new HSLFSlideShow(new
ByteArrayInputStream(out.toByteArray())));
        assertTrue(ppt.getSlides().length == 3);
    }

Regards, Yegor
Comment 1 Yegor Kozlov 2006-03-24 16:12:19 UTC
Created attachment 17969 [details]
test case
Comment 2 Nick Burch 2006-03-24 16:51:56 UTC
Bah, guess my changes to your code to make it easier to follow ended up breaking
stuff :(

Can you confirm that your test case does work on the code you submitted? If so,
I'll need to compare your original code to my new stuff, and see what I broke
when I tried to make it easier to understand.....
Comment 3 Nick Burch 2006-03-26 20:08:58 UTC
Should work now - had to make sure everything correctly updated internal views,
and then tweak how the PersistPtrHandler stuff happened