use of org.apache.poi.ddf.EscherRecord in project poi by apache.
the class InternalWorkbook method findDrawingManager.
private static DrawingManager2 findDrawingManager(DrawingGroupRecord dg, List<EscherBSERecord> escherBSERecords) {
if (dg == null) {
return null;
}
// If there is one, does it have a EscherDggRecord?
EscherContainerRecord cr = dg.getEscherContainer();
if (cr == null) {
return null;
}
EscherDggRecord dgg = null;
EscherContainerRecord bStore = null;
for (EscherRecord er : cr) {
if (er instanceof EscherDggRecord) {
dgg = (EscherDggRecord) er;
} else if (er.getRecordId() == EscherContainerRecord.BSTORE_CONTAINER) {
bStore = (EscherContainerRecord) er;
}
}
if (dgg == null) {
return null;
}
DrawingManager2 dm = new DrawingManager2(dgg);
if (bStore != null) {
for (EscherRecord bs : bStore.getChildRecords()) {
if (bs instanceof EscherBSERecord) {
escherBSERecords.add((EscherBSERecord) bs);
}
}
}
return dm;
}
use of org.apache.poi.ddf.EscherRecord in project poi by apache.
the class InternalWorkbook method addBSERecord.
public int addBSERecord(EscherBSERecord e) {
createDrawingGroup();
// maybe we don't need that as an instance variable anymore
escherBSERecords.add(e);
int dgLoc = findFirstRecordLocBySid(DrawingGroupRecord.sid);
DrawingGroupRecord drawingGroup = (DrawingGroupRecord) getRecords().get(dgLoc);
EscherContainerRecord dggContainer = (EscherContainerRecord) drawingGroup.getEscherRecord(0);
EscherContainerRecord bstoreContainer;
if (dggContainer.getChild(1).getRecordId() == EscherContainerRecord.BSTORE_CONTAINER) {
bstoreContainer = (EscherContainerRecord) dggContainer.getChild(1);
} else {
bstoreContainer = new EscherContainerRecord();
bstoreContainer.setRecordId(EscherContainerRecord.BSTORE_CONTAINER);
List<EscherRecord> childRecords = dggContainer.getChildRecords();
childRecords.add(1, bstoreContainer);
dggContainer.setChildRecords(childRecords);
}
bstoreContainer.setOptions((short) ((escherBSERecords.size() << 4) | 0xF));
bstoreContainer.addChildRecord(e);
return escherBSERecords.size();
}
use of org.apache.poi.ddf.EscherRecord in project poi by apache.
the class BiffDrawingToXml method writeToFile.
public static void writeToFile(OutputStream fos, InputStream xlsWorkbook, boolean excludeWorkbookRecords, String[] params) throws IOException {
HSSFWorkbook workbook = new HSSFWorkbook(xlsWorkbook);
InternalWorkbook internalWorkbook = workbook.getInternalWorkbook();
DrawingGroupRecord r = (DrawingGroupRecord) internalWorkbook.findFirstRecordBySid(DrawingGroupRecord.sid);
StringBuilder builder = new StringBuilder();
builder.append("<workbook>\n");
String tab = "\t";
if (!excludeWorkbookRecords && r != null) {
r.decode();
List<EscherRecord> escherRecords = r.getEscherRecords();
for (EscherRecord record : escherRecords) {
builder.append(record.toXml(tab));
}
}
List<Integer> sheets = getSheetsIndexes(params, workbook);
for (Integer i : sheets) {
HSSFPatriarch p = workbook.getSheetAt(i).getDrawingPatriarch();
if (p != null) {
builder.append(tab).append("<sheet").append(i).append(">\n");
builder.append(p.getBoundAggregate().toXml(tab + "\t"));
builder.append(tab).append("</sheet").append(i).append(">\n");
}
}
builder.append("</workbook>\n");
fos.write(builder.toString().getBytes(StringUtil.UTF8));
fos.close();
workbook.close();
}
use of org.apache.poi.ddf.EscherRecord in project poi by apache.
the class HSLFFill method getEscherBSERecord.
@SuppressWarnings("resource")
protected EscherBSERecord getEscherBSERecord(int idx) {
HSLFSheet sheet = shape.getSheet();
if (sheet == null) {
LOG.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet");
return null;
}
HSLFSlideShow ppt = sheet.getSlideShow();
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
if (bstore == null) {
LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
return null;
}
List<EscherRecord> lst = bstore.getChildRecords();
return (EscherBSERecord) lst.get(idx - 1);
}
use of org.apache.poi.ddf.EscherRecord in project poi by apache.
the class HSLFShapeFactory method createShapeGroup.
public static HSLFGroupShape createShapeGroup(EscherContainerRecord spContainer, ShapeContainer<HSLFShape, HSLFTextParagraph> parent) {
boolean isTable = false;
EscherContainerRecord ecr = (EscherContainerRecord) spContainer.getChild(0);
EscherRecord opt = HSLFShape.getEscherChild(ecr, RecordTypes.EscherUserDefined);
if (opt != null) {
EscherPropertyFactory f = new EscherPropertyFactory();
List<EscherProperty> props = f.createProperties(opt.serialize(), 8, opt.getInstance());
for (EscherProperty ep : props) {
if (ep.getPropertyNumber() == EscherProperties.GROUPSHAPE__TABLEPROPERTIES && ep instanceof EscherSimpleProperty && (((EscherSimpleProperty) ep).getPropertyValue() & 1) == 1) {
isTable = true;
break;
}
}
}
HSLFGroupShape group;
if (isTable) {
group = new HSLFTable(spContainer, parent);
} else {
group = new HSLFGroupShape(spContainer, parent);
}
return group;
}
Aggregations