nus-yam/ex-repair huggingface dataset:
Program: 56523
Project: 56523
Buggy source:
private void handleRefDependent(NBookSeries bookSeries,HashSet<Ref> dependentSet){
  new RefDependentHandler(bookSeries).handleRefDependent(dependentSet);
}

Fixed version (ground truth):
private void handleRefDependent(NBookSeries bookSeries,HashSet<Ref> dependentSet){
  new RefDependentHelper(bookSeries).handle(dependentSet);
}
Program: 56524
Project: 56524
Buggy source:
private void handleRefNotifySizeChange(NBookSeries bookSeries,HashSet<Ref> notifySet){
  new RefNotifySizeChangeHandler(bookSeries).handleRefNotify(notifySet);
}

Fixed version (ground truth):
private void handleRefNotifySizeChange(NBookSeries bookSeries,HashSet<Ref> notifySet){
  new RefNotifySizeChangeHelper(bookSeries).handle(notifySet);
}
Program: 56525
Project: 56525
Buggy source:
@Override public void setEditText(final String editText){
  final InputEngine ie=EngineFactory.getInstance().createInputEngine();
  final ResultWrap<InputResult> input=new ResultWrap<InputResult>();
  new CellVisitorTask(new CellVisitor(){
    public boolean visit(    NCell cell){
      InputResult result;
      if ((result=input.get()) == null) {
        result=ie.parseInput(editText == null ? "String_Node_Str" : editText,cell.getCellStyle().getDataFormat(),new InputParseContext(Locales.getCurrent()));
        input.set(result);
      }
      Object cellval=cell.getValue();
      Object resultVal=result.getValue();
      String format=result.getFormat();
      if (euqlas(cellval,resultVal)) {
        return false;
      }
switch (result.getType()) {
case BLANK:
        cell.clearValue();
      break;
case BOOLEAN:
    cell.setBooleanValue((Boolean)resultVal);
  break;
case FORMULA:
cell.setFormulaValue((String)resultVal);
break;
case NUMBER:
if (resultVal instanceof Date) {
cell.setDateValue((Date)resultVal);
}
 else {
cell.setNumberValue((Double)resultVal);
}
break;
case STRING:
cell.setStringValue((String)resultVal);
break;
case ERROR:
default :
cell.setValue(resultVal);
}
String oldFormat=cell.getCellStyle().getDataFormat();
if (format != null && NCellStyle.FORMAT_GENERAL.equals(oldFormat)) {
NStyles.setDataFormat(cell.getSheet(),cell.getRowIndex(),cell.getColumnIndex(),format);
}
return true;
}
}
).doInWriteLock(getLock());
}

Fixed version (ground truth):
@Override public void setEditText(final String editText){
  final InputEngine ie=EngineFactory.getInstance().createInputEngine();
  final ResultWrap<InputResult> input=new ResultWrap<InputResult>();
  new CellVisitorTask(new CellVisitor(){
    public boolean visit(    NCell cell){
      InputResult result;
      if ((result=input.get()) == null) {
        result=ie.parseInput(editText == null ? "String_Node_Str" : editText,cell.getCellStyle().getDataFormat(),new InputParseContext(Locales.getCurrent()));
        input.set(result);
      }
      Object cellval=cell.getValue();
      Object resultVal=result.getValue();
      String format=result.getFormat();
      if (euqlas(cellval,resultVal)) {
        return false;
      }
switch (result.getType()) {
case BLANK:
        cell.clearValue();
      break;
case BOOLEAN:
    cell.setBooleanValue((Boolean)resultVal);
  break;
case FORMULA:
cell.setFormulaValue((String)resultVal);
break;
case NUMBER:
if (resultVal instanceof Date) {
cell.setDateValue((Date)resultVal);
}
 else {
cell.setNumberValue((Double)resultVal);
}
break;
case STRING:
cell.setStringValue((String)resultVal);
break;
case ERROR:
default :
cell.setValue(resultVal);
}
String oldFormat=cell.getCellStyle().getDataFormat();
if (format != null && NCellStyle.FORMAT_GENERAL.equals(oldFormat)) {
StyleUtil.setDataFormat(cell.getSheet(),cell.getRowIndex(),cell.getColumnIndex(),format);
}
return true;
}
}
).doInWriteLock(getLock());
}
Program: 56526
Project: 56526
Buggy source:
private void handleRefNotifyContentChange(NBookSeries bookSeries,HashSet<Ref> notifySet){
  new RefNotifyContentChangeHandler(bookSeries).handleRefNotify(notifySet);
}

Fixed version (ground truth):
private void handleRefNotifyContentChange(NBookSeries bookSeries,HashSet<Ref> notifySet){
  new RefNotifyContentChangeHelper(bookSeries).handle(notifySet);
}
Program: 56529
Project: 56529
Buggy source:
@Override public void setFormulaValue(String formula){
  checkOrphan();
  Validations.argNotNull(formula);
  FormulaEngine fe=EngineFactory.getInstance().createFormulaEngine();
  FormulaExpression expr=fe.parse(formula,new FormulaParseContext(this,new RefImpl(this)));
  setValue(expr);
}

Fixed version (ground truth):
@Override public void setFormulaValue(String formula){
  checkOrphan();
  Validations.argNotNull(formula);
  clearValue();
  FormulaEngine fe=EngineFactory.getInstance().createFormulaEngine();
  FormulaExpression expr=fe.parse(formula,new FormulaParseContext(this,new RefImpl(this)));
  setValue(expr);
}
Program: 56530
Project: 56530
Buggy source:
@Override public void clearValue(){
  checkOrphan();
  value=null;
  richText=null;
  clearFormulaDependency();
  clearFormulaResultCache();
  type=CellType.BLANK;
}

Fixed version (ground truth):
private void clearValue(boolean clearDependency){
  checkOrphan();
  if (clearDependency) {
    clearFormulaDependency();
  }
  clearFormulaResultCache();
  value=null;
  richText=null;
  type=CellType.BLANK;
}
Program: 56531
Project: 56531
Buggy source:
private void clearFormulaDependency(){
  if (type == CellType.FORMULA) {
    Ref ref=new RefImpl(this);
    ((BookSeriesAdv)row.getSheet().getBook().getBookSeries()).getDependencyTable().clearDependents(ref);
  }
}

Fixed version (ground truth):
private void clearFormulaDependency(){
  if (type == CellType.FORMULA) {
    Ref ref=new RefImpl(this);
    ((BookSeriesAdv)getSheet().getBook().getBookSeries()).getDependencyTable().clearDependents(ref);
  }
}
Program: 56532
Project: 56532
Buggy source:
@Override public void setValue(Object newvalue){
  if (value != null && value.equals(newvalue)) {
    return;
  }
  clearValue();
  if (newvalue == null) {
  }
 else   if (newvalue instanceof String) {
    if ("String_Node_Str".equals(newvalue)) {
      type=CellType.BLANK;
      newvalue=null;
    }
 else     if (isFormula((String)newvalue)) {
      setFormulaValue(((String)newvalue).substring(1));
      return;
    }
 else {
      type=CellType.STRING;
    }
  }
 else   if (newvalue instanceof FormulaExpression) {
    type=CellType.FORMULA;
  }
 else   if (newvalue instanceof Date) {
    type=CellType.NUMBER;
    newvalue=EngineFactory.getInstance().getCalendarUtil().dateToDoubleValue((Date)newvalue,false);
  }
 else   if (newvalue instanceof Boolean) {
    type=CellType.BOOLEAN;
  }
 else   if (newvalue instanceof Double) {
    type=CellType.NUMBER;
  }
 else   if (newvalue instanceof Number) {
    type=CellType.NUMBER;
    newvalue=((Number)newvalue).doubleValue();
  }
 else   if (newvalue instanceof ErrorValue) {
    type=CellType.ERROR;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + newvalue + "String_Node_Str");
  }
  value=newvalue;
}

Fixed version (ground truth):
@Override public void setValue(Object newvalue){
  if (value != null && value.equals(newvalue)) {
    return;
  }
  clearValue(!(newvalue instanceof FormulaExpression));
  if (newvalue == null) {
  }
 else   if (newvalue instanceof String) {
    if ("String_Node_Str".equals(newvalue)) {
      type=CellType.BLANK;
      newvalue=null;
    }
 else     if (isFormula((String)newvalue)) {
      setFormulaValue(((String)newvalue).substring(1));
      return;
    }
 else {
      type=CellType.STRING;
    }
  }
 else   if (newvalue instanceof FormulaExpression) {
    type=CellType.FORMULA;
  }
 else   if (newvalue instanceof Date) {
    type=CellType.NUMBER;
    newvalue=EngineFactory.getInstance().getCalendarUtil().dateToDoubleValue((Date)newvalue,false);
  }
 else   if (newvalue instanceof Boolean) {
    type=CellType.BOOLEAN;
  }
 else   if (newvalue instanceof Double) {
    type=CellType.NUMBER;
  }
 else   if (newvalue instanceof Number) {
    type=CellType.NUMBER;
    newvalue=((Number)newvalue).doubleValue();
  }
 else   if (newvalue instanceof ErrorValue) {
    type=CellType.ERROR;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + newvalue + "String_Node_Str");
  }
  value=newvalue;
}
Program: 56533
Project: 56533
Buggy source:
private void checkColumnArrayStatus(){
  if (true)   return;
  ColumnArrayAdv prev=null;
  System.out.println("String_Node_Str");
  for (  ColumnArrayAdv array : columnArrays.values()) {
    System.out.println("String_Node_Str" + array.getIndex() + "String_Node_Str"+ array.getLastIndex());
  }
  for (  ColumnArrayAdv array : columnArrays.values()) {
    if (prev == null) {
      if (array.getIndex() != 0) {
        throw new IllegalStateException("String_Node_Str" + array.getIndex());
      }
    }
 else {
      if (prev.getLastIndex() + 1 != array.getIndex()) {
        throw new IllegalStateException("String_Node_Str" + prev.getLastIndex() + "String_Node_Str"+ array.getIndex());
      }
    }
    prev=array;
  }
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * internal use only for developing/test state, should remove when stable
 */
private void checkColumnArrayStatus(){
  if (!DEBUG)   return;
  ColumnArrayAdv prev=null;
  try {
    for (    ColumnArrayAdv array : columnArrays.values()) {
      if (prev == null) {
        if (array.getIndex() != 0) {
          throw new IllegalStateException("String_Node_Str" + array.getIndex());
        }
      }
 else {
        if (prev.getLastIndex() + 1 != array.getIndex()) {
          throw new IllegalStateException("String_Node_Str" + prev.getLastIndex() + "String_Node_Str"+ array.getIndex());
        }
      }
      prev=array;
    }
  }
 catch (  RuntimeException x) {
    System.out.println("String_Node_Str");
    for (    ColumnArrayAdv array : columnArrays.values()) {
      System.out.println("String_Node_Str" + array.getIndex() + "String_Node_Str"+ array.getLastIndex());
    }
    System.out.println("String_Node_Str");
    throw x;
  }
}
Program: 56534
Project: 56534
Buggy source:
@Override public NColumnArray setupColumnArray(int index,int lastIndex){
  if (index < 0 && lastIndex > index) {
    throw new IllegalArgumentException(index + "String_Node_Str" + lastIndex);
  }
  int start1, end1;
  start1=end1=-1;
  ColumnArrayAdv ov=columnArrays.overlap(index,lastIndex);
  if (ov != null) {
    throw new IllegalStateException("String_Node_Str" + index + "String_Node_Str"+ lastIndex+ "String_Node_Str"+ ov);
  }
  if (columnArrays.size() > 0) {
    start1=columnArrays.lastLastKey() + 1;
  }
  end1=index - 1;
  ColumnArrayAdv array;
  if (start1 <= end1 && end1 > -1) {
    array=new ColumnArrayImpl(this,start1,end1);
    columnArrays.put(array);
  }
  array=new ColumnArrayImpl(this,index,lastIndex);
  columnArrays.put(array);
  checkColumnArrayStatus();
  return array;
}

Fixed version (ground truth):
@Override public NColumnArray setupColumnArray(int index,int lastIndex){
  if (index < 0 && lastIndex > index) {
    throw new IllegalArgumentException(index + "String_Node_Str" + lastIndex);
  }
  int start1, end1;
  start1=end1=-1;
  ColumnArrayAdv ov=columnArrays.overlap(index,lastIndex);
  if (ov != null) {
    throw new IllegalStateException("String_Node_Str" + index + "String_Node_Str"+ lastIndex+ "String_Node_Str"+ ov);
  }
  if (columnArrays.size() == 0) {
    start1=0;
  }
 else {
    start1=columnArrays.lastLastKey() + 1;
  }
  end1=index - 1;
  ColumnArrayAdv array;
  if (start1 <= end1 && end1 > -1) {
    array=new ColumnArrayImpl(this,start1,end1);
    columnArrays.put(array);
  }
  array=new ColumnArrayImpl(this,index,lastIndex);
  columnArrays.put(array);
  checkColumnArrayStatus();
  return array;
}
Program: 56536
Project: 56536
Buggy source:
@Before public void beforeTest(){
  Locales.setThreadLocal(Locale.TAIWAN);
}

Fixed version (ground truth):
@Before public void beforeTest(){
  Locales.setThreadLocal(Locale.TAIWAN);
  SheetImpl.DEBUG=true;
}
Program: 56537
Project: 56537
Buggy source:
/** 
 * internal use only for developing/test state, should remove when stable
 */
private void checkColumnArrayStatus(){
  if (!DEBUG)   return;
  ColumnArrayAdv prev=null;
  try {
    for (    ColumnArrayAdv array : columnArrays.values()) {
      if (prev == null) {
        if (array.getIndex() != 0) {
          throw new IllegalStateException("String_Node_Str" + array.getIndex());
        }
      }
 else {
        if (prev.getLastIndex() + 1 != array.getIndex()) {
          throw new IllegalStateException("String_Node_Str" + prev.getLastIndex() + "String_Node_Str"+ array.getIndex());
        }
      }
      prev=array;
    }
  }
 catch (  RuntimeException x) {
    System.out.println("String_Node_Str");
    for (    ColumnArrayAdv array : columnArrays.values()) {
      System.out.println("String_Node_Str" + array.getIndex() + "String_Node_Str"+ array.getLastIndex());
    }
    System.out.println("String_Node_Str");
    throw x;
  }
}

Fixed version (ground truth):
private void checkColumnArrayStatus(){
  if (!DEBUG)   return;
  ColumnArrayAdv prev=null;
  try {
    for (    ColumnArrayAdv array : columnArrays.values()) {
      if (prev == null) {
        if (array.getIndex() != 0) {
          throw new IllegalStateException("String_Node_Str" + array.getIndex());
        }
      }
 else {
        if (prev.getLastIndex() + 1 != array.getIndex()) {
          throw new IllegalStateException("String_Node_Str" + prev.getLastIndex() + "String_Node_Str"+ array.getIndex());
        }
      }
      prev=array;
    }
  }
 catch (  RuntimeException x) {
    System.out.println("String_Node_Str");
    for (    ColumnArrayAdv array : columnArrays.values()) {
      System.out.println("String_Node_Str" + array.getIndex() + "String_Node_Str"+ array.getLastIndex());
    }
    System.out.println("String_Node_Str");
    throw x;
  }
}
Program: 56538
Project: 56538
Buggy source:
void evalFormula(){
  if (!evaluated) {
    FormulaEngine fe=EngineFactory.getInstance().createFormulaEngine();
    NBook book=chart.getSheet().getBook();
    if (nameExpr != null) {
      EvaluationResult result=fe.evaluate(nameExpr,new FormulaEvaluationContext(book));
      Object val=result.getValue();
      if (result.getType() == ResultType.SUCCESS) {
        evalNameResult=val;
      }
 else       if (result.getType() == ResultType.ERROR) {
        evalNameResult=(val instanceof ErrorValue) ? val : new ErrorValue(ErrorValue.INVALID_NAME);
      }
    }
    if (valueExpr != null) {
      EvaluationResult result=fe.evaluate(valueExpr,new FormulaEvaluationContext(book));
      Object val=result.getValue();
      if (result.getType() == ResultType.SUCCESS) {
        evalValuesResult=val;
      }
 else       if (result.getType() == ResultType.ERROR) {
        evalValuesResult=(val instanceof ErrorValue) ? val : new ErrorValue(ErrorValue.INVALID_NAME);
      }
    }
    if (yValueExpr != null) {
      EvaluationResult result=fe.evaluate(yValueExpr,new FormulaEvaluationContext(book));
      Object val=result.getValue();
      if (result.getType() == ResultType.SUCCESS) {
        evalYValuesResult=val;
      }
 else       if (result.getType() == ResultType.ERROR) {
        evalYValuesResult=(val instanceof ErrorValue) ? val : new ErrorValue(ErrorValue.INVALID_NAME);
      }
    }
    evaluated=true;
  }
}

Fixed version (ground truth):
void evalFormula(){
  if (!evaluated) {
    FormulaEngine fe=EngineFactory.getInstance().createFormulaEngine();
    NSheet sheet=chart.getSheet();
    if (nameExpr != null) {
      EvaluationResult result=fe.evaluate(nameExpr,new FormulaEvaluationContext(sheet));
      Object val=result.getValue();
      if (result.getType() == ResultType.SUCCESS) {
        evalNameResult=val;
      }
 else       if (result.getType() == ResultType.ERROR) {
        evalNameResult=(val instanceof ErrorValue) ? val : new ErrorValue(ErrorValue.INVALID_NAME);
      }
    }
    if (valueExpr != null) {
      EvaluationResult result=fe.evaluate(valueExpr,new FormulaEvaluationContext(sheet));
      Object val=result.getValue();
      if (result.getType() == ResultType.SUCCESS) {
        evalValuesResult=val;
      }
 else       if (result.getType() == ResultType.ERROR) {
        evalValuesResult=(val instanceof ErrorValue) ? val : new ErrorValue(ErrorValue.INVALID_NAME);
      }
    }
    if (yValueExpr != null) {
      EvaluationResult result=fe.evaluate(yValueExpr,new FormulaEvaluationContext(sheet));
      Object val=result.getValue();
      if (result.getType() == ResultType.SUCCESS) {
        evalYValuesResult=val;
      }
 else       if (result.getType() == ResultType.ERROR) {
        evalYValuesResult=(val instanceof ErrorValue) ? val : new ErrorValue(ErrorValue.INVALID_NAME);
      }
    }
    evaluated=true;
  }
}
Program: 56539
Project: 56539
Buggy source:
@Override public void add(Ref dependant,Ref precedent){
  Set<Ref> precedents=map.get(dependant);
  if (precedents == null) {
    precedents=new HashSet<Ref>();
    map.put(dependant,precedents);
  }
  precedents.add(precedent);
}

Fixed version (ground truth):
@Override public void add(Ref dependant,Ref precedent){
  Set<Ref> precedents=map.get(dependant);
  if (precedents == null) {
    precedents=new LinkedHashSet<Ref>();
    map.put(dependant,precedents);
  }
  precedents.add(precedent);
}
Program: 56540
Project: 56540
Buggy source:
@Override public Set<Ref> getDependents(Ref precedent){
  Set<Ref> result=new HashSet<Ref>();
  Queue<Ref> queue=new LinkedList<Ref>();
  queue.add(precedent);
  while (!queue.isEmpty()) {
    Ref p=queue.remove();
    for (    Entry<Ref,Set<Ref>> entry : map.entrySet()) {
      Ref target=entry.getKey();
      if (!result.contains(target)) {
        for (        Ref pre : entry.getValue()) {
          if (isMatched(pre,p)) {
            result.add(target);
            queue.add(target);
            break;
          }
        }
      }
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public Set<Ref> getDependents(Ref precedent){
  Set<Ref> result=new LinkedHashSet<Ref>();
  Queue<Ref> queue=new LinkedList<Ref>();
  queue.add(precedent);
  while (!queue.isEmpty()) {
    Ref p=queue.remove();
    for (    Entry<Ref,Set<Ref>> entry : map.entrySet()) {
      Ref target=entry.getKey();
      if (!result.contains(target)) {
        for (        Ref pre : entry.getValue()) {
          if (isMatched(pre,p)) {
            result.add(target);
            queue.add(target);
            break;
          }
        }
      }
    }
  }
  return result;
}
Program: 56543
Project: 56543
Buggy source:
private HeaderPositionHelper myGetColumnPositionHelper(NSheet sheet){
  HelperContainer<HeaderPositionHelper> helpers=(HelperContainer)getAttribute(COLUMN_SIZE_HELPER_KEY);
  if (helpers == null) {
    setAttribute(COLUMN_SIZE_HELPER_KEY,helpers=new HelperContainer<HeaderPositionHelper>());
  }
  final String sheetId=sheet.getId();
  HeaderPositionHelper helper=helpers.getHelper(sheetId);
  if (helper == null) {
    final int defaultColSize=sheet.getDefaultColumnWidth();
    List<HeaderPositionInfo> infos=new ArrayList<HeaderPositionInfo>();
    for (    NColumn column : sheet.getColumnList()) {
      final boolean hidden=column.isHidden();
      final int columnWidth=column.getWidth();
      if (columnWidth != defaultColSize || hidden) {
        infos.add(new HeaderPositionInfo(column.getIndex(),columnWidth,_custColId.next(),hidden));
      }
    }
    helpers.putHelper(sheetId,helper=new HeaderPositionHelper(defaultColSize,infos));
  }
  return helper;
}

Fixed version (ground truth):
private HeaderPositionHelper myGetColumnPositionHelper(NSheet sheet){
  HelperContainer<HeaderPositionHelper> helpers=(HelperContainer)getAttribute(COLUMN_SIZE_HELPER_KEY);
  if (helpers == null) {
    setAttribute(COLUMN_SIZE_HELPER_KEY,helpers=new HelperContainer<HeaderPositionHelper>());
  }
  final String sheetId=sheet.getId();
  HeaderPositionHelper helper=helpers.getHelper(sheetId);
  if (helper == null) {
    final int defaultColSize=sheet.getDefaultColumnWidth();
    List<HeaderPositionInfo> infos=new ArrayList<HeaderPositionInfo>();
    Iterator<NColumn> iter=sheet.getColumnIterator();
    while (iter.hasNext()) {
      NColumn column=iter.next();
      final boolean hidden=column.isHidden();
      final int columnWidth=column.getWidth();
      if (columnWidth != defaultColSize || hidden) {
        infos.add(new HeaderPositionInfo(column.getIndex(),columnWidth,_custColId.next(),hidden));
      }
    }
    helpers.putHelper(sheetId,helper=new HeaderPositionHelper(defaultColSize,infos));
  }
  return helper;
}
Program: 56544
Project: 56544
Buggy source:
private HeaderPositionHelper[] getPositionHelpers(NSheet sheet){
  if (sheet == null) {
    return null;
  }
  HelperContainer<HeaderPositionHelper> helpers=(HelperContainer)getAttribute(ROW_SIZE_HELPER_KEY);
  if (helpers == null) {
    setAttribute(ROW_SIZE_HELPER_KEY,helpers=new HelperContainer<HeaderPositionHelper>());
  }
  final String sheetId=sheet.getId();
  HeaderPositionHelper helper=helpers.getHelper(sheetId);
  if (helper == null) {
    int defaultSize=this.getRowheight();
    List<HeaderPositionInfo> infos=new ArrayList<HeaderPositionInfo>();
    for (    NRow row : sheet.getRowList()) {
      final boolean hidden=row.isHidden();
      final int height=row.getHeight();
      if (height != defaultSize || hidden) {
        infos.add(new HeaderPositionInfo(row.getIndex(),height,_custRowId.next(),hidden));
      }
    }
    helpers.putHelper(sheetId,helper=new HeaderPositionHelper(defaultSize,infos));
  }
  return new HeaderPositionHelper[]{helper,myGetColumnPositionHelper(sheet)};
}

Fixed version (ground truth):
private HeaderPositionHelper[] getPositionHelpers(NSheet sheet){
  if (sheet == null) {
    return null;
  }
  HelperContainer<HeaderPositionHelper> helpers=(HelperContainer)getAttribute(ROW_SIZE_HELPER_KEY);
  if (helpers == null) {
    setAttribute(ROW_SIZE_HELPER_KEY,helpers=new HelperContainer<HeaderPositionHelper>());
  }
  final String sheetId=sheet.getId();
  HeaderPositionHelper helper=helpers.getHelper(sheetId);
  if (helper == null) {
    int defaultSize=this.getRowheight();
    List<HeaderPositionInfo> infos=new ArrayList<HeaderPositionInfo>();
    Iterator<NRow> iter=sheet.getRowIterator();
    while (iter.hasNext()) {
      NRow row=iter.next();
      final boolean hidden=row.isHidden();
      final int height=row.getHeight();
      if (height != defaultSize || hidden) {
        infos.add(new HeaderPositionInfo(row.getIndex(),height,_custRowId.next(),hidden));
      }
    }
    helpers.putHelper(sheetId,helper=new HeaderPositionHelper(defaultSize,infos));
  }
  return new HeaderPositionHelper[]{helper,myGetColumnPositionHelper(sheet)};
}
Program: 56545
Project: 56545
Buggy source:
private void importPoiCell(NRow row,Cell poiCell){
  NCell cell=row.getCell(poiCell.getColumnIndex());
switch (poiCell.getCellType()) {
case Cell.CELL_TYPE_NUMERIC:
    cell.setNumberValue(poiCell.getNumericCellValue());
  break;
case Cell.CELL_TYPE_STRING:
cell.setStringValue(poiCell.getStringCellValue());
break;
case Cell.CELL_TYPE_BOOLEAN:
cell.setBooleanValue(poiCell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_FORMULA:
cell.setFormulaValue(poiCell.getCellFormula());
break;
case Cell.CELL_TYPE_ERROR:
cell.setErrorValue(convertErrorCode(poiCell.getErrorCellValue()));
break;
case Cell.CELL_TYPE_BLANK:
break;
default :
}
if (!importedStyle.containsKey(poiCell.getCellStyle().getIndex())) {
cell.setCellStyle(importXSSFCellStyle((XSSFCellStyle)poiCell.getCellStyle()));
}
}

Fixed version (ground truth):
private void importPoiCell(NRow row,Cell poiCell){
  NCell cell=row.getCell(poiCell.getColumnIndex());
switch (poiCell.getCellType()) {
case Cell.CELL_TYPE_NUMERIC:
    cell.setNumberValue(poiCell.getNumericCellValue());
  break;
case Cell.CELL_TYPE_STRING:
cell.setStringValue(poiCell.getStringCellValue());
break;
case Cell.CELL_TYPE_BOOLEAN:
cell.setBooleanValue(poiCell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_FORMULA:
cell.setFormulaValue(poiCell.getCellFormula());
break;
case Cell.CELL_TYPE_ERROR:
cell.setErrorValue(convertErrorCode(poiCell.getErrorCellValue()));
break;
case Cell.CELL_TYPE_BLANK:
break;
default :
}
cell.setCellStyle(importXSSFCellStyle((XSSFCellStyle)poiCell.getCellStyle()));
}
Program: 56547
Project: 56547
Buggy source:
@Test public void cellStyleTest(){
  NBook book=null;
  try {
    book=importer.imports(fileUnderTest,"String_Node_Str");
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  NSheet sheet=book.getSheetByName("String_Node_Str");
  assertEquals(true,sheet.getCell(24,1).getCellStyle().isWrapText());
  assertEquals(VerticalAlignment.TOP,sheet.getCell(26,1).getCellStyle().getVerticalAlignment());
  assertEquals(VerticalAlignment.CENTER,sheet.getCell(26,2).getCellStyle().getVerticalAlignment());
  assertEquals(VerticalAlignment.BOTTOM,sheet.getCell(26,3).getCellStyle().getVerticalAlignment());
  assertEquals(Alignment.LEFT,sheet.getCell(27,1).getCellStyle().getAlignment());
  assertEquals(Alignment.CENTER,sheet.getCell(27,2).getCellStyle().getAlignment());
  assertEquals(Alignment.RIGHT,sheet.getCell(27,3).getCellStyle().getAlignment());
  assertEquals("String_Node_Str",sheet.getCell(11,0).getCellStyle().getFillColor().getHtmlColor());
  assertEquals("String_Node_Str",sheet.getCell(11,1).getCellStyle().getFillColor().getHtmlColor());
  assertEquals("String_Node_Str",sheet.getCell(11,2).getCellStyle().getFillColor().getHtmlColor());
  NSheet protectedSheet=book.getSheetByName("String_Node_Str");
  assertEquals(true,protectedSheet.getCell(0,0).getCellStyle().isLocked());
  assertEquals(false,protectedSheet.getCell(1,0).getCellStyle().isLocked());
}

Fixed version (ground truth):
@Test public void cellStyleTest(){
  NBook book=null;
  try {
    book=importer.imports(fileUnderTest,"String_Node_Str");
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  NSheet sheet=book.getSheetByName("String_Node_Str");
  assertEquals(true,sheet.getCell(24,1).getCellStyle().isWrapText());
  assertEquals(VerticalAlignment.TOP,sheet.getCell(26,1).getCellStyle().getVerticalAlignment());
  assertEquals(VerticalAlignment.CENTER,sheet.getCell(26,2).getCellStyle().getVerticalAlignment());
  assertEquals(VerticalAlignment.BOTTOM,sheet.getCell(26,3).getCellStyle().getVerticalAlignment());
  assertEquals(Alignment.LEFT,sheet.getCell(27,1).getCellStyle().getAlignment());
  assertEquals(Alignment.CENTER,sheet.getCell(27,2).getCellStyle().getAlignment());
  assertEquals(Alignment.RIGHT,sheet.getCell(27,3).getCellStyle().getAlignment());
  assertEquals("String_Node_Str",sheet.getCell(11,0).getCellStyle().getFillColor().getHtmlColor());
  assertEquals("String_Node_Str",sheet.getCell(11,1).getCellStyle().getFillColor().getHtmlColor());
  assertEquals("String_Node_Str",sheet.getCell(11,2).getCellStyle().getFillColor().getHtmlColor());
  assertTrue(sheet.getCell(27,0).getCellStyle().equals(sheet.getCell(26,0).getCellStyle()));
  assertTrue(sheet.getCell(28,0).getCellStyle().equals(sheet.getCell(26,0).getCellStyle()));
  NSheet protectedSheet=book.getSheetByName("String_Node_Str");
  assertEquals(true,protectedSheet.getCell(0,0).getCellStyle().isLocked());
  assertEquals(false,protectedSheet.getCell(1,0).getCellStyle().isLocked());
}
Program: 56548
Project: 56548
Buggy source:
@Test public void testZSS401CutInSameSheet(){
  Book workbook=Util.loadBook(Issue400Test.class,"String_Node_Str");
  Range srcRange=Ranges.range(workbook.getSheet("String_Node_Str"),"String_Node_Str");
  Range destRange=Ranges.range(workbook.getSheet("String_Node_Str"),"String_Node_Str");
  assertEquals(true,srcRange.hasMergedCell());
  CellOperationUtil.cut(srcRange,destRange);
  assertEquals(false,srcRange.hasMergedCell());
}

Fixed version (ground truth):
@Test public void testZSS401CutInSameSheet(){
  Book workbook=Util.loadBook(Issue400Test.class,"String_Node_Str");
  Range srcRange=Ranges.range(workbook.getSheet("String_Node_Str"),"String_Node_Str");
  Range destRange=Ranges.range(workbook.getSheet("String_Node_Str"),"String_Node_Str");
  CellOperationUtil.cut(srcRange,destRange);
  assertEquals(false,srcRange.hasMergedCell());
}
Program: 56549
Project: 56549
Buggy source:
/** 
 * reference to a JavaBean is not evaluated to a cell reference even the value is "=B2". So it's not related to this issue.
 */
@Test public void testZSS441(){
  Book workbook=Util.loadBook("String_Node_Str");
  Sheet sheet=workbook.getSheet("String_Node_Str");
  Range sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(11,sumResult.getCellData().getDoubleValue().intValue());
  sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(22,sumResult.getCellData().getDoubleValue().intValue());
  sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(33,sumResult.getCellData().getDoubleValue().intValue());
}

Fixed version (ground truth):
/** 
 * reference to a JavaBean is not evaluated to a cell reference even the value is "=B2". So it's not related to this issue.
 */
@Test public void testZSS441(){
  Book workbook=Util.loadBook(this,"String_Node_Str");
  Sheet sheet=workbook.getSheet("String_Node_Str");
  Range sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(11,sumResult.getCellData().getDoubleValue().intValue());
  sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(22,sumResult.getCellData().getDoubleValue().intValue());
  sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(33,sumResult.getCellData().getDoubleValue().intValue());
}
Program: 56550
Project: 56550
Buggy source:
@Test public void testZSS441ThreeDimensionalReference(){
  Book workbook=Util.loadBook("String_Node_Str");
  Sheet sheet=workbook.getSheet("String_Node_Str");
  Range sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(11,sumResult.getCellData().getDoubleValue().intValue());
  sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(22,sumResult.getCellData().getDoubleValue().intValue());
  sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(33,sumResult.getCellData().getDoubleValue().intValue());
}

Fixed version (ground truth):
@Test public void testZSS441ThreeDimensionalReference(){
  Book workbook=Util.loadBook(this,"String_Node_Str");
  Sheet sheet=workbook.getSheet("String_Node_Str");
  Range sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(11,sumResult.getCellData().getDoubleValue().intValue());
  sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(22,sumResult.getCellData().getDoubleValue().intValue());
  sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(33,sumResult.getCellData().getDoubleValue().intValue());
}
Program: 56551
Project: 56551
Buggy source:
@Test public void testZSS441ExternalBook(){
  Book workbook=Util.loadBook("String_Node_Str");
  Book anotherWorkbook=Util.loadBook("String_Node_Str");
  BookSeriesBuilder.getInstance().buildBookSeries(new Book[]{workbook,anotherWorkbook});
  Sheet sheet=workbook.getSheet("String_Node_Str");
  Range sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(60,sumResult.getCellData().getDoubleValue().intValue());
}

Fixed version (ground truth):
@Test public void testZSS441ExternalBook(){
  Book workbook=Util.loadBook(this,"String_Node_Str");
  Book anotherWorkbook=Util.loadBook(this,"String_Node_Str");
  BookSeriesBuilder.getInstance().buildBookSeries(new Book[]{workbook,anotherWorkbook});
  Sheet sheet=workbook.getSheet("String_Node_Str");
  Range sumResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(60,sumResult.getCellData().getDoubleValue().intValue());
}
Program: 56552
Project: 56552
Buggy source:
/** 
 * "array formula" is the feature related to ZSS-441 http://office.microsoft.com/en-us/excel-help/guidelines-and-examples-of-array-formulas-HA010228458.aspx
 */
@Test public void testZSS441ArrayFormula(){
  Book workbook=Util.loadBook("String_Node_Str");
  Sheet sheet=workbook.getSheet("String_Node_Str");
  Range multiplyResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(4,multiplyResult.getCellData().getDoubleValue().intValue());
  multiplyResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(10,multiplyResult.getCellData().getDoubleValue().intValue());
  multiplyResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(18,multiplyResult.getCellData().getDoubleValue().intValue());
  Range arrayColumn=Ranges.range(sheet,"String_Node_Str");
  assertEquals(8,arrayColumn.getCellData().getDoubleValue().intValue());
  arrayColumn=Ranges.range(sheet,"String_Node_Str");
  assertEquals(9,arrayColumn.getCellData().getDoubleValue().intValue());
  arrayColumn=Ranges.range(sheet,"String_Node_Str");
  assertEquals(10,arrayColumn.getCellData().getDoubleValue().intValue());
  sheet=workbook.getSheet("String_Node_Str");
  Range arrayRow=Ranges.range(sheet,"String_Node_Str");
  assertEquals(1,arrayRow.getCellData().getDoubleValue().intValue());
  arrayRow=Ranges.range(sheet,"String_Node_Str");
  assertEquals(2,arrayRow.getCellData().getDoubleValue().intValue());
  arrayRow=Ranges.range(sheet,"String_Node_Str");
  assertEquals(3,arrayRow.getCellData().getDoubleValue().intValue());
}

Fixed version (ground truth):
/** 
 * "array formula" is the feature related to ZSS-441 http://office.microsoft.com/en-us/excel-help/guidelines-and-examples-of-array-formulas-HA010228458.aspx
 */
@Test public void testZSS441ArrayFormula(){
  Book workbook=Util.loadBook(this,"String_Node_Str");
  Sheet sheet=workbook.getSheet("String_Node_Str");
  Range multiplyResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(4,multiplyResult.getCellData().getDoubleValue().intValue());
  multiplyResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(10,multiplyResult.getCellData().getDoubleValue().intValue());
  multiplyResult=Ranges.range(sheet,"String_Node_Str");
  assertEquals(18,multiplyResult.getCellData().getDoubleValue().intValue());
  Range arrayColumn=Ranges.range(sheet,"String_Node_Str");
  assertEquals(8,arrayColumn.getCellData().getDoubleValue().intValue());
  arrayColumn=Ranges.range(sheet,"String_Node_Str");
  assertEquals(9,arrayColumn.getCellData().getDoubleValue().intValue());
  arrayColumn=Ranges.range(sheet,"String_Node_Str");
  assertEquals(10,arrayColumn.getCellData().getDoubleValue().intValue());
  sheet=workbook.getSheet("String_Node_Str");
  Range arrayRow=Ranges.range(sheet,"String_Node_Str");
  assertEquals(1,arrayRow.getCellData().getDoubleValue().intValue());
  arrayRow=Ranges.range(sheet,"String_Node_Str");
  assertEquals(2,arrayRow.getCellData().getDoubleValue().intValue());
  arrayRow=Ranges.range(sheet,"String_Node_Str");
  assertEquals(3,arrayRow.getCellData().getDoubleValue().intValue());
}
Program: 56555
Project: 56555
Buggy source:
@Override public boolean isRedoable(){
  return oldTexts == null && isSheetAvailable();
}

Fixed version (ground truth):
@Override public boolean isRedoable(){
  return oldTexts == null && isSheetAvailable() && !isRangeProtected();
}
Program: 56556
Project: 56556
Buggy source:
@Override public boolean isUndoable(){
  return oldTexts != null && isSheetAvailable();
}

Fixed version (ground truth):
@Override public boolean isUndoable(){
  return oldTexts != null && isSheetAvailable() && !isRangeProtected();
}
Program: 56557
Project: 56557
Buggy source:
@Override public void undoAction(){
  int row=getReservedRow();
  int column=getReservedColumn();
  int lastRow=getReservedLastRow();
  int lastColumn=getReservedLastColumn();
  Sheet sheet=getReservedSheet();
  for (int i=row; i <= lastRow; i++) {
    for (int j=column; j <= lastColumn; j++) {
      Range r=Ranges.range(sheet,i,j);
      try {
        r.setCellEditText(oldTexts[i - row][j - column]);
      }
 catch (      IllegalFormulaException x) {
      }
      ;
    }
  }
  oldTexts=null;
}

Fixed version (ground truth):
@Override public void undoAction(){
  if (isRangeProtected())   return;
  int row=getReservedRow();
  int column=getReservedColumn();
  int lastRow=getReservedLastRow();
  int lastColumn=getReservedLastColumn();
  Sheet sheet=getReservedSheet();
  for (int i=row; i <= lastRow; i++) {
    for (int j=column; j <= lastColumn; j++) {
      Range r=Ranges.range(sheet,i,j);
      try {
        r.setCellEditText(oldTexts[i - row][j - column]);
      }
 catch (      IllegalFormulaException x) {
      }
      ;
    }
  }
  oldTexts=null;
}
Program: 56559
Project: 56559
Buggy source:
/** 
 * @return Area reference of this selection
 * @since 3.0.0
 */
public String toAreaReference(){
  if (areaRef == null) {
    areaRef=new AreaReference(new CellReference(_top,_left),new CellReference(_bottom,_right)).toString();
  }
  return areaRef;
}

Fixed version (ground truth):
/** 
 * @return Area reference of this selection
 * @since 3.0.0
 */
public String toAreaReference(){
  if (areaRef == null) {
    areaRef=new AreaReference(new CellReference(_top,_left),new CellReference(_bottom,_right)).formatAsString();
  }
  return areaRef;
}
Program: 56560
Project: 56560
Buggy source:
public SortCellAction(String label,Sheet sheet,int row,int column,int lastRow,int lastColumn,Range index1,boolean desc1,SortDataOption dataOption1,Range index2,boolean desc2,SortDataOption dataOption2,Range index3,boolean desc3,SortDataOption dataOption3,boolean header,boolean matchCase,boolean sortByRows){
  super(label,sheet,row,column,lastRow,lastColumn);
  _simpleMode=false;
  _desc=false;
  _index1=index1;
  _desc1=desc1;
  _dataOption1=dataOption1;
  _index2=index2;
  _desc2=desc2;
  _dataOption2=dataOption2;
  _index3=index3;
  _desc3=desc3;
  _dataOption3=dataOption3;
  _header=header;
  _matchCase=matchCase;
  _sortByRows=sortByRows;
}

Fixed version (ground truth):
public SortCellAction(String label,Sheet sheet,int row,int column,int lastRow,int lastColumn,Range index1,boolean desc1,SortDataOption dataOption1,Range index2,boolean desc2,SortDataOption dataOption2,Range index3,boolean desc3,SortDataOption dataOption3,boolean header,boolean matchCase,boolean sortByRows){
  super(label,sheet,row,column,lastRow,lastColumn,ReserveType.ALL);
  _simpleMode=false;
  _desc=false;
  _index1=index1;
  _desc1=desc1;
  _dataOption1=dataOption1;
  _index2=index2;
  _desc2=desc2;
  _dataOption2=dataOption2;
  _index3=index3;
  _desc3=desc3;
  _dataOption3=dataOption3;
  _header=header;
  _matchCase=matchCase;
  _sortByRows=sortByRows;
}
Program: 56561
Project: 56561
Buggy source:
@Override public boolean isRedoable(){
  return oldTexts == null && isSheetAvailable() && !isSheetProtected();
}

Fixed version (ground truth):
@Override public boolean isRedoable(){
  return oldData == null && isSheetAvailable() && !isSheetProtected();
}
Program: 56562
Project: 56562
Buggy source:
@Override public boolean isUndoable(){
  return oldTexts != null && isSheetAvailable() && !isSheetProtected();
}

Fixed version (ground truth):
@Override public boolean isUndoable(){
  return oldData != null && isSheetAvailable() && !isSheetProtected();
}
Program: 56563
Project: 56563
Buggy source:
@Override public void doAction(){
  if (isSheetProtected())   return;
  int row=getReservedRow();
  int column=getReservedColumn();
  int lastRow=getReservedLastRow();
  int lastColumn=getReservedLastColumn();
  Sheet sheet=getReservedSheet();
  oldTexts=new String[lastRow - row + 1][lastColumn - column + 1];
  for (int i=row; i <= lastRow; i++) {
    for (int j=column; j <= lastColumn; j++) {
      Range r=Ranges.range(sheet,i,j);
      CellData d=r.getCellData();
      if (d.isBlank()) {
        oldTexts[i - row][j - column]=null;
      }
 else {
        oldTexts[i - row][j - column]=d.getEditText();
      }
    }
  }
  applyAction();
}

Fixed version (ground truth):
@Override public void doAction(){
  if (isSheetProtected())   return;
  int row=getReservedRow();
  int column=getReservedColumn();
  int lastRow=getReservedLastRow();
  int lastColumn=getReservedLastColumn();
  Sheet sheet=getReservedSheet();
  oldData=new ReservedCellData[lastRow - row + 1][lastColumn - column + 1];
  for (int i=row; i <= lastRow; i++) {
    for (int j=column; j <= lastColumn; j++) {
      Range r=Ranges.range(sheet,i,j);
      oldData[i - row][j - column]=ReservedCellData.reserve(r);
    }
  }
  applyAction();
}
Program: 56564
Project: 56564
Buggy source:
@Override public void undoAction(){
  if (isSheetProtected())   return;
  int row=getReservedRow();
  int column=getReservedColumn();
  int lastRow=getReservedLastRow();
  int lastColumn=getReservedLastColumn();
  Sheet sheet=getReservedSheet();
  for (int i=row; i <= lastRow; i++) {
    for (int j=column; j <= lastColumn; j++) {
      Range r=Ranges.range(sheet,i,j);
      try {
        r.setCellEditText(oldTexts[i - row][j - column]);
      }
 catch (      IllegalFormulaException x) {
      }
      ;
    }
  }
  oldTexts=null;
}

Fixed version (ground truth):
@Override public void undoAction(){
  if (isSheetProtected())   return;
  int row=getReservedRow();
  int column=getReservedColumn();
  int lastRow=getReservedLastRow();
  int lastColumn=getReservedLastColumn();
  Sheet sheet=getReservedSheet();
  for (int i=row; i <= lastRow; i++) {
    for (int j=column; j <= lastColumn; j++) {
      Range r=Ranges.range(sheet,i,j);
      oldData[i - row][j - column].apply(r);
    }
  }
  oldData=null;
}
Program: 56565
Project: 56565
Buggy source:
@Override public void doAction(){
  if (isSheetProtected())   return;
  int row=getReservedRow();
  int column=getReservedColumn();
  int lastRow=getReservedLastRow();
  int lastColumn=getReservedLastColumn();
  Sheet sheet=getReservedSheet();
switch (_reserveType) {
case DATA:
    _oldTexts=new String[lastRow - row + 1][lastColumn - column + 1];
  break;
case STYLE:
_oldStyles=new CellStyle[lastRow - row + 1][lastColumn - column + 1];
break;
case ALL:
_oldTexts=new String[lastRow - row + 1][lastColumn - column + 1];
_oldStyles=new CellStyle[lastRow - row + 1][lastColumn - column + 1];
}
for (int i=row; i <= lastRow; i++) {
for (int j=column; j <= lastColumn; j++) {
Range r=Ranges.range(sheet,i,j);
if (_oldStyles != null) {
_oldStyles[i - row][j - column]=r.getCellStyle();
}
if (_oldTexts != null) {
CellData d=r.getCellData();
if (d.isBlank()) {
_oldTexts[i - row][j - column]=null;
}
 else {
_oldTexts[i - row][j - column]=d.getEditText();
}
}
}
}
if (_newStyles != null || _newTexts != null) {
for (int i=row; i <= lastRow; i++) {
for (int j=column; j <= lastColumn; j++) {
Range r=Ranges.range(sheet,i,j);
if (_newStyles != null) {
r.setCellStyle(_newStyles[i - row][j - column]);
}
if (_newTexts != null) {
try {
r.setCellEditText(_newTexts[i - row][j - column]);
}
 catch (IllegalFormulaException x) {
}
;
}
}
}
_newStyles=null;
_newTexts=null;
}
 else {
applyAction();
}
}

Fixed version (ground truth):
@Override public void doAction(){
  if (isSheetProtected())   return;
  int row=getReservedRow();
  int column=getReservedColumn();
  int lastRow=getReservedLastRow();
  int lastColumn=getReservedLastColumn();
  Sheet sheet=getReservedSheet();
switch (_reserveType) {
case DATA:
    _oldData=new ReservedCellData[lastRow - row + 1][lastColumn - column + 1];
  break;
case STYLE:
_oldStyles=new CellStyle[lastRow - row + 1][lastColumn - column + 1];
break;
case ALL:
_oldData=new ReservedCellData[lastRow - row + 1][lastColumn - column + 1];
_oldStyles=new CellStyle[lastRow - row + 1][lastColumn - column + 1];
}
for (int i=row; i <= lastRow; i++) {
for (int j=column; j <= lastColumn; j++) {
Range r=Ranges.range(sheet,i,j);
if (_oldStyles != null) {
_oldStyles[i - row][j - column]=r.getCellStyle();
}
if (_oldData != null) {
_oldData[i - row][j - column]=ReservedCellData.reserve(r);
}
}
}
if (_newStyles != null || _newData != null) {
for (int i=row; i <= lastRow; i++) {
for (int j=column; j <= lastColumn; j++) {
Range r=Ranges.range(sheet,i,j);
if (_newStyles != null) {
r.setCellStyle(_newStyles[i - row][j - column]);
}
if (_newData != null) {
try {
_newData[i - row][j - column].apply(r);
}
 catch (IllegalFormulaException x) {
}
;
}
}
}
_newStyles=null;
_newData=null;
}
 else {
applyAction();
}
}
Program: 56566
Project: 56566
Buggy source:
@Override public void undoAction(){
  if (isSheetProtected())   return;
  int row=getReservedRow();
  int column=getReservedColumn();
  int lastRow=getReservedLastRow();
  int lastColumn=getReservedLastColumn();
  Sheet sheet=getReservedSheet();
switch (_reserveType) {
case DATA:
    _newTexts=new String[lastRow - row + 1][lastColumn - column + 1];
  break;
case STYLE:
_newStyles=new CellStyle[lastRow - row + 1][lastColumn - column + 1];
break;
case ALL:
_newTexts=new String[lastRow - row + 1][lastColumn - column + 1];
_newStyles=new CellStyle[lastRow - row + 1][lastColumn - column + 1];
}
for (int i=row; i <= lastRow; i++) {
for (int j=column; j <= lastColumn; j++) {
Range r=Ranges.range(sheet,i,j);
if (_newStyles != null) {
_newStyles[i - row][j - column]=r.getCellStyle();
}
if (_newTexts != null) {
CellData d=r.getCellData();
if (d.isBlank()) {
_newTexts[i - row][j - column]=null;
}
 else {
_newTexts[i - row][j - column]=d.getEditText();
}
}
}
}
for (int i=row; i <= lastRow; i++) {
for (int j=column; j <= lastColumn; j++) {
Range r=Ranges.range(sheet,i,j);
if (_oldStyles != null) {
r.setCellStyle(_oldStyles[i - row][j - column]);
}
if (_oldTexts != null) {
try {
r.setCellEditText(_oldTexts[i - row][j - column]);
}
 catch (IllegalFormulaException x) {
}
;
}
}
}
_oldTexts=null;
_oldStyles=null;
}

Fixed version (ground truth):
@Override public void undoAction(){
  if (isSheetProtected())   return;
  int row=getReservedRow();
  int column=getReservedColumn();
  int lastRow=getReservedLastRow();
  int lastColumn=getReservedLastColumn();
  Sheet sheet=getReservedSheet();
switch (_reserveType) {
case DATA:
    _newData=new ReservedCellData[lastRow - row + 1][lastColumn - column + 1];
  break;
case STYLE:
_newStyles=new CellStyle[lastRow - row + 1][lastColumn - column + 1];
break;
case ALL:
_newData=new ReservedCellData[lastRow - row + 1][lastColumn - column + 1];
_newStyles=new CellStyle[lastRow - row + 1][lastColumn - column + 1];
}
for (int i=row; i <= lastRow; i++) {
for (int j=column; j <= lastColumn; j++) {
Range r=Ranges.range(sheet,i,j);
if (_newStyles != null) {
_newStyles[i - row][j - column]=r.getCellStyle();
}
if (_newData != null) {
_newData[i - row][j - column]=ReservedCellData.reserve(r);
}
}
}
for (int i=row; i <= lastRow; i++) {
for (int j=column; j <= lastColumn; j++) {
Range r=Ranges.range(sheet,i,j);
if (_oldStyles != null) {
r.setCellStyle(_oldStyles[i - row][j - column]);
}
if (_oldData != null) {
_oldData[i - row][j - column].apply(r);
}
}
}
_oldData=null;
_oldStyles=null;
}
Program: 56568
Project: 56568
Buggy source:
@Override public Set<String> getSupportedUserAction(Sheet sheet){
  Set<String> actions=super.getSupportedUserAction(sheet);
  actions.add(DefaultUserAction.NEW_BOOK.getAction());
  if (sheet != null) {
    actions.add(DefaultUserAction.SAVE_BOOK.getAction());
    actions.add(DefaultUserAction.EXPORT_PDF.getAction());
  }
  return actions;
}

Fixed version (ground truth):
@Override public Set<String> getSupportedUserAction(Sheet sheet){
  Set<String> actions=super.getSupportedUserAction(sheet);
  actions.add(DefaultUserAction.NEW_BOOK.getAction());
  if (sheet != null) {
    boolean readonly=UiUtil.isRepositoryReadonly();
    if (!readonly) {
      actions.add(DefaultUserAction.SAVE_BOOK.getAction());
    }
    actions.add(DefaultUserAction.EXPORT_PDF.getAction());
  }
  return actions;
}