Beispiel #1
0
        /**
         * Creates the main Sp container for the drawing
         *
         * @return the SP container
         */
        public EscherContainer getSpContainer()
        {
            if (!initialized)
            {
                initialize();
            }

            if (origin == Origin.READ)
            {
                return(getReadSpContainer());
            }

            if (spContainer == null)
            {
                spContainer = new SpContainer();
                Sp sp = new Sp(type, shapeId, 2560);
                spContainer.add(sp);
                Opt opt = new Opt();
                opt.addProperty(344, false, false, 0);              // ?
                opt.addProperty(385, false, false, 134217808);      // fill colour
                opt.addProperty(387, false, false, 134217808);      // background colour
                opt.addProperty(959, false, false, 131074);         // hide
                spContainer.add(opt);

                ClientAnchor clientAnchor = new ClientAnchor(column + 1.3,
                                                             System.Math.Max(0, row - 0.6),
                                                             column + 1.3 + width,
                                                             row + height,
                                                             0x1);

                spContainer.add(clientAnchor);

                ClientData clientData = new ClientData();
                spContainer.add(clientData);

                ClientTextBox clientTextBox = new ClientTextBox();
                spContainer.add(clientTextBox);
            }

            return(spContainer);
        }
Beispiel #2
0
        /**
         * Creates the main Sp container for the drawing
         *
         * @return the SP container
         */
        public virtual EscherContainer getSpContainer()
        {
            if (!initialized)
            {
                initialize();
            }

            if (origin == Origin.READ)
            {
                return(getReadSpContainer());
            }

            SpContainer spContainer = new SpContainer();
            Sp          sp          = new Sp(type, shapeId, 2560);

            spContainer.add(sp);
            Opt opt = new Opt();

            opt.addProperty(260, true, false, blipId);

            if (type == ShapeType.PICTURE_FRAME)
            {
                string filePath = imageFile != null ? imageFile.FullName : string.Empty;
                opt.addProperty(261, true, true, filePath.Length * 2, filePath);
                opt.addProperty(447, false, false, 65536);
                opt.addProperty(959, false, false, 524288);
                spContainer.add(opt);
            }

            ClientAnchor clientAnchor = new ClientAnchor
                                            (x, y, x + width, y + height,
                                            imageAnchorProperties.getValue());

            spContainer.add(clientAnchor);
            ClientData clientData = new ClientData();

            spContainer.add(clientData);

            return(spContainer);
        }
Beispiel #3
0
        /**
         * Creates the main Sp container for the drawing
         *
         * @return the SP container
         */
        public virtual EscherContainer getSpContainer()
        {
            if (!initialized)
            {
                initialize();
            }

            if (origin == Origin.READ)
            {
                return(getReadSpContainer());
            }

            SpContainer spc = new SpContainer();
            Sp          sp  = new Sp(type, shapeId, 2560);

            spc.add(sp);
            Opt opt = new Opt();

            opt.addProperty(127, false, false, 17039620);
            opt.addProperty(191, false, false, 524296);
            opt.addProperty(511, false, false, 524288);
            opt.addProperty(959, false, false, 131072);
            //    opt.addProperty(260, true, false, blipId);
            //    opt.addProperty(261, false, false, 36);
            spc.add(opt);

            ClientAnchor clientAnchor = new ClientAnchor(column,
                                                         row,
                                                         column + 1,
                                                         row + 1,
                                                         0x1);

            spc.add(clientAnchor);
            ClientData clientData = new ClientData();

            spc.add(clientData);

            return(spc);
        }
        /**
         * Creates the main Sp container for the drawing
         *
         * @return the SP container
         */
        public EscherContainer getSpContainer()
        {
            if (!initialized)
                {
                initialize();
                }

            if (origin == Origin.READ)
                {
                return getReadSpContainer();
                }

            SpContainer spc = new SpContainer();
            Sp sp = new Sp(type,shapeId,2560);
            spc.add(sp);
            Opt opt = new Opt();
            opt.addProperty(127,false,false,17039620);
            opt.addProperty(191,false,false,524296);
            opt.addProperty(511,false,false,524288);
            opt.addProperty(959,false,false,131072);
            //    opt.addProperty(260, true, false, blipId);
            //    opt.addProperty(261, false, false, 36);
            spc.add(opt);

            ClientAnchor clientAnchor = new ClientAnchor(column,
                                                         row,
                                                         column + 1,
                                                         row + 1,
                                                         0x1);
            spc.add(clientAnchor);
            ClientData clientData = new ClientData();
            spc.add(clientData);

            return spc;
        }
        /**
         * Creates the main Sp container for the drawing
         *
         * @return the SP container
         */
        public EscherContainer getSpContainer()
        {
            if (!initialized)
                {
                initialize();
                }

            if (origin == Origin.READ)
                {
                return getReadSpContainer();
                }

            if (spContainer == null)
                {
                spContainer = new SpContainer();
                Sp sp = new Sp(type,shapeId,2560);
                spContainer.add(sp);
                Opt opt = new Opt();
                opt.addProperty(344,false,false,0); // ?
                opt.addProperty(385,false,false,134217808); // fill colour
                opt.addProperty(387,false,false,134217808); // background colour
                opt.addProperty(959,false,false,131074); // hide
                spContainer.add(opt);

                ClientAnchor clientAnchor = new ClientAnchor(column + 1.3,
                                                             System.Math.Max(0,row - 0.6),
                                                             column + 1.3 + width,
                                                             row + height,
                                                             0x1);

                spContainer.add(clientAnchor);

                ClientData clientData = new ClientData();
                spContainer.add(clientData);

                ClientTextBox clientTextBox = new ClientTextBox();
                spContainer.add(clientTextBox);
                }

            return spContainer;
        }
Beispiel #6
0
        /**
         * Writes the drawing group to the output file
         *
         * @param outputFile the file to write to
         * @exception IOException
         */
        public void write(File outputFile)
        {
            if (origin == Origin.WRITE)
            {
                DggContainer dggContainer = new DggContainer();

                Dgg dgg = new Dgg(numBlips + numCharts + 1, numBlips);

                dgg.addCluster(1, 0);
                dgg.addCluster(numBlips + 1, 0);

                dggContainer.add(dgg);

                int             drawingsAdded = 0;
                BStoreContainer bstoreCont    = new BStoreContainer();

                // Create a blip entry for each drawing
                foreach (object o in drawings)
                {
                    if (o is Drawing)
                    {
                        Drawing        d   = (Drawing)o;
                        BlipStoreEntry bse = new BlipStoreEntry(d);

                        bstoreCont.add(bse);
                        drawingsAdded++;
                    }
                }
                if (drawingsAdded > 0)
                {
                    bstoreCont.setNumBlips(drawingsAdded);
                    dggContainer.add(bstoreCont);
                }

                Opt opt = new Opt();

                dggContainer.add(opt);

                SplitMenuColors splitMenuColors = new SplitMenuColors();
                dggContainer.add(splitMenuColors);

                drawingData = dggContainer.getData();
            }
            else if (origin == Origin.READ_WRITE)
            {
                DggContainer dggContainer = new DggContainer();

                Dgg dgg = new Dgg(numBlips + numCharts + 1, numBlips);

                dgg.addCluster(1, 0);
                dgg.addCluster(drawingGroupId + numBlips + 1, 0);

                dggContainer.add(dgg);

                BStoreContainer bstoreCont = new BStoreContainer();
                bstoreCont.setNumBlips(numBlips);

                // Create a blip entry for each drawing that was read in
                BStoreContainer readBStoreContainer = getBStoreContainer();

                if (readBStoreContainer != null)
                {
                    EscherRecord[] children = readBStoreContainer.getChildren();
                    for (int i = 0; i < children.Length; i++)
                    {
                        BlipStoreEntry bse = (BlipStoreEntry)children[i];
                        bstoreCont.add(bse);
                    }
                }

                // Create a blip entry for each drawing that has been added
                foreach (DrawingGroupObject dgo in drawings)
                {
                    if (dgo is Drawing)
                    {
                        Drawing d = (Drawing)dgo;
                        if (d.getOrigin() == Origin.WRITE)
                        {
                            BlipStoreEntry bse = new BlipStoreEntry(d);
                            bstoreCont.add(bse);
                        }
                    }
                }

                dggContainer.add(bstoreCont);

                Opt opt = new Opt();

                opt.addProperty(191, false, false, 524296);
                opt.addProperty(385, false, false, 134217737);
                opt.addProperty(448, false, false, 134217792);

                dggContainer.add(opt);

                SplitMenuColors splitMenuColors = new SplitMenuColors();
                dggContainer.add(splitMenuColors);

                drawingData = dggContainer.getData();
            }

            MsoDrawingGroupRecord msodg = new MsoDrawingGroupRecord(drawingData);

            outputFile.write(msodg);
        }
Beispiel #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;
        }
Beispiel #8
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("???");
            }
        }
        /**
         * Initialization
         */
        private void initialize()
        {
            int curpos = getPos() + HEADER_LENGTH;
            int endpos = System.Math.Min(getPos() + getLength(),getStreamLength());

            EscherRecord newRecord = null;

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

                EscherRecordType type = erd.getType();
                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 if (type == EscherRecordType.CLIENT_TEXT_BOX)
                    newRecord = new ClientTextBox(erd);
                else
                    newRecord = new EscherAtom(erd);

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

            initialized = true;
        }
Beispiel #10
0
        /**
         * Initialization
         */
        private void initialize()
        {
            int curpos = getPos() + HEADER_LENGTH;
            int endpos = System.Math.Min(getPos() + getLength(), getStreamLength());

            EscherRecord newRecord = null;

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

                EscherRecordType type = erd.getType();
                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 if (type == EscherRecordType.CLIENT_TEXT_BOX)
                {
                    newRecord = new ClientTextBox(erd);
                }
                else
                {
                    newRecord = new EscherAtom(erd);
                }

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

            initialized = true;
        }
Beispiel #11
0
        /**
         * Creates the main Sp container for the drawing
         *
         * @return the SP container
         */
        public virtual EscherContainer getSpContainer()
        {
            if (!initialized)
                initialize();

            if (origin == Origin.READ)
                return getReadSpContainer();

            SpContainer spContainer = new SpContainer();
            Sp sp = new Sp(type,shapeId,2560);
            spContainer.add(sp);
            Opt opt = new Opt();
            opt.addProperty(260,true,false,blipId);

            if (type == ShapeType.PICTURE_FRAME)
                {
                string filePath = imageFile != null ? imageFile.FullName : string.Empty;
                opt.addProperty(261,true,true,filePath.Length * 2,filePath);
                opt.addProperty(447,false,false,65536);
                opt.addProperty(959,false,false,524288);
                spContainer.add(opt);
                }

            ClientAnchor clientAnchor = new ClientAnchor
              (x,y,x + width,y + height,
               imageAnchorProperties.getValue());
            spContainer.add(clientAnchor);
            ClientData clientData = new ClientData();
            spContainer.add(clientData);

            return spContainer;
        }