/** * Constructor * * @param d the drawing * @exception IOException */ public BlipStoreEntry(Drawing d) : base(EscherRecordType.BSE) { type = BlipType.PNG; setVersion(2); setInstance(type.getValue()); byte[] imageData = d.getImageBytes(); imageDataLength = imageData.Length; data = new byte[imageDataLength + IMAGE_DATA_OFFSET]; System.Array.Copy(imageData, 0, data, IMAGE_DATA_OFFSET, imageDataLength); referenceCount = d.getReferenceCount(); write = true; }
/** * Constructor * * @param d the drawing * @exception IOException */ public BlipStoreEntry(Drawing d) : base(EscherRecordType.BSE) { type = BlipType.PNG; setVersion(2); setInstance(type.getValue()); byte[] imageData = d.getImageBytes(); imageDataLength = imageData.Length; data = new byte[imageDataLength + IMAGE_DATA_OFFSET]; System.Array.Copy(imageData,0,data,IMAGE_DATA_OFFSET,imageDataLength); referenceCount = d.getReferenceCount(); write = true; }
/** * 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()); } }