Ejemplo n.º 1
0
        /// <summary> Adds a drawing from the public, writable interface
        ///
        /// </summary>
        /// <param name="d">the drawing to add
        /// </param>
        public virtual void  add(Drawing d)
        {
            if (origin == READ)
            {
                origin   = READ_WRITE;
                numBlips = BStoreContainer.NumBlips;

                Dgg dgg = (Dgg)escherData.Children[0];
                drawingGroupId = dgg.getCluster(1).drawingGroupId - numBlips - 1;
            }

            // See if this is referenced elsewhere
            Drawing refImage = (Drawing)imageFiles[d.ImageFilePath];

            if (refImage == null)
            {
                // There are no other references to this drawing, so assign
                // a new object id and put it on the hash map
                drawings.Add(d);
                d.DrawingGroup = this;
                d.setObjectId(numBlips + 1, numBlips + 1);
                numBlips++;
                imageFiles[d.ImageFilePath] = d;
            }
            else
            {
                // This drawing is used elsewhere in the workbook.  Increment the
                // reference count on the drawing, and set the object id of the drawing
                // passed in
                refImage.ReferenceCount = refImage.ReferenceCount + 1;
                d.DrawingGroup          = this;
                d.setObjectId(refImage.getObjectId(), refImage.BlipId);
            }
        }
Ejemplo n.º 2
0
        /// <summary> Interface method to remove a drawing from the group
        ///
        /// </summary>
        /// <param name="d">the drawing to remove
        /// </param>
        public virtual void  remove(Drawing d)
        {
            if (origin == READ)
            {
                origin   = READ_WRITE;
                numBlips = BStoreContainer.NumBlips;
                Dgg dgg = (Dgg)escherData.Children[0];
                drawingGroupId = dgg.getCluster(1).drawingGroupId - numBlips - 1;
            }

            // Get the blip
            EscherRecord[] children = BStoreContainer.Children;
            BlipStoreEntry bse      = (BlipStoreEntry)children[d.BlipId - 1];

            bse.dereference();

            if (bse.ReferenceCount == 0)
            {
                // Remove the blip
                BStoreContainer.remove(bse);

                // Adjust blipId on the other blips
                foreach (Drawing drawing in drawings)
                {
                    if (drawing.BlipId > d.BlipId)
                    {
                        drawing.setObjectId(drawing.getObjectId(), drawing.BlipId - 1);
                    }
                }


                numBlips--;
            }
        }
Ejemplo n.º 3
0
        private void  initialize()
        {
            int curpos = Pos + HEADER_LENGTH;
            int endpos = Pos + Length;

            EscherRecord newRecord = null;

            while (curpos < endpos)
            {
                EscherRecordData erd = new EscherRecordData(EscherStream, curpos);

                EscherRecordType type = erd.Type;
                if (type == EscherRecordType.DGG)
                {
                    newRecord = new Dgg(erd);
                }
                else if (type == EscherRecordType.DG)
                {
                    newRecord = new Dg(erd);
                }
                else if (type == EscherRecordType.BSTORE_CONTAINER)
                {
                    newRecord = new BStoreContainer(erd);
                }
                else if (type == EscherRecordType.SPGR_CONTAINER)
                {
                    newRecord = new SpgrContainer(erd);
                }
                else if (type == EscherRecordType.SP_CONTAINER)
                {
                    newRecord = new SpContainer(erd);
                }
                else if (type == EscherRecordType.SPGR)
                {
                    newRecord = new Spgr(erd);
                }
                else if (type == EscherRecordType.SP)
                {
                    newRecord = new Sp(erd);
                }
                else if (type == EscherRecordType.CLIENT_ANCHOR)
                {
                    newRecord = new ClientAnchor(erd);
                }
                else if (type == EscherRecordType.CLIENT_DATA)
                {
                    newRecord = new ClientData(erd);
                }
                else if (type == EscherRecordType.BSE)
                {
                    newRecord = new BlipStoreEntry(erd);
                }
                else if (type == EscherRecordType.OPT)
                {
                    newRecord = new Opt(erd);
                }
                else if (type == EscherRecordType.SPLIT_MENU_COLORS)
                {
                    newRecord = new SplitMenuColors(erd);
                }
                else
                {
                    newRecord = new EscherAtom(erd);
                }

                children.Add(newRecord);
                curpos += newRecord.Length;
            }

            initialized = true;
        }