Ejemplo n.º 1
0
        /**
         * Initialization
         */
        private void initialize()
        {
            EscherRecordData er = new EscherRecordData(this, 0);

            Assert.verify(er.isContainer());

            EscherContainer dgContainer = new EscherContainer(er);

            EscherRecord[] children = dgContainer.getChildren();

            children = dgContainer.getChildren();
            // Dg dg = (Dg) children[0];

            EscherContainer spgrContainer = null;

            for (int i = 0; i < children.Length && spgrContainer == null; i++)
            {
                EscherRecord child = children[i];
                if (child.getType() == EscherRecordType.SPGR_CONTAINER)
                {
                    spgrContainer = (EscherContainer)child;
                }
            }
            Assert.verify(spgrContainer != null);

            EscherRecord[] spgrChildren = spgrContainer.getChildren();

            // See if any of the spgrChildren are SpgrContainer
            bool nestedContainers = false;

            for (int i = 0; i < spgrChildren.Length && !nestedContainers; i++)
            {
                if (spgrChildren[i].getType() == EscherRecordType.SPGR_CONTAINER)
                {
                    nestedContainers = true;
                }
            }

            // If there are no nested containers, simply set the spContainer list
            // to be the list of children
            if (!nestedContainers)
            {
                spContainers = spgrChildren;
            }
            else
            {
                // Go through the hierarchy and dig out all the Sp containers
                ArrayList sps = new ArrayList();
                getSpContainers(spgrContainer, sps);

                spContainers = new EscherRecord[sps.Count];
                int pos = 0;
                foreach (EscherRecord record in sps)
                {
                    spContainers[pos++] = record;
                }
            }

            initialized = true;
        }
Ejemplo n.º 2
0
        /**
         * Initializes the member variables from the Escher stream data
         */
        private void initialize()
        {
            readSpContainer = drawingData.getSpContainer(drawingNumber);
            Assert.verify(readSpContainer != null);

            EscherRecord[] children = readSpContainer.getChildren();

            Sp sp = (Sp)readSpContainer.getChildren()[0];

            objectId = objRecord.getObjectId();
            shapeId  = sp.getShapeId();
            type     = ShapeType.getType(sp.getShapeType());

            if (type == ShapeType.UNKNOWN)
            {
                //logger.warn("Unknown shape type");
            }

            ClientAnchor clientAnchor = null;

            for (int i = 0; i < children.Length && clientAnchor == null; i++)
            {
                if (children[i].getType() == EscherRecordType.CLIENT_ANCHOR)
                {
                    clientAnchor = (ClientAnchor)children[i];
                }
            }

            if (clientAnchor == null)
            {
                //logger.warn("client anchor not found");
            }
            else
            {
                column = (int)clientAnchor.getX1() - 1;
                row    = (int)clientAnchor.getY1() + 1;
                width  = clientAnchor.getX2() - clientAnchor.getX1();
                height = clientAnchor.getY2() - clientAnchor.getY1();
            }

            initialized = true;
        }
Ejemplo n.º 3
0
 /**
  * Gets the sp container from the internal data
  *
  * @param spgrContainer the spgr container
  * @param sps the list of sp records
  */
 private void getSpContainers(EscherContainer spgrContainer, ArrayList sps)
 {
     EscherRecord[] spgrChildren = spgrContainer.getChildren();
     for (int i = 0; i < spgrChildren.Length; i++)
     {
         if (spgrChildren[i].getType() == EscherRecordType.SP_CONTAINER)
         {
             sps.Add(spgrChildren[i]);
         }
         else if (spgrChildren[i].getType() == EscherRecordType.SPGR_CONTAINER)
         {
             getSpContainers((EscherContainer)spgrChildren[i], sps);
         }
         else
         {
             //logger.warn("Spgr Containers contains a record other than Sp/Spgr containers");
         }
     }
 }
Ejemplo n.º 4
0
        /**
         * Displays the escher container as text
         *
         * @param ec the escher container
         * @param level the indent level
         * @exception IOException
         */
        private void displayContainer(EscherContainer ec, int level)
        {
            displayRecord(ec, level);

            // Display the contents of the container
            level++;

            EscherRecord[] children = ec.getChildren();

            for (int i = 0; i < children.Length; i++)
            {
                EscherRecord er = children[i];
                if (er.getEscherData().isContainer())
                {
                    displayContainer((EscherContainer)er, level);
                }
                else
                {
                    displayRecord(er, level);
                }
            }
        }
Ejemplo n.º 5
0
        /**
         * Initializes the member variables from the Escher stream data
         */
        private void initialize()
        {
            readSpContainer = drawingData.getSpContainer(drawingNumber);
            Assert.verify(readSpContainer != null);

            EscherRecord[] children = readSpContainer.getChildren();

            Sp sp = (Sp)readSpContainer.getChildren()[0];
            objectId = objRecord.getObjectId();
            shapeId = sp.getShapeId();
            type = ShapeType.getType(sp.getShapeType());

            if (type == ShapeType.UNKNOWN)
                {
                //logger.warn("Unknown shape type");
                }

            ClientAnchor clientAnchor = null;
            for (int i = 0; i < children.Length && clientAnchor == null; i++)
                {
                if (children[i].getType() == EscherRecordType.CLIENT_ANCHOR)
                    clientAnchor = (ClientAnchor)children[i];
                }

            if (clientAnchor == null)
                {
                //logger.warn("Client anchor not found");
                }
            else
                {
                column = (int)clientAnchor.getX1();
                row = (int)clientAnchor.getY1();
                }

            initialized = true;
        }
Ejemplo n.º 6
0
        /**
         * Adds a drawing from the public, writable interface
         *
         * @param d the drawing to add
         */
        public void add(DrawingGroupObject d)
        {
            if (origin == Origin.READ)
            {
                origin = Origin.READ_WRITE;
                BStoreContainer bsc = getBStoreContainer();                 // force initialization
                Dgg             dgg = (Dgg)escherData.getChildren()[0];
                drawingGroupId = dgg.getCluster(1).drawingGroupId - numBlips - 1;
                numBlips       = bsc != null?bsc.getNumBlips() : 0;

                if (bsc != null)
                {
                    Assert.verify(numBlips == bsc.getNumBlips());
                }
            }

            if (!(d is Drawing))
            {
                // Assign a new object id and add it to the list
                //      drawings.add(d);
                maxobjectId++;
                maxShapeId++;
                d.setDrawingGroup(this);
                d.setObjectId(maxobjectId, numBlips + 1, maxShapeId);
                if (drawings.Count > maxobjectId)
                {
                    //logger.warn("drawings length " + drawings.Count +
                    //            " exceeds the max object id " + maxobjectId);
                }
                //      numBlips++;
                return;
            }

            Drawing drawing = (Drawing)d;

            // See if this is referenced elsewhere
            Drawing refImage = null;

            if (imageFiles.ContainsKey(d.getImageFilePath()))
            {
                refImage = imageFiles[d.getImageFilePath()];
            }

            if (refImage == null)
            {
                // There are no other references to this drawing, so assign
                // a new object id and put it on the hash map
                maxobjectId++;
                maxShapeId++;
                drawings.Add(drawing);
                drawing.setDrawingGroup(this);
                drawing.setObjectId(maxobjectId, numBlips + 1, maxShapeId);
                numBlips++;
                imageFiles.Add(drawing.getImageFilePath(), drawing);
            }
            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.setReferenceCount(refImage.getReferenceCount() + 1);
                drawing.setDrawingGroup(this);
                drawing.setObjectId(refImage.getObjectId(),
                                    refImage.getBlipId(),
                                    refImage.getShapeId());
            }
        }
Ejemplo n.º 7
0
        /**
         * Initializes the member variables from the Escher stream data
         */
        private void initialize()
        {
            readSpContainer = drawingData.getSpContainer(drawingNumber);
            Assert.verify(readSpContainer != null);

            EscherRecord[] children = readSpContainer.getChildren();

            Sp sp = (Sp)readSpContainer.getChildren()[0];

            shapeId  = sp.getShapeId();
            objectId = objRecord.getObjectId();
            type     = ShapeType.getType(sp.getShapeType());

            if (type == ShapeType.UNKNOWN)
            {
                //logger.warn("Unknown shape type");
            }

            Opt opt = (Opt)readSpContainer.getChildren()[1];

            if (opt.getProperty(260) != null)
            {
                blipId = opt.getProperty(260).value;
            }

            if (opt.getProperty(261) != null)
            {
                imageFile = new System.IO.FileInfo(opt.getProperty(261).StringValue);
            }
            else
            {
                if (type == ShapeType.PICTURE_FRAME)
                {
                    //logger.warn("no filename property for drawing");
                    imageFile = new System.IO.FileInfo(blipId.ToString().Trim());
                }
            }

            ClientAnchor clientAnchor = null;

            for (int i = 0; i < children.Length && clientAnchor == null; i++)
            {
                if (children[i].getType() == EscherRecordType.CLIENT_ANCHOR)
                {
                    clientAnchor = (ClientAnchor)children[i];
                }
            }

            if (clientAnchor == null)
            {
                //logger.warn("client anchor not found");
            }
            else
            {
                x      = clientAnchor.getX1();
                y      = clientAnchor.getY1();
                width  = clientAnchor.getX2() - x;
                height = clientAnchor.getY2() - y;
                imageAnchorProperties = ImageAnchorProperties.getImageAnchorProperties(clientAnchor.getProperties());
            }

            if (blipId == 0)
            {
                //logger.warn("linked drawings are not supported");
            }

            initialized = true;
        }
Ejemplo n.º 8
0
        /**
         * Initialization
         */
        private void initialize()
        {
            EscherRecordData er = new EscherRecordData(this,0);
            Assert.verify(er.isContainer());

            EscherContainer dgContainer = new EscherContainer(er);
            EscherRecord[] children = dgContainer.getChildren();

            children = dgContainer.getChildren();
            // Dg dg = (Dg) children[0];

            EscherContainer spgrContainer = null;

            for (int i = 0; i < children.Length && spgrContainer == null; i++)
                {
                EscherRecord child = children[i];
                if (child.getType() == EscherRecordType.SPGR_CONTAINER)
                    {
                    spgrContainer = (EscherContainer)child;
                    }
                }
            Assert.verify(spgrContainer != null);

            EscherRecord[] spgrChildren = spgrContainer.getChildren();

            // See if any of the spgrChildren are SpgrContainer
            bool nestedContainers = false;
            for (int i = 0; i < spgrChildren.Length && !nestedContainers; i++)
                {
                if (spgrChildren[i].getType() == EscherRecordType.SPGR_CONTAINER)
                    {
                    nestedContainers = true;
                    }
                }

            // If there are no nested containers, simply set the spContainer list
            // to be the list of children
            if (!nestedContainers)
                spContainers = spgrChildren;
            else
                {
                // Go through the hierarchy and dig out all the Sp containers
                ArrayList sps = new ArrayList();
                getSpContainers(spgrContainer,sps);

                spContainers = new EscherRecord[sps.Count];
                int pos = 0;
                foreach (EscherRecord record in sps)
                    spContainers[pos++] = record;
                }

            initialized = true;
        }
Ejemplo n.º 9
0
 /**
  * Gets the sp container from the internal data
  *
  * @param spgrContainer the spgr container
  * @param sps the list of sp records
  */
 private void getSpContainers(EscherContainer spgrContainer,ArrayList sps)
 {
     EscherRecord[] spgrChildren = spgrContainer.getChildren();
     for (int i = 0; i < spgrChildren.Length; i++)
         {
         if (spgrChildren[i].getType() == EscherRecordType.SP_CONTAINER)
             {
             sps.Add(spgrChildren[i]);
             }
         else if (spgrChildren[i].getType() == EscherRecordType.SPGR_CONTAINER)
             {
             getSpContainers((EscherContainer)spgrChildren[i],sps);
             }
         else
             {
             //logger.warn("Spgr Containers contains a record other than Sp/Spgr containers");
             }
         }
 }
Ejemplo n.º 10
0
        /**
         * Initializes the member variables from the Escher stream data
         */
        private void initialize()
        {
            readSpContainer = drawingData.getSpContainer(drawingNumber);
            Assert.verify(readSpContainer != null);

            EscherRecord[] children = readSpContainer.getChildren();

            Sp sp = (Sp)readSpContainer.getChildren()[0];
            shapeId = sp.getShapeId();
            objectId = objRecord.getObjectId();
            type = ShapeType.getType(sp.getShapeType());

            if (type == ShapeType.UNKNOWN)
                {
                //logger.warn("Unknown shape type");
                }

            Opt opt = (Opt)readSpContainer.getChildren()[1];

            if (opt.getProperty(260) != null)
                blipId = opt.getProperty(260).value;

            if (opt.getProperty(261) != null)
                imageFile = new System.IO.FileInfo(opt.getProperty(261).StringValue);
            else
                {
                if (type == ShapeType.PICTURE_FRAME)
                    {
                    //logger.warn("no filename property for drawing");
                    imageFile = new System.IO.FileInfo(blipId.ToString().Trim());
                    }
                }

            ClientAnchor clientAnchor = null;
            for (int i = 0; i < children.Length && clientAnchor == null; i++)
                {
                if (children[i].getType() == EscherRecordType.CLIENT_ANCHOR)
                    clientAnchor = (ClientAnchor)children[i];
                }

            if (clientAnchor == null)
                {
                //logger.warn("client anchor not found");
                }
            else
                {
                x = clientAnchor.getX1();
                y = clientAnchor.getY1();
                width = clientAnchor.getX2() - x;
                height = clientAnchor.getY2() - y;
                imageAnchorProperties = ImageAnchorProperties.getImageAnchorProperties(clientAnchor.getProperties());
                }

            if (blipId == 0)
                {
                //logger.warn("linked drawings are not supported");
                }

            initialized = true;
        }