--- src/java/org/apache/poi/POIDocument.java (revision 655041) +++ src/java/org/apache/poi/POIDocument.java (working copy) @@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.Iterator; import java.util.List; @@ -170,6 +171,11 @@ } } + public void write(OutputStream out) + { + System.err.println("Not implemented in this class"); + } + /** * Writes out a given ProperySet * @param name the (POIFS Level) name of the property to write --- src/scratchpad/src/org/apache/poi/hdgf/HDGFDiagram.java (revision 655041) +++ src/scratchpad/src/org/apache/poi/hdgf/HDGFDiagram.java (working copy) @@ -27,6 +27,7 @@ import org.apache.poi.hdgf.streams.Stream; import org.apache.poi.hdgf.streams.StringsStream; import org.apache.poi.hdgf.streams.TrailerStream; +import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.LittleEndian; @@ -53,43 +54,47 @@ private PointerFactory ptrFactory; public HDGFDiagram(POIFSFileSystem fs) throws IOException { - super(fs); - - DocumentEntry docProps = - (DocumentEntry)filesystem.getRoot().getEntry("VisioDocument"); + this(fs.getRoot(), fs); + } + + public HDGFDiagram(DirectoryNode dir, POIFSFileSystem fs) throws IOException { + super(fs); - // Grab the document stream - _docstream = new byte[docProps.getSize()]; - filesystem.createDocumentInputStream("VisioDocument").read(_docstream); - - // Read in the common POI streams - readProperties(); - - // Check it's really visio - String typeString = new String(_docstream, 0, 20); - if(! typeString.equals(VISIO_HEADER)) { - throw new IllegalArgumentException("Wasn't a valid visio document, started with " + typeString); - } - - // Grab the version number, 0x1a -> 0x1b - version = LittleEndian.getShort(_docstream, 0x1a); - // Grab the document size, 0x1c -> 0x1f - docSize = LittleEndian.getUInt(_docstream, 0x1c); - // ??? 0x20 -> 0x23 - - // Create the Chunk+Pointer Factories for the document version - ptrFactory = new PointerFactory(version); - chunkFactory = new ChunkFactory(version); - - // Grab the pointer to the trailer - trailerPointer = ptrFactory.createPointer(_docstream, 0x24); - - // Now grab the trailer - trailer = (TrailerStream) - Stream.createStream(trailerPointer, _docstream, chunkFactory, ptrFactory); - - // Finally, find all our streams - trailer.findChildren(_docstream); + DocumentEntry docProps = + (DocumentEntry)dir.getEntry("VisioDocument"); + + // Grab the document stream + _docstream = new byte[docProps.getSize()]; + dir.createDocumentInputStream("VisioDocument").read(_docstream); + + // Read in the common POI streams + readProperties(); + + // Check it's really visio + String typeString = new String(_docstream, 0, 20); + if(! typeString.equals(VISIO_HEADER)) { + throw new IllegalArgumentException("Wasn't a valid visio document, started with " + typeString); + } + + // Grab the version number, 0x1a -> 0x1b + version = LittleEndian.getShort(_docstream, 0x1a); + // Grab the document size, 0x1c -> 0x1f + docSize = LittleEndian.getUInt(_docstream, 0x1c); + // ??? 0x20 -> 0x23 + + // Create the Chunk+Pointer Factories for the document version + ptrFactory = new PointerFactory(version); + chunkFactory = new ChunkFactory(version); + + // Grab the pointer to the trailer + trailerPointer = ptrFactory.createPointer(_docstream, 0x24); + + // Now grab the trailer + trailer = (TrailerStream) + Stream.createStream(trailerPointer, _docstream, chunkFactory, ptrFactory); + + // Finally, find all our streams + trailer.findChildren(_docstream); } /**