List of usage examples for org.apache.poi.xslf.usermodel XSLFSlide getRelationParts
public final List<RelationPart> getRelationParts()
From source file:com.hp.autonomy.frontend.reports.powerpoint.SlideShowTemplate.java
License:MIT License
/** * Given an existing slide, search its relations to find a chart object. * @param slide a slide from the template. * @param error if we can't find a slide, this error message will be returned as the exception. * @return a pair containing the chart.xml data and the graphical object which represented it on the slide. * @throws TemplateLoadException if we can't find a chart object. *///w w w . ja v a 2s . c om private ImmutablePair<XSLFChart, CTGraphicalObjectFrame> getChart(final XSLFSlide slide, final String error) throws TemplateLoadException { for (POIXMLDocumentPart.RelationPart part : slide.getRelationParts()) { if (part.getDocumentPart() instanceof XSLFChart) { final String relId = part.getRelationship().getId(); for (XSLFShape shape : slide.getShapes()) { if (shape instanceof XSLFGraphicFrame) { final CTGraphicalObjectFrame frameXML = (CTGraphicalObjectFrame) shape.getXmlObject(); final XmlObject[] children = frameXML.getGraphic().getGraphicData() .selectChildren(new QName(XSSFRelation.NS_CHART, "chart")); for (final XmlObject child : children) { final String imageRel = child.getDomNode().getAttributes() .getNamedItemNS(RELATION_NAMESPACE, "id").getNodeValue(); if (relId.equals(imageRel)) { return new ImmutablePair<>(part.getDocumentPart(), frameXML); } } } } } } throw new TemplateLoadException(error); }