First preparations for HPSF writing functionality.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353013 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
75d0858b6f
commit
9ccba56e8e
@ -92,6 +92,18 @@ public class ClassID
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Creates a {@link ClassID} and initializes its value with
|
||||
* 0x00 bytes.</p>
|
||||
*/
|
||||
public ClassID()
|
||||
{
|
||||
bytes = new byte[LENGTH];
|
||||
for (int i = 0; i < LENGTH; i++)
|
||||
bytes[i] = 0x00;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final static int LENGTH = 16;
|
||||
|
||||
@ -114,8 +126,8 @@ public class ClassID
|
||||
|
||||
|
||||
/**
|
||||
* <p>Reads a class ID from a byte array by turning little-endian
|
||||
* into big-endian.</p>
|
||||
* <p>Reads the class ID's value from a byte array by turning
|
||||
* little-endian into big-endian.</p>
|
||||
*
|
||||
* @param src The byte array to read from
|
||||
*
|
||||
@ -148,4 +160,40 @@ public class ClassID
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Writes the class ID to a byte array in the
|
||||
* little-endian.</p>
|
||||
*
|
||||
* @param dst The byte array to write to.
|
||||
*
|
||||
* @param offset The offset within the <var>dst</var> byte array.
|
||||
*
|
||||
* @throws ArrayIndexOutOfBoundsException if there is not enough
|
||||
* room for the class ID in the byte array. There must be at least
|
||||
* 16 bytes in the byte array after the <var>offset</var>
|
||||
* position.
|
||||
*/
|
||||
public void write(final byte[] dst, final int offset)
|
||||
{
|
||||
/* Write double word. */
|
||||
dst[0 + offset] = bytes[3];
|
||||
dst[1 + offset] = bytes[2];
|
||||
dst[2 + offset] = bytes[1];
|
||||
dst[3 + offset] = bytes[0];
|
||||
|
||||
/* Write first word. */
|
||||
dst[4 + offset] = bytes[5];
|
||||
dst[5 + offset] = bytes[4];
|
||||
|
||||
/* Write second word. */
|
||||
dst[6 + offset] = bytes[7];
|
||||
dst[7 + offset] = bytes[6];
|
||||
|
||||
/* Write 8 bytes. */
|
||||
for (int i = 8; i < 16; i++)
|
||||
dst[i + offset] = bytes[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,6 +71,15 @@ import org.apache.poi.hpsf.wellknown.*;
|
||||
public class DocumentSummaryInformation extends SpecialPropertySet
|
||||
{
|
||||
|
||||
/**
|
||||
* <p>The document name a document summary information stream
|
||||
* usually has in a POIFS filesystem.</p>
|
||||
*/
|
||||
public static final String DEFAULT_STREAM_NAME =
|
||||
"\005DocumentSummaryInformation";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Creates a {@link DocumentSummaryInformation} from a given
|
||||
* {@link PropertySet}.</p>
|
||||
|
@ -102,17 +102,11 @@ public class PropertySet
|
||||
final static byte[] BYTE_ORDER_ASSERTION =
|
||||
new byte[]{(byte) 0xFE, (byte) 0xFF};
|
||||
|
||||
/**
|
||||
* <p>The "format" field must equal this value.</p>
|
||||
*/
|
||||
final static byte[] FORMAT_ASSERTION =
|
||||
new byte[]{(byte) 0x00, (byte) 0x00};
|
||||
|
||||
/**
|
||||
* <p>Specifies this {@link PropertySet}'s byte order. See the
|
||||
* HPFS documentation for details!</p>
|
||||
*/
|
||||
private int byteOrder;
|
||||
protected int byteOrder;
|
||||
|
||||
/**
|
||||
* <p>Returns the property set stream's low-level "byte order"
|
||||
@ -127,11 +121,17 @@ public class PropertySet
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>The "format" field must equal this value.</p>
|
||||
*/
|
||||
final static byte[] FORMAT_ASSERTION =
|
||||
new byte[]{(byte) 0x00, (byte) 0x00};
|
||||
|
||||
/**
|
||||
* <p>Specifies this {@link PropertySet}'s format. See the HPFS
|
||||
* documentation for details!</p>
|
||||
*/
|
||||
private int format;
|
||||
protected int format;
|
||||
|
||||
/**
|
||||
* <p>Returns the property set stream's low-level "format"
|
||||
@ -151,12 +151,21 @@ public class PropertySet
|
||||
* this {@link PropertySet}. See the HPFS documentation for
|
||||
* details!</p>
|
||||
*/
|
||||
private long osVersion;
|
||||
protected int osVersion;
|
||||
|
||||
|
||||
public final static int OS_WIN16 = 0x0000;
|
||||
public final static int OS_MACINTOSH = 0x0001;
|
||||
public final static int OS_WIN32 = 0x0002;
|
||||
|
||||
/**
|
||||
* <p>Returns the property set stream's low-level "OS version"
|
||||
* field.</p>
|
||||
*
|
||||
* <p><strong>FIXME:</strong> Return an <code>int</code> instead
|
||||
* of a <code>long</code> in the next major version, i.e. when
|
||||
* incompatible changes are allowed.</p>
|
||||
*
|
||||
* @return The property set stream's low-level "OS version" field.
|
||||
*/
|
||||
public long getOSVersion()
|
||||
@ -170,7 +179,7 @@ public class PropertySet
|
||||
* <p>Specifies this {@link PropertySet}'s "classID" field. See
|
||||
* the HPFS documentation for details!</p>
|
||||
*/
|
||||
private ClassID classID;
|
||||
protected ClassID classID;
|
||||
|
||||
/**
|
||||
* <p>Returns the property set stream's low-level "class ID"
|
||||
@ -188,13 +197,17 @@ public class PropertySet
|
||||
/**
|
||||
* <p>The number of sections in this {@link PropertySet}.</p>
|
||||
*/
|
||||
private long sectionCount;
|
||||
protected int sectionCount;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Returns the number of {@link Section}s in the property
|
||||
* set.</p>
|
||||
*
|
||||
* <p><strong>FIXME:</strong> Return an <code>int</code> instead
|
||||
* of a <code>long</code> in the next major version, i.e. when
|
||||
* incompatible changes are allowed.</p>
|
||||
*
|
||||
* @return The number of {@link Section}s in the property set.
|
||||
*/
|
||||
public long getSectionCount()
|
||||
@ -207,7 +220,7 @@ public class PropertySet
|
||||
/**
|
||||
* <p>The sections in this {@link PropertySet}.</p>
|
||||
*/
|
||||
private List sections;
|
||||
protected List sections;
|
||||
|
||||
|
||||
/**
|
||||
@ -420,12 +433,15 @@ public class PropertySet
|
||||
offset += LittleEndian.SHORT_SIZE;
|
||||
format = LittleEndian.getUShort(src, offset);
|
||||
offset += LittleEndian.SHORT_SIZE;
|
||||
osVersion = LittleEndian.getUInt(src, offset);
|
||||
osVersion = (int) LittleEndian.getUInt(src, offset);
|
||||
offset += LittleEndian.INT_SIZE;
|
||||
classID = new ClassID(src, offset);
|
||||
offset += ClassID.LENGTH;
|
||||
sectionCount = LittleEndian.getUInt(src, offset);
|
||||
sectionCount = LittleEndian.getInt(src, offset);
|
||||
offset += LittleEndian.INT_SIZE;
|
||||
if (sectionCount <= 0)
|
||||
throw new HPSFRuntimeException("Section count " + sectionCount +
|
||||
" must be greater than 0.");
|
||||
|
||||
/*
|
||||
* Read the sections, which are following the header. They
|
||||
|
@ -75,7 +75,7 @@ public class Section
|
||||
*/
|
||||
protected Map dictionary;
|
||||
|
||||
private ClassID formatID;
|
||||
protected ClassID formatID;
|
||||
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ public class Section
|
||||
|
||||
|
||||
|
||||
private long offset;
|
||||
protected long offset;
|
||||
|
||||
|
||||
/**
|
||||
@ -110,7 +110,7 @@ public class Section
|
||||
|
||||
|
||||
|
||||
private int size;
|
||||
protected int size;
|
||||
|
||||
|
||||
/**
|
||||
@ -125,7 +125,7 @@ public class Section
|
||||
|
||||
|
||||
|
||||
private int propertyCount;
|
||||
protected int propertyCount;
|
||||
|
||||
|
||||
/**
|
||||
@ -140,7 +140,7 @@ public class Section
|
||||
|
||||
|
||||
|
||||
private Property[] properties;
|
||||
protected Property[] properties;
|
||||
|
||||
|
||||
/**
|
||||
@ -155,6 +155,14 @@ public class Section
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Creates an empty and uninitialized {@link Section}.
|
||||
*/
|
||||
protected Section()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Creates a {@link Section} instance from a byte array.</p>
|
||||
*
|
||||
|
@ -115,6 +115,13 @@ public abstract class SpecialPropertySet extends PropertySet
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This is intentionally no javadoc comment.
|
||||
*
|
||||
* FIXME: Return an <code>int</code> instead of a
|
||||
* <code>long</code> in the next major version, i.e. when
|
||||
* incompatible changes are allowed.
|
||||
*/
|
||||
public long getOSVersion()
|
||||
{
|
||||
return delegate.getOSVersion();
|
||||
@ -129,6 +136,13 @@ public abstract class SpecialPropertySet extends PropertySet
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This is intentionally no javadoc comment.
|
||||
*
|
||||
* FIXME: Return an <code>int</code> instead of a
|
||||
* <code>long</code> in the next major version, i.e. when
|
||||
* incompatible changes are allowed.
|
||||
*/
|
||||
public long getSectionCount()
|
||||
{
|
||||
return delegate.getSectionCount();
|
||||
|
@ -78,6 +78,14 @@ import org.apache.poi.hpsf.wellknown.*;
|
||||
public class SummaryInformation extends SpecialPropertySet
|
||||
{
|
||||
|
||||
/**
|
||||
* <p>The document name a summary information stream usually has
|
||||
* in a POIFS filesystem.</p>
|
||||
*/
|
||||
public static final String DEFAULT_STREAM_NAME = "\005SummaryInformation";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Creates a {@link SummaryInformation} from a given {@link
|
||||
* PropertySet}.</p>
|
||||
|
Loading…
Reference in New Issue
Block a user