// }
for (int z = 0; z < p.numCharacterRuns(); z++) {
// character run
CharacterRun run = p.getCharacterRun(z);
// No character styles defined in there??
org.docx4j.wml.RPr rPr = null;
if (run.isBold()) {
// TODO - HIGH PRIORITY- handle other run properties
// esp underline, font size
if (rPr == null) {
rPr = factory.createRPr();
}
org.docx4j.wml.BooleanDefaultTrue boldOn = factory
.createBooleanDefaultTrue();
boldOn.setVal(Boolean.TRUE);
rPr.setB(boldOn);
}
//Process image
if (doc instanceof HWPFDocument
&& ((HWPFDocument) doc).getPicturesTable().hasPicture(run)) {
Picture picture = doc.getPicturesTable().extractPicture(run,
true);
Inline inline;
try {
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage
.createImagePart(wordMLPackage, picture.getContent());
long cx = UnitsOfMeasurement
.twipToEMU(Math.round((double) imagePart
.getImageInfo().getSize().getWidthMpt()
* ((double) picture
.getHorizontalScalingFactor() * 0.00001d))) * 2L;
long cy = UnitsOfMeasurement
.twipToEMU(Math.round((double) imagePart
.getImageInfo().getSize().getHeightMpt()
* ((double) picture
.getVerticalScalingFactor() * 0.00001d))) * 2L;
inline = imagePart.createImageInline(null, "", ID1++,
ID2++, cx, cy, false);
org.docx4j.wml.R imgrun = factory.createR();
org.docx4j.wml.Drawing drawing = factory.createDrawing();
imgrun.getContent().add(drawing);
drawing.getAnchorOrInline().add(inline);
wmlP.getContent().add(imgrun);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else {
// character run text
String text = run.text();
// show us the text
log.debug("Processing: " + text);
String cleansed = stripNonValidXMLCharacters(text);