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
Created attachment 17969 [details] test case
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.....
Should work now - had to make sure everything correctly updated internal views, and then tweak how the PersistPtrHandler stuff happened