Exemple #1
0
        private bool ImportTextContent()
        {
            try {
                fLog.Clear();

                GDMLines buffer = new GDMLines();
                try {
                    int prev_id = 0;

                    int num = fRawContents.Count;
                    for (int i = 0; i < num; i++)
                    {
                        string  line    = PrepareLine(fRawContents[i]);
                        RawLine rawLine = (RawLine)fRawContents.GetObject(i);

                        switch (rawLine.Type)
                        {
                        case RawLineType.rltComment:
                            buffer.Add(line);
                            break;

                        case RawLineType.rltPerson:
                        case RawLineType.rltRomeGeneration:
                        case RawLineType.rltEOF:
                        {
                            prev_id = ParseBuffer(buffer);
                            buffer.Clear();

                            switch (rawLine.Type)
                            {
                            case RawLineType.rltPerson:
                                buffer.Add(line);
                                break;

                            case RawLineType.rltRomeGeneration:
                                fLog.Add("> " + fLangMan.LS(ILS.LSID_Generation) + " \"" + line + "\"");
                                break;

                            case RawLineType.rltEOF:
                                fLog.Add("> EOF.");
                                break;
                            }
                        }
                        break;
                        }
                    }

                    return(true);
                } finally {
                }
            } catch (Exception ex) {
                Logger.WriteError("Importer.ImportTextContent()", ex);
                throw;
            }
        }
        PopulateSourceColumnsCheckedListBox()
        {
            AssertValid();

            System.Windows.Forms.ListBox.ObjectCollection oItems =
                clbSourceColumns.Items;

            oItems.Clear();

            // Attempt to get the non-empty range of the active worksheet of the
            // selected source workbook.

            Range oNonEmptyRange;

            if (!TryGetSourceWorkbookNonEmptyRange(out oNonEmptyRange))
            {
                return;
            }

            Boolean bSourceColumnsHaveHeaders =
                cbxSourceColumnsHaveHeaders.Checked;

            // Get the first row and column of the non-empty range.

            Range oFirstRow = oNonEmptyRange.get_Resize(1, Missing.Value);
            Range oColumn   = oNonEmptyRange.get_Resize(Missing.Value, 1);

            Object [,] oFirstRowValues = ExcelUtil.GetRangeValues(oFirstRow);

            // Loop through the columns.

            Int32 iNonEmptyColumns = oNonEmptyRange.Columns.Count;
            Int32 iColumnOneBased  = oColumn.Column;

            for (Int32 i = 1; i <= iNonEmptyColumns; i++, iColumnOneBased++)
            {
                String sColumnLetter = ExcelUtil.GetColumnLetter(
                    ExcelUtil.GetRangeAddress((Range)oColumn.Cells[1, 1]));

                // Get the value of the column's first cell, if there is one.

                String sFirstCellValue;

                if (!ExcelUtil.TryGetNonEmptyStringFromCell(oFirstRowValues, 1,
                                                            i, out sFirstCellValue))
                {
                    sFirstCellValue = null;
                }

                String sItemText = GetSourceColumnItemText(sFirstCellValue,
                                                           sColumnLetter, bSourceColumnsHaveHeaders);

                oItems.Add(new ObjectWithText(iColumnOneBased, sItemText));

                // Move to the next column.

                oColumn = oColumn.get_Offset(0, 1);
            }
        }