private static Record EncodePictures(Dictionary<Pair<int, int>, Picture> pictures, SharedResource sharedResource, Worksheet worksheet)
        {
            MSODRAWING msoDrawing = new MSODRAWING();
            MsofbtDgContainer dgContainer = new MsofbtDgContainer();
            msoDrawing.EscherRecords.Add(dgContainer);

            MsofbtDg dg = new MsofbtDg();
            dg.Instance = 1;
            dg.NumShapes = pictures.Count + 1;
            dg.LastShapeID = 1024 + pictures.Count;
            dgContainer.EscherRecords.Add(dg);

            MsofbtSpgrContainer spgrContainer = new MsofbtSpgrContainer();
            dgContainer.EscherRecords.Add(spgrContainer);

            MsofbtSpContainer spContainer0 = new MsofbtSpContainer();
            spContainer0.EscherRecords.Add(new MsofbtSpgr());
            MsofbtSp shape0 = new MsofbtSp();
            shape0.ShapeId = 1024;
            shape0.Flags = ShapeFlag.Group | ShapeFlag.Patriarch;
            shape0.Version = 2;
            spContainer0.EscherRecords.Add(shape0);
            spgrContainer.EscherRecords.Add(spContainer0);

            foreach (Picture pic in pictures.Values)
            {
                if (!sharedResource.Images.Contains(pic.Image))
                {
                    sharedResource.Images.Add(pic.Image);
                }
                MsofbtSpContainer spContainer = new MsofbtSpContainer();
                MsofbtSp shape = new MsofbtSp();
                shape.Version = 2;
                shape.ShapeType = ShapeType.PictureFrame;
                shape.ShapeId = 1024 + spgrContainer.EscherRecords.Count;
                shape.Flags = ShapeFlag.Haveanchor | ShapeFlag.Hasshapetype;
                spContainer.EscherRecords.Add(shape);

                MsofbtOPT opt = new MsofbtOPT();
                opt.Add(PropertyIDs.LockAgainstGrouping, 33226880);
                opt.Add(PropertyIDs.FitTextToShape, 262148);
                opt.Add(PropertyIDs.BlipId, (uint)sharedResource.Images.IndexOf(pic.Image) + 1);
                spContainer.EscherRecords.Add(opt);

                MsofbtClientAnchor anchor = new MsofbtClientAnchor();
                anchor.Row1 = pic.TopLeftCorner.RowIndex;
                anchor.Col1 = pic.TopLeftCorner.ColIndex;
                anchor.DX1 = pic.TopLeftCorner.DX;
                anchor.DY1 = pic.TopLeftCorner.DY;
                anchor.Row2 = pic.BottomRightCorner.RowIndex;
                anchor.Col2 = pic.BottomRightCorner.ColIndex;
                anchor.DX2 = pic.BottomRightCorner.DX;
                anchor.DY2 = pic.BottomRightCorner.DY;
                anchor.ExtraData = new byte[0];
                spContainer.EscherRecords.Add(anchor);

                spContainer.EscherRecords.Add(new MsofbtClientData());

                spgrContainer.EscherRecords.Add(spContainer);
            }
            return msoDrawing;
        }
示例#2
0
        public static EscherRecord Read(Stream stream)
        {
            EscherRecord escherRecord = EscherRecord.ReadBase(stream);
            ushort       type         = escherRecord.Type;
            EscherRecord result;

            switch (type)
            {
            case 61440:
                result = new MsofbtDggContainer(escherRecord);
                return(result);

            case 61441:
                result = new MsofbtBstoreContainer(escherRecord);
                return(result);

            case 61442:
                result = new MsofbtDgContainer(escherRecord);
                return(result);

            case 61443:
                result = new MsofbtSpgrContainer(escherRecord);
                return(result);

            case 61444:
                result = new MsofbtSpContainer(escherRecord);
                return(result);

            case 61445:
                result = new MsofbtSolverContainer(escherRecord);
                return(result);

            case 61446:
                result = new MsofbtDgg(escherRecord);
                return(result);

            case 61447:
                result = new MsofbtBSE(escherRecord);
                return(result);

            case 61448:
                result = new MsofbtDg(escherRecord);
                return(result);

            case 61449:
                result = new MsofbtSpgr(escherRecord);
                return(result);

            case 61450:
                result = new MsofbtSp(escherRecord);
                return(result);

            case 61451:
                result = new MsofbtOPT(escherRecord);
                return(result);

            case 61452:
                result = new MsofbtTextbox(escherRecord);
                return(result);

            case 61453:
                result = new MsofbtClientTextbox(escherRecord);
                return(result);

            case 61454:
                result = new MsofbtAnchor(escherRecord);
                return(result);

            case 61455:
                result = new MsofbtChildAnchor(escherRecord);
                return(result);

            case 61456:
                result = new MsofbtClientAnchor(escherRecord);
                return(result);

            case 61457:
                result = new MsofbtClientData(escherRecord);
                return(result);

            case 61458:
                result = new MsofbtConnectorRule(escherRecord);
                return(result);

            case 61459:
                result = new MsofbtAlignRule(escherRecord);
                return(result);

            case 61460:
                result = new MsofbtArcRule(escherRecord);
                return(result);

            case 61461:
                result = new MsofbtClientRule(escherRecord);
                return(result);

            case 61462:
                result = new MsofbtCLSID(escherRecord);
                return(result);

            case 61463:
                result = new MsofbtCalloutRule(escherRecord);
                return(result);

            case 61464:
                result = new MsofbtBlipStart(escherRecord);
                return(result);

            case 61465:
                break;

            case 61466:
                result = new MsofbtBlipMetafileEMF(escherRecord);
                return(result);

            case 61467:
                result = new MsofbtBlipMetafileWMF(escherRecord);
                return(result);

            case 61468:
                result = new MsofbtBlipMetafilePICT(escherRecord);
                return(result);

            case 61469:
                result = new MsofbtBlipBitmapJPEG(escherRecord);
                return(result);

            case 61470:
                result = new MsofbtBlipBitmapPNG(escherRecord);
                return(result);

            case 61471:
                result = new MsofbtBlipBitmapDIB(escherRecord);
                return(result);

            default:
                switch (type)
                {
                case 61719:
                    result = new MsofbtBlipEnd(escherRecord);
                    return(result);

                case 61720:
                    result = new MsofbtRegroupItems(escherRecord);
                    return(result);

                case 61721:
                    result = new MsofbtSelection(escherRecord);
                    return(result);

                case 61722:
                    result = new MsofbtColorMRU(escherRecord);
                    return(result);

                case 61725:
                    result = new MsofbtDeletedPspl(escherRecord);
                    return(result);

                case 61726:
                    result = new MsofbtSplitMenuColors(escherRecord);
                    return(result);

                case 61727:
                    result = new MsofbtOleObject(escherRecord);
                    return(result);

                case 61728:
                    result = new MsofbtColorScheme(escherRecord);
                    return(result);
                }
                break;
            }
            result = escherRecord;
            return(result);
        }