Example #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;
        }
Example #2
0
        /**
         * Displays an escher record
         *
         * @param er the record to display
         * @param level the amount of indentation
         * @exception IOException
         */
        private void displayRecord(EscherRecord er, int level)
        {
            indent(level);

            EscherRecordType type = er.getType();

            // Display the code
            writer.Write(System.String.Format("{0:X}", type.getValue()));
            writer.Write(" - ");

            // Display the name
            if (type == EscherRecordType.DGG_CONTAINER)
            {
                writer.WriteLine("Dgg Container");
            }
            else if (type == EscherRecordType.BSTORE_CONTAINER)
            {
                writer.WriteLine("BStore Container");
            }
            else if (type == EscherRecordType.DG_CONTAINER)
            {
                writer.WriteLine("Dg Container");
            }
            else if (type == EscherRecordType.SPGR_CONTAINER)
            {
                writer.WriteLine("Spgr Container");
            }
            else if (type == EscherRecordType.SP_CONTAINER)
            {
                writer.WriteLine("Sp Container");
            }
            else if (type == EscherRecordType.DGG)
            {
                writer.WriteLine("Dgg");
            }
            else if (type == EscherRecordType.BSE)
            {
                writer.WriteLine("Bse");
            }
            else if (type == EscherRecordType.DG)
            {
                Dg dg = new Dg(er.getEscherData());
                writer.WriteLine("Dg:  drawing id " + dg.getDrawingId() + " shape count " + dg.getShapeCount());
            }
            else if (type == EscherRecordType.SPGR)
            {
                writer.WriteLine("Spgr");
            }
            else if (type == EscherRecordType.SP)
            {
                Sp sp = new Sp(er.getEscherData());
                writer.WriteLine("Sp:  shape id " + sp.getShapeId() + " shape type " + sp.getShapeType());
            }
            else if (type == EscherRecordType.OPT)
            {
                Opt          opt  = new Opt(er.getEscherData());
                Opt.Property p260 = opt.getProperty(260);
                Opt.Property p261 = opt.getProperty(261);
                writer.Write("Opt (value, StringValue): ");
                if (p260 != null)
                {
                    writer.Write("260: " +
                                 p260.value + ", " +
                                 p260.StringValue +
                                 ";");
                }
                if (p261 != null)
                {
                    writer.Write("261: " +
                                 p261.value + ", " +
                                 p261.StringValue +
                                 ";");
                }
                writer.WriteLine(string.Empty);
            }
            else if (type == EscherRecordType.CLIENT_ANCHOR)
            {
                writer.WriteLine("Client Anchor");
            }
            else if (type == EscherRecordType.CLIENT_DATA)
            {
                writer.WriteLine("Client Data");
            }
            else if (type == EscherRecordType.CLIENT_TEXT_BOX)
            {
                writer.WriteLine("Client Text Box");
            }
            else if (type == EscherRecordType.SPLIT_MENU_COLORS)
            {
                writer.WriteLine("Split Menu Colors");
            }
            else
            {
                writer.WriteLine("???");
            }
        }