Package org.apache.poi.openxml4j.opc

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


     */
    protected static OPCPackage newPackage() {
        try {
            OPCPackage pkg = OPCPackage.create(new ByteArrayOutputStream());
            // Main part
            PackagePartName corePartName = PackagingURIHelper.createPartName(XWPFRelation.DOCUMENT.getDefaultFileName());
            // Create main part relationship
            pkg.addRelationship(corePartName, TargetMode.INTERNAL, PackageRelationshipTypes.CORE_DOCUMENT);
            // Create main document part
            pkg.createPart(corePartName, XWPFRelation.DOCUMENT.getContentType());

View Full Code Here


             * POIXMLDocumentPart data.
             */
            PackagePart picDataPart = xwpfPicData.getPackagePart();
            // TODO add support for TargetMode.EXTERNAL relations.
            TargetMode targetMode = TargetMode.INTERNAL;
            PackagePartName partName = picDataPart.getPartName();
            String relation = relDesc.getRelation();
            PackageRelationship relShip = getPackagePart().addRelationship(partName,targetMode,relation);
            String id = relShip.getId();
            addRelation(id,xwpfPicData);
            pictures.add(xwpfPicData);
View Full Code Here

     * @throws InvalidFormatException
     */
    public int getNextPicNameNumber(int format) throws InvalidFormatException {
        int img = getAllPackagePictures().size() + 1;
        String proposal = XWPFPictureData.RELATIONS[format].getFileName(img);
        PackagePartName createPartName = PackagingURIHelper.createPartName(proposal);
        while (this.getPackage().getPart(createPartName) != null) {
            img++;
            proposal = XWPFPictureData.RELATIONS[format].getFileName(img);
            createPartName = PackagingURIHelper.createPartName(proposal);
        }
View Full Code Here

        PackageRelationshipCollection prc =
            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

        slideId.setId2(slide.getPackageRelationship().getId());

        layout.copyLayout(slide);
        slide.addRelation(layout.getPackageRelationship().getId(), layout);

        PackagePartName ppName = layout.getPackagePart().getPartName();
        slide.getPackagePart().addRelationship(ppName, TargetMode.INTERNAL,
                layout.getPackageRelationship().getRelationshipType());

        _slides.add(slide);
        return slide;
View Full Code Here

         
          // If it has drawings, return those too
          try {
             for(PackageRelationship rel : slidePart.getRelationshipsByType(XSLFRelation.VML_DRAWING.getRelation())) {
               if(rel.getTargetMode() == TargetMode.INTERNAL) {
                   PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI());
                   parts.add( rel.getPackage().getPart(relName) );
                }
             }
          } catch(InvalidFormatException e) {
             throw new TikaException("Broken OOXML file", e);
View Full Code Here

        PackageRelationshipCollection prc =
            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

      Iterator elementIteratorOverride = overrideTypes.iterator();
      while (elementIteratorOverride.hasNext()) {
        Element element = (Element) elementIteratorOverride.next();
        URI uri = new URI(element.attribute(PART_NAME_ATTRIBUTE_NAME)
            .getValue());
        PackagePartName partName = PackagingURIHelper
            .createPartName(uri);
        String contentType = element.attribute(
            CONTENT_TYPE_ATTRIBUTE_NAME).getValue();
        addOverrideContentType(partName, contentType);
      }
View Full Code Here

     */
    protected static OPCPackage newPackage() {
        try {
            OPCPackage pkg = OPCPackage.create(new ByteArrayOutputStream());
            // Main part
            PackagePartName corePartName = PackagingURIHelper.createPartName(XSSFRelation.WORKBOOK.getDefaultFileName());
            // Create main part relationship
            pkg.addRelationship(corePartName, TargetMode.INTERNAL, PackageRelationshipTypes.CORE_DOCUMENT);
            // Create main document part
            pkg.createPart(corePartName, XSSFRelation.WORKBOOK.getContentType());

View Full Code Here

      XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("issue_51265_1.docx");
     
      /* manually assemble a new image package part*/
      OPCPackage opcPckg = doc.getPackage();
      XWPFRelation jpgRelation = XWPFRelation.IMAGE_JPEG;
      PackagePartName partName = PackagingURIHelper.createPartName(jpgRelation.getDefaultFileName().replace('#', '2'));
        PackagePart newImagePart = opcPckg.createPart(partName, jpgRelation.getContentType());
        byte[] nature1 = XWPFTestDataSamples.getImage("abstract4.jpg");
        OutputStream os = newImagePart.getOutputStream();
        os.write(nature1);
      os.close();
View Full Code Here

TOP

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

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.