/** * Add the \1OLE marker entry, which is not the Ole10Native entry. * Beside this "\u0001Ole" record there were several other records, e.g. CompObj, * OlePresXXX, but it seems, that they aren't necessary */ public static void createOleMarkerEntry(final POIFSFileSystem poifs) throws IOException { createOleMarkerEntry(poifs.getRoot()); }
@Override public int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException { // check if we were created by POIFS otherwise create a new dummy POIFS for storing the package data if (initDirectory()) { preserveNodes = true; } // get free MBD-Node int storageId = 0; DirectoryEntry oleDir = null; do { String storageStr = "MBD"+ HexDump.toHex(++storageId); if (!getDirectory().hasEntry(storageStr)) { oleDir = getDirectory().createDirectory(storageStr); oleDir.setStorageClsid(ClassIDPredefined.OLE_V1_PACKAGE.getClassID()); } } while (oleDir == null); Ole10Native.createOleMarkerEntry(oleDir); Ole10Native oleNative = new Ole10Native(label, fileName, command, oleData); ByteArrayOutputStream bos = new ByteArrayOutputStream(); oleNative.writeOut(bos); oleDir.createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray())); return storageId; }
public void close() throws IOException { objectPart.clear(); try (final OutputStream os = objectPart.getOutputStream()) { final ByteArrayInputStream bis = new ByteArrayInputStream(this.buf, 0, size()); final FileMagic fm = FileMagic.valueOf(this.buf); if (fm == FileMagic.OLE2) { try (final POIFSFileSystem poifs = new POIFSFileSystem(bis)) { poifs.getRoot().setStorageClsid(metaData.getClassID()); poifs.writeFilesystem(os); } } else if (metaData.getOleEntry() == null) { // OLE Name hasn't been specified, pass the input through os.write(this.buf, 0, size()); } else { try (final POIFSFileSystem poifs = new POIFSFileSystem()) { final ClassID clsId = metaData.getClassID(); if (clsId != null) { poifs.getRoot().setStorageClsid(clsId); } poifs.createDocument(bis, metaData.getOleEntry()); Ole10Native.createOleMarkerEntry(poifs); poifs.writeFilesystem(os); } } } } }
/** * Add the \1OLE marker entry, which is not the Ole10Native entry. * Beside this "\u0001Ole" record there were several other records, e.g. CompObj, * OlePresXXX, but it seems, that they aren't necessary */ public static void createOleMarkerEntry(final POIFSFileSystem poifs) throws IOException { createOleMarkerEntry(poifs.getRoot()); }
@Override public int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException { // check if we were created by POIFS otherwise create a new dummy POIFS for storing the package data if (initDirectory()) { preserveNodes = true; } // get free MBD-Node int storageId = 0; DirectoryEntry oleDir = null; do { String storageStr = "MBD"+ HexDump.toHex(++storageId); if (!getDirectory().hasEntry(storageStr)) { oleDir = getDirectory().createDirectory(storageStr); oleDir.setStorageClsid(ClassIDPredefined.OLE_V1_PACKAGE.getClassID()); } } while (oleDir == null); Ole10Native.createOleMarkerEntry(oleDir); Ole10Native oleNative = new Ole10Native(label, fileName, command, oleData); ByteArrayOutputStream bos = new ByteArrayOutputStream(); oleNative.writeOut(bos); oleDir.createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray())); return storageId; }
public void close() throws IOException { final FileMagic fm = FileMagic.valueOf(this.buf); final ByteArrayInputStream bis = new ByteArrayInputStream(this.buf, 0, this.count); final HSLFSlideShow ppt = getSheet().getSlideShow(); try (POIFSFileSystem poifs = (fm == FileMagic.OLE2) ? new POIFSFileSystem(bis) : new POIFSFileSystem()) { if (fm != FileMagic.OLE2) { poifs.createDocument(bis, md.getOleEntry()); } Ole10Native.createOleMarkerEntry(poifs); poifs.getRoot().setStorageClsid(md.getClassID()); int oid = getObjectID(); if (oid == 0) { // assign new embedding oid = ppt.addEmbed(poifs); setObjectID(oid); } else { final HSLFObjectData od = getObjectData(); if (od != null) { ByteArrayOutputStream bos = new ByteArrayOutputStream(this.size()+1000); poifs.writeFilesystem(bos); od.setData(bos.toByteArray()); } } setProgId(md.getProgId()); setFullName(md.getObjectName()); } } };
Ole10Native.createOleMarkerEntry(poiData); ByteArrayOutputStream bos = new ByteArrayOutputStream(); poiData.writeFilesystem(bos);
public void close() throws IOException { objectPart.clear(); try (final OutputStream os = objectPart.getOutputStream()) { final ByteArrayInputStream bis = new ByteArrayInputStream(this.buf, 0, size()); final FileMagic fm = FileMagic.valueOf(this.buf); if (fm == FileMagic.OLE2) { try (final POIFSFileSystem poifs = new POIFSFileSystem(bis)) { poifs.getRoot().setStorageClsid(metaData.getClassID()); poifs.writeFilesystem(os); } } else if (metaData.getOleEntry() == null) { // OLE Name hasn't been specified, pass the input through os.write(this.buf, 0, size()); } else { try (final POIFSFileSystem poifs = new POIFSFileSystem()) { final ClassID clsId = metaData.getClassID(); if (clsId != null) { poifs.getRoot().setStorageClsid(clsId); } poifs.createDocument(bis, metaData.getOleEntry()); Ole10Native.createOleMarkerEntry(poifs); poifs.writeFilesystem(os); } } } } }