Finished my work converting HPSF to use the org.apache.poi.util.LittleEndian

implementation.  ClassID and poibrowser/PropertySetDescriptorRendeder are probably broken.  I couldn't figure out what ClassID is meaning to do someone else
who understands the code there will have to work on it.

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-05-19 18:09:26 +00:00
parent 13935d307f
commit 7393982224
6 changed files with 67 additions and 50 deletions

View File

@ -85,6 +85,9 @@ public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
final int row,
final boolean hasFocus)
{
throw new RuntimeException("THIS FUNCTION BROKEN -- FIX IT");
/*
final PropertySetDescriptor d = (PropertySetDescriptor)
((DefaultMutableTreeNode) value).getUserObject();
final PropertySet ps = d.getPropertySet();
@ -94,21 +97,22 @@ public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
text.setFont(new Font("Monospaced", Font.PLAIN, 10));
text.append(renderAsString(d));
text.append("\nByte order: " +
Codec.hexEncode(ps.getByteOrder().getBytes()));
Codec.hexEncode(ps.getByteOrder()));
text.append("\nFormat: " +
Codec.hexEncode(ps.getFormat().getBytes()));
Codec.hexEncode(ps.getFormat()));
text.append("\nOS version: " +
Codec.hexEncode(ps.getOSVersion().getBytes()));
Codec.hexEncode(ps.getOSVersion()));
text.append("\nClass ID: " +
Codec.hexEncode(ps.getClassID().getBytes()));
Codec.hexEncode(ps.getClassID()));
text.append("\nSection count: " + ps.getSectionCount());
text.append(sectionsToString(ps.getSections()));
p.add(text);
if (ps instanceof SummaryInformation)
{
*/
/* Use the convenience methods. */
final SummaryInformation si = (SummaryInformation) ps;
/* final SummaryInformation si = (SummaryInformation) ps;
text.append("\n");
text.append("\nTitle: " + si.getTitle());
text.append("\nSubject: " + si.getSubject());
@ -132,7 +136,7 @@ public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
if (selected)
Util.invert(text);
return p;
return p;*/
}
@ -160,9 +164,12 @@ public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
*/
protected String toString(final Section s, final String name)
{
throw new RuntimeException("THIS FUNCTION BROKEN -- FIX IT");
/*
final StringBuffer b = new StringBuffer();
b.append("\n" + name + " Format ID: ");
b.append(Codec.hexEncode(s.getFormatID().getBytes()));
b.append(Integer.toHexString(s.getFormatID()));
b.append("\n" + name + " Offset: " + s.getOffset());
b.append("\n" + name + " Section size: " + s.getSize());
b.append("\n" + name + " Property count: " + s.getPropertyCount());
@ -188,6 +195,7 @@ public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
b.append(value.toString());
}
return b.toString();
*/
}
}

View File

@ -82,7 +82,7 @@ public class ClassID {
*@param offset The offset of the first byte to read.
*/
public ClassID(final byte[] src, final int offset) {
super(src, offset);
// super(src, offset);
}
@ -93,6 +93,11 @@ public class ClassID {
return LENGTH;
}
public byte[] getBytes() {
throw new RuntimeException("This fucntion must be rewritten");
}
/**
* Description of the Method - REWRITE ME REWRITE ME REWRITE ME

View File

@ -56,7 +56,7 @@ package org.apache.poi.hpsf;
import java.io.*;
import java.util.*;
import org.apache.poi.hpsf.littleendian.*;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hpsf.wellknown.*;
import org.apache.poi.poifs.filesystem.*;
@ -99,7 +99,7 @@ public class PropertySet {
final static byte[] FORMAT_ASSERTION =
new byte[]{(byte) 0x00, (byte) 0x00};
private Word byteOrder;
private int byteOrder;
// Must equal BYTE_ORDER_ASSERTION
@ -112,13 +112,13 @@ public class PropertySet {
*
*@return The byteOrder value
*/
public Word getByteOrder() {
public int getByteOrder() {
return byteOrder;
}
private Word format;
private int format;
// Must equal FORMAT_ASSERTION
@ -131,13 +131,13 @@ public class PropertySet {
*
*@return The format value
*/
public Word getFormat() {
public int getFormat() {
return format;
}
private DWord osVersion;
private long osVersion;
/**
@ -147,7 +147,7 @@ public class PropertySet {
*
*@return The oSVersion value
*/
public DWord getOSVersion() {
public long getOSVersion() {
return osVersion;
}
@ -169,7 +169,7 @@ public class PropertySet {
private int sectionCount;
private long sectionCount;
/**
@ -179,7 +179,7 @@ public class PropertySet {
*
*@return The sectionCount value
*/
public int getSectionCount() {
public long getSectionCount() {
return sectionCount;
}
@ -366,23 +366,27 @@ public class PropertySet {
* Read the header fields of the stream. They must always be
* there.
*/
final Word byteOrder = new Word(src, offset);
offset += Word.LENGTH;
if (!Util.equal(byteOrder.getBytes(), BYTE_ORDER_ASSERTION)) {
final int byteOrder = LittleEndian.getUShort(src, offset);
offset += LittleEndian.SHORT_SIZE;
byte[] temp = new byte[LittleEndian.SHORT_SIZE];
LittleEndian.putShort(temp,(short)byteOrder);
if (!Util.equal(temp, BYTE_ORDER_ASSERTION)) {
return false;
}
final Word format = new Word(src, offset);
offset += Word.LENGTH;
if (!Util.equal(format.getBytes(), FORMAT_ASSERTION)) {
final int format = LittleEndian.getUShort(src, offset);
offset += LittleEndian.SHORT_SIZE;
temp = new byte[LittleEndian.SHORT_SIZE];
LittleEndian.putShort(temp,(short)format);
if (!Util.equal(temp, FORMAT_ASSERTION)) {
return false;
}
final DWord osVersion = new DWord(src, offset);
offset += DWord.LENGTH;
final long osVersion = LittleEndian.getUInt(src, offset);
offset += LittleEndian.INT_SIZE;
final ClassID classID = new ClassID(src, offset);
offset += ClassID.LENGTH;
final DWord sectionCount = new DWord(src, offset);
offset += DWord.LENGTH;
if (sectionCount.intValue() < 1) {
final long sectionCount = LittleEndian.getUInt(src, offset);
offset += LittleEndian.INT_SIZE;
if (sectionCount < 1) {
return false;
}
return true;
@ -406,16 +410,16 @@ public class PropertySet {
/*
* Read the stream's header fields.
*/
byteOrder = new Word(src, offset);
offset += Word.LENGTH;
format = new Word(src, offset);
offset += Word.LENGTH;
osVersion = new DWord(src, offset);
offset += DWord.LENGTH;
byteOrder = LittleEndian.getUShort(src, offset);
offset += LittleEndian.SHORT_SIZE;
format = LittleEndian.getUShort(src, offset);
offset += LittleEndian.SHORT_SIZE;
osVersion = LittleEndian.getUInt(src, offset);
offset += LittleEndian.INT_SIZE;
classID = new ClassID(src, offset);
offset += ClassID.LENGTH;
sectionCount = new DWord(src, offset).intValue();
offset += DWord.LENGTH;
sectionCount = LittleEndian.getUInt(src, offset);
offset += LittleEndian.INT_SIZE;
/*
* Read the sections, which are following the header. They
@ -438,7 +442,7 @@ public class PropertySet {
*/
for (int i = 0; i < sectionCount; i++) {
final Section s = new Section(src, offset);
offset += ClassID.LENGTH + DWord.LENGTH;
offset += ClassID.LENGTH + LittleEndian.INT_SIZE;
sections.add(s);
}
}

View File

@ -105,7 +105,7 @@ public class Section {
*
*@return The offset value
*/
public int getOffset() {
public long getOffset() {
return offset;
}

View File

@ -55,7 +55,7 @@
package org.apache.poi.hpsf;
import java.util.*;
import org.apache.poi.hpsf.littleendian.*;
import org.apache.poi.util.LittleEndian;
/**
* <p>
@ -110,7 +110,7 @@ public abstract class SpecialPropertySet extends PropertySet {
*
*@return The byteOrder value
*/
public Word getByteOrder() {
public int getByteOrder() {
return delegate.getByteOrder();
}
@ -121,7 +121,7 @@ public abstract class SpecialPropertySet extends PropertySet {
*
*@return The format value
*/
public Word getFormat() {
public int getFormat() {
return delegate.getFormat();
}
@ -132,7 +132,7 @@ public abstract class SpecialPropertySet extends PropertySet {
*
*@return The oSVersion value
*/
public DWord getOSVersion() {
public long getOSVersion() {
return delegate.getOSVersion();
}
@ -154,7 +154,7 @@ public abstract class SpecialPropertySet extends PropertySet {
*
*@return The sectionCount value
*/
public int getSectionCount() {
public long getSectionCount() {
return delegate.getSectionCount();
}

View File

@ -54,7 +54,7 @@
*/
package org.apache.poi.hpsf;
import org.apache.poi.hpsf.littleendian.DWord;
import org.apache.poi.util.LittleEndian;
/**
* <p>
*
@ -282,9 +282,9 @@ public class Thumbnail {
*
*@return a flag indicating the Clipboard Format Tag
*/
public int getClipboardFormatTag() {
DWord clipboardFormatTag = new DWord(getThumbnail(), OFFSET_CFTAG);
return clipboardFormatTag.intValue();
public long getClipboardFormatTag() {
long clipboardFormatTag = LittleEndian.getUInt(getThumbnail(), OFFSET_CFTAG);
return clipboardFormatTag;
}
@ -309,14 +309,14 @@ public class Thumbnail {
*@return a flag indicating the Clipboard Format
*@throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS
*/
public int getClipboardFormat() throws HPSFException {
public long getClipboardFormat() throws HPSFException {
if (!(getClipboardFormatTag() == CFTAG_WINDOWS)) {
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
"be CFTAG_WINDOWS.");
}
DWord clipboardFormat = new DWord(getThumbnail(), OFFSET_CF);
return clipboardFormat.intValue();
long clipboardFormat = LittleEndian.getUInt(getThumbnail(), OFFSET_CF);
return clipboardFormat;
}