/** * Set things up, and find our more interesting children * * @param source the source data as a byte array. * @param start the start offset into the byte array. * @param len the length of the slice in the byte array. */ protected ExEmbed(byte[] source, int start, int len) { // Grab the header _header = new byte[8]; System.arraycopy(source,start,_header,0,8); // Find our children _children = Record.findChildRecords(source,start+8,len-8); findInterestingChildren(); }
/** * Returns the full name of the embedded object, * e.g. "Microsoft Word Document" or "Microsoft Office Excel Worksheet". * * @return the full name of the embedded object */ public String getFullName(){ return getExEmbed().getClipboardName(); }
/** * Returns the instance name of the embedded object, e.g. "Document" or "Workbook". * * @return the instance name of the embedded object */ public String getInstanceName(){ return getExEmbed().getMenuName(); }
/** * Have the contents printer out into an OutputStream, used when * writing a file back out to disk. * * @param out the output stream. * @throws IOException if there was an error writing to the stream. */ @Override public void writeOut(final OutputStream out) throws IOException { writeOut(_header[0],_header[1],getRecordType(),_children,out); }
ExEmbed exEmbed = new ExEmbed(); Record children[] = exEmbed.getChildRecords(); exEmbed.removeChild(children[2]); exEmbed.removeChild(children[3]); exEmbed.removeChild(children[4]); ExEmbedAtom eeEmbed = exEmbed.getExEmbedAtom(); eeEmbed.setCantLockServerB(true); ExOleObjAtom eeAtom = exEmbed.getExOleObjAtom(); eeAtom.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE); eeAtom.setType(ExOleObjAtom.TYPE_EMBEDDED);
/** * Create a new ExEmbed, with blank fields */ public ExEmbed() { _header = new byte[8]; _children = new Record[5]; // Setup our header block _header[0] = 0x0f; // We are a container record LittleEndian.putShort(_header, 2, (short)getRecordType()); // Setup our child records final CString cs1 = new CString(); cs1.setOptions(0x1 << 4); final CString cs2 = new CString(); cs2.setOptions(0x2 << 4); final CString cs3 = new CString(); cs3.setOptions(0x3 << 4); _children[0] = new ExEmbedAtom(); _children[1] = new ExOleObjAtom(); _children[2] = cs1; _children[3] = cs2; _children[4] = cs3; findInterestingChildren(); }
private ExEmbed getExEmbed(boolean create) { if (_exEmbed == null) { HSLFSlideShow ppt = getSheet().getSlideShow(); ExObjList lst = ppt.getDocumentRecord().getExObjList(create); if(lst == null){ LOG.log(POILogger.WARN, "ExObjList not found"); return null; } int id = getObjectID(); for (Record ch : lst.getChildRecords()) { if(ch instanceof ExEmbed){ ExEmbed embd = (ExEmbed)ch; if( embd.getExOleObjAtom().getObjID() == id) { _exEmbed = embd; } } } if (_exEmbed == null && create) { _exEmbed = new ExEmbed(); _exEmbed.getExOleObjAtom().setObjID(id); lst.appendChildRecord(_exEmbed); } } return _exEmbed; }
/** * Returns unique identifier for the OLE object. * * @return the unique identifier for the OLE object */ public ObjectData getObjectData(){ SlideShow ppt = getSheet().getSlideShow(); ObjectData[] ole = ppt.getEmbeddedObjects(); //persist reference ExEmbed exEmbed = getExEmbed(); ObjectData data = null; if(exEmbed != null) { int ref = exEmbed.getExOleObjAtom().getObjStgDataRef(); for (int i = 0; i < ole.length; i++) { if(ole[i].getExOleObjStg().getPersistId() == ref) { data=ole[i]; } } } if (data==null) { logger.log(POILogger.WARN, "OLE data not found"); } return data; }
/** * Returns the ProgID that stores the OLE Programmatic Identifier. * A ProgID is a string that uniquely identifies a given object, for example, * "Word.Document.8" or "Excel.Sheet.8". * * @return the ProgID */ public String getProgID(){ return getExEmbed().getProgId(); } }
objAtom.setObjectIDSeed(objectId); ExEmbed exEmbed = new ExEmbed();
private CString safeCString(CString oldStr, int optionsId) { CString newStr = oldStr; if (newStr == null) { newStr = new CString(); newStr.setOptions(optionsId << 4); } boolean found = false; for (final Record r : _children) { // for simplicity just check for object identity if (r == newStr) { found = true; break; } } if (!found) { appendChildRecord(newStr); } return newStr; } }
/** * Have the contents printer out into an OutputStream, used when * writing a file back out to disk. * * @param out the output stream. * @throws IOException if there was an error writing to the stream. */ public void writeOut(OutputStream out) throws IOException { writeOut(_header[0],_header[1],getRecordType(),_children,out); } }
/** * Create a new ExEmbed, with blank fields */ public ExEmbed() { _header = new byte[8]; _children = new Record[5]; // Setup our header block _header[0] = 0x0f; // We are a container record LittleEndian.putShort(_header, 2, (short)getRecordType()); // Setup our child records CString cs1 = new CString(); cs1.setOptions(0x1 << 4); CString cs2 = new CString(); cs2.setOptions(0x2 << 4); CString cs3 = new CString(); cs3.setOptions(0x3 << 4); _children[0] = new ExEmbedAtom(); _children[1] = new ExOleObjAtom(); _children[2] = cs1; _children[3] = cs2; _children[4] = cs3; findInterestingChildren(); }
/** * Returns unique identifier for the OLE object. * * @return the unique identifier for the OLE object */ public HSLFObjectData getObjectData(){ HSLFSlideShow ppt = getSheet().getSlideShow(); HSLFObjectData[] ole = ppt.getEmbeddedObjects(); //persist reference ExEmbed exEmbed = getExEmbed(); HSLFObjectData data = null; if(exEmbed != null) { int ref = exEmbed.getExOleObjAtom().getObjStgDataRef(); for (HSLFObjectData hod : ole) { if(hod.getExOleObjStg().getPersistId() == ref) { data=hod; // keep searching to return the last persistent object with that refId } } } if (data==null) { LOG.log(POILogger.WARN, "OLE data not found"); } return data; }
@Override public String getProgId(){ ExEmbed ee = getExEmbed(); return (ee == null) ? null : ee.getProgId(); }
if(ch[i] instanceof ExEmbed){ ExEmbed embd = (ExEmbed)ch[i]; if( embd.getExOleObjAtom().getObjID() == id) _exEmbed = embd;
@Override public String getFullName(){ ExEmbed ee = getExEmbed(); return (ee == null) ? null : ee.getClipboardName(); }
/** * Returns the instance name of the embedded object, e.g. "Document" or "Workbook". * * @return the instance name of the embedded object */ public String getInstanceName(){ ExEmbed ee = getExEmbed(); return (ee == null) ? null : ee.getMenuName(); }
/** * Set things up, and find our more interesting children * * @param source the source data as a byte array. * @param start the start offset into the byte array. * @param len the length of the slice in the byte array. */ protected ExEmbed(final byte[] source, final int start, final int len) { // Grab the header _header = new byte[8]; System.arraycopy(source,start,_header,0,8); // Find our children _children = Record.findChildRecords(source,start+8,len-8); findInterestingChildren(); }