Search in sources :

Example 1 with CmLstDocument

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);
    }
}
Also used : CmLstDocument(org.openxmlformats.schemas.presentationml.x2006.main.CmLstDocument) PackageRelationshipCollection(org.apache.poi.openxml4j.opc.PackageRelationshipCollection) PackagePart(org.apache.poi.openxml4j.opc.PackagePart) InvalidFormatException(org.apache.poi.openxml4j.exceptions.InvalidFormatException) Internal(org.apache.poi.util.Internal)

Aggregations

InvalidFormatException (org.apache.poi.openxml4j.exceptions.InvalidFormatException)1 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)1 PackageRelationshipCollection (org.apache.poi.openxml4j.opc.PackageRelationshipCollection)1 Internal (org.apache.poi.util.Internal)1 CmLstDocument (org.openxmlformats.schemas.presentationml.x2006.main.CmLstDocument)1