Package org.apache.poi.openxml4j.opc

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


        Map<String, String> map = new HashMap<String, String>();
        map.put(NAMESPACE_A, "a");
        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
        xmlOptions.setSaveSuggestedPrefixes(map);

        PackagePart part = getPackagePart();
        OutputStream out = part.getOutputStream();
        drawing.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 slidePart =
                  getTargetPart(getCorePart().getRelationship(ctSlide.getId2()));
           
            for(PackageRelationship rel : slidePart.getRelationshipsByType(OLE_OBJECT_REL_TYPE))
                embedds.add(getTargetPart(rel)); // TODO: Add this reference to each slide as well
           
            for(PackageRelationship rel : slidePart.getRelationshipsByType(PACK_OBJECT_REL_TYPE))
                  embedds.add(getTargetPart(rel));
    }
  }
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

   * 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) {
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

    map.put(XSSFDrawing.NAMESPACE_A, "a");
    map.put(XSSFDrawing.NAMESPACE_C, "c");
    map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
    xmlOptions.setSaveSuggestedPrefixes(map);

    PackagePart part = getPackagePart();
    OutputStream out = part.getOutputStream();
    chartSpace.save(out, xmlOptions);
    out.close();
  }
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 = getTargetPart(
          commentRels.getRelationship(0)
      );
      CmLstDocument commDoc =
        CmLstDocument.Factory.parse(cPart.getInputStream());
      return commDoc.getCmLst();
    } catch(InvalidFormatException e) {
      throw new IllegalStateException(e);
    }
  }
View Full Code Here

    doc.save(out, options);
  }

  @Override
  protected void commit() throws IOException {
    PackagePart part = getPackagePart();
    OutputStream out = part.getOutputStream();
    writeTo(out);
    out.close();
  }
View Full Code Here

          corePart.getRelationshipsByType(_relation);
        Iterator<PackageRelationship> it = prc.iterator();
        if(it.hasNext()) {
            PackageRelationship rel = it.next();
            PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI());
            PackagePart part = corePart.getPackage().getPart(relName);
            return part.getInputStream();
        }
        log.log(POILogger.WARN, "No part " + _defaultName + " found");
        return null;
  }
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.