protected String getBlipId(){ String id = getBlip().getEmbed(); if (id.isEmpty()) { return null; } return id; }
@SuppressWarnings("WeakerAccess") protected String getBlipLink(){ CTBlip blip = getBlip(); if (blip != null) { String link = blip.getLink(); return (link.isEmpty()) ? null : link; } else { return null; } }
@Override public XSLFSlide importContent(XSLFSheet src){ super.importContent(src); if (!(src instanceof XSLFSlide)) { return this; } // only copy direct backgrounds - not backgrounds of master sheet CTBackground bgOther = ((XSLFSlide)src)._slide.getCSld().getBg(); if (bgOther == null) { return this; } CTBackground bgThis = _slide.getCSld().getBg(); // remove existing background if (bgThis != null) { if (bgThis.isSetBgPr() && bgThis.getBgPr().isSetBlipFill()) { String oldId = bgThis.getBgPr().getBlipFill().getBlip().getEmbed(); removeRelation(oldId); } _slide.getCSld().unsetBg(); } bgThis = (CTBackground)_slide.getCSld().addNewBg().set(bgOther); if(bgOther.isSetBgPr() && bgOther.getBgPr().isSetBlipFill()){ String idOther = bgOther.getBgPr().getBlipFill().getBlip().getEmbed(); String idThis = importBlip(idOther, src); bgThis.getBgPr().getBlipFill().getBlip().setEmbed(idThis); } return this; }
@Override public int getAlpha() { return (blip.sizeOfAlphaModFixArray() > 0) ? blip.getAlphaModFixArray(0).getAmt() : 100000; } };
blip.setEmbed(relId); if(blip.isSetExtLst()) { CTOfficeArtExtensionList extLst = blip.getExtLst();
private Paint createTexturePaint(CTBlipFillProperties blipFill, Graphics2D graphics, PackagePart parentPart){ Paint paint = null; CTBlip blip = blipFill.getBlip(); String blipId = blip.getEmbed(); PackageRelationship rel = parentPart.getRelationship(blipId); if (rel != null) { XSLFImageRenderer renderer = null; if (graphics != null) renderer = (XSLFImageRenderer) graphics.getRenderingHint(XSLFRenderingHint.IMAGE_RENDERER); if (renderer == null) renderer = new XSLFImageRenderer(); try { BufferedImage img = renderer.readImage(parentPart.getRelatedPart(rel)); if (blip.sizeOfAlphaModFixArray() > 0) { float alpha = blip.getAlphaModFixArray(0).getAmt() / 100000.f; AlphaComposite ac = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha); if (graphics != null) graphics.setComposite(ac); } if(img != null) { paint = new TexturePaint( img, new Rectangle2D.Double(0, 0, img.getWidth(), img.getHeight())); } } catch (Exception e) { e.printStackTrace(); } } return paint; }
/** * Link Picture with PictureData * * @param rel */ public void setPictureReference(PackageRelationship rel) { ctPic.getBlipFill().getBlip().setEmbed(rel.getId()); }
/** * Link this shape with the picture data * * @param rel relationship referring the picture data */ protected void setPictureReference(PackageRelationship rel){ ctPicture.getBlipFill().getBlip().setEmbed(rel.getId()); }
blip.setEmbed(relId); if(blip.isSetExtLst()) { CTOfficeArtExtensionList extLst = blip.getExtLst();
@Override public int getAlpha() { return (blip.sizeOfAlphaModFixArray() > 0) ? blip.getAlphaModFixArray(0).getAmt() : 100000; } };
@SuppressWarnings("WeakerAccess") protected String getBlipId(){ CTBlip blip = getBlip(); if (blip != null) { String id = blip.getEmbed(); return (id.isEmpty()) ? null : id; } else { return null; } }
blip.setEmbed(parent.getPart().getRelationId(picData)); blipFill.addNewStretch().addNewFillRect();
@SuppressWarnings("WeakerAccess") protected String getBlipLink(){ CTBlip blip = getBlip(); if (blip != null) { String link = blip.getLink(); return (link.isEmpty()) ? null : link; } else { return null; } }
private PackagePart getPart() { try { String blipId = blip.getEmbed(); PackageRelationship rel = parentPart.getRelationship(blipId); return parentPart.getRelatedPart(rel); } catch (InvalidFormatException e) { throw new RuntimeException(e); } }
@Override public XSLFSlide importContent(XSLFSheet src){ super.importContent(src); XSLFBackground bgShape = getBackground(); if(bgShape != null) { CTBackground bg = (CTBackground)bgShape.getXmlObject(); if(bg.isSetBgPr() && bg.getBgPr().isSetBlipFill()){ CTBlip blip = bg.getBgPr().getBlipFill().getBlip(); String blipId = blip.getEmbed(); String relId = importBlip(blipId, src.getPackagePart()); blip.setEmbed(relId); } } return this; }
/** * @param shapeId 1-based shapeId * @param rel relationship to the picture data in the ooxml package */ static CTPicture prototype(int shapeId, String rel) { CTPicture ct = CTPicture.Factory.newInstance(); CTPictureNonVisual nvSpPr = ct.addNewNvPicPr(); CTNonVisualDrawingProps cnv = nvSpPr.addNewCNvPr(); cnv.setName("Picture " + shapeId); cnv.setId(shapeId); nvSpPr.addNewCNvPicPr().addNewPicLocks().setNoChangeAspect(true); nvSpPr.addNewNvPr(); CTBlipFillProperties blipFill = ct.addNewBlipFill(); CTBlip blip = blipFill.addNewBlip(); blip.setEmbed(rel); blipFill.addNewStretch().addNewFillRect(); CTShapeProperties spPr = ct.addNewSpPr(); CTPresetGeometry2D prst = spPr.addNewPrstGeom(); prst.setPrst(STShapeType.RECT); prst.addNewAvLst(); return ct; }
String link = picture.getBlipFill().getBlip().getLink(); String src = document.getPackagePart().getRelationships().getRelationshipByID(link).getTargetURI().toString(); attributes = SAXHelper.addAttrValue( null, SRC_ATTR, src );
/** * Return picture data for this shape * * @return picture data for this shape */ public XSSFPictureData getPictureData() { String blipId = ctPicture.getBlipFill().getBlip().getEmbed(); return (XSSFPictureData)getDrawing().getRelationById(blipId); }
@Override public XSLFSlide importContent(XSLFSheet src){ super.importContent(src); if (!(src instanceof XSLFSlide)) { return this; } // only copy direct backgrounds - not backgrounds of master sheet CTBackground bgOther = ((XSLFSlide)src)._slide.getCSld().getBg(); if (bgOther == null) { return this; } CTBackground bgThis = _slide.getCSld().getBg(); // remove existing background if (bgThis != null) { if (bgThis.isSetBgPr() && bgThis.getBgPr().isSetBlipFill()) { String oldId = bgThis.getBgPr().getBlipFill().getBlip().getEmbed(); removeRelation(oldId); } _slide.getCSld().unsetBg(); } bgThis = (CTBackground)_slide.getCSld().addNewBg().set(bgOther); if(bgOther.isSetBgPr() && bgOther.getBgPr().isSetBlipFill()){ String idOther = bgOther.getBgPr().getBlipFill().getBlip().getEmbed(); String idThis = importBlip(idOther, src); bgThis.getBgPr().getBlipFill().getBlip().setEmbed(idThis); } return this; }