private void EnsureNoSpannedCellsExist(int row, int col, Cells.ICell p_cell)
{
var spanRange = new Range(row, col, row + p_cell.RowSpan - 1, col + p_cell.ColumnSpan - 1);
var ranges = spannedCellReferences.SpannedRangesCollection.GetRanges(
spanRange);
if (ranges.Count == 0)
{
return;
}
var start = new Position(row, col);
foreach (var range in ranges)
{
if (start.Equals(range.Start) == true)
{
continue;
}
Cells.ICell existingSpannedCell = this[range.Start];
if (existingSpannedCell == null)
{
throw new ArgumentException("internal error. please report this bug to developers");
}
throw new OverlappingCellException(string.Format(
"Given cell at position ({0}, {1}), " +
"intersects with another cell " +
"at position ({2}, {3}) '{4}'",
row, col,
existingSpannedCell.Row.Index,
existingSpannedCell.Column.Index,
existingSpannedCell.DisplayText));
}
}