JDK 1.4 fixes for new hpbf stuff. Some clean-up
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@688642 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9156cf6c55
commit
313d71cc51
@ -14,9 +14,9 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hpbf;
|
package org.apache.poi.hpbf;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -34,7 +34,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
|||||||
* for HPBF, our implementation of the publisher
|
* for HPBF, our implementation of the publisher
|
||||||
* file format.
|
* file format.
|
||||||
*/
|
*/
|
||||||
public class HPBFDocument extends POIDocument {
|
public final class HPBFDocument extends POIDocument {
|
||||||
private MainContents mainContents;
|
private MainContents mainContents;
|
||||||
private QuillContents quillContents;
|
private QuillContents quillContents;
|
||||||
private EscherStm escherStm;
|
private EscherStm escherStm;
|
||||||
@ -59,28 +59,12 @@ public class HPBFDocument extends POIDocument {
|
|||||||
|
|
||||||
// Go looking for our interesting child
|
// Go looking for our interesting child
|
||||||
// streams
|
// streams
|
||||||
try {
|
|
||||||
mainContents = new MainContents(dir);
|
mainContents = new MainContents(dir);
|
||||||
} catch(FileNotFoundException e) {
|
|
||||||
throw new IllegalArgumentException("File invalid - missing required main Contents part", e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
quillContents = new QuillContents(dir);
|
quillContents = new QuillContents(dir);
|
||||||
} catch(FileNotFoundException e) {
|
|
||||||
throw new IllegalArgumentException("File invalid - missing required Quill CONTENTS part", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now the Escher bits
|
// Now the Escher bits
|
||||||
try {
|
|
||||||
escherStm = new EscherStm(dir);
|
escherStm = new EscherStm(dir);
|
||||||
} catch(FileNotFoundException e) {
|
|
||||||
throw new IllegalArgumentException("File invalid - missing required EscherStm part", e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
escherDelayStm = new EscherDelayStm(dir);
|
escherDelayStm = new EscherDelayStm(dir);
|
||||||
} catch(FileNotFoundException e) {
|
|
||||||
throw new IllegalArgumentException("File invalid - missing required EscherDelayStm part", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainContents getMainContents() {
|
public MainContents getMainContents() {
|
||||||
|
@ -14,22 +14,17 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hpbf.model;
|
package org.apache.poi.hpbf.model;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||||
|
|
||||||
public class EscherDelayStm extends EscherPart {
|
public final class EscherDelayStm extends EscherPart {
|
||||||
public EscherDelayStm(DirectoryNode baseDir) throws FileNotFoundException,
|
private static final String[] PATH = { "Escher", "EscherDelayStm", };
|
||||||
IOException {
|
|
||||||
super(baseDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getPath() {
|
public EscherDelayStm(DirectoryNode baseDir) throws IOException {
|
||||||
return new String[] {
|
super(baseDir, PATH);
|
||||||
"Escher", "EscherDelayStm"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hpbf.model;
|
package org.apache.poi.hpbf.model;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -34,9 +34,8 @@ public abstract class EscherPart extends HPBFPart {
|
|||||||
* Creates the Escher Part, and finds our child
|
* Creates the Escher Part, and finds our child
|
||||||
* escher records
|
* escher records
|
||||||
*/
|
*/
|
||||||
public EscherPart(DirectoryNode baseDir) throws FileNotFoundException,
|
public EscherPart(DirectoryNode baseDir, String[] parts) throws IOException {
|
||||||
IOException {
|
super(baseDir, parts);
|
||||||
super(baseDir);
|
|
||||||
|
|
||||||
// Now create our Escher children
|
// Now create our Escher children
|
||||||
DefaultEscherRecordFactory erf =
|
DefaultEscherRecordFactory erf =
|
||||||
|
@ -14,22 +14,16 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hpbf.model;
|
package org.apache.poi.hpbf.model;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||||
|
|
||||||
public class EscherStm extends EscherPart {
|
public final class EscherStm extends EscherPart {
|
||||||
public EscherStm(DirectoryNode baseDir) throws FileNotFoundException,
|
private static final String[] PATH = { "Escher", "EscherStm", };
|
||||||
IOException {
|
public EscherStm(DirectoryNode baseDir) throws IOException {
|
||||||
super(baseDir);
|
super(baseDir, PATH);
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getPath() {
|
|
||||||
return new String[] {
|
|
||||||
"Escher", "EscherStm"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,23 +30,35 @@ import org.apache.poi.poifs.filesystem.DocumentEntry;
|
|||||||
*/
|
*/
|
||||||
public abstract class HPBFPart {
|
public abstract class HPBFPart {
|
||||||
protected byte[] data;
|
protected byte[] data;
|
||||||
|
/**
|
||||||
|
* @param path the path to the part, eg Contents or Quill, QuillSub, CONTENTS
|
||||||
|
*/
|
||||||
|
public HPBFPart(DirectoryNode baseDir, String[] path) throws IOException {
|
||||||
|
|
||||||
public HPBFPart(DirectoryNode baseDir) throws FileNotFoundException, IOException {
|
|
||||||
String[] path = getPath();
|
|
||||||
DirectoryNode dir = getDir(path, baseDir);
|
DirectoryNode dir = getDir(path, baseDir);
|
||||||
String name = path[path.length-1];
|
String name = path[path.length-1];
|
||||||
|
|
||||||
DocumentEntry docProps =
|
DocumentEntry docProps;
|
||||||
(DocumentEntry)dir.getEntry(name);
|
try {
|
||||||
|
docProps = (DocumentEntry)dir.getEntry(name);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new IllegalArgumentException("File invalid - failed to find document entry '"
|
||||||
|
+ name + "'");
|
||||||
|
}
|
||||||
|
|
||||||
// Grab the data from the part stream
|
// Grab the data from the part stream
|
||||||
data = new byte[docProps.getSize()];
|
data = new byte[docProps.getSize()];
|
||||||
dir.createDocumentInputStream(name).read(data);
|
dir.createDocumentInputStream(name).read(data);
|
||||||
}
|
}
|
||||||
private DirectoryNode getDir(String[] path, DirectoryNode baseDir) throws FileNotFoundException {
|
private DirectoryNode getDir(String[] path, DirectoryNode baseDir) {
|
||||||
DirectoryNode dir = baseDir;
|
DirectoryNode dir = baseDir;
|
||||||
for(int i=0; i<path.length-1; i++) {
|
for(int i=0; i<path.length-1; i++) {
|
||||||
|
try {
|
||||||
dir = (DirectoryNode)dir.getEntry(path[i]);
|
dir = (DirectoryNode)dir.getEntry(path[i]);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new IllegalArgumentException("File invalid - failed to find directory entry '"
|
||||||
|
+ path[i] + "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
@ -86,8 +98,7 @@ public abstract class HPBFPart {
|
|||||||
public byte[] getData() { return data; }
|
public byte[] getData() { return data; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path to the part, eg Contents
|
* Returns
|
||||||
* or Quill, QuillSub, CONTENTS
|
|
||||||
*/
|
*/
|
||||||
public abstract String[] getPath();
|
public final String[] getPath() {return null;}
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.hpbf.model;
|
package org.apache.poi.hpbf.model;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||||
@ -24,14 +24,11 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
|
|||||||
/**
|
/**
|
||||||
* The main Contents. Not yet understood
|
* The main Contents. Not yet understood
|
||||||
*/
|
*/
|
||||||
public class MainContents extends HPBFPart {
|
public final class MainContents extends HPBFPart {
|
||||||
public MainContents(DirectoryNode baseDir)
|
private static final String[] PATH = { "Contents", };
|
||||||
throws FileNotFoundException, IOException {
|
|
||||||
super(baseDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getPath() {
|
public MainContents(DirectoryNode baseDir) throws IOException {
|
||||||
return new String[] { "Contents" };
|
super(baseDir, PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateData() {
|
protected void generateData() {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi.hpbf.model;
|
package org.apache.poi.hpbf.model;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.poi.hpbf.model.qcbits.QCBit;
|
import org.apache.poi.hpbf.model.qcbits.QCBit;
|
||||||
@ -28,12 +27,12 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
/**
|
/**
|
||||||
* Quill -> QuillSub -> CONTENTS
|
* Quill -> QuillSub -> CONTENTS
|
||||||
*/
|
*/
|
||||||
public class QuillContents extends HPBFPart {
|
public final class QuillContents extends HPBFPart {
|
||||||
|
private static final String[] PATH = { "Quill", "QuillSub", "CONTENTS", };
|
||||||
private QCBit[] bits;
|
private QCBit[] bits;
|
||||||
|
|
||||||
public QuillContents(DirectoryNode baseDir)
|
public QuillContents(DirectoryNode baseDir) throws IOException {
|
||||||
throws FileNotFoundException, IOException {
|
super(baseDir, PATH);
|
||||||
super(baseDir);
|
|
||||||
|
|
||||||
// Now parse the first 512 bytes, and produce
|
// Now parse the first 512 bytes, and produce
|
||||||
// all our bits
|
// all our bits
|
||||||
@ -85,10 +84,4 @@ public class QuillContents extends HPBFPart {
|
|||||||
// TODO
|
// TODO
|
||||||
throw new IllegalStateException("Not done yet!");
|
throw new IllegalStateException("Not done yet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getPath() {
|
|
||||||
return new String[] {
|
|
||||||
"Quill", "QuillSub", "CONTENTS"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user