예제 #1
0
 public void Add(TColumnInfo s)
 {
     if (ColumnOrder.ContainsKey(s.Field))
     {
         return;
     }
     ColumnOrder.Add(s.Field, s);
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        // напрямую используется, пока 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);
        }