private void extractMacros(HSLFSlideShow ppt, XHTMLContentHandler xhtml) { //get macro persist id DocInfoListContainer list = (DocInfoListContainer)ppt.getDocumentRecord().findFirstOfType(RecordTypes.List.typeID); if (list == null) { return; } VBAInfoContainer vbaInfo = (VBAInfoContainer)list.findFirstOfType(RecordTypes.VBAInfo.typeID); if (vbaInfo == null) { return; } VBAInfoAtom vbaAtom = (VBAInfoAtom)vbaInfo.findFirstOfType(RecordTypes.VBAInfoAtom.typeID); if (vbaAtom == null) { return; } long persistId = vbaAtom.getPersistIdRef(); for (HSLFObjectData objData : ppt.getEmbeddedObjects()) { if (objData.getExOleObjStg().getPersistId() == persistId) { try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(objData.getInputStream())) { try { OfficeParser.extractMacros(poifsFileSystem, xhtml, EmbeddedDocumentUtil.getEmbeddedDocumentExtractor(context)); } catch (IOException|SAXException inner) { EmbeddedDocumentUtil.recordException(inner, parentMetadata); } } catch (IOException e) { EmbeddedDocumentUtil.recordEmbeddedStreamException(e, parentMetadata);//swallow } } } }
/** * Set things up, and find our more interesting children */ protected DocInfoListContainer(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(); }
/** * Write the contents of the record back, so it can be written * to disk */ public void writeOut(OutputStream out) throws IOException { writeOut(_header[0],_header[1],_type,_children,out); }
private void extractMacros(HSLFSlideShow ppt, XHTMLContentHandler xhtml) { //get macro persist id DocInfoListContainer list = (DocInfoListContainer)ppt.getDocumentRecord().findFirstOfType(RecordTypes.List.typeID); if (list == null) { return; } VBAInfoContainer vbaInfo = (VBAInfoContainer)list.findFirstOfType(RecordTypes.VBAInfo.typeID); if (vbaInfo == null) { return; } VBAInfoAtom vbaAtom = (VBAInfoAtom)vbaInfo.findFirstOfType(RecordTypes.VBAInfoAtom.typeID); if (vbaAtom == null) { return; } long persistId = vbaAtom.getPersistIdRef(); for (HSLFObjectData objData : ppt.getEmbeddedObjects()) { if (objData.getExOleObjStg().getPersistId() == persistId) { try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(objData.getInputStream())) { try { OfficeParser.extractMacros(poifsFileSystem, xhtml, EmbeddedDocumentUtil.getEmbeddedDocumentExtractor(context)); } catch (IOException|SAXException inner) { EmbeddedDocumentUtil.recordException(inner, parentMetadata); } } catch (IOException e) { EmbeddedDocumentUtil.recordEmbeddedStreamException(e, parentMetadata);//swallow } } } }
/** * Create a new DocInfoListContainer, with blank fields - not yet supported */ private DocInfoListContainer() { _header = new byte[8]; _children = new Record[0]; // Setup our header block _header[0] = 0x0f; // We are a container record LittleEndian.putShort(_header, 2, (short)_type); // Setup our child records findInterestingChildren(); }