use of org.apache.poi.ddf.EscherRecord in project poi by apache.
the class OfficeDrawingsImpl method getBitmapRecord.
private EscherBlipRecord getBitmapRecord(int bitmapIndex) {
List<? extends EscherContainerRecord> bContainers = _escherRecordHolder.getBStoreContainers();
if (bContainers == null || bContainers.size() != 1)
return null;
EscherContainerRecord bContainer = bContainers.get(0);
final List<EscherRecord> bitmapRecords = bContainer.getChildRecords();
if (bitmapRecords.size() < bitmapIndex)
return null;
EscherRecord imageRecord = bitmapRecords.get(bitmapIndex - 1);
if (imageRecord instanceof EscherBlipRecord) {
return (EscherBlipRecord) imageRecord;
}
if (imageRecord instanceof EscherBSERecord) {
EscherBSERecord bseRecord = (EscherBSERecord) imageRecord;
EscherBlipRecord blip = bseRecord.getBlipRecord();
if (blip != null) {
return blip;
}
if (bseRecord.getOffset() > 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.getOffset());
if (record instanceof EscherBlipRecord) {
record.fillFields(_mainStream, bseRecord.getOffset(), recordFactory);
return (EscherBlipRecord) record;
}
}
}
return null;
}
use of org.apache.poi.ddf.EscherRecord in project poi by apache.
the class TestBackground method getFillPictureRefCount.
private int getFillPictureRefCount(HSLFShape shape, HSLFFill fill) {
AbstractEscherOptRecord opt = shape.getEscherOptRecord();
EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
if (p != null) {
int idx = p.getPropertyValue();
HSLFSheet sheet = shape.getSheet();
HSLFSlideShow ppt = sheet.getSlideShow();
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
List<EscherRecord> lst = bstore.getChildRecords();
return ((EscherBSERecord) lst.get(idx - 1)).getRef();
}
return 0;
}
use of org.apache.poi.ddf.EscherRecord in project poi by apache.
the class HSSFWorkbook method dumpDrawingGroupRecords.
/**
* Spits out a list of all the drawing records in the workbook.
*/
public void dumpDrawingGroupRecords(boolean fat) {
DrawingGroupRecord r = (DrawingGroupRecord) workbook.findFirstRecordBySid(DrawingGroupRecord.sid);
r.decode();
List<EscherRecord> escherRecords = r.getEscherRecords();
PrintWriter w = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
for (EscherRecord escherRecord : escherRecords) {
if (fat) {
System.out.println(escherRecord);
} else {
escherRecord.display(w, 0);
}
}
w.flush();
}
use of org.apache.poi.ddf.EscherRecord in project poi by apache.
the class HSSFWorkbook method searchForPictures.
/**
* 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(List<EscherRecord> escherRecords, List<HSSFPictureData> pictures) {
for (EscherRecord escherRecord : escherRecords) {
if (escherRecord instanceof EscherBSERecord) {
EscherBlipRecord blip = ((EscherBSERecord) escherRecord).getBlipRecord();
if (blip != null) {
// TODO: Some kind of structure.
HSSFPictureData picture = new HSSFPictureData(blip);
pictures.add(picture);
}
}
// Recursive call.
searchForPictures(escherRecord.getChildRecords(), pictures);
}
}
use of org.apache.poi.ddf.EscherRecord in project poi by apache.
the class SlideShowRecordDumper method printEscherContainerRecord.
private void printEscherContainerRecord(EscherContainerRecord ecr, int indent) {
String ind = tabs.substring(0, indent);
ps.println(ind + ecr.getClass().getName() + " (" + ecr.getRecordName() + "):");
ps.println(ind + " isContainer: " + ecr.isContainerRecord());
ps.println(ind + " options: 0x" + HexDump.toHex(ecr.getOptions()));
ps.println(ind + " recordId: 0x" + HexDump.toHex(ecr.getRecordId()));
List<EscherRecord> childRecords = ecr.getChildRecords();
ps.println(ind + " numchildren: " + childRecords.size());
ps.println(ind + " children: ");
int count = 0;
for (EscherRecord record : childRecords) {
ps.println(ind + " Child " + count + ":");
printEscherRecord(record, indent + 1);
count++;
}
}
Aggregations