/** * Construct a new XSSFGraphicFrame object. * * @param drawing the XSSFDrawing that owns this frame * @param ctGraphicFrame the XML bean that stores this frame content */ protected XSSFGraphicFrame(XSSFDrawing drawing, CTGraphicalObjectFrame ctGraphicFrame) { this.drawing = drawing; // protected field on XSSFShape this.graphicFrame = ctGraphicFrame; // TODO: there may be a better way to delegate this CTGraphicalObjectData graphicData = graphicFrame.getGraphic().getGraphicData(); if (graphicData != null) { NodeList nodes = graphicData.getDomNode().getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node node = nodes.item(i); // if the frame references a chart, associate the chart with this instance if (node.getNodeName().equals("c:chart")) { // this better succeed or the document is invalid POIXMLDocumentPart relation = drawing.getRelationById(node.getAttributes().getNamedItem("r:id").getNodeValue()); // Do XWPF charts need similar treatment? if (relation instanceof XSSFChart) { ((XSSFChart) relation).setGraphicFrame(this); } } } } }
/** * Construct a new XSSFGraphicFrame object. * * @param drawing the XSSFDrawing that owns this frame * @param ctGraphicFrame the XML bean that stores this frame content */ protected XSSFGraphicFrame(XSSFDrawing drawing, CTGraphicalObjectFrame ctGraphicFrame) { this.drawing = drawing; // protected field on XSSFShape this.graphicFrame = ctGraphicFrame; // TODO: there may be a better way to delegate this CTGraphicalObjectData graphicData = graphicFrame.getGraphic().getGraphicData(); if (graphicData != null) { NodeList nodes = graphicData.getDomNode().getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node node = nodes.item(i); // if the frame references a chart, associate the chart with this instance if (node.getNodeName().equals("c:chart")) { // this better succeed or the document is invalid POIXMLDocumentPart relation = drawing.getRelationById(node.getAttributes().getNamedItem("r:id").getNodeValue()); // Do XWPF charts need similar treatment? if (relation instanceof XSSFChart) { ((XSSFChart) relation).setGraphicFrame(this); } } } } }