Пример #1
0
        private static Record EncodeImages(IList <Image> images)
        {
            MSODRAWINGGROUP    drawingGroup = new MSODRAWINGGROUP();
            MsofbtDggContainer dggContainer = new MsofbtDggContainer();

            drawingGroup.EscherRecords.Add(dggContainer);

            MsofbtDgg dgg = new MsofbtDgg();

            dgg.NumSavedDrawings = images.Count;
            dgg.NumSavedShapes   = images.Count + 1;
            dgg.MaxShapeID       = 1024 + dgg.NumSavedShapes;
            dgg.GroupIdClusters.Add(1, dgg.NumSavedShapes);
            dggContainer.EscherRecords.Add(dgg);

            MsofbtBstoreContainer bstoreContainer = new MsofbtBstoreContainer();

            bstoreContainer.Instance = (ushort)images.Count;
            foreach (Image image in images)
            {
                MsofbtBSE blipStoreEntry = new MsofbtBSE();
                blipStoreEntry.UID                  = Guid.NewGuid();
                blipStoreEntry.Ref                  = 1;
                blipStoreEntry.Version              = 2;
                blipStoreEntry.BlipRecord           = CreateBlipRecord(image);
                blipStoreEntry.BlipRecord.Type      = image.Format;
                blipStoreEntry.BlipRecord.ImageData = image.Data;
                blipStoreEntry.BlipRecord.UID       = blipStoreEntry.UID;
                blipStoreEntry.BlipRecord.Marker    = 255;
                blipStoreEntry.SetBlipType(image.Format);
                bstoreContainer.EscherRecords.Add(blipStoreEntry);
            }
            dggContainer.EscherRecords.Add(bstoreContainer);

            MsofbtOPT defautProperties = new MsofbtOPT();

            defautProperties.Add(PropertyIDs.FitTextToShape, 524296);
            defautProperties.Add(PropertyIDs.FillColor, 134217793);
            defautProperties.Add(PropertyIDs.LineColor, 134217792);
            dggContainer.EscherRecords.Add(defautProperties);

            MsofbtSplitMenuColors splitMenuColors = new MsofbtSplitMenuColors();

            splitMenuColors.Instance = 4;
            splitMenuColors.Color1   = 134217741;
            splitMenuColors.Color2   = 134217740;
            splitMenuColors.Color3   = 134217751;
            splitMenuColors.Color4   = 268435703;
            dggContainer.EscherRecords.Add(splitMenuColors);

            return(drawingGroup);
        }
Пример #2
0
        private static List <Record> ReadRecords(Stream stream, out MSODRAWINGGROUP drawingGroup)
        {
            List <Record> records = new List <Record>();

            drawingGroup = null;
            Record record = Record.Read(stream);

            record.Decode();
            Record last_record = record;

            if (record is BOF && ((BOF)record).StreamType == StreamType.WorkbookGlobals)
            {
                while (record.Type != RecordType.EOF)
                {
                    if (record.Type == RecordType.CONTINUE)
                    {
                        last_record.ContinuedRecords.Add(record);
                    }
                    else
                    {
                        switch (record.Type)
                        {
                        case RecordType.MSODRAWINGGROUP:
                            if (drawingGroup == null)
                            {
                                drawingGroup = record as MSODRAWINGGROUP;
                                records.Add(record);
                            }
                            else
                            {
                                drawingGroup.ContinuedRecords.Add(record);
                            }
                            break;

                        default:
                            records.Add(record);
                            break;
                        }
                        last_record = record;
                    }
                    record = Record.Read(stream);
                }
                records.Add(record);
            }
            else
            {
                throw new Exception("Invalid Workbook.");
            }
            return(records);
        }
Пример #3
0
        private static Record EncodeImages(IList <Image> images)
        {
            MSODRAWINGGROUP    mSODRAWINGGROUP    = new MSODRAWINGGROUP();
            MsofbtDggContainer msofbtDggContainer = new MsofbtDggContainer();

            mSODRAWINGGROUP.EscherRecords.Add(msofbtDggContainer);
            MsofbtDgg msofbtDgg = new MsofbtDgg();

            msofbtDgg.NumSavedDrawings = images.Count;
            checked
            {
                msofbtDgg.NumSavedShapes = images.Count + 1;
                msofbtDgg.MaxShapeID     = 1024 + msofbtDgg.NumSavedShapes;
                msofbtDgg.GroupIdClusters.Add(1, msofbtDgg.NumSavedShapes);
                msofbtDggContainer.EscherRecords.Add(msofbtDgg);
                MsofbtBstoreContainer msofbtBstoreContainer = new MsofbtBstoreContainer();
                msofbtBstoreContainer.Instance = (ushort)images.Count;
                foreach (Image current in images)
                {
                    MsofbtBSE msofbtBSE = new MsofbtBSE();
                    msofbtBSE.UID                  = Guid.NewGuid();
                    msofbtBSE.Ref                  = 1;
                    msofbtBSE.Version              = 2;
                    msofbtBSE.BlipRecord           = WorkbookEncoder.CreateBlipRecord(current);
                    msofbtBSE.BlipRecord.Type      = current.Format;
                    msofbtBSE.BlipRecord.ImageData = current.Data;
                    msofbtBSE.BlipRecord.UID       = msofbtBSE.UID;
                    msofbtBSE.BlipRecord.Marker    = 255;
                    msofbtBSE.SetBlipType(current.Format);
                    msofbtBstoreContainer.EscherRecords.Add(msofbtBSE);
                }
                msofbtDggContainer.EscherRecords.Add(msofbtBstoreContainer);
                MsofbtOPT msofbtOPT = new MsofbtOPT();
                msofbtOPT.Add(PropertyIDs.FitTextToShape, 524296u);
                msofbtOPT.Add(PropertyIDs.FillColor, 134217793u);
                msofbtOPT.Add(PropertyIDs.LineColor, 134217792u);
                msofbtDggContainer.EscherRecords.Add(msofbtOPT);
                MsofbtSplitMenuColors msofbtSplitMenuColors = new MsofbtSplitMenuColors();
                msofbtSplitMenuColors.Instance = 4;
                msofbtSplitMenuColors.Color1   = 134217741;
                msofbtSplitMenuColors.Color2   = 134217740;
                msofbtSplitMenuColors.Color3   = 134217751;
                msofbtSplitMenuColors.Color4   = 268435703;
                msofbtDggContainer.EscherRecords.Add(msofbtSplitMenuColors);
                return(mSODRAWINGGROUP);
            }
        }
Пример #4
0
        private static Record EncodeImages(IList<Image> images)
        {
            MSODRAWINGGROUP drawingGroup = new MSODRAWINGGROUP();
            MsofbtDggContainer dggContainer = new MsofbtDggContainer();
            drawingGroup.EscherRecords.Add(dggContainer);

            MsofbtDgg dgg = new MsofbtDgg();
            dgg.NumSavedDrawings = images.Count;
            dgg.NumSavedShapes = images.Count + 1;
            dgg.MaxShapeID = 1024 + dgg.NumSavedShapes;
            dgg.GroupIdClusters.Add(1, dgg.NumSavedShapes);
            dggContainer.EscherRecords.Add(dgg);

            MsofbtBstoreContainer bstoreContainer = new MsofbtBstoreContainer();
            bstoreContainer.Instance = (ushort)images.Count;
            foreach (Image image in images)
            {
                MsofbtBSE blipStoreEntry = new MsofbtBSE();
                blipStoreEntry.UID = Guid.NewGuid();
                blipStoreEntry.Ref = 1;
                blipStoreEntry.Version = 2;
                blipStoreEntry.BlipRecord = CreateBlipRecord(image);
                blipStoreEntry.BlipRecord.Type = image.Format;
                blipStoreEntry.BlipRecord.ImageData = image.Data;
                blipStoreEntry.BlipRecord.UID = blipStoreEntry.UID;
                blipStoreEntry.BlipRecord.Marker = 255;
                blipStoreEntry.SetBlipType(image.Format);
                bstoreContainer.EscherRecords.Add(blipStoreEntry);
            }
            dggContainer.EscherRecords.Add(bstoreContainer);

            MsofbtOPT defautProperties = new MsofbtOPT();
            defautProperties.Add(PropertyIDs.FitTextToShape, 524296);
            defautProperties.Add(PropertyIDs.FillColor, 134217793);
            defautProperties.Add(PropertyIDs.LineColor, 134217792);
            dggContainer.EscherRecords.Add(defautProperties);

            MsofbtSplitMenuColors splitMenuColors = new MsofbtSplitMenuColors();
            splitMenuColors.Instance = 4;
            splitMenuColors.Color1 = 134217741;
            splitMenuColors.Color2 = 134217740;
            splitMenuColors.Color3 = 134217751;
            splitMenuColors.Color4 = 268435703;
            dggContainer.EscherRecords.Add(splitMenuColors);

            return drawingGroup;
        }
Пример #5
0
 private static List<Record> ReadRecords(Stream stream, out MSODRAWINGGROUP drawingGroup)
 {
     List<Record> records = new List<Record>();
     drawingGroup = null;
     Record record = Record.Read(stream);
     record.Decode();
     Record last_record = record;
     if (record is BOF && ((BOF)record).StreamType == StreamType.WorkbookGlobals)
     {
         while (record.Type != RecordType.EOF)
         {
             if (record.Type == RecordType.CONTINUE)
             {
                 last_record.ContinuedRecords.Add(record);
             }
             else
             {
                 switch (record.Type)
                 {
                     case RecordType.MSODRAWINGGROUP:
                         if (drawingGroup == null)
                         {
                             drawingGroup = record as MSODRAWINGGROUP;
                             records.Add(record);
                         }
                         else
                         {
                             drawingGroup.ContinuedRecords.Add(record);
                         }
                         break;
                     default:
                         records.Add(record);
                         break;
                 }
                 last_record = record;
             }
             record = Record.Read(stream);
         }
         records.Add(record);
     }
     else
     {
         throw new Exception("Invalid Workbook.");
     }
     return records;
 }
Пример #6
0
        private static List <Record> ReadRecords(Stream stream, out MSODRAWINGGROUP drawingGroup)
        {
            List <Record> list = new List <Record>();

            drawingGroup = null;
            Record record = Record.Read(stream);

            record.Decode();
            Record record2 = record;

            if (record is BOF && ((BOF)record).StreamType == 5)
            {
                while (record.Type != 10)
                {
                    if (record.Type == 60)
                    {
                        record2.ContinuedRecords.Add(record);
                    }
                    else
                    {
                        ushort type = record.Type;
                        if (type != 235)
                        {
                            list.Add(record);
                        }
                        else
                        {
                            if (drawingGroup == null)
                            {
                                drawingGroup = (record as MSODRAWINGGROUP);
                                list.Add(record);
                            }
                            else
                            {
                                drawingGroup.ContinuedRecords.Add(record);
                            }
                        }
                        record2 = record;
                    }
                    record = Record.Read(stream);
                }
                list.Add(record);
                return(list);
            }
            throw new Exception("Invalid Workbook.");
        }
Пример #7
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);
        }