Examples of PackageRelationship


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

            // No link recorded, nothing we can do
            return null;
        }
       
        PackagePart p = getSheet().getPackagePart();
        PackageRelationship rel = p.getRelationship(rId);
        if (rel != null) {
            return rel.getTargetURI();
        }
        return null;
    }
View Full Code Here

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

            throw new IllegalArgumentException("Picture with index=" + pictureIndex + " was not found");
        }

        PackagePart pic = pics.get(0);

        PackageRelationship rel = getPackagePart().addRelationship(
                pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation());
        addRelation(rel.getId(), new XSLFPictureData(pic, rel));

        XSLFPictureShape sh = getDrawing().createPicture(rel.getId());
        sh.resize();

        getShapeList().add(sh);
        return sh;
    }
View Full Code Here

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

     * @param blipId        ID of the package relationship to retrieve.
     * @param packagePart   package part containing the data to import
     * @return ID of the created relationship
     */
    String importBlip(String blipId, PackagePart packagePart) {
        PackageRelationship blipRel = packagePart.getRelationship(blipId);
        PackagePart blipPart;
        try {
            blipPart = packagePart.getRelatedPart(blipRel);
        } catch (InvalidFormatException e){
            throw new POIXMLException(e);
        }
        XSLFPictureData data = new XSLFPictureData(blipPart, null);

        XMLSlideShow ppt = getSlideShow();
        int pictureIdx = ppt.addPicture(data.getData(), data.getPictureType());
        PackagePart pic = ppt.getAllPictures().get(pictureIdx).getPackagePart();

        PackageRelationship rel = getPackagePart().addRelationship(
                pic.getPartName(), TargetMode.INTERNAL, blipRel.getRelationshipType());
        addRelation(rel.getId(), new XSLFPictureData(pic, rel));

        return rel.getId();
    }
View Full Code Here

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

     */
    PackagePart importPart(PackageRelationship srcRel, PackagePart srcPafrt) {

        OPCPackage pkg = getPackagePart().getPackage();
        if(!pkg.containPart(srcPafrt.getPartName())){
            PackageRelationship rel = getPackagePart().addRelationship(
                    srcPafrt.getPartName(), TargetMode.INTERNAL, srcRel.getRelationshipType());

            PackagePart part = pkg.createPart(srcPafrt.getPartName(), srcPafrt.getContentType());
            OutputStream out = part.getOutputStream();
            try {
View Full Code Here

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

     * Generates the relation if required
     */
    protected void generateRelationIfNeeded(PackagePart sheetPart) {
        if (_externalRel == null && needsRelationToo()) {
            // Generate the relation
            PackageRelationship rel =
                    sheetPart.addExternalRelationship(_location, XSSFRelation.SHEET_HYPERLINKS.getRelation());

            // Update the r:id
            _ctHyperlink.setId(rel.getId());
        }
    }
View Full Code Here

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

    public InputStream getContents(PackagePart corePart) throws IOException, InvalidFormatException {
        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

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

            if(r instanceof XSSFDrawing) {
                dg = (XSSFDrawing)r;
                continue;
            }

            PackageRelationship rel = r.getPackageRelationship();
            clonedSheet.getPackagePart().addRelationship(
                    rel.getTargetURI(), rel.getTargetMode(),rel.getRelationshipType());
            clonedSheet.addRelation(rel.getId(), r);
        }

        // clone the sheet drawing alongs with its relationships
        if (dg != null) {
            if(ct.isSetDrawing()) {
                // unset the existing reference to the drawing,
                // so that subsequent call of clonedSheet.createDrawingPatriarch() will create a new one
                ct.unsetDrawing();
            }
            XSSFDrawing clonedDg = clonedSheet.createDrawingPatriarch();
            // copy drawing contents
            clonedDg.getCTDrawing().set(dg.getCTDrawing());

            // Clone drawing relations
            List<POIXMLDocumentPart> srcRels = srcSheet.createDrawingPatriarch().getRelations();
            for (POIXMLDocumentPart rel : srcRels) {
                PackageRelationship relation = rel.getPackageRelationship();
                clonedSheet
                        .createDrawingPatriarch()
                        .getPackagePart()
                        .addRelationship(relation.getTargetURI(), relation.getTargetMode(),
                                relation.getRelationshipType(), relation.getId());
            }
        }
        return clonedSheet;
    }
View Full Code Here

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

        byte[] nature1 = XWPFTestDataSamples.getImage("abstract4.jpg");
        OutputStream os = newImagePart.getOutputStream();
        os.write(nature1);
      os.close();
      XWPFHeader xwpfHeader = doc.getHeaderList().get(0);
      PackageRelationship relationship = xwpfHeader.getPackagePart().addRelationship(partName, TargetMode.INTERNAL, jpgRelation.getRelation());
      XWPFPictureData newPicData = new XWPFPictureData(newImagePart,relationship);
      /* new part is now ready to rumble */
     
      assertFalse(xwpfHeader.getAllPictures().contains(newPicData));
      assertFalse(doc.getAllPictures().contains(newPicData));
View Full Code Here

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

     * @param img the PictureData of the Picture,
     */
    public PackageRelationship addPictureReference(byte[] pictureData, int format){
      int imageNumber = getNextPicNameNumber(format);
        XWPFPictureData img = (XWPFPictureData)createRelationship(XWPFPictureData.RELATIONS[format], XWPFFactory.getInstance(), imageNumber, false);
        PackageRelationship rel = null;
        try {
            OutputStream out = img.getPackagePart().getOutputStream();
            out.write(pictureData);
             out.close();
             rel = img.getPackageRelationship();
View Full Code Here

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

       *
       * @param img the PictureData of the Picture,
       */
      public PackageRelationship addPictureReference(InputStream is, int format){
       
        PackageRelationship rel = null;
          try {
            int imageNumber = getNextPicNameNumber(format);
            XWPFPictureData img = (XWPFPictureData)createRelationship(XWPFPictureData.RELATIONS[format], XWPFFactory.getInstance(), imageNumber, false);
            OutputStream out = img.getPackagePart().getOutputStream();
            IOUtils.copy(is, out);
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.