Fix the indenting to be consistent throughout the file

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1496519 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2013-06-25 15:44:36 +00:00
parent 56d1f1b97a
commit 456f6171d9

View File

@ -50,330 +50,329 @@ import org.apache.poi.util.POILogger;
public final class StyleTextPropAtom extends RecordAtom public final class StyleTextPropAtom extends RecordAtom
{ {
private byte[] _header; private byte[] _header;
private static long _type = 4001l; private static long _type = 4001l;
private byte[] reserved; private byte[] reserved;
private byte[] rawContents; // Holds the contents between write-outs private byte[] rawContents; // Holds the contents between write-outs
/** /**
* Only set to true once setParentTextSize(int) is called. * Only set to true once setParentTextSize(int) is called.
* Until then, no stylings will have been decoded * Until then, no stylings will have been decoded
*/ */
private boolean initialised = false; private boolean initialised = false;
/** /**
* The list of all the different paragraph stylings we code for. * The list of all the different paragraph stylings we code for.
* Each entry is a TextPropCollection, which tells you how many * Each entry is a TextPropCollection, which tells you how many
* Characters the paragraph covers, and also contains the TextProps * Characters the paragraph covers, and also contains the TextProps
* that actually define the styling of the paragraph. * that actually define the styling of the paragraph.
*/ */
private LinkedList<TextPropCollection> paragraphStyles; private LinkedList<TextPropCollection> paragraphStyles;
public LinkedList<TextPropCollection> getParagraphStyles() { return paragraphStyles; } public LinkedList<TextPropCollection> getParagraphStyles() { return paragraphStyles; }
/** /**
* Updates the link list of TextPropCollections which make up the * Updates the link list of TextPropCollections which make up the
* paragraph stylings * paragraph stylings
*/ */
public void setParagraphStyles(LinkedList<TextPropCollection> ps) { paragraphStyles = ps; } public void setParagraphStyles(LinkedList<TextPropCollection> ps) { paragraphStyles = ps; }
/** /**
* The list of all the different character stylings we code for. * The list of all the different character stylings we code for.
* Each entry is a TextPropCollection, which tells you how many * Each entry is a TextPropCollection, which tells you how many
* Characters the character styling covers, and also contains the * Characters the character styling covers, and also contains the
* TextProps that actually define the styling of the characters. * TextProps that actually define the styling of the characters.
*/ */
private LinkedList<TextPropCollection> charStyles; private LinkedList<TextPropCollection> charStyles;
public LinkedList<TextPropCollection> getCharacterStyles() { return charStyles; } public LinkedList<TextPropCollection> getCharacterStyles() { return charStyles; }
/** /**
* Updates the link list of TextPropCollections which make up the * Updates the link list of TextPropCollections which make up the
* character stylings * character stylings
*/ */
public void setCharacterStyles(LinkedList<TextPropCollection> cs) { charStyles = cs; } public void setCharacterStyles(LinkedList<TextPropCollection> cs) { charStyles = cs; }
/** /**
* Returns how many characters the paragraph's * Returns how many characters the paragraph's
* TextPropCollections cover. * TextPropCollections cover.
* (May be one or two more than the underlying text does, * (May be one or two more than the underlying text does,
* due to having extra characters meaning something * due to having extra characters meaning something
* special to powerpoint) * special to powerpoint)
*/ */
public int getParagraphTextLengthCovered() { public int getParagraphTextLengthCovered() {
return getCharactersCovered(paragraphStyles); return getCharactersCovered(paragraphStyles);
} }
/** /**
* Returns how many characters the character's * Returns how many characters the character's
* TextPropCollections cover. * TextPropCollections cover.
* (May be one or two more than the underlying text does, * (May be one or two more than the underlying text does,
* due to having extra characters meaning something * due to having extra characters meaning something
* special to powerpoint) * special to powerpoint)
*/ */
public int getCharacterTextLengthCovered() { public int getCharacterTextLengthCovered() {
return getCharactersCovered(charStyles); return getCharactersCovered(charStyles);
} }
private int getCharactersCovered(LinkedList<TextPropCollection> styles) { private int getCharactersCovered(LinkedList<TextPropCollection> styles) {
int length = 0; int length = 0;
for(TextPropCollection tpc : styles) { for(TextPropCollection tpc : styles) {
length += tpc.getCharactersCovered(); length += tpc.getCharactersCovered();
} }
return length; return length;
} }
/** All the different kinds of paragraph properties we might handle */
public static TextProp[] paragraphTextPropTypes = new TextProp[] {
new TextProp(0, 0x1, "hasBullet"),
new TextProp(0, 0x2, "hasBulletFont"),
new TextProp(0, 0x4, "hasBulletColor"),
new TextProp(0, 0x8, "hasBulletSize"),
new ParagraphFlagsTextProp(),
new TextProp(2, 0x80, "bullet.char"),
new TextProp(2, 0x10, "bullet.font"),
new TextProp(2, 0x40, "bullet.size"),
new TextProp(4, 0x20, "bullet.color"),
new AlignmentTextProp(),
new TextProp(2, 0x100, "text.offset"),
new TextProp(2, 0x400, "bullet.offset"),
new TextProp(2, 0x1000, "linespacing"),
new TextProp(2, 0x2000, "spacebefore"),
new TextProp(2, 0x4000, "spaceafter"),
new TextProp(2, 0x8000, "defaultTabSize"),
new TextProp(2, 0x100000, "tabStops"),
new TextProp(2, 0x10000, "fontAlign"),
new TextProp(2, 0xA0000, "wrapFlags"),
new TextProp(2, 0x200000, "textDirection")
};
/** All the different kinds of character properties we might handle */
public static TextProp[] characterTextPropTypes = new TextProp[] {
new TextProp(0, 0x1, "bold"),
new TextProp(0, 0x2, "italic"),
new TextProp(0, 0x4, "underline"),
new TextProp(0, 0x8, "unused1"),
new TextProp(0, 0x10, "shadow"),
new TextProp(0, 0x20, "fehint"),
new TextProp(0, 0x40, "unused2"),
new TextProp(0, 0x80, "kumi"),
new TextProp(0, 0x100, "unused3"),
new TextProp(0, 0x200, "emboss"),
new TextProp(0, 0x400, "nibble1"),
new TextProp(0, 0x800, "nibble2"),
new TextProp(0, 0x1000, "nibble3"),
new TextProp(0, 0x2000, "nibble4"),
new TextProp(0, 0x4000, "unused4"),
new TextProp(0, 0x8000, "unused5"),
new CharFlagsTextProp(),
new TextProp(2, 0x10000, "font.index"),
new TextProp(0, 0x100000, "pp10ext"),
new TextProp(2, 0x200000, "asian.font.index"),
new TextProp(2, 0x400000, "ansi.font.index"),
new TextProp(2, 0x800000, "symbol.font.index"),
new TextProp(2, 0x20000, "font.size"),
new TextProp(4, 0x40000, "font.color"),
new TextProp(2, 0x80000, "superscript"),
/** All the different kinds of paragraph properties we might handle */
public static TextProp[] paragraphTextPropTypes = new TextProp[] {
new TextProp(0, 0x1, "hasBullet"),
new TextProp(0, 0x2, "hasBulletFont"),
new TextProp(0, 0x4, "hasBulletColor"),
new TextProp(0, 0x8, "hasBulletSize"),
new ParagraphFlagsTextProp(),
new TextProp(2, 0x80, "bullet.char"),
new TextProp(2, 0x10, "bullet.font"),
new TextProp(2, 0x40, "bullet.size"),
new TextProp(4, 0x20, "bullet.color"),
new AlignmentTextProp(),
new TextProp(2, 0x100, "text.offset"),
new TextProp(2, 0x400, "bullet.offset"),
new TextProp(2, 0x1000, "linespacing"),
new TextProp(2, 0x2000, "spacebefore"),
new TextProp(2, 0x4000, "spaceafter"),
new TextProp(2, 0x8000, "defaultTabSize"),
new TextProp(2, 0x100000, "tabStops"),
new TextProp(2, 0x10000, "fontAlign"),
new TextProp(2, 0xA0000, "wrapFlags"),
new TextProp(2, 0x200000, "textDirection")
};
/** All the different kinds of character properties we might handle */
public static TextProp[] characterTextPropTypes = new TextProp[] {
new TextProp(0, 0x1, "bold"),
new TextProp(0, 0x2, "italic"),
new TextProp(0, 0x4, "underline"),
new TextProp(0, 0x8, "unused1"),
new TextProp(0, 0x10, "shadow"),
new TextProp(0, 0x20, "fehint"),
new TextProp(0, 0x40, "unused2"),
new TextProp(0, 0x80, "kumi"),
new TextProp(0, 0x100, "unused3"),
new TextProp(0, 0x200, "emboss"),
new TextProp(0, 0x400, "nibble1"),
new TextProp(0, 0x800, "nibble2"),
new TextProp(0, 0x1000, "nibble3"),
new TextProp(0, 0x2000, "nibble4"),
new TextProp(0, 0x4000, "unused4"),
new TextProp(0, 0x8000, "unused5"),
new CharFlagsTextProp(),
new TextProp(2, 0x10000, "font.index"),
new TextProp(0, 0x100000, "pp10ext"),
new TextProp(2, 0x200000, "asian.font.index"),
new TextProp(2, 0x400000, "ansi.font.index"),
new TextProp(2, 0x800000, "symbol.font.index"),
new TextProp(2, 0x20000, "font.size"),
new TextProp(4, 0x40000, "font.color"),
new TextProp(2, 0x80000, "superscript")
}; };
/* *************** record code follows ********************** */ /* *************** record code follows ********************** */
/** /**
* For the Text Style Properties (StyleTextProp) Atom * For the Text Style Properties (StyleTextProp) Atom
*/ */
public StyleTextPropAtom(byte[] source, int start, int len) { public StyleTextPropAtom(byte[] source, int start, int len) {
// Sanity Checking - we're always at least 8+10 bytes long // Sanity Checking - we're always at least 8+10 bytes long
if(len < 18) { if(len < 18) {
len = 18; len = 18;
if(source.length - start < 18) { if(source.length - start < 18) {
throw new RuntimeException("Not enough data to form a StyleTextPropAtom (min size 18 bytes long) - found " + (source.length - start)); throw new RuntimeException("Not enough data to form a StyleTextPropAtom (min size 18 bytes long) - found " + (source.length - start));
} }
} }
// Get the header // Get the header
_header = new byte[8]; _header = new byte[8];
System.arraycopy(source,start,_header,0,8); System.arraycopy(source,start,_header,0,8);
// Save the contents of the atom, until we're asked to go and // Save the contents of the atom, until we're asked to go and
// decode them (via a call to setParentTextSize(int) // decode them (via a call to setParentTextSize(int)
rawContents = new byte[len-8]; rawContents = new byte[len-8];
System.arraycopy(source,start+8,rawContents,0,rawContents.length); System.arraycopy(source,start+8,rawContents,0,rawContents.length);
reserved = new byte[0]; reserved = new byte[0];
// Set empty linked lists, ready for when they call setParentTextSize // Set empty linked lists, ready for when they call setParentTextSize
paragraphStyles = new LinkedList<TextPropCollection>(); paragraphStyles = new LinkedList<TextPropCollection>();
charStyles = new LinkedList<TextPropCollection>(); charStyles = new LinkedList<TextPropCollection>();
} }
/** /**
* A new set of text style properties for some text without any. * A new set of text style properties for some text without any.
*/ */
public StyleTextPropAtom(int parentTextSize) { public StyleTextPropAtom(int parentTextSize) {
_header = new byte[8]; _header = new byte[8];
rawContents = new byte[0]; rawContents = new byte[0];
reserved = new byte[0]; reserved = new byte[0];
// Set our type // Set our type
LittleEndian.putInt(_header,2,(short)_type); LittleEndian.putInt(_header,2,(short)_type);
// Our initial size is 10 // Our initial size is 10
LittleEndian.putInt(_header,4,10); LittleEndian.putInt(_header,4,10);
// Set empty paragraph and character styles // Set empty paragraph and character styles
paragraphStyles = new LinkedList<TextPropCollection>(); paragraphStyles = new LinkedList<TextPropCollection>();
charStyles = new LinkedList<TextPropCollection>(); charStyles = new LinkedList<TextPropCollection>();
TextPropCollection defaultParagraphTextProps = TextPropCollection defaultParagraphTextProps =
new TextPropCollection(parentTextSize, (short)0); new TextPropCollection(parentTextSize, (short)0);
paragraphStyles.add(defaultParagraphTextProps); paragraphStyles.add(defaultParagraphTextProps);
TextPropCollection defaultCharacterTextProps = TextPropCollection defaultCharacterTextProps =
new TextPropCollection(parentTextSize); new TextPropCollection(parentTextSize);
charStyles.add(defaultCharacterTextProps); charStyles.add(defaultCharacterTextProps);
// Set us as now initialised // Set us as now initialised
initialised = true; initialised = true;
} }
/** /**
* We are of type 4001 * We are of type 4001
*/ */
public long getRecordType() { return _type; } public long getRecordType() { return _type; }
/** /**
* Write the contents of the record back, so it can be written * Write the contents of the record back, so it can be written
* to disk * to disk
*/ */
public void writeOut(OutputStream out) throws IOException { public void writeOut(OutputStream out) throws IOException {
// First thing to do is update the raw bytes of the contents, based // First thing to do is update the raw bytes of the contents, based
// on the properties // on the properties
updateRawContents(); updateRawContents();
// Now ensure that the header size is correct // Now ensure that the header size is correct
int newSize = rawContents.length + reserved.length; int newSize = rawContents.length + reserved.length;
LittleEndian.putInt(_header,4,newSize); LittleEndian.putInt(_header,4,newSize);
// Write out the (new) header // Write out the (new) header
out.write(_header); out.write(_header);
// Write out the styles // Write out the styles
out.write(rawContents); out.write(rawContents);
// Write out any extra bits // Write out any extra bits
out.write(reserved); out.write(reserved);
} }
/** /**
* Tell us how much text the parent TextCharsAtom or TextBytesAtom * Tell us how much text the parent TextCharsAtom or TextBytesAtom
* contains, so we can go ahead and initialise ourselves. * contains, so we can go ahead and initialise ourselves.
*/ */
public void setParentTextSize(int size) { public void setParentTextSize(int size) {
int pos = 0; int pos = 0;
int textHandled = 0; int textHandled = 0;
// While we have text in need of paragraph stylings, go ahead and // While we have text in need of paragraph stylings, go ahead and
// grok the contents as paragraph formatting data // grok the contents as paragraph formatting data
int prsize = size; int prsize = size;
while(pos < rawContents.length && textHandled < prsize) { while(pos < rawContents.length && textHandled < prsize) {
// First up, fetch the number of characters this applies to // First up, fetch the number of characters this applies to
int textLen = LittleEndian.getInt(rawContents,pos); int textLen = LittleEndian.getInt(rawContents,pos);
textHandled += textLen; textHandled += textLen;
pos += 4; pos += 4;
short indent = LittleEndian.getShort(rawContents,pos); short indent = LittleEndian.getShort(rawContents,pos);
pos += 2; pos += 2;
// Grab the 4 byte value that tells us what properties follow // Grab the 4 byte value that tells us what properties follow
int paraFlags = LittleEndian.getInt(rawContents,pos); int paraFlags = LittleEndian.getInt(rawContents,pos);
pos += 4; pos += 4;
// Now make sense of those properties // Now make sense of those properties
TextPropCollection thisCollection = new TextPropCollection(textLen, indent); TextPropCollection thisCollection = new TextPropCollection(textLen, indent);
int plSize = thisCollection.buildTextPropList( int plSize = thisCollection.buildTextPropList(
paraFlags, paragraphTextPropTypes, rawContents, pos); paraFlags, paragraphTextPropTypes, rawContents, pos);
pos += plSize; pos += plSize;
// Save this properties set // Save this properties set
paragraphStyles.add(thisCollection); paragraphStyles.add(thisCollection);
// Handle extra 1 paragraph styles at the end // Handle extra 1 paragraph styles at the end
if(pos < rawContents.length && textHandled == size) { if(pos < rawContents.length && textHandled == size) {
prsize++; prsize++;
} }
} }
if (rawContents.length > 0 && textHandled != (size+1)){ if (rawContents.length > 0 && textHandled != (size+1)){
logger.log(POILogger.WARN, "Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1)); logger.log(POILogger.WARN, "Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
} }
// Now do the character stylings // Now do the character stylings
textHandled = 0; textHandled = 0;
int chsize = size; int chsize = size;
while(pos < rawContents.length && textHandled < chsize) { while(pos < rawContents.length && textHandled < chsize) {
// First up, fetch the number of characters this applies to // First up, fetch the number of characters this applies to
int textLen = LittleEndian.getInt(rawContents,pos); int textLen = LittleEndian.getInt(rawContents,pos);
textHandled += textLen; textHandled += textLen;
pos += 4; pos += 4;
// There is no 2 byte value // There is no 2 byte value
short no_val = -1; short no_val = -1;
// Grab the 4 byte value that tells us what properties follow // Grab the 4 byte value that tells us what properties follow
int charFlags = LittleEndian.getInt(rawContents,pos); int charFlags = LittleEndian.getInt(rawContents,pos);
pos += 4; pos += 4;
// Now make sense of those properties // Now make sense of those properties
// (Assuming we actually have some) // (Assuming we actually have some)
TextPropCollection thisCollection = new TextPropCollection(textLen, no_val); TextPropCollection thisCollection = new TextPropCollection(textLen, no_val);
int chSize = thisCollection.buildTextPropList( int chSize = thisCollection.buildTextPropList(
charFlags, characterTextPropTypes, rawContents, pos); charFlags, characterTextPropTypes, rawContents, pos);
pos += chSize; pos += chSize;
// Save this properties set // Save this properties set
charStyles.add(thisCollection); charStyles.add(thisCollection);
// Handle extra 1 char styles at the end // Handle extra 1 char styles at the end
if(pos < rawContents.length && textHandled == size) { if(pos < rawContents.length && textHandled == size) {
chsize++; chsize++;
} }
} }
if (rawContents.length > 0 && textHandled != (size+1)){ if (rawContents.length > 0 && textHandled != (size+1)){
logger.log(POILogger.WARN, "Problem reading character style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1)); logger.log(POILogger.WARN, "Problem reading character style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
} }
// Handle anything left over // Handle anything left over
if(pos < rawContents.length) { if(pos < rawContents.length) {
reserved = new byte[rawContents.length-pos]; reserved = new byte[rawContents.length-pos];
System.arraycopy(rawContents,pos,reserved,0,reserved.length); System.arraycopy(rawContents,pos,reserved,0,reserved.length);
} }
initialised = true; initialised = true;
} }
/** /**
* Updates the cache of the raw contents. Serialised the styles out. * Updates the cache of the raw contents. Serialised the styles out.
*/ */
private void updateRawContents() throws IOException { private void updateRawContents() throws IOException {
if(!initialised) { if(!initialised) {
// We haven't groked the styles since creation, so just stick // We haven't groked the styles since creation, so just stick
// with what we found // with what we found
return; return;
} }
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
// First up, we need to serialise the paragraph properties // First up, we need to serialise the paragraph properties
for(int i=0; i<paragraphStyles.size(); i++) { for(int i=0; i<paragraphStyles.size(); i++) {
TextPropCollection tpc = paragraphStyles.get(i); TextPropCollection tpc = paragraphStyles.get(i);
tpc.writeOut(baos); tpc.writeOut(baos);
} }
// Now, we do the character ones // Now, we do the character ones
for(int i=0; i<charStyles.size(); i++) { for(int i=0; i<charStyles.size(); i++) {
TextPropCollection tpc = charStyles.get(i); TextPropCollection tpc = charStyles.get(i);
tpc.writeOut(baos); tpc.writeOut(baos);
} }
rawContents = baos.toByteArray(); rawContents = baos.toByteArray();
} }
public void setRawContents(byte[] bytes) { public void setRawContents(byte[] bytes) {
rawContents = bytes; rawContents = bytes;
@ -382,30 +381,30 @@ public final class StyleTextPropAtom extends RecordAtom
} }
/** /**
* Create a new Paragraph TextPropCollection, and add it to the list * Create a new Paragraph TextPropCollection, and add it to the list
* @param charactersCovered The number of characters this TextPropCollection will cover * @param charactersCovered The number of characters this TextPropCollection will cover
* @return the new TextPropCollection, which will then be in the list * @return the new TextPropCollection, which will then be in the list
*/ */
public TextPropCollection addParagraphTextPropCollection(int charactersCovered) { public TextPropCollection addParagraphTextPropCollection(int charactersCovered) {
TextPropCollection tpc = new TextPropCollection(charactersCovered, (short)0); TextPropCollection tpc = new TextPropCollection(charactersCovered, (short)0);
paragraphStyles.add(tpc); paragraphStyles.add(tpc);
return tpc; return tpc;
} }
/** /**
* Create a new Character TextPropCollection, and add it to the list * Create a new Character TextPropCollection, and add it to the list
* @param charactersCovered The number of characters this TextPropCollection will cover * @param charactersCovered The number of characters this TextPropCollection will cover
* @return the new TextPropCollection, which will then be in the list * @return the new TextPropCollection, which will then be in the list
*/ */
public TextPropCollection addCharacterTextPropCollection(int charactersCovered) { public TextPropCollection addCharacterTextPropCollection(int charactersCovered) {
TextPropCollection tpc = new TextPropCollection(charactersCovered); TextPropCollection tpc = new TextPropCollection(charactersCovered);
charStyles.add(tpc); charStyles.add(tpc);
return tpc; return tpc;
} }
/* ************************************************************************ */ /* ************************************************************************ */
/** /**
* Dump the record content into <code>StringBuffer</code> * Dump the record content into <code>StringBuffer</code>
* *
* @return the string representation of the record data * @return the string representation of the record data
@ -413,57 +412,57 @@ public final class StyleTextPropAtom extends RecordAtom
public String toString(){ public String toString(){
StringBuffer out = new StringBuffer(); StringBuffer out = new StringBuffer();
out.append("StyleTextPropAtom:\n"); out.append("StyleTextPropAtom:\n");
if (!initialised) { if (!initialised) {
out.append("Uninitialised, dumping Raw Style Data\n"); out.append("Uninitialised, dumping Raw Style Data\n");
} else { } else {
out.append("Paragraph properties\n"); out.append("Paragraph properties\n");
for(TextPropCollection pr : getParagraphStyles()) { for(TextPropCollection pr : getParagraphStyles()) {
out.append(" chars covered: " + pr.getCharactersCovered()); out.append(" chars covered: " + pr.getCharactersCovered());
out.append(" special mask flags: 0x" + HexDump.toHex(pr.getSpecialMask()) + "\n"); out.append(" special mask flags: 0x" + HexDump.toHex(pr.getSpecialMask()) + "\n");
for(TextProp p : pr.getTextPropList()) { for(TextProp p : pr.getTextPropList()) {
out.append(" " + p.getName() + " = " + p.getValue() ); out.append(" " + p.getName() + " = " + p.getValue() );
out.append(" (0x" + HexDump.toHex(p.getValue()) + ")\n"); out.append(" (0x" + HexDump.toHex(p.getValue()) + ")\n");
} }
out.append(" para bytes that would be written: \n"); out.append(" para bytes that would be written: \n");
try { try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
pr.writeOut(baos); pr.writeOut(baos);
byte[] b = baos.toByteArray(); byte[] b = baos.toByteArray();
out.append(HexDump.dump(b, 0, 0)); out.append(HexDump.dump(b, 0, 0));
} catch (Exception e ) { } catch (Exception e ) {
e.printStackTrace(); e.printStackTrace();
} }
} }
out.append("Character properties\n"); out.append("Character properties\n");
for(TextPropCollection pr : getCharacterStyles()) { for(TextPropCollection pr : getCharacterStyles()) {
out.append(" chars covered: " + pr.getCharactersCovered() ); out.append(" chars covered: " + pr.getCharactersCovered() );
out.append(" special mask flags: 0x" + HexDump.toHex(pr.getSpecialMask()) + "\n"); out.append(" special mask flags: 0x" + HexDump.toHex(pr.getSpecialMask()) + "\n");
for(TextProp p : pr.getTextPropList()) { for(TextProp p : pr.getTextPropList()) {
out.append(" " + p.getName() + " = " + p.getValue() ); out.append(" " + p.getName() + " = " + p.getValue() );
out.append(" (0x" + HexDump.toHex(p.getValue()) + ")\n"); out.append(" (0x" + HexDump.toHex(p.getValue()) + ")\n");
} }
out.append(" char bytes that would be written: \n"); out.append(" char bytes that would be written: \n");
try { try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
pr.writeOut(baos); pr.writeOut(baos);
byte[] b = baos.toByteArray(); byte[] b = baos.toByteArray();
out.append(HexDump.dump(b, 0, 0)); out.append(HexDump.dump(b, 0, 0));
} catch (Exception e ) { } catch (Exception e ) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
out.append(" original byte stream \n"); out.append(" original byte stream \n");
out.append( HexDump.dump(rawContents, 0, 0) ); out.append( HexDump.dump(rawContents, 0, 0) );
return out.toString(); return out.toString();
} }