public void Add(TColumnInfo s) { if (ColumnOrder.ContainsKey(s.Field)) { return; } ColumnOrder.Add(s.Field, s); }
static void FixBadColumnName02(TableHeader c) { //move NameAndOccupationOrRelativeType to NameOrRelativeType if Occupation is present if (c.ContainsField(DeclarationField.NameAndOccupationOrRelativeType) && c.ContainsField(DeclarationField.Occupation) ) { TColumnInfo s = c.ColumnOrder[DeclarationField.NameAndOccupationOrRelativeType]; s.Field = DeclarationField.NameOrRelativeType; c.Add(s); c.Delete(DeclarationField.NameAndOccupationOrRelativeType); } }
static void FixBadColumnName01_Template(TableHeader c, DeclarationField naturalText, DeclarationField country, DeclarationField square, DeclarationField type) { //move MixedColumnWithNaturalText to MixedRealEstateType if (!c.ContainsField(naturalText)) { return; } if (c.ContainsField(country) && c.ContainsField(square) ) { TColumnInfo s = c.ColumnOrder[naturalText]; s.Field = type; c.Add(s); c.Delete(naturalText); } }
static void FixMissingSubheadersForVehicle(IAdapter adapter, TableHeader columnOrdering) { if (!columnOrdering.ContainsField(DeclarationField.Vehicle)) { return; } TColumnInfo dummy; var headerCell = adapter.GetDeclarationFieldWeak(columnOrdering, columnOrdering.HeaderBegin.Value, DeclarationField.Vehicle, out dummy); if (headerCell.MergedColsCount != 2) { return; } var subCells = FindSubcellsUnder(adapter, headerCell); if (subCells.Count == 1) { return; } string cleanHeader = headerCell.Text.ToLower().Replace(" ", ""); if (cleanHeader.Contains("транспортныесредства") && cleanHeader.Contains("марка") && cleanHeader.Contains("вид")) { TColumnInfo columnVehicleType = new TColumnInfo(); columnVehicleType.BeginColumn = headerCell.Col; columnVehicleType.EndColumn = headerCell.Col + 1; columnVehicleType.ColumnPixelWidth = headerCell.CellWidth / 2; columnVehicleType.Field = DeclarationField.VehicleType; columnOrdering.Add(columnVehicleType); TColumnInfo columnVehicleModel = new TColumnInfo(); columnVehicleModel.BeginColumn = headerCell.Col + 1; columnVehicleModel.EndColumn = headerCell.Col + 2; columnVehicleModel.ColumnPixelWidth = headerCell.CellWidth / 2; columnVehicleModel.Field = DeclarationField.VehicleModel; columnOrdering.Add(columnVehicleModel); columnOrdering.Delete(DeclarationField.Vehicle); } }
static void AddColumn(TableHeader ordering, DeclarationField field, Cell cell) { TColumnInfo s = new TColumnInfo(); s.BeginColumn = cell.Col; s.EndColumn = cell.Col + cell.MergedColsCount; s.ColumnPixelWidth = cell.CellWidth; //s.ColumnPixelStart is unknown and initialized in FinishOrderingBuilding s.Field = field; if (IsIncomeColumn(field)) { string dummy = ""; int? year = null; if (TableHeaderRecognizer.GetValuesFromTitle(cell.GetText(), ref dummy, ref year, ref dummy) && year.HasValue) { ordering.YearFromIncome = year.Value; } } ordering.Add(s); }
// напрямую используется, пока ColumnOrdering еще не построен // во всех остальных случаях надо использовать Row.GetDeclarationField virtual public Cell GetDeclarationFieldWeak(TableHeader columnOrdering, int row, DeclarationField field, out TColumnInfo colSpan) { if (!columnOrdering.ColumnOrder.TryGetValue(field, out colSpan)) { throw new SmartParserFieldNotFoundException(String.Format("Field {0} not found, row={1}", field.ToString(), row)); } var exactCell = GetCell(row, colSpan.BeginColumn); if (exactCell == null) { var cells = GetDataCells(row); throw new SmartParserFieldNotFoundException(String.Format("Field {0} not found, row={1}, col={2}. Row.Cells.Count = {3}", field.ToString(), row, colSpan.BeginColumn, cells.Count )); } return(exactCell); }