Program: 185131
Project: 185131
Buggy source:
/** 
 * Create a <wp:inline> element suitable for this image, which can be embedded in w:p/w:r/w:drawing
 * @param filenameHint Any text, for example the original filename
 * @param altText  Like HTML's alt text
 * @param id1   An id unique in the document
 * @param id2   Another id unique in the documentNone of these things seem to be exposed in Word 2007's user interface, but Word won't open the document if  any of the attributes these go in (except @ desc) aren't present!
 * @throws Exception
 */
public Inline createImageInline(String filenameHint,String altText,int id1,int id2) throws Exception {
  if (filenameHint == null) {
    filenameHint="String_Node_Str";
  }
  if (altText == null) {
    altText="String_Node_Str";
  }
  WordprocessingMLPackage wordMLPackage=((WordprocessingMLPackage)this.getPackage());
  MainDocumentPart documentPart=wordMLPackage.getMainDocumentPart();
  org.docx4j.wml.Document wmlDocumentEl=(org.docx4j.wml.Document)documentPart.getJaxbElement();
  SectPr sectPr=wmlDocumentEl.getBody().getSectPr();
  double writableWidthTwips;
  if (sectPr == null) {
    log.debug("String_Node_Str");
    writableWidthTwips=DEFAULT_PAGE_WIDTH_TWIPS - (DEFAULT_LEFT_MARGIN_TWIPS + DEFAULT_RIGHT_MARGIN_TWIPS);
  }
 else {
    PgSz pgSz=sectPr.getPgSz();
    PgMar pgMar=sectPr.getPgMar();
    double pageWidth;
    double leftMargin;
    double rightMargin;
    if (pgSz == null) {
      pageWidth=DEFAULT_PAGE_WIDTH_TWIPS;
    }
 else {
      pageWidth=pgSz.getW().doubleValue();
    }
    if (pgMar == null || pgMar.getLeft() == null) {
      leftMargin=DEFAULT_LEFT_MARGIN_TWIPS;
    }
 else {
      leftMargin=pgMar.getLeft().doubleValue();
    }
    if (pgMar == null || pgMar.getRight() == null) {
      rightMargin=DEFAULT_RIGHT_MARGIN_TWIPS;
    }
 else {
      rightMargin=pgMar.getRight().doubleValue();
    }
    writableWidthTwips=pageWidth - (leftMargin + rightMargin);
  }
  log.debug("String_Node_Str" + writableWidthTwips);
  ImageSize size=imageInfo.getSize();
  Dimension2D dPt=size.getDimensionPt();
  double imageWidthTwips=dPt.getWidth() * 20;
  log.debug("String_Node_Str" + imageWidthTwips);
  long cx;
  long cy;
  if (imageWidthTwips > writableWidthTwips) {
    log.debug("String_Node_Str");
    cx=twipToEMU(writableWidthTwips);
    cy=twipToEMU(dPt.getHeight() * 20 * writableWidthTwips / imageWidthTwips);
  }
 else {
    log.debug("String_Node_Str");
    cx=twipToEMU(imageWidthTwips);
    cy=twipToEMU(dPt.getHeight() * 20);
  }
  log.debug("String_Node_Str" + cx + "String_Node_Str"+ cy);
  String ml="String_Node_Str" + namespaces + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  java.util.HashMap<String,String> mappings=new java.util.HashMap<String,String>();
  mappings.put("String_Node_Str",Long.toString(cx));
  mappings.put("String_Node_Str",Long.toString(cy));
  mappings.put("String_Node_Str",filenameHint);
  mappings.put("String_Node_Str",altText);
  mappings.put("String_Node_Str",rel.getId());
  mappings.put("String_Node_Str",Integer.toString(id1));
  mappings.put("String_Node_Str",Integer.toString(id2));
  Object o=org.docx4j.XmlUtils.unmarshallFromTemplate(ml,mappings);
  Inline inline=(Inline)((JAXBElement)o).getValue();
  return inline;
}

Fixed version (ground truth):
/** 
 * Create a <wp:inline> element suitable for this image, which can be embedded in w:p/w:r/w:drawing, specifying height and width.  Note that you'd ordinarily use one of the methods which don't require you to specify height (cy). 
 * @param filenameHint Any text, for example the original filename
 * @param altText Like HTML's alt text
 * @param id1 An id unique in the document
 * @param id2 Another id unique in the document None of these things seem to be exposed in Word 2007's user interface, but Word won't open the document if any of the attributes these go in (except @ desc) aren't present!
 * @param cx    Image width in twip
 * @param cy    Image height in twip
 * @throws Exception
 */
public Inline createImageInline(String filenameHint,String altText,int id1,int id2,long cx,long cy) throws Exception {
  if (filenameHint == null) {
    filenameHint="String_Node_Str";
  }
  if (altText == null) {
    altText="String_Node_Str";
  }
  String ml="String_Node_Str" + namespaces + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  java.util.HashMap<String,String> mappings=new java.util.HashMap<String,String>();
  mappings.put("String_Node_Str",Long.toString(cx));
  mappings.put("String_Node_Str",Long.toString(cy));
  mappings.put("String_Node_Str",filenameHint);
  mappings.put("String_Node_Str",altText);
  mappings.put("String_Node_Str",rel.getId());
  mappings.put("String_Node_Str",Integer.toString(id1));
  mappings.put("String_Node_Str",Integer.toString(id2));
  Object o=org.docx4j.XmlUtils.unmarshallFromTemplate(ml,mappings);
  Inline inline=(Inline)((JAXBElement)o).getValue();
  return inline;
}