iTextSharp.text.Table.IsValidLocation C# (CSharp) Метод

IsValidLocation() приватный Метод

check if Cell 'fits' the table.
  • rowspan/colspan not beyond borders
  • spanned cell don't overlap existing cells
private IsValidLocation ( Cell aCell, System aLocation ) : bool
aCell Cell the cell that has to be checked
aLocation System the location where the cell has to be placed
Результат bool
        private bool IsValidLocation(Cell aCell, System.Drawing.Point aLocation) {
            // rowspan not beyond last column
            if ( aLocation.X < rows.Count ) {        // if false : new location is already at new, not-yet-created area so no check
                if ((aLocation.Y + aCell.Colspan) > columns) {
                    return false;
                }

                int difx = ((rows.Count - aLocation.X) >  aCell.Rowspan) ? aCell.Rowspan : rows.Count - aLocation.X;
                int dify = ((columns - aLocation.Y) >  aCell.Colspan) ? aCell.Colspan : columns - aLocation.Y;
                // no other content at cells targetted by rowspan/colspan
                for (int i=aLocation.X; i < (aLocation.X + difx); i++) {
                    for (int j=aLocation.Y; j < (aLocation.Y + dify); j++) {
                        if ( ((Row) rows[i]).IsReserved(j) == true ) {
                            return false;
                        }
                    }
                }
            }
            else {
                if ((aLocation.Y + aCell.Colspan) > columns) {
                    return false;
                }
            }

            return true;
        }