/// <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--; } }
// [TODO-NExcel_Next] // /** // * Writes the drawing group to the output file // * // * @param outputFile the file to write to // * @exception IOException // */ // public void write(File outputFile) throws IOException // { // if (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); // // BStoreContainer bstoreCont = new BStoreContainer(drawings.size()); // // // Create a blip entry for each drawing // for (Iterator i = drawings.iterator(); i.hasNext();) // { // Drawing d = (Drawing) i.next(); // 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(); // } // else if (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(numBlips); // // // Create a blip entry for each drawing that was read in // BStoreContainer readBStoreContainer = getBStoreContainer(); // 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 // for (Iterator i = drawings.iterator(); i.hasNext();) // { // Drawing d = (Drawing) i.next(); // if (d.getOrigin() != Drawing.READ) // { // 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); // } /// <summary> Gets the drawing data for the given blip id. Called by the Drawing /// object /// /// </summary> /// <param name="blipId">the blipId /// </param> /// <returns> the drawing data /// </returns> internal virtual sbyte[] getImageData(int blipId) { numBlips = BStoreContainer.NumBlips; Assert.verify(blipId <= numBlips); Assert.verify(origin == READ || origin == READ_WRITE); // Get the blip EscherRecord[] children = BStoreContainer.Children; BlipStoreEntry bse = (BlipStoreEntry)children[blipId - 1]; return(bse.ImageData); }
private void initialize() { int curpos = Pos + HEADER_LENGTH; int endpos = Pos + Length; EscherRecord newRecord = null; while (curpos < endpos) { EscherRecordData erd = new EscherRecordData(EscherStream, curpos); EscherRecordType type = erd.Type; 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 { newRecord = new EscherAtom(erd); } children.Add(newRecord); curpos += newRecord.Length; } initialized = true; }