Beispiel #1
0
        private static List <BOUNDSHEET> DecodeRecords(List <Record> records, out SharedResource sharedResource)
        {
            sharedResource = new SharedResource();
            List <BOUNDSHEET> boundSheets = new List <BOUNDSHEET>();

            foreach (Record record in records)
            {
                record.Decode();
                switch (record.Type)
                {
                case RecordType.BOUNDSHEET:
                    boundSheets.Add(record as BOUNDSHEET);
                    break;

                case RecordType.XF:
                    sharedResource.ExtendedFormats.Add(record as XF);
                    break;

                case RecordType.FORMAT:
                    sharedResource.CellFormats.Add(record as FORMAT);
                    break;

                case RecordType.SST:
                    sharedResource.SharedStringTable = record as SST;
                    break;

                case RecordType.DATEMODE:
                    DATEMODE dateMode = record as DATEMODE;
                    switch (dateMode.Mode)
                    {
                    case 0:
                        sharedResource.BaseDate = Constants.WindowsBaseDate;
                        break;

                    case 1:
                        sharedResource.BaseDate = Constants.MacintoshBaseDate;
                        break;
                    }
                    break;

                case RecordType.PALETTE:
                    PALETTE palette    = record as PALETTE;
                    int     colorIndex = 8;
                    foreach (int color in palette.Colors)
                    {
                        sharedResource.ColorPalette[colorIndex] = Color.FromArgb(color);
                        colorIndex++;
                    }
                    break;

                case RecordType.FONT:
                    FONT f = record as FONT;
                    sharedResource.Fonts.Add(f);
                    break;
                }
            }
            return(boundSheets);
        }
Beispiel #2
0
        public static Record Read(Stream stream)
        {
            Record record = Record.ReadBase(stream);
            ushort type   = record.Type;
            Record result;

            if (type <= 146)
            {
                if (type <= 49)
                {
                    if (type <= 13)
                    {
                        if (type == 6)
                        {
                            result = new FORMULA(record);
                            return(result);
                        }
                        switch (type)
                        {
                        case 10:
                            result = new EOF(record);
                            return(result);

                        case 12:
                            result = new CALCCOUNT(record);
                            return(result);

                        case 13:
                            result = new CALCMODE(record);
                            return(result);
                        }
                    }
                    else
                    {
                        if (type == 34)
                        {
                            result = new DATEMODE(record);
                            return(result);
                        }
                        if (type == 41)
                        {
                            result = new BOTTOMMARGIN(record);
                            return(result);
                        }
                        if (type == 49)
                        {
                            result = new FONT(record);
                            return(result);
                        }
                    }
                }
                else
                {
                    if (type <= 93)
                    {
                        switch (type)
                        {
                        case 60:
                            result = new CONTINUE(record);
                            return(result);

                        case 61:
                            result = new WINDOW1(record);
                            return(result);

                        case 62:
                        case 63:
                        case 65:
                            break;

                        case 64:
                            result = new BACKUP(record);
                            return(result);

                        case 66:
                            result = new CODEPAGE(record);
                            return(result);

                        default:
                            if (type == 85)
                            {
                                result = new DEFCOLWIDTH(record);
                                return(result);
                            }
                            if (type == 93)
                            {
                                result = new OBJ(record);
                                return(result);
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (type == 125)
                        {
                            result = new COLINFO(record);
                            return(result);
                        }
                        if (type == 133)
                        {
                            result = new BOUNDSHEET(record);
                            return(result);
                        }
                        if (type == 146)
                        {
                            result = new PALETTE(record);
                            return(result);
                        }
                    }
                }
            }
            else
            {
                if (type <= 237)
                {
                    if (type <= 190)
                    {
                        if (type == 153)
                        {
                            result = new STANDARDWIDTH(record);
                            return(result);
                        }
                        switch (type)
                        {
                        case 189:
                            result = new MULRK(record);
                            return(result);

                        case 190:
                            result = new MULBLANK(record);
                            return(result);
                        }
                    }
                    else
                    {
                        switch (type)
                        {
                        case 214:
                            result = new RSTRING(record);
                            return(result);

                        case 215:
                            result = new DBCELL(record);
                            return(result);

                        case 216:
                        case 217:
                            break;

                        case 218:
                            result = new BOOKBOOL(record);
                            return(result);

                        default:
                            if (type == 224)
                            {
                                result = new XF(record);
                                return(result);
                            }
                            switch (type)
                            {
                            case 233:
                                result = new BITMAP(record);
                                return(result);

                            case 235:
                                result = new MSODRAWINGGROUP(record);
                                return(result);

                            case 236:
                                result = new MSODRAWING(record);
                                return(result);

                            case 237:
                                result = new MSODRAWINGSELECTION(record);
                                return(result);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    if (type <= 545)
                    {
                        switch (type)
                        {
                        case 252:
                            result = new SST(record);
                            return(result);

                        case 253:
                            result = new LABELSST(record);
                            return(result);

                        case 254:
                            break;

                        case 255:
                            result = new EXTSST(record);
                            return(result);

                        default:
                            switch (type)
                            {
                            case 512:
                                result = new DIMENSIONS(record);
                                return(result);

                            case 513:
                                result = new BLANK(record);
                                return(result);

                            case 514:
                            case 516:
                            case 518:
                                break;

                            case 515:
                                result = new NUMBER(record);
                                return(result);

                            case 517:
                                result = new BOOLERR(record);
                                return(result);

                            case 519:
                                result = new STRING(record);
                                return(result);

                            case 520:
                                result = new ROW(record);
                                return(result);

                            default:
                                if (type == 545)
                                {
                                    result = new ARRAY(record);
                                    return(result);
                                }
                                break;
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (type == 638)
                        {
                            result = new RK(record);
                            return(result);
                        }
                        if (type == 1054)
                        {
                            result = new FORMAT(record);
                            return(result);
                        }
                        if (type == 2057)
                        {
                            result = new BOF(record);
                            return(result);
                        }
                    }
                }
            }
            result = record;
            return(result);
        }
        private static List <BOUNDSHEET> DecodeRecords(List <Record> records, out SharedResource sharedResource)
        {
            sharedResource = new SharedResource();
            List <BOUNDSHEET> list = new List <BOUNDSHEET>();

            checked
            {
                foreach (Record current in records)
                {
                    current.Decode();
                    ushort type = current.Type;
                    if (type <= 133)
                    {
                        if (type != 34)
                        {
                            if (type != 49)
                            {
                                if (type == 133)
                                {
                                    list.Add(current as BOUNDSHEET);
                                }
                            }
                            else
                            {
                                FONT item = current as FONT;
                                sharedResource.Fonts.Add(item);
                            }
                        }
                        else
                        {
                            DATEMODE dATEMODE = current as DATEMODE;
                            switch (dATEMODE.Mode)
                            {
                            case 0:
                                sharedResource.BaseDate = DateTime.Parse("1899-12-31");
                                break;

                            case 1:
                                sharedResource.BaseDate = DateTime.Parse("1904-01-01");
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (type <= 224)
                        {
                            if (type != 146)
                            {
                                if (type == 224)
                                {
                                    sharedResource.ExtendedFormats.Add(current as XF);
                                }
                            }
                            else
                            {
                                PALETTE pALETTE = current as PALETTE;
                                int     num     = 8;
                                foreach (int current2 in pALETTE.Colors)
                                {
                                    sharedResource.ColorPalette[num] = Color.FromArgb(current2);
                                    num++;
                                }
                            }
                        }
                        else
                        {
                            if (type != 252)
                            {
                                if (type == 1054)
                                {
                                    sharedResource.CellFormats.Add(current as FORMAT);
                                }
                            }
                            else
                            {
                                sharedResource.SharedStringTable = (current as SST);
                            }
                        }
                    }
                }
                return(list);
            }
        }