Examples of PackageRelationship


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

            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);
            return id;
        }
        else
View Full Code Here

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

     * Generates the relation if required
     */
    protected void generateRelationIfNeeded(PackagePart sheetPart) {
        if (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

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

        PackagePart pic = pics.get(0);

        PackageRelationship rel = _sheet.getPackagePart().addRelationship(
                pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation());

        XSLFPictureShape sh = getDrawing().createPicture(rel.getId());
        sh.resize();
        _shapes.add(sh);
        return sh;
    }
View Full Code Here

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

        assertEquals("jpeg",jpgPicData.suggestFileExtension());
        assertArrayEquals(jpegData,jpgPicData.getData());

        // Ensure it now has one
        assertEquals(14,doc.getPackagePart().getRelationships().size());
        PackageRelationship jpegRel = null;
        for (PackageRelationship rel : doc.getPackagePart().getRelationships())
        {
            if (rel.getRelationshipType().equals(XWPFRelation.IMAGE_JPEG.getRelation()))
            {
                if (jpegRel != null)
                    fail("Found 2 jpegs!");
                jpegRel = rel;
            }
        }
        assertNotNull("JPEG Relationship not found",jpegRel);

        // Check the details
        assertNotNull(jpegRel);
        assertEquals(XWPFRelation.IMAGE_JPEG.getRelation(),jpegRel.getRelationshipType());
        assertEquals("/word/document.xml",jpegRel.getSource().getPartName().toString());
        assertEquals("/word/media/image1.jpeg",jpegRel.getTargetURI().getPath());

        XWPFPictureData pictureDataByID = doc.getPictureDataByID(jpegRel.getId());
        assertArrayEquals(jpegData, pictureDataByID.getData());

        // Save an re-load, check it appears
        doc = XWPFTestDataSamples.writeOutAndReadBack(doc);
        assertEquals(1,doc.getAllPictures().size());
        assertEquals(1,doc.getAllPackagePictures().size());

        // verify the picture that we read back in
        pictureDataByID = doc.getPictureDataByID(jpegRel.getId());
        assertArrayEquals(jpegData, pictureDataByID.getData());
       
    }
View Full Code Here

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

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

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

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

        // TODO: make me optional/separated in private function
        try {
            Iterator<PackageRelationship> relIter =
                getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation()).iterator();
            while(relIter.hasNext()) {
                PackageRelationship rel = relIter.next();
                hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
            }
        } catch (InvalidFormatException e){
            throw new POIXMLException(e);
        }
    }
View Full Code Here

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

            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);
            return id;
        }
        else
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.openxml4j.opc.PackageRelationship

      return null;
    }
    if(rels.size() > 1) {
      throw new IllegalArgumentException("Found " + rels.size() + " relations for the type " + relationType + ", should only ever be one!");
    }
    PackageRelationship rel = rels.getRelationship(0);
    return getPackagePart(rel);
  }
View Full Code Here

Examples of org.openxml4j.opc.PackageRelationship

      return null;
    }
    if(rels.size() > 1) {
      throw new IllegalArgumentException("Found " + rels.size() + " relations for the type " + relationType + ", should only ever be one!");
    }
    PackageRelationship rel = rels.getRelationship(0);
    return getPackagePart(rel);
  }
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.