use of org.apache.poi.openxml4j.opc.PackageRelationship in project poi by apache.
the class XSLFGroupShape method createPicture.
@Override
public XSLFPictureShape createPicture(PictureData pictureData) {
if (!(pictureData instanceof XSLFPictureData)) {
throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData");
}
XSLFPictureData xPictureData = (XSLFPictureData) pictureData;
PackagePart pic = xPictureData.getPackagePart();
PackageRelationship rel = getSheet().getPackagePart().addRelationship(pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation());
XSLFPictureShape sh = getDrawing().createPicture(rel.getId());
new DrawPictureShape(sh).resize();
_shapes.add(sh);
sh.setParent(this);
return sh;
}
use of org.apache.poi.openxml4j.opc.PackageRelationship in project poi by apache.
the class XSLFHyperlink method linkToSlide.
@Override
public void linkToSlide(Slide<XSLFShape, XSLFTextParagraph> slide) {
PackagePart thisPP = _sheet.getPackagePart();
PackagePartName otherPPN = ((XSLFSheet) slide).getPackagePart().getPartName();
if (_link.isSetId() && !_link.getId().isEmpty()) {
thisPP.removeRelationship(_link.getId());
}
PackageRelationship rel = thisPP.addRelationship(otherPPN, TargetMode.INTERNAL, XSLFRelation.SLIDE.getRelation());
_link.setId(rel.getId());
_link.setAction("ppaction://hlinksldjump");
}
use of org.apache.poi.openxml4j.opc.PackageRelationship in project poi by apache.
the class XSLFPictureShape method getPictureLink.
/**
* For an external linked picture, return the last-seen
* path to the picture.
* For an internal picture, returns null.
*/
public URI getPictureLink() {
if (getBlipId() != null) {
// Internal picture, nothing to return
return null;
}
String rId = getBlipLink();
if (rId == null) {
// 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;
}
use of org.apache.poi.openxml4j.opc.PackageRelationship in project poi by apache.
the class XSSFReader method getSheet.
/**
* Returns an InputStream to read the contents of the
* specified Sheet.
* @param relId The relationId of the sheet, from a r:id on the workbook
*/
public InputStream getSheet(String relId) throws IOException, InvalidFormatException {
PackageRelationship rel = workbookPart.getRelationship(relId);
if (rel == null) {
throw new IllegalArgumentException("No Sheet found with r:id " + relId);
}
PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI());
PackagePart sheet = pkg.getPart(relName);
if (sheet == null) {
throw new IllegalArgumentException("No data found for Sheet with r:id " + relId);
}
return sheet.getInputStream();
}
use of org.apache.poi.openxml4j.opc.PackageRelationship in project poi by apache.
the class ExternalLinksTable method getLinkedFileName.
/**
* Returns the last recorded name of the file that this
* is linked to
*/
public String getLinkedFileName() {
String rId = link.getExternalBook().getId();
PackageRelationship rel = getPackagePart().getRelationship(rId);
if (rel != null && rel.getTargetMode() == TargetMode.EXTERNAL) {
return rel.getTargetURI().toString();
} else {
return null;
}
}
Aggregations