diff --git a/src/contrib/src/org/apache/poi/contrib/poibrowser/PropertySetDescriptorRenderer.java b/src/contrib/src/org/apache/poi/contrib/poibrowser/PropertySetDescriptorRenderer.java index 32541ed0ce..522fa061a2 100644 --- a/src/contrib/src/org/apache/poi/contrib/poibrowser/PropertySetDescriptorRenderer.java +++ b/src/contrib/src/org/apache/poi/contrib/poibrowser/PropertySetDescriptorRenderer.java @@ -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(); +*/ } } diff --git a/src/java/org/apache/poi/hpsf/ClassID.java b/src/java/org/apache/poi/hpsf/ClassID.java index 0746e85e32..74069dd09e 100644 --- a/src/java/org/apache/poi/hpsf/ClassID.java +++ b/src/java/org/apache/poi/hpsf/ClassID.java @@ -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 diff --git a/src/java/org/apache/poi/hpsf/PropertySet.java b/src/java/org/apache/poi/hpsf/PropertySet.java index 80f94cf9f9..f4f856b485 100644 --- a/src/java/org/apache/poi/hpsf/PropertySet.java +++ b/src/java/org/apache/poi/hpsf/PropertySet.java @@ -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); } } diff --git a/src/java/org/apache/poi/hpsf/Section.java b/src/java/org/apache/poi/hpsf/Section.java index d24a040f50..9137b034b2 100644 --- a/src/java/org/apache/poi/hpsf/Section.java +++ b/src/java/org/apache/poi/hpsf/Section.java @@ -105,7 +105,7 @@ public class Section { * *@return The offset value */ - public int getOffset() { + public long getOffset() { return offset; } diff --git a/src/java/org/apache/poi/hpsf/SpecialPropertySet.java b/src/java/org/apache/poi/hpsf/SpecialPropertySet.java index 9b8a7cd365..42d30f0710 100644 --- a/src/java/org/apache/poi/hpsf/SpecialPropertySet.java +++ b/src/java/org/apache/poi/hpsf/SpecialPropertySet.java @@ -55,7 +55,7 @@ package org.apache.poi.hpsf; import java.util.*; -import org.apache.poi.hpsf.littleendian.*; +import org.apache.poi.util.LittleEndian; /** *
@@ -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(); } diff --git a/src/java/org/apache/poi/hpsf/Thumbnail.java b/src/java/org/apache/poi/hpsf/Thumbnail.java index 19c3fa9892..bcc6fe84b2 100644 --- a/src/java/org/apache/poi/hpsf/Thumbnail.java +++ b/src/java/org/apache/poi/hpsf/Thumbnail.java @@ -54,7 +54,7 @@ */ package org.apache.poi.hpsf; -import org.apache.poi.hpsf.littleendian.DWord; +import org.apache.poi.util.LittleEndian; /** *
* @@ -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; }