Search in sources :

Example 1 with CTSlide

use of org.openxmlformats.schemas.presentationml.x2006.main.CTSlide in project poi by apache.

the class XSLFSlideShow method getSlide.

/**
	 * Returns the low level slide object from
	 *  the supplied slide reference
	 */
@Internal
public CTSlide getSlide(CTSlideIdListEntry slide) throws IOException, XmlException {
    PackagePart slidePart = getSlidePart(slide);
    SldDocument slideDoc = SldDocument.Factory.parse(slidePart.getInputStream(), DEFAULT_XML_OPTIONS);
    return slideDoc.getSld();
}
Also used : SldDocument(org.openxmlformats.schemas.presentationml.x2006.main.SldDocument) PackagePart(org.apache.poi.openxml4j.opc.PackagePart) Internal(org.apache.poi.util.Internal)

Example 2 with CTSlide

use of org.openxmlformats.schemas.presentationml.x2006.main.CTSlide in project poi by apache.

the class XSLFSlide method prototype.

private static CTSlide prototype() {
    CTSlide ctSlide = CTSlide.Factory.newInstance();
    CTCommonSlideData cSld = ctSlide.addNewCSld();
    CTGroupShape spTree = cSld.addNewSpTree();
    CTGroupShapeNonVisual nvGrpSpPr = spTree.addNewNvGrpSpPr();
    CTNonVisualDrawingProps cnvPr = nvGrpSpPr.addNewCNvPr();
    cnvPr.setId(1);
    cnvPr.setName("");
    nvGrpSpPr.addNewCNvGrpSpPr();
    nvGrpSpPr.addNewNvPr();
    CTGroupShapeProperties grpSpr = spTree.addNewGrpSpPr();
    CTGroupTransform2D xfrm = grpSpr.addNewXfrm();
    CTPoint2D off = xfrm.addNewOff();
    off.setX(0);
    off.setY(0);
    CTPositiveSize2D ext = xfrm.addNewExt();
    ext.setCx(0);
    ext.setCy(0);
    CTPoint2D choff = xfrm.addNewChOff();
    choff.setX(0);
    choff.setY(0);
    CTPositiveSize2D chExt = xfrm.addNewChExt();
    chExt.setCx(0);
    chExt.setCy(0);
    ctSlide.addNewClrMapOvr().addNewMasterClrMapping();
    return ctSlide;
}
Also used : CTCommonSlideData(org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData) CTPoint2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D) CTGroupTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D) CTGroupShapeNonVisual(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual) CTNonVisualDrawingProps(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps) CTGroupShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties) CTSlide(org.openxmlformats.schemas.presentationml.x2006.main.CTSlide) CTPositiveSize2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D) CTGroupShape(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)

Example 3 with CTSlide

use of org.openxmlformats.schemas.presentationml.x2006.main.CTSlide in project tika by apache.

the class XSLFPowerPointExtractorDecorator method getMainDocumentParts.

/**
     * In PowerPoint files, slides have things embedded in them,
     * and slide drawings which have the images
     */
@Override
protected List<PackagePart> getMainDocumentParts() throws TikaException {
    List<PackagePart> parts = new ArrayList<>();
    XSLFSlideShow document = null;
    try {
        document = new XSLFSlideShow(extractor.getPackage());
    } catch (Exception e) {
        // Shouldn't happen
        throw new TikaException(e.getMessage());
    }
    CTSlideIdList ctSlideIdList = document.getSlideReferences();
    if (ctSlideIdList != null) {
        for (int i = 0; i < ctSlideIdList.sizeOfSldIdArray(); i++) {
            CTSlideIdListEntry ctSlide = ctSlideIdList.getSldIdArray(i);
            // Add the slide
            PackagePart slidePart;
            try {
                slidePart = document.getSlidePart(ctSlide);
            } catch (IOException e) {
                throw new TikaException("Broken OOXML file", e);
            } catch (XmlException xe) {
                throw new TikaException("Broken OOXML file", xe);
            }
            addSlideParts(slidePart, parts);
        }
    }
    //add full document to include macros
    parts.add(document.getPackagePart());
    for (String rel : new String[] { XSLFRelation.SLIDE_MASTER.getRelation(), HANDOUT_MASTER }) {
        try {
            PackageRelationshipCollection prc = document.getPackagePart().getRelationshipsByType(rel);
            for (int i = 0; i < prc.size(); i++) {
                PackagePart pp = document.getPackagePart().getRelatedPart(prc.getRelationship(i));
                if (pp != null) {
                    parts.add(pp);
                }
            }
        } catch (InvalidFormatException e) {
        //log
        }
    }
    return parts;
}
Also used : TikaException(org.apache.tika.exception.TikaException) PackageRelationshipCollection(org.apache.poi.openxml4j.opc.PackageRelationshipCollection) ArrayList(java.util.ArrayList) IOException(java.io.IOException) PackagePart(org.apache.poi.openxml4j.opc.PackagePart) CTSlideIdListEntry(org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry) InvalidFormatException(org.apache.poi.openxml4j.exceptions.InvalidFormatException) TikaException(org.apache.tika.exception.TikaException) InvalidFormatException(org.apache.poi.openxml4j.exceptions.InvalidFormatException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) SAXException(org.xml.sax.SAXException) CTSlideIdList(org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdList) XmlException(org.apache.xmlbeans.XmlException)

Aggregations

PackagePart (org.apache.poi.openxml4j.opc.PackagePart)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 InvalidFormatException (org.apache.poi.openxml4j.exceptions.InvalidFormatException)1 PackageRelationshipCollection (org.apache.poi.openxml4j.opc.PackageRelationshipCollection)1 Internal (org.apache.poi.util.Internal)1 TikaException (org.apache.tika.exception.TikaException)1 XmlException (org.apache.xmlbeans.XmlException)1 CTGroupShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties)1 CTGroupTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D)1 CTNonVisualDrawingProps (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps)1 CTPoint2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D)1 CTPositiveSize2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)1 CTCommonSlideData (org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData)1 CTGroupShape (org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape)1 CTGroupShapeNonVisual (org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual)1 CTSlide (org.openxmlformats.schemas.presentationml.x2006.main.CTSlide)1 CTSlideIdList (org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdList)1 CTSlideIdListEntry (org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry)1 SldDocument (org.openxmlformats.schemas.presentationml.x2006.main.SldDocument)1