public void remove(PartName partName) { if (get(partName) != null) { log.info("Deleting part " + partName); parts.remove(partName); } else { log.error("Couldn't delete part " + partName + " - nothing by that name"); } }
protected static Part deepCopyPart(OpcPackage opcPackage, Base targetParent, Part sourcePart, Set<String> relationshipTypes) throws Docx4JException { //check if already handled Part ret = opcPackage.getParts().get(sourcePart.getPartName()); if (ret == null) { // ret = copyPart(sourcePart, opcPackage, ((relationshipTypes == null) || relationshipTypes.contains(sourcePart.getRelationshipType())) ); opcPackage.getParts().put(ret); targetParent.setPartShortcut(ret, ret.getRelationshipType()); } return ret; }
private void putImage(WorksheetPart worksheetPart, SpreadsheetMLPackage pkg, BinaryPartAbstractImage imagePart, CTOneCellAnchor anchor) throws Docx4JException { PartName drawingPart = new PartName(worksheetPart.getPartName().getName().replace("worksheets/sheet", "drawings/drawing")); String imagePartName = imagePart.getPartName().getName(); Drawing drawing = (Drawing) pkg.getParts().get(drawingPart); int currentId = 0; if (drawing == null) { pkg.getParts().remove(relPart.getPartName()); pkg.getParts().put(relPart); pkg.getParts().remove(drawing.getPartName()); pkg.getParts().put(drawing);
public Map<String, ShapeWrapper> getPlaceHoldersFromAcrossLayouts() { if (globalPlaceHolders!=null) { return globalPlaceHolders; } // All this for the 16 possible things defined in STPlaceholderType! Map<String, ShapeWrapper> globalPlaceHolders = new HashMap<String, ShapeWrapper>(); Iterator partIterator = this.getParts().getParts().entrySet().iterator(); while (partIterator.hasNext()) { Map.Entry pairs = (Map.Entry)partIterator.next(); Part p = (Part)pairs.getValue(); if (p instanceof SlideLayoutPart) { SldLayout sldLayout = ((SlideLayoutPart)p).getJaxbElement(); globalPlaceHolders.putAll( ((SlideLayoutPart)p).getIndexedPlaceHolders() ); } } return globalPlaceHolders; }
log.info("adding part with proposed name: " + newPartName.getName()); if (this.getPackage().getParts().get( newPartName )!=null) { part = this.getPackage().getParts().get( newPartName ); this.getPackage().getParts().getParts() ); } else { newPartName = getNewPartName( proposedName, "." , this.getPackage().getParts().getParts() ); if (this.getPackage().getParts().get( newPartName )!=null && mode.equals(AddPartBehaviour.OVERWRITE_IF_NAME_EXISTS)) { if (this.getPackage().getParts().get( newPartName )!=null) {
log.warn(this.getPartName().getName() + " not attached to any package"); } else { this.getPackage().getParts().remove(getPartName());
getPackage().getParts().put(part);
/** * Reinit fields so this pkg object can be re-used. * @since 3.3.7 */ @Override public void reset() { super.reset(); handled = new HashMap<String, String>(); parts = new Parts(); externalResources = new HashMap<ExternalTarget, Part>(); customXmlDataStorageParts= new HashMap<String, CustomXmlPart>(); sourcePartStore=null; targetPartStore=null; docPropsCorePart=null; docPropsExtendedPart=null; docPropsCustomPart=null; name=null; log.info("reset complete"); }
"worksheets/sheet", "drawings/drawing")); String imagePartName = imagePart.getPartName().getName(); Part part = pkg.getParts().get(drawingPart); if (part != null && !(part instanceof Drawing)) throw new ReportFormattingException("Wrong Class: not a Drawing"); pkg.getParts().remove(relPart.getPartName()); pkg.getParts().put(relPart); pkg.getParts().remove(drawing.getPartName()); pkg.getParts().put(drawing);
/** * This method replaces images with 2x2 pixels (which Word scales appropriately) * * @throws InvalidFormatException */ private void handleImages() throws InvalidFormatException { // Apply map to headers/footers for (Entry<PartName, Part> entry : pkg.getParts().getParts().entrySet()) { Part p = entry.getValue(); if (p instanceof ImagePngPart || p instanceof ImageGifPart || p instanceof ImageJpegPart || p instanceof ImageBmpPart || p instanceof ImageTiffPart // Others treated as unsafe ) { ((BinaryPart)p).setBinaryData(PNG_IMAGE_DATA); } } }
log.info("adding part with proposed name: " + newPartName.getName()); if (this.getPackage().getParts().get( newPartName )!=null) { part = this.getPackage().getParts().get( newPartName ); this.getPackage().getParts().getParts() ); } else { newPartName = getNewPartName( proposedName, "." , this.getPackage().getParts().getParts() ); if (this.getPackage().getParts().get( newPartName )!=null && mode.equals(AddPartBehaviour.OVERWRITE_IF_NAME_EXISTS)) { if (this.getPackage().getParts().get( newPartName )!=null) {
/** * @param index * @throws Pptx4jException * @since 3.0 */ public void removeSlide(int index) throws Pptx4jException { List<SldId> sldIds = this.getJaxbElement().getSldIdLst().getSldId(); int zeroBasedCount = sldIds.size() -1; if (index< 0 || index>zeroBasedCount) { throw new Pptx4jException("No slide at index " + index + ". (There are " + sldIds.size() + " slides) "); } Presentation.SldIdLst.SldId entry = this.getJaxbElement().getSldIdLst().getSldId().remove(index); Relationship rel = this.getRelationshipsPart().getRelationshipByID(entry.getRid()); Part part = this.getRelationshipsPart().getPart(rel); this.getPackage().getParts().remove(part.getPartName()); this.getRelationshipsPart().removeRelationship(rel); }
getPackage().getParts().put(part);
/** * Reinit fields so this pkg object can be re-used. * @since 3.3.7 */ @Override public void reset() { super.reset(); handled = new HashMap<String, String>(); parts = new Parts(); externalResources = new HashMap<ExternalTarget, Part>(); customXmlDataStorageParts= new HashMap<String, CustomXmlPart>(); sourcePartStore=null; targetPartStore=null; docPropsCorePart=null; docPropsExtendedPart=null; docPropsCustomPart=null; name=null; log.info("reset complete"); }
public void put(Part part) { if (get(part.getPartName()) != null) { log.info("Overwriting existing part " + part.getPartName()); } else { log.debug("put part " + part.getPartName()); } parts.put(part.getPartName(), part); }
Part parentPart = otherPackage.getParts().get(a.getSourcePartName()); if (a.getPart().getContentType().equals(ContentTypes.RELATIONSHIPS_PART)) { parentPart.setRelationships(null); Part parentPart = otherPackage.getParts().get(a.getSourcePartName()); newRP = parentPart.getRelationshipsPart(true); Part targetPart = otherPackage.getParts().get( new PartName(a.getPart().getName())); Part parentPart = otherPackage.getParts().get(a.getSourcePartName()); newRP = parentPart.getRelationshipsPart(true); Part parentPart = otherPackage.getParts().get(a.getSourcePartName()); Part newPart = FlatOpcXmlImporter.getRawPart(otherPackage.getContentTypeManager(), a.getPart(), null); newPart.getSourceRelationships().add( parentPart.getRelationshipsPart().getRel(new PartName(a.getPart().getName()))); otherPackage.getParts().put(newPart); newPart.setPackage( otherPackage );