Bug 57250 - XMLSlideShow.setSlideOrder() produces corrupted CTSlideIdList
Summary: XMLSlideShow.setSlideOrder() produces corrupted CTSlideIdList
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 3.11-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-24 11:58 UTC by vladk
Modified: 2014-12-07 15:28 UTC (History)
0 users



Attachments
Fix for bug 57250 (3.53 KB, patch)
2014-12-07 14:46 UTC, Yaniv Kunda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description vladk 2014-11-24 11:58:39 UTC
I guess the bug was introduced by commit 1620997 (Bug 56854 - XMLBeans performance when using getXXXList() and other proxy methods).

Tested with version 3.11-beta3.

The setSlideOrder() method removes old slide at wrong position:

after insert:
<xml-fragment xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
  <p:sldId id="257" r:id="rId7"/>
  <p:sldId id="256" r:id="rId2"/>
  <p:sldId id="257" r:id="rId7"/>
</xml-fragment>

after remove:
<xml-fragment xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
  <p:sldId id="257" r:id="rId7"/>
  <p:sldId id="257" r:id="rId7"/>
</xml-fragment>

Finally the presentation refers to the same slide twice and the old slide is not more reachable.

The following unit test fails (create a slide show insert-infront.pptx with a single slide containing text "Test me"):

    @Test
    public void testInsertInfront() throws Exception {
       XMLSlideShow ss = XSLFTestDataSamples.openSampleDocument("insert-infront.pptx");
       XSLFSlide slide;
       
       assertEquals(1, ss.getSlides().length);
       
       slide = ss.getSlides()[0];
       assertContains(getSlideText(slide), "Test me");
       
       slide = ss.createSlide();
       ss.setSlideOrder(slide, 0);
       slide.createTextBox().setText("New slide");
       
       // Save and re-load
       ss = XSLFTestDataSamples.writeOutAndReadBack(ss);

       assertEquals(2, ss.getSlides().length);
       
       slide = ss.getSlides()[0];
       assertContains(getSlideText(slide), "New slide");
       
       slide = ss.getSlides()[1];
       assertContains(getSlideText(slide), "Test me");
    }
Comment 1 Yaniv Kunda 2014-12-04 07:43:08 UTC
I will fix as soon as Apache SVN server comes back.
Comment 2 Yaniv Kunda 2014-12-07 14:46:33 UTC
Created attachment 32266 [details]
Fix for bug 57250
Comment 3 Andreas Beeker 2014-12-07 15:28:45 UTC
Thank you for the patch. Applied with r1643684