Creating new slide layouts
Posted: Wed Apr 20, 2011 12:59 am
I've managed to work with the library pretty well so far, but have become stuck when trying to create a slide with a layout other than slideLayout1.xml, which is the Title and Subtitle slide. I want to create a slide that has a Title and Content box, which I have identified as slideLayout2.xml in the ppt/slideLayouts/ folder of a pptx. My code for creating the layouts is as follows:
I can successfully create slideLayout1.xml, but when I try to create slideLayout2.xml tempLayout becomes null and then fails when trying to setJaxbElement (if the null check was removed).
I really hope I am just forgetting something because I have enjoyed working this library and it has saved me a lot of time and headaches up until this point. Thanks for your help.
- Code: Select all
PartName pn = new PartName("/ppt/slideLayouts/slideLayout"+slideNumber+".xml");
System.err.println("PC> tpn: "+pn.toString());
tempLayout = (SlideLayoutPart)presMLPackage.getParts().getParts().get(pn);
if (tempLayout != null){
String layoutString = this.getLayoutXML(slideName);
System.err.println("layoutXML: " + layoutString.substring(305, 341));
SldLayout temp = (SldLayout) XmlUtils.unmarshalString(layoutString, Context.jcPML);
tempLayout.setJaxbElement(temp);
}else{
throw new Exception();
}
I can successfully create slideLayout1.xml, but when I try to create slideLayout2.xml tempLayout becomes null and then fails when trying to setJaxbElement (if the null check was removed).
I really hope I am just forgetting something because I have enjoyed working this library and it has saved me a lot of time and headaches up until this point. Thanks for your help.