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