/** * Performs a recursive search for pictures in the given list of escher records. * * @param escherRecords the escher records. * @param pictures the list to populate with the pictures. */ private void SearchForPictures(IList escherRecords, List <Picture> pictures) { foreach (EscherRecord escherRecord in escherRecords) { if (escherRecord is EscherBSERecord) { EscherBSERecord bse = (EscherBSERecord)escherRecord; EscherBlipRecord blip = bse.BlipRecord; if (blip != null) { pictures.Add(new Picture(blip.PictureData)); } else if (bse.Offset > 0) { // Blip stored in delay stream, which in a word doc, is the main stream EscherRecordFactory recordFactory = new DefaultEscherRecordFactory(); EscherRecord record = recordFactory.CreateRecord(_mainStream, bse.Offset); if (record is EscherBlipRecord) { record.FillFields(_mainStream, bse.Offset, recordFactory); blip = (EscherBlipRecord)record; pictures.Add(new Picture(blip.PictureData)); } } } // Recursive call. SearchForPictures(escherRecord.ChildRecords, pictures); } }
public byte[] GetPictureData() { EscherContainerRecord shapeDescription = od.GetEscherShapeRecordContainer(GetShapeId()); if (shapeDescription == null) { return(null); } EscherRecord escherOptRecord = (EscherRecord)shapeDescription .GetChildById(EscherOptRecord.RECORD_ID); if (escherOptRecord == null) { return(null); } EscherSimpleProperty escherProperty = (EscherSimpleProperty)((EscherOptRecord)escherOptRecord) .Lookup(EscherProperties.BLIP__BLIPTODISPLAY); if (escherProperty == null) { return(null); } int bitmapIndex = escherProperty.PropertyValue; EscherBlipRecord escherBlipRecord = od.GetBitmapRecord(bitmapIndex); if (escherBlipRecord == null) { return(null); } return(escherBlipRecord.PictureData); }
private EscherBlipRecord GetBitmapRecord(int bitmapIndex) { List <EscherContainerRecord> bContainers = _escherRecordHolder .GetBStoreContainers(); if (bContainers == null || bContainers.Count != 1) { return(null); } EscherContainerRecord bContainer = bContainers[0]; IList bitmapRecords = bContainer.ChildRecords; if (bitmapRecords.Count < bitmapIndex) { return(null); } EscherRecord imageRecord = (EscherRecord)bitmapRecords[bitmapIndex - 1]; if (imageRecord is EscherBlipRecord) { return((EscherBlipRecord)imageRecord); } if (imageRecord is EscherBSERecord) { EscherBSERecord bseRecord = (EscherBSERecord)imageRecord; EscherBlipRecord blip = bseRecord.BlipRecord; if (blip != null) { return(blip); } if (bseRecord.Offset > 0) { /* * Blip stored in delay stream, which in a word doc, is the main * stream */ EscherRecordFactory recordFactory = new DefaultEscherRecordFactory(); EscherRecord record = recordFactory.CreateRecord(_mainStream, bseRecord.Offset); if (record is EscherBlipRecord) { record.FillFields(_mainStream, bseRecord.Offset, recordFactory); return((EscherBlipRecord)record); } } } return(null); }
/** * Performs a recursive search for pictures in the given list of escher records. * * @param escherRecords the escher records. * @param pictures the list to populate with the pictures. */ private void SearchForPictures(IList escherRecords, List <Picture> pictures) { foreach (EscherRecord escherRecord in escherRecords) { if (escherRecord is EscherBSERecord) { EscherBSERecord bse = (EscherBSERecord)escherRecord; EscherBlipRecord blip = bse.BlipRecord; if (blip != null) { pictures.Add(new Picture(blip.PictureData)); } else if (bse.Offset > 0) { try { // Blip stored in delay stream, which in a word doc, is the main stream IEscherRecordFactory recordFactory = new DefaultEscherRecordFactory(); EscherRecord record = recordFactory.CreateRecord(_mainStream, bse.Offset); if (record is EscherBlipRecord) { record.FillFields(_mainStream, bse.Offset, recordFactory); blip = (EscherBlipRecord)record; pictures.Add(new Picture(blip.PictureData)); } } catch (Exception exc) { logger.Log( POILogger.WARN, "Unable to load picture from BLIB record at offset #", bse.Offset, exc); } } } // Recursive call. SearchForPictures(escherRecord.ChildRecords, pictures); } }
/// <summary> /// Constructs a picture object. /// </summary> /// <param name="blip">the underlying blip record containing the bitmap data.</param> public HSSFPictureData(EscherBlipRecord blip) { this.blip = blip; }