/** * Notifies this evaluation tracker that evaluation of the specified cell Is * about to start.<br/> * * In the case of a <c>true</c> return code, the caller should * continue evaluation of the specified cell, and also be sure to call * <c>endEvaluate()</c> when complete.<br/> * * In the case of a <c>false</c> return code, the caller should * return an evaluation result of * <c>ErrorEval.CIRCULAR_REF_ERROR</c>, and not call <c>endEvaluate()</c>. * <br/> * @return <c>true</c> if the specified cell has not been visited yet in the current * evaluation. <c>false</c> if the specified cell Is alReady being evaluated. */ public bool StartEvaluate(HSSFWorkbook workbook, HSSFSheet sheet, int srcRowNum, int srcColNum) { CellEvaluationFrame cef = new CellEvaluationFrame(workbook, sheet, srcRowNum, srcColNum); if (_evaluationFrames.Contains(cef)) { return(false); } _evaluationFrames.Add(cef); return(true); }
/** * Notifies this evaluation tracker that the evaluation of the specified * cell Is complete. <p/> * * Every successful call to <tt>startEvaluate</tt> must be followed by a * call to <tt>endEvaluate</tt> (recommended in a finally block) to enable * proper tracking of which cells are being evaluated at any point in time.<p/> * * Assuming a well behaved client, parameters to this method would not be * required. However, they have been included to assert correct behaviour, * and form more meaningful error messages. */ public void EndEvaluate(HSSFWorkbook workbook, HSSFSheet sheet, int srcRowNum, int srcColNum) { int nFrames = _evaluationFrames.Count; if (nFrames < 1) { throw new InvalidOperationException("Call to endEvaluate without matching call to startEvaluate"); } nFrames--; CellEvaluationFrame cefExpected = (CellEvaluationFrame)_evaluationFrames[nFrames]; CellEvaluationFrame cefActual = new CellEvaluationFrame(workbook, sheet, srcRowNum, srcColNum); if (!cefActual.Equals(cefExpected)) { throw new Exception("Wrong cell specified. " + "Corresponding startEvaluate() call was for cell {" + cefExpected.FormatAsString() + "} this endEvaluate() call Is for cell {" + cefActual.FormatAsString() + "}"); } // else - no problems so pop current frame _evaluationFrames.Remove(nFrames); }
public override bool Equals(Object obj) { CellEvaluationFrame other = (CellEvaluationFrame)obj; if (_workbook != other._workbook) { return(false); } if (_sheet != other._sheet) { return(false); } if (_srcRowNum != other._srcRowNum) { return(false); } if (_srcColNum != other._srcColNum) { return(false); } return(true); }
/** * Notifies this evaluation tracker that the evaluation of the specified * cell Is complete. <p/> * * Every successful call to <c>startEvaluate</c> must be followed by a * call to <c>endEvaluate</c> (recommended in a finally block) to enable * proper tracking of which cells are being evaluated at any point in time.<p/> * * Assuming a well behaved client, parameters to this method would not be * required. However, they have been included to assert correct behaviour, * and form more meaningful error messages. */ public void EndEvaluate(HSSFWorkbook workbook, HSSFSheet sheet, int srcRowNum, int srcColNum) { int nFrames = _evaluationFrames.Count; if (nFrames < 1) { throw new InvalidOperationException("Call to endEvaluate without matching call to startEvaluate"); } nFrames--; CellEvaluationFrame cefExpected = (CellEvaluationFrame)_evaluationFrames[nFrames]; CellEvaluationFrame cefActual = new CellEvaluationFrame(workbook, sheet, srcRowNum, srcColNum); if (!cefActual.Equals(cefExpected)) { throw new Exception("Wrong cell specified. " + "Corresponding startEvaluate() call was for cell {" + cefExpected.FormatAsString() + "} this endEvaluate() call Is for cell {" + cefActual.FormatAsString() + "}"); } // else - no problems so pop current frame _evaluationFrames.Remove(nFrames); }
/** * Notifies this evaluation tracker that evaluation of the specified cell Is * about to start.<br/> * * In the case of a <c>true</c> return code, the caller should * continue evaluation of the specified cell, and also be sure to call * <c>endEvaluate()</c> when complete.<br/> * * In the case of a <c>false</c> return code, the caller should * return an evaluation result of * <c>ErrorEval.CIRCULAR_REF_ERROR</c>, and not call <c>endEvaluate()</c>. * <br/> * @return <c>true</c> if the specified cell has not been visited yet in the current * evaluation. <c>false</c> if the specified cell Is alReady being evaluated. */ public bool StartEvaluate(HSSFWorkbook workbook, HSSFSheet sheet, int srcRowNum, int srcColNum) { CellEvaluationFrame cef = new CellEvaluationFrame(workbook, sheet, srcRowNum, srcColNum); if (_evaluationFrames.Contains(cef)) { return false; } _evaluationFrames.Add(cef); return true; }