Package org.apache.poi.openxml4j.opc

Examples of org.apache.poi.openxml4j.opc.PackagePart


    protected void commit() throws IOException {
        XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
        //Sets the pivotTableDefinition tag
        xmlOptions.setSaveSyntheticDocumentElement(new QName(CTPivotTableDefinition.type.getName().
                getNamespaceURI(), "pivotTableDefinition"));
        PackagePart part = getPackagePart();
        OutputStream out = part.getOutputStream();
        pivotTableDefinition.save(out, xmlOptions);
        out.close();
    }
View Full Code Here


    presentationDoc =
      PresentationDocument.Factory.parse(getCorePart().getInputStream());
   
      embedds = new LinkedList<PackagePart>();
      for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdList()) {
             PackagePart corePart = getCorePart();
            PackagePart slidePart = corePart.getRelatedPart(
                  corePart.getRelationship(ctSlide.getId2()));

            for(PackageRelationship rel : slidePart.getRelationshipsByType(OLE_OBJECT_REL_TYPE))
                embedds.add(slidePart.getRelatedPart(rel)); // TODO: Add this reference to each slide as well

            for(PackageRelationship rel : slidePart.getRelationshipsByType(PACK_OBJECT_REL_TYPE))
                  embedds.add(slidePart.getRelatedPart(rel));
    }
  }
View Full Code Here

    return getPresentation().getSldMasterIdLst();
  }
 
  public PackagePart getSlideMasterPart(CTSlideMasterIdListEntry master) throws IOException, XmlException {
    try {
       PackagePart corePart = getCorePart();
      return corePart.getRelatedPart(
        corePart.getRelationship(master.getId2())
      );
    } catch(InvalidFormatException e) {
      throw new XmlException(e);
    }
  }
View Full Code Here

   * Returns the low level slide master object from
   *  the supplied slide master reference
   */
    @Internal
  public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) throws IOException, XmlException {
    PackagePart masterPart = getSlideMasterPart(master);
    SldMasterDocument masterDoc =
      SldMasterDocument.Factory.parse(masterPart.getInputStream());
    return masterDoc.getSldMaster();
  }
View Full Code Here

    return masterDoc.getSldMaster();
  }

  public PackagePart getSlidePart(CTSlideIdListEntry slide) throws IOException, XmlException {
    try {
        PackagePart corePart = getCorePart();
        return corePart.getRelatedPart(
           corePart.getRelationship(slide.getId2())
        );
    } catch(InvalidFormatException e) {
      throw new XmlException(e);
    }
  }
View Full Code Here

   * 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());
    return slideDoc.getSld();
  }
View Full Code Here

   * Gets the PackagePart of the notes for the
   *  given slide, or null if there isn't one.
   */
  public PackagePart getNodesPart(CTSlideIdListEntry parentSlide) throws IOException, XmlException {
    PackageRelationshipCollection notes;
    PackagePart slidePart = getSlidePart(parentSlide);
   
    try {
      notes = slidePart.getRelationshipsByType(XSLFRelation.NOTES.getRelation());
    } catch(InvalidFormatException e) {
      throw new IllegalStateException(e);
    }
   
    if(notes.size() == 0) {
      // No notes for this slide
      return null;
    }
    if(notes.size() > 1) {
      throw new IllegalStateException("Expecting 0 or 1 notes for a slide, but found " + notes.size());
    }
   
    try {
       return slidePart.getRelatedPart(notes.getRelationship(0));
    } catch(InvalidFormatException e) {
      throw new IllegalStateException(e);
    }
  }
View Full Code Here

   * Returns the low level notes object for the given
   *  slide, as found from the supplied slide reference
   */
    @Internal
  public CTNotesSlide getNotes(CTSlideIdListEntry slide) throws IOException, XmlException {
    PackagePart notesPart = getNodesPart(slide);
    if(notesPart == null)
      return null;
   
    NotesDocument notesDoc =
      NotesDocument.Factory.parse(notesPart.getInputStream());
   
    return notesDoc.getNotes();
  }
View Full Code Here

   * 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());
      return commDoc.getCmLst();
    } catch(InvalidFormatException e) {
      throw new IllegalStateException(e);
    }
  }
View Full Code Here

    public XSLFPictureData getPictureData() {
        if(_data == null){
            String blipId = getBlipId();
            if (blipId == null) return null;

            PackagePart p = getSheet().getPackagePart();
            PackageRelationship rel = p.getRelationship(blipId);
            if (rel != null) {
                try {
                    PackagePart imgPart = p.getRelatedPart(rel);
                    _data = new XSLFPictureData(imgPart, rel);
                }
                catch (Exception e) {
                    throw new POIXMLException(e);
                }
View Full Code Here

TOP

Related Classes of org.apache.poi.openxml4j.opc.PackagePart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.