/** * @param opcPackage * @param sourcePart * @param proposedRelId * @param ext extension eg png * @return */ public static String createImageName( OpcPackage opcPackage, Base sourcePart, String proposedRelId, String ext) { if (opcPackage instanceof WordprocessingMLPackage) { return PartName.generateUniqueName( sourcePart, proposedRelId, IMAGE_DIR_PREFIX, IMAGE_NAME_PREFIX, ext); } else if (opcPackage instanceof PresentationMLPackage) { return PartName.generateUniqueName( sourcePart, proposedRelId, "/ppt/media/", IMAGE_NAME_PREFIX, ext); } else if (opcPackage instanceof SpreadsheetMLPackage) { return PartName.generateUniqueName( sourcePart, proposedRelId, "/xl/media/", IMAGE_NAME_PREFIX, ext); } else { // Shouldn't happen return PartName.generateUniqueName( sourcePart, proposedRelId, IMAGE_DIR_PREFIX, IMAGE_NAME_PREFIX, ext); } }
/** * This method assumes your package is a docx (not a pptx or xlsx). * * @param sourcePart * @param proposedRelId * @param ext * @return */ @Deprecated public static String createImageName(Base sourcePart, String proposedRelId, String ext) { return PartName.generateUniqueName( sourcePart, proposedRelId, IMAGE_DIR_PREFIX, IMAGE_NAME_PREFIX, ext); }