Page 1 of 1
How do I rename a slide part?
Posted:
Tue Jun 11, 2013 4:55 pm
by pupul07
I tried using
- Code: Select all
presentationMLpackage.getParts().get(new PartName("/ppt/slides/slide6.xml")).setPartName((new PartName("/ppt/slides/slide6-1.xml"));
This does change the name of the part; however, the [Content_Types].xml file doesn't get updated.
How do I update the content types?
Re: How do I rename a slide part?
Posted:
Tue Jun 11, 2013 7:29 pm
by jason
See MainPresentationPart's addSlideIdListEntry for what needs to be done
Re: How do I rename a slide part?
Posted:
Wed Jun 12, 2013 5:49 pm
by pupul07
Hi Jason,
I tried doing this:
- Code: Select all
//rename part
presentationMLPackage.getParts().get(new PartName("/ppt/slides/slide6.xml")).setPartName(new PartName("/ppt/slides/slide6-1.xml"));
SlidePart tempPart = (SlidePart) presentationMLPackage.getParts().get(new PartName("/ppt/slides/slide6-1.xml"));
presentationMLPackage.getMainPresentationPart().addSlideIdListEntry(tempPart);
But the problem still remains.
Re: How do I rename a slide part?
Posted:
Wed Jun 12, 2013 6:37 pm
by jason
What is your objective?
Re: How do I rename a slide part?
Posted:
Wed Jun 19, 2013 9:46 pm
by pupul07
I have a function that duplicates slides:
public void createDuplicateSlide(String slidePartName, int n)
This is how I use it:
createDuplicateSlide("ppt/slides/slide6-1.xml",3)
so that I have:
ppt/slides/slide6-1.xml
ppt/slides/slide6-2.xml
ppt/slides/slide6-3.xml
ppt/slides/slide6-4.xml
But as you can see, the problem is the fact that the first slide needs to be named slide<number>-1.xml.
I was wondering if there was a simple way I could rename slide<number>.xml to slide<number>-1.xml.
I could, of course, start naming from slide<number>-2.xml for the duplicates; however, this leads to
complications later in my program where I try to split the contents of a table across several slides.
Is there an easy fix to this?
Re: How do I rename a slide part?
Posted:
Thu Jun 20, 2013 10:55 pm
by jason
I think it is easy provided you are happy for your duplicate slides to use a single notes slide (and assuming Powerpoint and other consumers are ok with that), and where the slide has references to images etc, your duplicate slides can/do just use a copy of the slide's rels part (again, pointing to the original objects).
If you post your method, I'll have a quick go at it.
Otherwise, Plutext's MergePptx can do this sort of thing for you, but that's a commercial extension.