View | Details | Raw Unified | Return to bug 45003
Collapse All | Expand All

(-)src/java/org/apache/poi/POIDocument.java (+6 lines)
Lines 20-25 Link Here
20
import java.io.ByteArrayInputStream;
20
import java.io.ByteArrayInputStream;
21
import java.io.ByteArrayOutputStream;
21
import java.io.ByteArrayOutputStream;
22
import java.io.IOException;
22
import java.io.IOException;
23
import java.io.OutputStream;
23
import java.util.Iterator;
24
import java.util.Iterator;
24
import java.util.List;
25
import java.util.List;
25
26
Lines 170-175 Link Here
170
		}
171
		}
171
	}
172
	}
172
	
173
	
174
	public void write(OutputStream out) throws IOException
175
	{
176
	    System.err.println("Not implemented in this class");
177
	}
178
	
173
	/**
179
	/**
174
	 * Writes out a given ProperySet
180
	 * Writes out a given ProperySet
175
	 * @param name the (POIFS Level) name of the property to write
181
	 * @param name the (POIFS Level) name of the property to write
(-)src/scratchpad/src/org/apache/poi/hdgf/HDGFDiagram.java (-36 / +41 lines)
Lines 27-32 Link Here
27
import org.apache.poi.hdgf.streams.Stream;
27
import org.apache.poi.hdgf.streams.Stream;
28
import org.apache.poi.hdgf.streams.StringsStream;
28
import org.apache.poi.hdgf.streams.StringsStream;
29
import org.apache.poi.hdgf.streams.TrailerStream;
29
import org.apache.poi.hdgf.streams.TrailerStream;
30
import org.apache.poi.poifs.filesystem.DirectoryNode;
30
import org.apache.poi.poifs.filesystem.DocumentEntry;
31
import org.apache.poi.poifs.filesystem.DocumentEntry;
31
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
32
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
32
import org.apache.poi.util.LittleEndian;
33
import org.apache.poi.util.LittleEndian;
Lines 53-95 Link Here
53
	private PointerFactory ptrFactory;
54
	private PointerFactory ptrFactory;
54
	
55
	
55
	public HDGFDiagram(POIFSFileSystem fs) throws IOException {
56
	public HDGFDiagram(POIFSFileSystem fs) throws IOException {
56
		super(fs);
57
	    this(fs.getRoot(), fs);
57
		
58
	}
58
		DocumentEntry docProps =
59
	
59
			(DocumentEntry)filesystem.getRoot().getEntry("VisioDocument");
60
	public HDGFDiagram(DirectoryNode dir, POIFSFileSystem fs) throws IOException {
61
	    super(fs);
60
62
61
		// Grab the document stream
63
	    DocumentEntry docProps =
62
		_docstream = new byte[docProps.getSize()];
64
	        (DocumentEntry)dir.getEntry("VisioDocument");
63
		filesystem.createDocumentInputStream("VisioDocument").read(_docstream);
65
64
		
66
	    // Grab the document stream
65
		// Read in the common POI streams
67
	    _docstream = new byte[docProps.getSize()];
66
		readProperties();
68
	    dir.createDocumentInputStream("VisioDocument").read(_docstream);
67
		
69
68
		// Check it's really visio
70
	    // Read in the common POI streams
69
		String typeString = new String(_docstream, 0, 20);
71
	    readProperties();
70
		if(! typeString.equals(VISIO_HEADER)) {
72
71
			throw new IllegalArgumentException("Wasn't a valid visio document, started with " + typeString);
73
	    // Check it's really visio
72
		}
74
	    String typeString = new String(_docstream, 0, 20);
73
		
75
	    if(! typeString.equals(VISIO_HEADER)) {
74
		// Grab the version number, 0x1a -> 0x1b
76
	        throw new IllegalArgumentException("Wasn't a valid visio document, started with " + typeString);
75
		version = LittleEndian.getShort(_docstream, 0x1a);
77
	    }
76
		// Grab the document size, 0x1c -> 0x1f
78
77
		docSize = LittleEndian.getUInt(_docstream, 0x1c);
79
	    // Grab the version number, 0x1a -> 0x1b
78
		// ??? 0x20 -> 0x23
80
	    version = LittleEndian.getShort(_docstream, 0x1a);
79
		
81
	    // Grab the document size, 0x1c -> 0x1f
80
		// Create the Chunk+Pointer Factories for the document version
82
	    docSize = LittleEndian.getUInt(_docstream, 0x1c);
81
		ptrFactory = new PointerFactory(version);
83
	    // ??? 0x20 -> 0x23
82
		chunkFactory = new ChunkFactory(version);
84
83
		
85
	    // Create the Chunk+Pointer Factories for the document version
84
		// Grab the pointer to the trailer
86
	    ptrFactory = new PointerFactory(version);
85
		trailerPointer = ptrFactory.createPointer(_docstream, 0x24);
87
	    chunkFactory = new ChunkFactory(version);
86
		
88
87
		// Now grab the trailer
89
	    // Grab the pointer to the trailer
88
		trailer = (TrailerStream)
90
	    trailerPointer = ptrFactory.createPointer(_docstream, 0x24);
89
			Stream.createStream(trailerPointer, _docstream, chunkFactory, ptrFactory);
91
90
		
92
	    // Now grab the trailer
91
		// Finally, find all our streams
93
	    trailer = (TrailerStream)
92
		trailer.findChildren(_docstream);
94
	    Stream.createStream(trailerPointer, _docstream, chunkFactory, ptrFactory);
95
96
	    // Finally, find all our streams
97
	    trailer.findChildren(_docstream);
93
	}
98
	}
94
99
95
	/**
100
	/**

Return to bug 45003