use of org.apache.poi.hwpf.usermodel.OfficeDrawing in project poi by apache.
the class AbstractWordConverter method processDrawnObject.
protected void processDrawnObject(HWPFDocument doc, CharacterRun characterRun, Element block) {
if (getPicturesManager() == null)
return;
// TODO: support headers
OfficeDrawing officeDrawing = doc.getOfficeDrawingsMain().getOfficeDrawingAt(characterRun.getStartOffset());
if (officeDrawing == null) {
logger.log(POILogger.WARN, "Characters #" + characterRun + " references missing drawn object");
return;
}
byte[] pictureData = officeDrawing.getPictureData();
if (pictureData == null)
// usual shape?
return;
float width = (officeDrawing.getRectangleRight() - officeDrawing.getRectangleLeft()) / AbstractWordUtils.TWIPS_PER_INCH;
float height = (officeDrawing.getRectangleBottom() - officeDrawing.getRectangleTop()) / AbstractWordUtils.TWIPS_PER_INCH;
final PictureType type = PictureType.findMatchingType(pictureData);
String path = getPicturesManager().savePicture(pictureData, type, "s" + characterRun.getStartOffset() + "." + type, width, height);
processDrawnObject(doc, characterRun, officeDrawing, path, block);
}
Aggregations