Ejemplo n.º 1
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.º 2
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);
            }
        }