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:
parent
13935d307f
commit
7393982224
@ -85,6 +85,9 @@ public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
|
|||||||
final int row,
|
final int row,
|
||||||
final boolean hasFocus)
|
final boolean hasFocus)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
throw new RuntimeException("THIS FUNCTION BROKEN -- FIX IT");
|
||||||
|
/*
|
||||||
final PropertySetDescriptor d = (PropertySetDescriptor)
|
final PropertySetDescriptor d = (PropertySetDescriptor)
|
||||||
((DefaultMutableTreeNode) value).getUserObject();
|
((DefaultMutableTreeNode) value).getUserObject();
|
||||||
final PropertySet ps = d.getPropertySet();
|
final PropertySet ps = d.getPropertySet();
|
||||||
@ -94,21 +97,22 @@ public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
|
|||||||
text.setFont(new Font("Monospaced", Font.PLAIN, 10));
|
text.setFont(new Font("Monospaced", Font.PLAIN, 10));
|
||||||
text.append(renderAsString(d));
|
text.append(renderAsString(d));
|
||||||
text.append("\nByte order: " +
|
text.append("\nByte order: " +
|
||||||
Codec.hexEncode(ps.getByteOrder().getBytes()));
|
Codec.hexEncode(ps.getByteOrder()));
|
||||||
text.append("\nFormat: " +
|
text.append("\nFormat: " +
|
||||||
Codec.hexEncode(ps.getFormat().getBytes()));
|
Codec.hexEncode(ps.getFormat()));
|
||||||
text.append("\nOS version: " +
|
text.append("\nOS version: " +
|
||||||
Codec.hexEncode(ps.getOSVersion().getBytes()));
|
Codec.hexEncode(ps.getOSVersion()));
|
||||||
text.append("\nClass ID: " +
|
text.append("\nClass ID: " +
|
||||||
Codec.hexEncode(ps.getClassID().getBytes()));
|
Codec.hexEncode(ps.getClassID()));
|
||||||
text.append("\nSection count: " + ps.getSectionCount());
|
text.append("\nSection count: " + ps.getSectionCount());
|
||||||
text.append(sectionsToString(ps.getSections()));
|
text.append(sectionsToString(ps.getSections()));
|
||||||
p.add(text);
|
p.add(text);
|
||||||
|
|
||||||
if (ps instanceof SummaryInformation)
|
if (ps instanceof SummaryInformation)
|
||||||
{
|
{
|
||||||
|
*/
|
||||||
/* Use the convenience methods. */
|
/* Use the convenience methods. */
|
||||||
final SummaryInformation si = (SummaryInformation) ps;
|
/* final SummaryInformation si = (SummaryInformation) ps;
|
||||||
text.append("\n");
|
text.append("\n");
|
||||||
text.append("\nTitle: " + si.getTitle());
|
text.append("\nTitle: " + si.getTitle());
|
||||||
text.append("\nSubject: " + si.getSubject());
|
text.append("\nSubject: " + si.getSubject());
|
||||||
@ -132,7 +136,7 @@ public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
|
|||||||
|
|
||||||
if (selected)
|
if (selected)
|
||||||
Util.invert(text);
|
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)
|
protected String toString(final Section s, final String name)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
throw new RuntimeException("THIS FUNCTION BROKEN -- FIX IT");
|
||||||
|
/*
|
||||||
final StringBuffer b = new StringBuffer();
|
final StringBuffer b = new StringBuffer();
|
||||||
b.append("\n" + name + " Format ID: ");
|
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 + " Offset: " + s.getOffset());
|
||||||
b.append("\n" + name + " Section size: " + s.getSize());
|
b.append("\n" + name + " Section size: " + s.getSize());
|
||||||
b.append("\n" + name + " Property count: " + s.getPropertyCount());
|
b.append("\n" + name + " Property count: " + s.getPropertyCount());
|
||||||
@ -188,6 +195,7 @@ public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
|
|||||||
b.append(value.toString());
|
b.append(value.toString());
|
||||||
}
|
}
|
||||||
return b.toString();
|
return b.toString();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public class ClassID {
|
|||||||
*@param offset The offset of the first byte to read.
|
*@param offset The offset of the first byte to read.
|
||||||
*/
|
*/
|
||||||
public ClassID(final byte[] src, final int offset) {
|
public ClassID(final byte[] src, final int offset) {
|
||||||
super(src, offset);
|
// super(src, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -93,6 +93,11 @@ public class ClassID {
|
|||||||
return LENGTH;
|
return LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] getBytes() {
|
||||||
|
|
||||||
|
throw new RuntimeException("This fucntion must be rewritten");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of the Method - REWRITE ME REWRITE ME REWRITE ME
|
* Description of the Method - REWRITE ME REWRITE ME REWRITE ME
|
||||||
|
@ -56,7 +56,7 @@ package org.apache.poi.hpsf;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
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.hpsf.wellknown.*;
|
||||||
import org.apache.poi.poifs.filesystem.*;
|
import org.apache.poi.poifs.filesystem.*;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ public class PropertySet {
|
|||||||
final static byte[] FORMAT_ASSERTION =
|
final static byte[] FORMAT_ASSERTION =
|
||||||
new byte[]{(byte) 0x00, (byte) 0x00};
|
new byte[]{(byte) 0x00, (byte) 0x00};
|
||||||
|
|
||||||
private Word byteOrder;
|
private int byteOrder;
|
||||||
|
|
||||||
|
|
||||||
// Must equal BYTE_ORDER_ASSERTION
|
// Must equal BYTE_ORDER_ASSERTION
|
||||||
@ -112,13 +112,13 @@ public class PropertySet {
|
|||||||
*
|
*
|
||||||
*@return The byteOrder value
|
*@return The byteOrder value
|
||||||
*/
|
*/
|
||||||
public Word getByteOrder() {
|
public int getByteOrder() {
|
||||||
return byteOrder;
|
return byteOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Word format;
|
private int format;
|
||||||
|
|
||||||
|
|
||||||
// Must equal FORMAT_ASSERTION
|
// Must equal FORMAT_ASSERTION
|
||||||
@ -131,13 +131,13 @@ public class PropertySet {
|
|||||||
*
|
*
|
||||||
*@return The format value
|
*@return The format value
|
||||||
*/
|
*/
|
||||||
public Word getFormat() {
|
public int getFormat() {
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private DWord osVersion;
|
private long osVersion;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,7 +147,7 @@ public class PropertySet {
|
|||||||
*
|
*
|
||||||
*@return The oSVersion value
|
*@return The oSVersion value
|
||||||
*/
|
*/
|
||||||
public DWord getOSVersion() {
|
public long getOSVersion() {
|
||||||
return osVersion;
|
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
|
*@return The sectionCount value
|
||||||
*/
|
*/
|
||||||
public int getSectionCount() {
|
public long getSectionCount() {
|
||||||
return sectionCount;
|
return sectionCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,23 +366,27 @@ public class PropertySet {
|
|||||||
* Read the header fields of the stream. They must always be
|
* Read the header fields of the stream. They must always be
|
||||||
* there.
|
* there.
|
||||||
*/
|
*/
|
||||||
final Word byteOrder = new Word(src, offset);
|
final int byteOrder = LittleEndian.getUShort(src, offset);
|
||||||
offset += Word.LENGTH;
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
if (!Util.equal(byteOrder.getBytes(), BYTE_ORDER_ASSERTION)) {
|
byte[] temp = new byte[LittleEndian.SHORT_SIZE];
|
||||||
|
LittleEndian.putShort(temp,(short)byteOrder);
|
||||||
|
if (!Util.equal(temp, BYTE_ORDER_ASSERTION)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Word format = new Word(src, offset);
|
final int format = LittleEndian.getUShort(src, offset);
|
||||||
offset += Word.LENGTH;
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
if (!Util.equal(format.getBytes(), FORMAT_ASSERTION)) {
|
temp = new byte[LittleEndian.SHORT_SIZE];
|
||||||
|
LittleEndian.putShort(temp,(short)format);
|
||||||
|
if (!Util.equal(temp, FORMAT_ASSERTION)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final DWord osVersion = new DWord(src, offset);
|
final long osVersion = LittleEndian.getUInt(src, offset);
|
||||||
offset += DWord.LENGTH;
|
offset += LittleEndian.INT_SIZE;
|
||||||
final ClassID classID = new ClassID(src, offset);
|
final ClassID classID = new ClassID(src, offset);
|
||||||
offset += ClassID.LENGTH;
|
offset += ClassID.LENGTH;
|
||||||
final DWord sectionCount = new DWord(src, offset);
|
final long sectionCount = LittleEndian.getUInt(src, offset);
|
||||||
offset += DWord.LENGTH;
|
offset += LittleEndian.INT_SIZE;
|
||||||
if (sectionCount.intValue() < 1) {
|
if (sectionCount < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -406,16 +410,16 @@ public class PropertySet {
|
|||||||
/*
|
/*
|
||||||
* Read the stream's header fields.
|
* Read the stream's header fields.
|
||||||
*/
|
*/
|
||||||
byteOrder = new Word(src, offset);
|
byteOrder = LittleEndian.getUShort(src, offset);
|
||||||
offset += Word.LENGTH;
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
format = new Word(src, offset);
|
format = LittleEndian.getUShort(src, offset);
|
||||||
offset += Word.LENGTH;
|
offset += LittleEndian.SHORT_SIZE;
|
||||||
osVersion = new DWord(src, offset);
|
osVersion = LittleEndian.getUInt(src, offset);
|
||||||
offset += DWord.LENGTH;
|
offset += LittleEndian.INT_SIZE;
|
||||||
classID = new ClassID(src, offset);
|
classID = new ClassID(src, offset);
|
||||||
offset += ClassID.LENGTH;
|
offset += ClassID.LENGTH;
|
||||||
sectionCount = new DWord(src, offset).intValue();
|
sectionCount = LittleEndian.getUInt(src, offset);
|
||||||
offset += DWord.LENGTH;
|
offset += LittleEndian.INT_SIZE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the sections, which are following the header. They
|
* Read the sections, which are following the header. They
|
||||||
@ -438,7 +442,7 @@ public class PropertySet {
|
|||||||
*/
|
*/
|
||||||
for (int i = 0; i < sectionCount; i++) {
|
for (int i = 0; i < sectionCount; i++) {
|
||||||
final Section s = new Section(src, offset);
|
final Section s = new Section(src, offset);
|
||||||
offset += ClassID.LENGTH + DWord.LENGTH;
|
offset += ClassID.LENGTH + LittleEndian.INT_SIZE;
|
||||||
sections.add(s);
|
sections.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class Section {
|
|||||||
*
|
*
|
||||||
*@return The offset value
|
*@return The offset value
|
||||||
*/
|
*/
|
||||||
public int getOffset() {
|
public long getOffset() {
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.apache.poi.hpsf.littleendian.*;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -110,7 +110,7 @@ public abstract class SpecialPropertySet extends PropertySet {
|
|||||||
*
|
*
|
||||||
*@return The byteOrder value
|
*@return The byteOrder value
|
||||||
*/
|
*/
|
||||||
public Word getByteOrder() {
|
public int getByteOrder() {
|
||||||
return delegate.getByteOrder();
|
return delegate.getByteOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ public abstract class SpecialPropertySet extends PropertySet {
|
|||||||
*
|
*
|
||||||
*@return The format value
|
*@return The format value
|
||||||
*/
|
*/
|
||||||
public Word getFormat() {
|
public int getFormat() {
|
||||||
return delegate.getFormat();
|
return delegate.getFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ public abstract class SpecialPropertySet extends PropertySet {
|
|||||||
*
|
*
|
||||||
*@return The oSVersion value
|
*@return The oSVersion value
|
||||||
*/
|
*/
|
||||||
public DWord getOSVersion() {
|
public long getOSVersion() {
|
||||||
return delegate.getOSVersion();
|
return delegate.getOSVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ public abstract class SpecialPropertySet extends PropertySet {
|
|||||||
*
|
*
|
||||||
*@return The sectionCount value
|
*@return The sectionCount value
|
||||||
*/
|
*/
|
||||||
public int getSectionCount() {
|
public long getSectionCount() {
|
||||||
return delegate.getSectionCount();
|
return delegate.getSectionCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.poi.hpsf;
|
package org.apache.poi.hpsf;
|
||||||
|
|
||||||
import org.apache.poi.hpsf.littleendian.DWord;
|
import org.apache.poi.util.LittleEndian;
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
@ -282,9 +282,9 @@ public class Thumbnail {
|
|||||||
*
|
*
|
||||||
*@return a flag indicating the Clipboard Format Tag
|
*@return a flag indicating the Clipboard Format Tag
|
||||||
*/
|
*/
|
||||||
public int getClipboardFormatTag() {
|
public long getClipboardFormatTag() {
|
||||||
DWord clipboardFormatTag = new DWord(getThumbnail(), OFFSET_CFTAG);
|
long clipboardFormatTag = LittleEndian.getUInt(getThumbnail(), OFFSET_CFTAG);
|
||||||
return clipboardFormatTag.intValue();
|
return clipboardFormatTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -309,14 +309,14 @@ public class Thumbnail {
|
|||||||
*@return a flag indicating the Clipboard Format
|
*@return a flag indicating the Clipboard Format
|
||||||
*@throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS
|
*@throws HPSFException if the Thumbnail isn't CFTAG_WINDOWS
|
||||||
*/
|
*/
|
||||||
public int getClipboardFormat() throws HPSFException {
|
public long getClipboardFormat() throws HPSFException {
|
||||||
if (!(getClipboardFormatTag() == CFTAG_WINDOWS)) {
|
if (!(getClipboardFormatTag() == CFTAG_WINDOWS)) {
|
||||||
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
|
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
|
||||||
"be CFTAG_WINDOWS.");
|
"be CFTAG_WINDOWS.");
|
||||||
}
|
}
|
||||||
|
|
||||||
DWord clipboardFormat = new DWord(getThumbnail(), OFFSET_CF);
|
long clipboardFormat = LittleEndian.getUInt(getThumbnail(), OFFSET_CF);
|
||||||
return clipboardFormat.intValue();
|
return clipboardFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user