Examples of PackagePart


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

   * 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(NOTES_RELATION_TYPE);
    } catch(InvalidFormatException e) {
      throw new IllegalStateException(e);
    }
   
    if(notes.size() == 0) {
View Full Code Here

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

   * 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

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

   * 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(COMMENT_RELATION_TYPE);
    } 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

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

      pkg.getRelationshipsByType(CORE_DOCUMENT_REL);
    if(core.size() != 1) {
      throw new IllegalArgumentException("Invalid OOXML Package received - expected 1 core document, found " + core.size());
    }

        PackagePart corePart = pkg.getPart(core.getRelationship(0));
        if (corePart.getContentType().equals(XSSFRelation.WORKBOOK.getContentType()) ||
            corePart.getContentType().equals(XSSFRelation.MACRO_TEMPLATE_WORKBOOK.getContentType()) ||
            corePart.getContentType().equals(XSSFRelation.MACRO_ADDIN_WORKBOOK.getContentType()) ||
            corePart.getContentType().equals(XSSFRelation.TEMPLATE_WORKBOOK.getContentType()) ||
            corePart.getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType())) {
            return new XSSFExcelExtractor(pkg);
        }

        if(corePart.getContentType().equals(XWPFRelation.DOCUMENT.getContentType()) ||
            corePart.getContentType().equals(XWPFRelation.TEMPLATE.getContentType()) ||
            corePart.getContentType().equals(XWPFRelation.MACRO_DOCUMENT.getContentType()) ||
            corePart.getContentType().equals(XWPFRelation.MACRO_TEMPLATE_DOCUMENT.getContentType()) ) {
      return new XWPFWordExtractor(pkg);
    }

    if(corePart.getContentType().equals(XSLFSlideShow.MAIN_CONTENT_TYPE)) {
      return new XSLFPowerPointExtractor(pkg);
    }
    throw new IllegalArgumentException("No supported documents found in the OOXML package (found "+corePart.getContentType()+")");
  }
View Full Code Here

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

          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

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

        rootObject.save(out, xmlOptions);
    }

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

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

        xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorkbook.type.getName().getNamespaceURI(), "workbook"));
        Map<String, String> map = new HashMap<String, String>();
        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
        xmlOptions.setSaveSuggestedPrefixes(map);

        PackagePart part = getPackagePart();
        OutputStream out = part.getOutputStream();
        workbook.save(out, xmlOptions);
        out.close();
    }
View Full Code Here

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

        _sstDoc.save(out, options);
    }

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

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

        doc.save(out, DEFAULT_XML_OPTIONS);
    }

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

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

        }
    }

    @Override
    protected void commit() throws IOException {
        PackagePart part = getPackagePart();
        OutputStream out = part.getOutputStream();
        write(out);
        out.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.