Program: 75344
Project: 75344
Buggy source:
public void startForeign(IForeignContent foreign){
  IStyle mergedStyle=foreign.getStyle();
  logger.log(Level.FINE,"String_Node_Str");
  resizeTemplateElement(foreign);
  DimensionType x=foreign.getX();
  DimensionType y=foreign.getY();
  DimensionType width=foreign.getWidth();
  DimensionType height=foreign.getHeight();
  int display;
  display=getElementType(x,y,width,height,mergedStyle);
  if (foreign.getGenerateBy() instanceof TemplateDesign) {
    String bookmark=foreign.getBookmark();
    if (bookmark == null) {
      bookmark=idGenerator.generateUniqueID();
      foreign.setBookmark(bookmark);
    }
  }
  String tagName;
  String url=validate(foreign.getHyperlinkAction());
  boolean metadataOutput=false;
  if (url != null) {
    if (enableMetadata) {
      metadataOutput=metadataEmitter.startForeign(foreign,HTMLTags.TAG_SPAN);
    }
    tagName=HTMLTags.TAG_A;
    outputAction(foreign.getHyperlinkAction(),url);
  }
 else {
    if (enableMetadata) {
      metadataOutput=metadataEmitter.startForeign(foreign,HTMLEmitterUtil.getTagByType(display,DISPLAY_FLAG_ALL));
    }
    tagName=openTagByType(display,DISPLAY_FLAG_ALL);
  }
  setStyleName(foreign.getStyleClass());
  if (!metadataOutput) {
    outputBookmark(foreign,tagName);
  }
  writer.attribute(HTMLTags.ATTR_TITLE,foreign.getHelpText());
  if (isTalbeTemplateElement(foreign)) {
    mergedStyle.setProperty(IStyle.STYLE_BORDER_TOP_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_BORDER_BOTTOM_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_BORDER_LEFT_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_BORDER_RIGHT_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_FONT_FAMILY,IStyle.SANS_SERIF_VALUE);
  }
  StringBuffer styleBuffer=new StringBuffer();
  htmlEmitter.buildForeignStyle(foreign,styleBuffer,display,url);
  writer.attribute(HTMLTags.ATTR_STYLE,styleBuffer.toString());
  String rawType=foreign.getRawType();
  boolean isHtml=IForeignContent.HTML_TYPE.equalsIgnoreCase(rawType);
  if (isHtml) {
    htmlEmitter.handleVerticalAlignBegine(foreign);
    outputHtmlText(foreign);
    htmlEmitter.handleVerticalAlignEnd(foreign);
  }
  writer.closeTag(tagName);
  if (enableMetadata) {
    metadataEmitter.endForeign(foreign);
  }
  cellFilled=true;
}

Fixed version (ground truth):
public void startForeign(IForeignContent foreign){
  IStyle mergedStyle=foreign.getStyle();
  logger.log(Level.FINE,"String_Node_Str");
  resizeTemplateElement(foreign);
  DimensionType x=foreign.getX();
  DimensionType y=foreign.getY();
  DimensionType width=foreign.getWidth();
  DimensionType height=foreign.getHeight();
  int display;
  display=getElementType(x,y,width,height,mergedStyle);
  if (foreign.getGenerateBy() instanceof TemplateDesign) {
    String bookmark=foreign.getBookmark();
    if (bookmark == null) {
      bookmark=idGenerator.generateUniqueID();
      foreign.setBookmark(bookmark);
    }
  }
  boolean isTemplate=false;
  Object genBy=foreign.getGenerateBy();
  if (genBy instanceof TemplateDesign) {
    isTemplate=true;
    writer.openTag(HTMLTags.TAG_DIV);
    writer.attribute(HTMLTags.ATTR_ALIGN,"String_Node_Str");
  }
  String tagName;
  String url=validate(foreign.getHyperlinkAction());
  boolean metadataOutput=false;
  if (url != null) {
    if (enableMetadata) {
      metadataOutput=metadataEmitter.startForeign(foreign,HTMLTags.TAG_SPAN);
    }
    tagName=HTMLTags.TAG_A;
    outputAction(foreign.getHyperlinkAction(),url);
  }
 else {
    if (enableMetadata) {
      metadataOutput=metadataEmitter.startForeign(foreign,HTMLEmitterUtil.getTagByType(display,DISPLAY_FLAG_ALL));
    }
    tagName=openTagByType(display,DISPLAY_FLAG_ALL);
  }
  setStyleName(foreign.getStyleClass());
  if (!metadataOutput) {
    outputBookmark(foreign,tagName);
  }
  writer.attribute(HTMLTags.ATTR_TITLE,foreign.getHelpText());
  if (isTalbeTemplateElement(foreign)) {
    mergedStyle.setProperty(IStyle.STYLE_BORDER_TOP_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_BORDER_BOTTOM_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_BORDER_LEFT_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_BORDER_RIGHT_STYLE,IStyle.DOTTED_VALUE);
    mergedStyle.setProperty(IStyle.STYLE_FONT_FAMILY,IStyle.SANS_SERIF_VALUE);
  }
  StringBuffer styleBuffer=new StringBuffer();
  htmlEmitter.buildForeignStyle(foreign,styleBuffer,display,url);
  writer.attribute(HTMLTags.ATTR_STYLE,styleBuffer.toString());
  String rawType=foreign.getRawType();
  boolean isHtml=IForeignContent.HTML_TYPE.equalsIgnoreCase(rawType);
  if (isHtml) {
    htmlEmitter.handleVerticalAlignBegine(foreign);
    outputHtmlText(foreign);
    htmlEmitter.handleVerticalAlignEnd(foreign);
  }
  writer.closeTag(tagName);
  if (isTemplate) {
    writer.openTag(HTMLTags.TAG_DIV);
  }
  if (enableMetadata) {
    metadataEmitter.endForeign(foreign);
  }
  cellFilled=true;
}