static int ProcessTitle(IAdapter adapter, ColumnOrdering columnOrdering)
        {
            int    row      = 0;
            string title    = null;
            string ministry = null;
            int?   year     = null;

            bool findTitle        = false;
            bool prevRowIsSection = false;

            while (true)
            {
                var    currRow = adapter.GetCells(row);
                string section_text;
                bool   isSection = IAdapter.IsSectionRow(currRow, adapter.GetColsCount(), prevRowIsSection, out section_text);
                if (isSection)
                {
                    if (section_text.Length > 20)
                    {
                        if (GetValuesFromTitle(section_text, ref title, ref year, ref ministry))
                        {
                            findTitle = true;
                        }
                    }
                    else
                    {
                        columnOrdering.Section = section_text;
                    }
                }
                else if (WeakHeaderCheck(currRow))
                {
                    break;
                }

                row += 1;

                if (row >= adapter.GetRowsCount())
                {
                    row = 0;
                    break;
                    throw new ColumnDetectorException(String.Format("Headers not found"));
                }
                prevRowIsSection = isSection;
            }
            if (!findTitle)
            {
                if (GetValuesFromTitle(adapter.GetTitleOutsideTheTable(), ref title, ref year, ref ministry))
                {
                    findTitle = true;
                }
            }

            if (findTitle)
            {
                columnOrdering.Title        = title;
                columnOrdering.Year         = year;
                columnOrdering.MinistryName = ministry;
            }
            return(row);
        }
        public static DeclarationField PredictEmptyColumnTitle(IAdapter adapter, Cell headerCell)
        {
            List <string> texts           = new List <string>();
            int           rowIndex        = headerCell.Row + headerCell.MergedRowsCount;
            const int     maxRowToCollect = 10;

            for (int i = 0; i < maxRowToCollect; i++)
            {
                var    cells = adapter.GetCells(rowIndex, IAdapter.MaxColumnsCount);
                string dummy;
                if (IAdapter.IsSectionRow(cells, adapter.GetColsCount(), false, out dummy))
                {
                    rowIndex += 1;
                }
                else
                {
                    var c = adapter.GetCell(rowIndex, headerCell.Col);
                    if (c != null)
                    {
                        texts.Add(c.GetText(true));
                        rowIndex += c.MergedRowsCount;
                    }
                    else
                    {
                        rowIndex += 1;
                    }
                }
                if (rowIndex >= adapter.GetRowsCount())
                {
                    break;
                }
            }
            var field = PredictByStrings(texts);

            if (headerCell.TextAbove != null && ((field & DeclarationField.AllOwnTypes) > 0))
            {
                string h = headerCell.TextAbove;
                // AllOwnTypes defined from
                field &= ~DeclarationField.AllOwnTypes;
                if (HeaderHelpers.IsMixedColumn(h))
                {
                    field |= DeclarationField.Mixed;
                }
                else if (HeaderHelpers.IsStateColumn(h))
                {
                    field |= DeclarationField.State;
                }
                else if (HeaderHelpers.IsOwnedColumn(h))
                {
                    field |= DeclarationField.Owned;
                }
            }
            Logger.Debug(string.Format("predict by {0}  -> {1}",
                                       String.Join("\\n", texts), field));
            return(field);
        }