use of org.openxmlformats.schemas.presentationml.x2006.main.CmLstDocument in project poi by apache.
the class XSLFSlideShow method getSlideComments.
/**
* Returns all the comments for the given slide
*/
@Internal
public CTCommentList getSlideComments(CTSlideIdListEntry slide) throws IOException, XmlException {
PackageRelationshipCollection commentRels;
PackagePart slidePart = getSlidePart(slide);
try {
commentRels = slidePart.getRelationshipsByType(XSLFRelation.COMMENTS.getRelation());
} catch (InvalidFormatException e) {
throw new IllegalStateException(e);
}
if (commentRels.size() == 0) {
// No comments for this slide
return null;
}
if (commentRels.size() > 1) {
throw new IllegalStateException("Expecting 0 or 1 comments for a slide, but found " + commentRels.size());
}
try {
PackagePart cPart = slidePart.getRelatedPart(commentRels.getRelationship(0));
CmLstDocument commDoc = CmLstDocument.Factory.parse(cPart.getInputStream(), DEFAULT_XML_OPTIONS);
return commDoc.getCmLst();
} catch (InvalidFormatException e) {
throw new IllegalStateException(e);
}
}
Aggregations