Add check for no image in Draw parser

This commit is contained in:
Georgy Litvinov 2020-02-06 16:39:36 +01:00
parent f0a377345e
commit de9dc7e456

View file

@ -597,20 +597,25 @@ public class DrawParser extends Parser {
} }
} }
else { else {
// In all other cases, create an img element // In all other cases, create an img element
if (bgd!=null && !bgd.isLinked() && !bgd.isRecycled() && !bEmbedImg) { converter.addDocument(bgd); } if (bgd != null && !bgd.isLinked() && !bgd.isRecycled() && !bEmbedImg) {
Element image = converter.createElement("img"); converter.addDocument(bgd);
String sName = Misc.getAttribute(getFrame(onode),XMLString.DRAW_NAME); }
converter.addTarget(image,sName+"|graphic"); Element image = converter.createElement("img");
if (!bEmbedImg || bgd.isLinked()) { String sName = Misc.getAttribute(getFrame(onode), XMLString.DRAW_NAME);
image.setAttribute("src",sFileName); converter.addTarget(image, sName + "|graphic");
} if (!bEmbedImg || bgd.isLinked()) {
else { image.setAttribute("src", sFileName);
StringBuilder buf = new StringBuilder(); } else {
buf.append("data:").append(bgd.getMIMEType()).append(";base64,") StringBuilder buf = new StringBuilder();
.append(DatatypeConverter.printBase64Binary(bgd.getData())); buf.append("data:");
image.setAttribute("src", buf.toString()); buf.append(bgd.getMIMEType());
} buf.append(";base64,");
if (bgd.getData() != null) {
buf.append(DatatypeConverter.printBase64Binary(bgd.getData()));
}
image.setAttribute("src", buf.toString());
}
// Add alternative text, using either alt.text, name or file name // Add alternative text, using either alt.text, name or file name
Element desc = Misc.getChildByTagName(frame,XMLString.SVG_DESC); Element desc = Misc.getChildByTagName(frame,XMLString.SVG_DESC);
if (desc==null) { if (desc==null) {