mirror of https://github.com/apache/poi.git
#61243 - Refactor and unify toString/toXml in DDF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1800452 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a420b90906
commit
6e6136ba89
|
@ -22,7 +22,6 @@ import java.util.Comparator;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
|
@ -175,53 +174,20 @@ public abstract class AbstractEscherOptRecord extends EscherRecord
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the string representation of this record.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String nl = System.getProperty( "line.separator" );
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append( getClass().getName() );
|
||||
stringBuilder.append( ":" );
|
||||
stringBuilder.append( nl );
|
||||
stringBuilder.append( " isContainer: " );
|
||||
stringBuilder.append( isContainerRecord() );
|
||||
stringBuilder.append( nl );
|
||||
stringBuilder.append( " version: 0x" );
|
||||
stringBuilder.append( HexDump.toHex( getVersion() ) );
|
||||
stringBuilder.append( nl );
|
||||
stringBuilder.append( " instance: 0x" );
|
||||
stringBuilder.append( HexDump.toHex( getInstance() ) );
|
||||
stringBuilder.append( nl );
|
||||
stringBuilder.append( " recordId: 0x" );
|
||||
stringBuilder.append( HexDump.toHex( getRecordId() ) );
|
||||
stringBuilder.append( nl );
|
||||
stringBuilder.append( " numchildren: " );
|
||||
stringBuilder.append( getChildRecords().size() );
|
||||
stringBuilder.append( nl );
|
||||
stringBuilder.append( " properties:" );
|
||||
stringBuilder.append( nl );
|
||||
|
||||
for ( EscherProperty property : properties )
|
||||
{
|
||||
stringBuilder.append(" ").append(property).append(nl);
|
||||
protected Object[][] getAttributeMap() {
|
||||
List<Object> attrList = new ArrayList<Object>(properties.size()*2+2);
|
||||
attrList.add("properties");
|
||||
attrList.add(properties.size());
|
||||
for ( EscherProperty property : properties ) {
|
||||
attrList.add(property.getName());
|
||||
attrList.add(property);
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(),
|
||||
HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())));
|
||||
for (EscherProperty property: getEscherProperties()){
|
||||
builder.append(property.toXml(tab+"\t"));
|
||||
}
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
|
||||
return new Object[][]{
|
||||
{ "isContainer", isContainerRecord() },
|
||||
{ "numchildren", getChildRecords().size() },
|
||||
attrList.toArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,11 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuilder results = new StringBuilder();
|
||||
results.append("propNum: ").append(getPropertyNumber());
|
||||
results.append(", propName: ").append(EscherProperties.getPropertyName( getPropertyNumber() ));
|
||||
results.append(", complex: ").append(isComplex());
|
||||
results.append(", blipId: ").append(isBlipId());
|
||||
results.append(", data: \n");
|
||||
results.append(" {EscherArrayProperty:" + '\n');
|
||||
results.append(" Num Elements: ").append(getNumberOfElementsInArray()).append('\n');
|
||||
results.append(" Num Elements In Memory: ").append(getNumberOfElementsInMemory()).append('\n');
|
||||
|
@ -130,11 +135,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
|
|||
}
|
||||
results.append("}" + '\n');
|
||||
|
||||
return "propNum: " + getPropertyNumber()
|
||||
+ ", propName: " + EscherProperties.getPropertyName( getPropertyNumber() )
|
||||
+ ", complex: " + isComplex()
|
||||
+ ", blipId: " + isBlipId()
|
||||
+ ", data: " + '\n' + results;
|
||||
return results.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -146,7 +147,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
|
|||
for (int i = 0; i < getNumberOfElementsInArray(); i++) {
|
||||
builder.append("\t").append(tab).append("<Element>").append(HexDump.toHex(getElement(i))).append("</Element>\n");
|
||||
}
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
@ -220,7 +221,9 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
|
|||
|
||||
@Override
|
||||
public byte[] next() {
|
||||
if (!hasNext()) throw new NoSuchElementException();
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return getElement(idx++);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,10 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
* The BSE record is related closely to the <code>EscherBlipRecord</code> and stores
|
||||
* The BSE record is related closely to the {@code EscherBlipRecord} and stores
|
||||
* extra information about the blip. A blip record is actually stored inside
|
||||
* the BSE record even though the BSE record isn't actually a container record.
|
||||
*
|
||||
|
@ -55,6 +54,10 @@ public final class EscherBSERecord extends EscherRecord {
|
|||
|
||||
private byte[] _remainingData = new byte[0];
|
||||
|
||||
public EscherBSERecord() {
|
||||
setRecordId(RECORD_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
|
||||
int bytesRemaining = readHeader( data, offset );
|
||||
|
@ -103,8 +106,7 @@ public final class EscherBSERecord extends EscherRecord {
|
|||
|
||||
data[offset + 8] = field_1_blipTypeWin32;
|
||||
data[offset + 9] = field_2_blipTypeMacOS;
|
||||
for ( int i = 0; i < 16; i++ )
|
||||
data[offset + 10 + i] = field_3_uid[i];
|
||||
System.arraycopy(field_3_uid, 0, data, offset + 10, 16);
|
||||
LittleEndian.putShort( data, offset + 26, field_4_tag );
|
||||
LittleEndian.putInt( data, offset + 28, field_5_size );
|
||||
LittleEndian.putInt( data, offset + 32, field_6_ref );
|
||||
|
@ -114,8 +116,7 @@ public final class EscherBSERecord extends EscherRecord {
|
|||
data[offset + 42] = field_10_unused2;
|
||||
data[offset + 43] = field_11_unused3;
|
||||
int bytesWritten = 0;
|
||||
if (field_12_blipRecord != null)
|
||||
{
|
||||
if (field_12_blipRecord != null) {
|
||||
bytesWritten = field_12_blipRecord.serialize( offset + 44, data, new NullEscherSerializationListener() );
|
||||
}
|
||||
System.arraycopy( _remainingData, 0, data, offset + 44 + bytesWritten, _remainingData.length );
|
||||
|
@ -350,52 +351,7 @@ public final class EscherBSERecord extends EscherRecord {
|
|||
* @param remainingData the remaining bytes
|
||||
*/
|
||||
public void setRemainingData(byte[] remainingData) {
|
||||
if (remainingData == null) {
|
||||
_remainingData = new byte[0];
|
||||
} else {
|
||||
_remainingData = remainingData.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String extraData = _remainingData == null ? null : HexDump.toHex(_remainingData, 32);
|
||||
return getClass().getName() + ":" + '\n' +
|
||||
" RecordId: 0x" + HexDump.toHex( RECORD_ID ) + '\n' +
|
||||
" Version: 0x" + HexDump.toHex( getVersion() ) + '\n' +
|
||||
" Instance: 0x" + HexDump.toHex( getInstance() ) + '\n' +
|
||||
" BlipTypeWin32: " + field_1_blipTypeWin32 + '\n' +
|
||||
" BlipTypeMacOS: " + field_2_blipTypeMacOS + '\n' +
|
||||
" SUID: " + (field_3_uid == null ? "" : HexDump.toHex(field_3_uid)) + '\n' +
|
||||
" Tag: " + field_4_tag + '\n' +
|
||||
" Size: " + field_5_size + '\n' +
|
||||
" Ref: " + field_6_ref + '\n' +
|
||||
" Offset: " + field_7_offset + '\n' +
|
||||
" Usage: " + field_8_usage + '\n' +
|
||||
" Name: " + field_9_name + '\n' +
|
||||
" Unused2: " + field_10_unused2 + '\n' +
|
||||
" Unused3: " + field_11_unused3 + '\n' +
|
||||
" blipRecord: " + field_12_blipRecord + '\n' +
|
||||
" Extra Data:" + '\n' + extraData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<BlipTypeWin32>").append(field_1_blipTypeWin32).append("</BlipTypeWin32>\n")
|
||||
.append(tab).append("\t").append("<BlipTypeMacOS>").append(field_2_blipTypeMacOS).append("</BlipTypeMacOS>\n")
|
||||
.append(tab).append("\t").append("<SUID>").append(field_3_uid == null ? "" : HexDump.toHex(field_3_uid)).append("</SUID>\n")
|
||||
.append(tab).append("\t").append("<Tag>").append(field_4_tag).append("</Tag>\n")
|
||||
.append(tab).append("\t").append("<Size>").append(field_5_size).append("</Size>\n")
|
||||
.append(tab).append("\t").append("<Ref>").append(field_6_ref).append("</Ref>\n")
|
||||
.append(tab).append("\t").append("<Offset>").append(field_7_offset).append("</Offset>\n")
|
||||
.append(tab).append("\t").append("<Usage>").append(field_8_usage).append("</Usage>\n")
|
||||
.append(tab).append("\t").append("<Name>").append(field_9_name).append("</Name>\n")
|
||||
.append(tab).append("\t").append("<Unused2>").append(field_10_unused2).append("</Unused2>\n")
|
||||
.append(tab).append("\t").append("<Unused3>").append(field_11_unused3).append("</Unused3>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
_remainingData = (remainingData == null) ? new byte[0] : remainingData.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -421,4 +377,23 @@ public final class EscherBSERecord extends EscherRecord {
|
|||
}
|
||||
return " Client";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "BlipTypeWin32", field_1_blipTypeWin32 },
|
||||
{ "BlipTypeMacOS", field_2_blipTypeMacOS },
|
||||
{ "SUID", field_3_uid },
|
||||
{ "Tag", field_4_tag },
|
||||
{ "Size", field_5_size },
|
||||
{ "Ref", field_6_ref },
|
||||
{ "Offset", field_7_offset },
|
||||
{ "Usage", field_8_usage },
|
||||
{ "Name", field_9_name },
|
||||
{ "Unused2", field_10_unused2 },
|
||||
{ "Unused3", field_11_unused3 },
|
||||
{ "Blip Record", field_12_blipRecord },
|
||||
{ "Extra Data", _remainingData }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
public class EscherBitmapBlip extends EscherBlipRecord {
|
||||
|
@ -110,29 +109,10 @@ public class EscherBitmapBlip extends EscherBlipRecord {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String nl = System.getProperty( "line.separator" );
|
||||
|
||||
String extraData = HexDump.dump(getPicturedata(), 0, 0);
|
||||
|
||||
return getClass().getName() + ":" + nl +
|
||||
" RecordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
|
||||
" Version: 0x" + HexDump.toHex( getVersion() ) + nl +
|
||||
" Instance: 0x" + HexDump.toHex( getInstance() ) + nl +
|
||||
" UID: 0x" + HexDump.toHex( field_1_UID ) + nl +
|
||||
" Marker: 0x" + HexDump.toHex( field_2_marker ) + nl +
|
||||
" Extra Data:" + nl + extraData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
String extraData = HexDump.dump(getPicturedata(), 0, 0);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<UID>0x").append(HexDump.toHex(field_1_UID)).append("</UID>\n")
|
||||
.append(tab).append("\t").append("<Marker>0x").append(HexDump.toHex(field_2_marker)).append("</Marker>\n")
|
||||
.append(tab).append("\t").append("<ExtraData>").append(extraData).append("</ExtraData>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "Marker", field_2_marker },
|
||||
{ "Extra Data", getPicturedata() }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.HexDump;
|
||||
|
||||
public class EscherBlipRecord extends EscherRecord {
|
||||
public static final short RECORD_ID_START = (short) 0xF018;
|
||||
|
@ -100,22 +99,9 @@ public class EscherBlipRecord extends EscherRecord {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String extraData = HexDump.toHex(field_pictureData, 32);
|
||||
return getClass().getName() + ":" + '\n' +
|
||||
" RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' +
|
||||
" Version: 0x" + HexDump.toHex( getVersion() ) + '\n' +
|
||||
" Instance: 0x" + HexDump.toHex( getInstance() ) + '\n' +
|
||||
" Extra Data:" + '\n' + extraData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
String extraData = HexDump.toHex(field_pictureData, 32);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<ExtraData>").append(extraData).append("</ExtraData>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "Extra Data", getPicturedata() }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ public class EscherBoolProperty
|
|||
*
|
||||
* @deprecated use !isTrue() instead, planed to be removed in POI 3.17
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isFalse()
|
||||
{
|
||||
return !isTrue();
|
||||
|
@ -77,7 +78,7 @@ public class EscherBoolProperty
|
|||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append("<").append(getClass().getSimpleName()).append(" id=\"0x").append(HexDump.toHex(getId()))
|
||||
.append("\" name=\"").append(getName()).append("\" simpleValue=\"").append(getPropertyValue()).append("\" blipId=\"")
|
||||
.append(isBlipId()).append("\" value=\"").append(isTrue()).append("\"").append("/>\n");
|
||||
.append(isBlipId()).append("\" value=\"").append(isTrue()).append("\"").append("/>");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
|
@ -96,37 +95,6 @@ public class EscherChildAnchorRecord
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* The string representation of this record
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String nl = System.getProperty("line.separator");
|
||||
|
||||
return getClass().getName() + ":" + nl +
|
||||
" RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl +
|
||||
" Version: 0x" + HexDump.toHex(getVersion()) + nl +
|
||||
" Instance: 0x" + HexDump.toHex(getInstance()) + nl +
|
||||
" X1: " + field_1_dx1 + nl +
|
||||
" Y1: " + field_2_dy1 + nl +
|
||||
" X2: " + field_3_dx2 + nl +
|
||||
" Y2: " + field_4_dy2 + nl ;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<X1>").append(field_1_dx1).append("</X1>\n")
|
||||
.append(tab).append("\t").append("<Y1>").append(field_2_dy1).append("</Y1>\n")
|
||||
.append(tab).append("\t").append("<X2>").append(field_3_dx2).append("</X2>\n")
|
||||
.append(tab).append("\t").append("<Y2>").append(field_4_dy2).append("</Y2>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves offset within the parent coordinate space for the top left point.
|
||||
*
|
||||
|
@ -207,4 +175,13 @@ public class EscherChildAnchorRecord
|
|||
this.field_4_dy2 = field_4_dy2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "X1", field_1_dx1 },
|
||||
{ "Y1", field_2_dy1 },
|
||||
{ "X2", field_3_dx2 },
|
||||
{ "Y2", field_4_dy2 }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
|
@ -94,7 +93,9 @@ public class EscherClientAnchorRecord
|
|||
{
|
||||
listener.beforeRecordSerialize( offset, getRecordId(), this );
|
||||
|
||||
if (remainingData == null) remainingData = new byte[0];
|
||||
if (remainingData == null) {
|
||||
remainingData = new byte[0];
|
||||
}
|
||||
LittleEndian.putShort( data, offset, getOptions() );
|
||||
LittleEndian.putShort( data, offset + 2, getRecordId() );
|
||||
int remainingBytes = remainingData.length + (shortRecord ? 8 : 18);
|
||||
|
@ -133,53 +134,9 @@ public class EscherClientAnchorRecord
|
|||
return "ClientAnchor";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation for this record.
|
||||
*
|
||||
* @return A string
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String nl = System.getProperty("line.separator");
|
||||
String extraData = HexDump.dump(this.remainingData, 0, 0);
|
||||
return getClass().getName() + ":" + nl +
|
||||
" RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl +
|
||||
" Version: 0x" + HexDump.toHex(getVersion()) + nl +
|
||||
" Instance: 0x" + HexDump.toHex(getInstance()) + nl +
|
||||
" Flag: " + field_1_flag + nl +
|
||||
" Col1: " + field_2_col1 + nl +
|
||||
" DX1: " + field_3_dx1 + nl +
|
||||
" Row1: " + field_4_row1 + nl +
|
||||
" DY1: " + field_5_dy1 + nl +
|
||||
" Col2: " + field_6_col2 + nl +
|
||||
" DX2: " + field_7_dx2 + nl +
|
||||
" Row2: " + field_8_row2 + nl +
|
||||
" DY2: " + field_9_dy2 + nl +
|
||||
" Extra Data:" + nl + extraData;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
String extraData = HexDump.dump(this.remainingData, 0, 0).trim();
|
||||
return tab + formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())) +
|
||||
tab + "\t" + "<Flag>" + field_1_flag + "</Flag>\n" +
|
||||
tab + "\t" + "<Col1>" + field_2_col1 + "</Col1>\n" +
|
||||
tab + "\t" + "<DX1>" + field_3_dx1 + "</DX1>\n" +
|
||||
tab + "\t" + "<Row1>" + field_4_row1 + "</Row1>\n" +
|
||||
tab + "\t" + "<DY1>" + field_5_dy1 + "</DY1>\n" +
|
||||
tab + "\t" + "<Col2>" + field_6_col2 + "</Col2>\n" +
|
||||
tab + "\t" + "<DX2>" + field_7_dx2 + "</DX2>\n" +
|
||||
tab + "\t" + "<Row2>" + field_8_row2 + "</Row2>\n" +
|
||||
tab + "\t" + "<DY2>" + field_9_dy2 + "</DY2>\n" +
|
||||
tab + "\t" + "<ExtraData>" + extraData + "</ExtraData>\n" +
|
||||
tab + "</" + getClass().getSimpleName() + ">\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.
|
||||
*
|
||||
*
|
||||
* @return the move/size flag
|
||||
*/
|
||||
public short getFlag()
|
||||
|
@ -189,7 +146,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.
|
||||
*
|
||||
*
|
||||
* @param field_1_flag the move/size flag
|
||||
*/
|
||||
public void setFlag( short field_1_flag )
|
||||
|
@ -199,7 +156,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The column number for the top-left position. 0 based.
|
||||
*
|
||||
*
|
||||
* @return the column number of the top-left corner
|
||||
*/
|
||||
public short getCol1()
|
||||
|
@ -209,7 +166,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The column number for the top-left position. 0 based.
|
||||
*
|
||||
*
|
||||
* @param field_2_col1 the column number of the top-left corner
|
||||
*/
|
||||
public void setCol1( short field_2_col1 )
|
||||
|
@ -219,7 +176,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The x offset within the top-left cell. Range is from 0 to 1023.
|
||||
*
|
||||
*
|
||||
* @return the x offset of the top-left corner
|
||||
*/
|
||||
public short getDx1()
|
||||
|
@ -229,7 +186,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The x offset within the top-left cell. Range is from 0 to 1023.
|
||||
*
|
||||
*
|
||||
* @param field_3_dx1 the x offset of the top-left corner
|
||||
*/
|
||||
public void setDx1( short field_3_dx1 )
|
||||
|
@ -239,7 +196,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The row number for the top-left corner of the shape.
|
||||
*
|
||||
*
|
||||
* @return the row number of the top-left corner
|
||||
*/
|
||||
public short getRow1()
|
||||
|
@ -249,7 +206,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The row number of the top-left corner of the shape.
|
||||
*
|
||||
*
|
||||
* @param field_4_row1 the row number of the top-left corner
|
||||
*/
|
||||
public void setRow1( short field_4_row1 )
|
||||
|
@ -259,7 +216,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The y offset within the top-left corner of the current shape.
|
||||
*
|
||||
*
|
||||
* @return the y offset of the top-left corner
|
||||
*/
|
||||
public short getDy1()
|
||||
|
@ -269,7 +226,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The y offset within the top-left corner of the current shape.
|
||||
*
|
||||
*
|
||||
* @param field_5_dy1 the y offset of the top-left corner
|
||||
*/
|
||||
public void setDy1( short field_5_dy1 )
|
||||
|
@ -280,7 +237,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The column of the bottom right corner of this shape.
|
||||
*
|
||||
*
|
||||
* @return the column of the bottom right corner
|
||||
*/
|
||||
public short getCol2()
|
||||
|
@ -290,7 +247,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The column of the bottom right corner of this shape.
|
||||
*
|
||||
*
|
||||
* @param field_6_col2 the column of the bottom right corner
|
||||
*/
|
||||
public void setCol2( short field_6_col2 )
|
||||
|
@ -301,7 +258,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The x offset withing the cell for the bottom-right corner of this shape.
|
||||
*
|
||||
*
|
||||
* @return the x offset of the bottom-right corner
|
||||
*/
|
||||
public short getDx2()
|
||||
|
@ -311,7 +268,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The x offset withing the cell for the bottom-right corner of this shape.
|
||||
*
|
||||
*
|
||||
* @param field_7_dx2 the x offset of the bottom-right corner
|
||||
*/
|
||||
public void setDx2( short field_7_dx2 )
|
||||
|
@ -322,7 +279,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The row number for the bottom-right corner of the current shape.
|
||||
*
|
||||
*
|
||||
* @return the row number for the bottom-right corner
|
||||
*/
|
||||
public short getRow2()
|
||||
|
@ -332,7 +289,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The row number for the bottom-right corner of the current shape.
|
||||
*
|
||||
*
|
||||
* @param field_8_row2 the row number for the bottom-right corner
|
||||
*/
|
||||
public void setRow2( short field_8_row2 )
|
||||
|
@ -343,7 +300,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The y offset withing the cell for the bottom-right corner of this shape.
|
||||
*
|
||||
*
|
||||
* @return the y offset of the bottom-right corner
|
||||
*/
|
||||
public short getDy2()
|
||||
|
@ -353,7 +310,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* The y offset withing the cell for the bottom-right corner of this shape.
|
||||
*
|
||||
*
|
||||
* @param field_9_dy2 the y offset of the bottom-right corner
|
||||
*/
|
||||
public void setDy2( short field_9_dy2 )
|
||||
|
@ -364,7 +321,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* Any remaining data in the record
|
||||
*
|
||||
*
|
||||
* @return the remaining bytes
|
||||
*/
|
||||
public byte[] getRemainingData()
|
||||
|
@ -374,7 +331,7 @@ public class EscherClientAnchorRecord
|
|||
|
||||
/**
|
||||
* Any remaining data in the record
|
||||
*
|
||||
*
|
||||
* @param remainingData the remaining bytes
|
||||
*/
|
||||
public void setRemainingData( byte[] remainingData ) {
|
||||
|
@ -384,4 +341,20 @@ public class EscherClientAnchorRecord
|
|||
this.remainingData = remainingData.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "Flag", field_1_flag },
|
||||
{ "Col1", field_2_col1 },
|
||||
{ "DX1", field_3_dx1 },
|
||||
{ "Row1", field_4_row1 },
|
||||
{ "DY1", field_5_dy1 },
|
||||
{ "Col2", field_6_col2 },
|
||||
{ "DX2", field_7_dx2 },
|
||||
{ "Row2", field_8_row2 },
|
||||
{ "DY2", field_9_dy2 },
|
||||
{ "Extra Data", remainingData }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +45,9 @@ public class EscherClientDataRecord
|
|||
public int serialize(int offset, byte[] data, EscherSerializationListener listener) {
|
||||
listener.beforeRecordSerialize( offset, getRecordId(), this );
|
||||
|
||||
if (remainingData == null) remainingData = new byte[0];
|
||||
if (remainingData == null) {
|
||||
remainingData = new byte[0];
|
||||
}
|
||||
LittleEndian.putShort( data, offset, getOptions() );
|
||||
LittleEndian.putShort( data, offset + 2, getRecordId() );
|
||||
LittleEndian.putInt( data, offset + 4, remainingData.length );
|
||||
|
@ -73,34 +74,6 @@ public class EscherClientDataRecord
|
|||
return "ClientData";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of this record.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String nl = System.getProperty("line.separator");
|
||||
String extraData = HexDump.dump(getRemainingData(), 0, 0);
|
||||
return getClass().getName() + ":" + nl +
|
||||
" RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl +
|
||||
" Version: 0x" + HexDump.toHex(getVersion()) + nl +
|
||||
" Instance: 0x" + HexDump.toHex(getInstance()) + nl +
|
||||
" Extra Data:" + nl +
|
||||
extraData;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
String extraData = HexDump.dump(getRemainingData(), 0, 0).trim();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()),
|
||||
HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<ExtraData>").append(extraData).append("</ExtraData>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Any data recording this record.
|
||||
*
|
||||
|
@ -121,4 +94,11 @@ public class EscherClientDataRecord
|
|||
? new byte[0]
|
||||
: remainingData.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "Extra Data", getRemainingData() }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,10 +230,14 @@ public class EscherColorRef {
|
|||
* @return {@link SysIndexSource} if {@link #hasSysIndexFlag()} is {@code true}, otherwise null
|
||||
*/
|
||||
public SysIndexSource getSysIndexSource() {
|
||||
if (!hasSysIndexFlag()) return null;
|
||||
if (!hasSysIndexFlag()) {
|
||||
return null;
|
||||
}
|
||||
int val = FLAG_RED.getValue(colorRef);
|
||||
for (SysIndexSource sis : SysIndexSource.values()) {
|
||||
if (sis.value == val) return sis;
|
||||
if (sis.value == val) {
|
||||
return sis;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -243,11 +247,17 @@ public class EscherColorRef {
|
|||
* @return {@link SysIndexProcedure} if {@link #hasSysIndexFlag()} is {@code true}, otherwise null
|
||||
*/
|
||||
public SysIndexProcedure getSysIndexProcedure() {
|
||||
if (!hasSysIndexFlag()) return null;
|
||||
if (!hasSysIndexFlag()) {
|
||||
return null;
|
||||
}
|
||||
int val = FLAG_GREEN.getValue(colorRef);
|
||||
for (SysIndexProcedure sip : SysIndexProcedure.values()) {
|
||||
if (sip == SysIndexProcedure.INVERT_AFTER || sip == SysIndexProcedure.INVERT_HIGHBIT_AFTER) continue;
|
||||
if (sip.mask.isSet(val)) return sip;
|
||||
if (sip == SysIndexProcedure.INVERT_AFTER || sip == SysIndexProcedure.INVERT_HIGHBIT_AFTER) {
|
||||
continue;
|
||||
}
|
||||
if (sip.mask.isSet(val)) {
|
||||
return sip;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -257,10 +267,16 @@ public class EscherColorRef {
|
|||
* 2 for {@link SysIndexProcedure#INVERT_HIGHBIT_AFTER}
|
||||
*/
|
||||
public int getSysIndexInvert() {
|
||||
if (!hasSysIndexFlag()) return 0;
|
||||
if (!hasSysIndexFlag()) {
|
||||
return 0;
|
||||
}
|
||||
int val = FLAG_GREEN.getValue(colorRef);
|
||||
if ((SysIndexProcedure.INVERT_AFTER.mask.isSet(val))) return 1;
|
||||
if ((SysIndexProcedure.INVERT_HIGHBIT_AFTER.mask.isSet(val))) return 2;
|
||||
if ((SysIndexProcedure.INVERT_AFTER.mask.isSet(val))) {
|
||||
return 1;
|
||||
}
|
||||
if ((SysIndexProcedure.INVERT_HIGHBIT_AFTER.mask.isSet(val))) {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -270,7 +286,9 @@ public class EscherColorRef {
|
|||
* @see org.apache.poi.hslf.record.ColorSchemeAtom#getColor(int)
|
||||
*/
|
||||
public int getSchemeIndex() {
|
||||
if (!hasSchemeIndexFlag()) return -1;
|
||||
if (!hasSchemeIndexFlag()) {
|
||||
return -1;
|
||||
}
|
||||
return FLAG_RED.getValue(colorRef);
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ public class EscherComplexProperty extends EscherProperty {
|
|||
return tab + "<" + getClass().getSimpleName() + " id=\"0x" + HexDump.toHex(getId()) +
|
||||
"\" name=\"" + getName() + "\" blipId=\"" +
|
||||
isBlipId() + "\">\n" +
|
||||
tab + "</" + getClass().getSimpleName() + ">\n";
|
||||
tab + "</" + getClass().getSimpleName() + ">";
|
||||
//builder.append("\t").append(tab).append(dataStr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,9 +126,9 @@ public final class EscherContainerRecord extends EscherRecord implements Iterabl
|
|||
|
||||
/**
|
||||
* Do any of our (top level) children have the given recordId?
|
||||
*
|
||||
*
|
||||
* @param recordId the recordId of the child
|
||||
*
|
||||
*
|
||||
* @return true, if any child has the given recordId
|
||||
*/
|
||||
public boolean hasChildOfType(short recordId) {
|
||||
|
@ -162,7 +162,7 @@ public final class EscherContainerRecord extends EscherRecord implements Iterabl
|
|||
public Iterator<EscherRecord> getChildIterator() {
|
||||
return iterator();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return an iterator over the child records
|
||||
*/
|
||||
|
@ -198,7 +198,7 @@ public final class EscherContainerRecord extends EscherRecord implements Iterabl
|
|||
/**
|
||||
* Returns all of our children which are also
|
||||
* EscherContainers (may be 0, 1, or vary rarely 2 or 3)
|
||||
*
|
||||
*
|
||||
* @return EscherContainer children
|
||||
*/
|
||||
public List<EscherContainerRecord> getChildContainers() {
|
||||
|
@ -266,48 +266,6 @@ public final class EscherContainerRecord extends EscherRecord implements Iterabl
|
|||
_childRecords.add(idx, record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String nl = System.getProperty( "line.separator" );
|
||||
|
||||
StringBuffer children = new StringBuffer();
|
||||
if ( _childRecords.size() > 0 )
|
||||
{
|
||||
children.append( " children: " + nl );
|
||||
|
||||
int count = 0;
|
||||
for ( EscherRecord record : this ) {
|
||||
children.append( " Child " + count + ":" + nl );
|
||||
String childResult = String.valueOf( record );
|
||||
childResult = childResult.replaceAll( "\n", "\n " );
|
||||
children.append( " " );
|
||||
children.append( childResult );
|
||||
children.append( nl );
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return getClass().getName() + " (" + getRecordName() + "):" + nl
|
||||
+ " isContainer: " + isContainerRecord() + nl
|
||||
+ " version: 0x" + HexDump.toHex( getVersion() ) + nl
|
||||
+ " instance: 0x" + HexDump.toHex( getInstance() ) + nl
|
||||
+ " recordId: 0x" + HexDump.toHex( getRecordId() ) + nl
|
||||
+ " numchildren: " + _childRecords.size() + nl
|
||||
+ children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getRecordName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())));
|
||||
for ( EscherRecord record : this ) {
|
||||
builder.append(record.toXml(tab+"\t"));
|
||||
}
|
||||
builder.append(tab).append("</").append(getRecordName()).append(">\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public <T extends EscherRecord> T getChildById( short recordId ) {
|
||||
for ( EscherRecord childRecord : this ) {
|
||||
if ( childRecord.getRecordId() == recordId ) {
|
||||
|
@ -335,4 +293,21 @@ public final class EscherContainerRecord extends EscherRecord implements Iterabl
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
List<Object> chList = new ArrayList<Object>(_childRecords.size()*2+2);
|
||||
chList.add("children");
|
||||
chList.add(_childRecords.size());
|
||||
int count = 0;
|
||||
for ( EscherRecord record : this ) {
|
||||
chList.add("Child "+count);
|
||||
chList.add(record);
|
||||
count++;
|
||||
}
|
||||
return new Object[][] {
|
||||
{ "isContainer", isContainerRecord() },
|
||||
chList.toArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
|
@ -85,29 +84,6 @@ public class EscherDgRecord
|
|||
return "Dg";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of this record.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ":" + '\n' +
|
||||
" RecordId: 0x" + HexDump.toHex(RECORD_ID) + '\n' +
|
||||
" Version: 0x" + HexDump.toHex(getVersion()) + '\n' +
|
||||
" Instance: 0x" + HexDump.toHex(getInstance()) + '\n' +
|
||||
" NumShapes: " + field_1_numShapes + '\n' +
|
||||
" LastMSOSPID: " + field_2_lastMSOSPID + '\n';
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<NumShapes>").append(field_1_numShapes).append("</NumShapes>\n")
|
||||
.append(tab).append("\t").append("<LastMSOSPID>").append(field_2_lastMSOSPID).append("</LastMSOSPID>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of shapes in this drawing group.
|
||||
*
|
||||
|
@ -166,4 +142,12 @@ public class EscherDgRecord
|
|||
{
|
||||
this.field_1_numShapes++;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "NumShapes", field_1_numShapes },
|
||||
{ "LastMSOSPID", field_2_lastMSOSPID }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,15 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.RecordFormatException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* This record defines the drawing groups used for a particular sheet.
|
||||
*/
|
||||
|
@ -82,8 +85,9 @@ public final class EscherDggRecord extends EscherRecord {
|
|||
size += 8;
|
||||
}
|
||||
bytesRemaining -= size;
|
||||
if (bytesRemaining != 0)
|
||||
if (bytesRemaining != 0) {
|
||||
throw new RecordFormatException("Expecting no remaining data but got " + bytesRemaining + " byte(s).");
|
||||
}
|
||||
return 8 + size + bytesRemaining;
|
||||
}
|
||||
|
||||
|
@ -125,42 +129,6 @@ public final class EscherDggRecord extends EscherRecord {
|
|||
return "Dgg";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder field_5_string = new StringBuilder();
|
||||
if(field_5_fileIdClusters != null) for (int i = 0; i < field_5_fileIdClusters.length; i++) {
|
||||
field_5_string.append(" DrawingGroupId").append(i+1).append(": ");
|
||||
field_5_string.append(field_5_fileIdClusters[i].field_1_drawingGroupId);
|
||||
field_5_string.append('\n');
|
||||
field_5_string.append(" NumShapeIdsUsed").append(i+1).append(": ");
|
||||
field_5_string.append(field_5_fileIdClusters[i].field_2_numShapeIdsUsed);
|
||||
field_5_string.append('\n');
|
||||
}
|
||||
return getClass().getName() + ":" + '\n' +
|
||||
" RecordId: 0x" + HexDump.toHex(RECORD_ID) + '\n' +
|
||||
" Version: 0x" + HexDump.toHex(getVersion()) + '\n' +
|
||||
" Instance: 0x" + HexDump.toHex(getInstance()) + '\n' +
|
||||
" ShapeIdMax: " + field_1_shapeIdMax + '\n' +
|
||||
" NumIdClusters: " + getNumIdClusters() + '\n' +
|
||||
" NumShapesSaved: " + field_3_numShapesSaved + '\n' +
|
||||
" DrawingsSaved: " + field_4_drawingsSaved + '\n' +
|
||||
"" + field_5_string;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<ShapeIdMax>").append(field_1_shapeIdMax).append("</ShapeIdMax>\n")
|
||||
.append(tab).append("\t").append("<NumIdClusters>").append(getNumIdClusters()).append("</NumIdClusters>\n")
|
||||
.append(tab).append("\t").append("<NumShapesSaved>").append(field_3_numShapesSaved).append("</NumShapesSaved>\n")
|
||||
.append(tab).append("\t").append("<DrawingsSaved>").append(field_4_drawingsSaved).append("</DrawingsSaved>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next available shape id
|
||||
*
|
||||
|
@ -280,7 +248,9 @@ public final class EscherDggRecord extends EscherRecord {
|
|||
public void addCluster( int dgId, int numShapedUsed, boolean sort ) {
|
||||
List<FileIdCluster> clusters = new ArrayList<FileIdCluster>(Arrays.asList(field_5_fileIdClusters));
|
||||
clusters.add(new FileIdCluster(dgId, numShapedUsed));
|
||||
if(sort) Collections.sort(clusters, MY_COMP );
|
||||
if(sort) {
|
||||
Collections.sort(clusters, MY_COMP );
|
||||
}
|
||||
maxDgId = Math.min(maxDgId, dgId);
|
||||
field_5_fileIdClusters = clusters.toArray( new FileIdCluster[clusters.size()] );
|
||||
}
|
||||
|
@ -297,4 +267,25 @@ public final class EscherDggRecord extends EscherRecord {
|
|||
return +1;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
List<Object> fldIds = new ArrayList<Object>();
|
||||
fldIds.add("FileId Clusters");
|
||||
fldIds.add(field_5_fileIdClusters.length);
|
||||
if(field_5_fileIdClusters != null) {
|
||||
for (FileIdCluster fic : field_5_fileIdClusters) {
|
||||
fldIds.add("Group"+fic.field_1_drawingGroupId);
|
||||
fldIds.add(fic.field_2_numShapeIdsUsed);
|
||||
}
|
||||
}
|
||||
|
||||
return new Object[][] {
|
||||
{ "ShapeIdMax", field_1_shapeIdMax },
|
||||
{ "NumIdClusters", getNumIdClusters() },
|
||||
{ "NumShapesSaved", field_3_numShapesSaved },
|
||||
{ "DrawingsSaved", field_4_drawingsSaved },
|
||||
fldIds.toArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,16 +17,16 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
* Used to dump the contents of escher records to a PrintStream.
|
||||
*/
|
||||
|
@ -185,12 +185,13 @@ public final class EscherDump {
|
|||
recordName = "MsofbtUDefProp";
|
||||
break;
|
||||
default:
|
||||
if ( recordId >= (short) 0xF018 && recordId <= (short) 0xF117 )
|
||||
if ( recordId >= (short) 0xF018 && recordId <= (short) 0xF117 ) {
|
||||
recordName = "MsofbtBLIP";
|
||||
else if ( ( options & (short) 0x000F ) == (short) 0x000F )
|
||||
} else if ( ( options & (short) 0x000F ) == (short) 0x000F ) {
|
||||
recordName = "UNKNOWN container";
|
||||
else
|
||||
} else {
|
||||
recordName = "UNKNOWN ID";
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder stringBuf = new StringBuilder();
|
||||
|
@ -308,8 +309,9 @@ public final class EscherDump {
|
|||
out.print( " " + propertyId );
|
||||
if ( ( n16 & (short) 0x8000 ) == 0 )
|
||||
{
|
||||
if ( ( n16 & (short) 0x4000 ) != 0 )
|
||||
if ( ( n16 & (short) 0x4000 ) != 0 ) {
|
||||
out.print( ", fBlipID" );
|
||||
}
|
||||
out.print( ") " );
|
||||
|
||||
out.print( HexDump.toHex( n32 ) );
|
||||
|
@ -386,8 +388,9 @@ public final class EscherDump {
|
|||
|
||||
byte[] buf = new byte[nDumpSize];
|
||||
int read = in.read( buf );
|
||||
while ( read != -1 && read < nDumpSize )
|
||||
while ( read != -1 && read < nDumpSize ) {
|
||||
read += in.read( buf, read, buf.length );
|
||||
}
|
||||
ByteArrayInputStream bin = new ByteArrayInputStream( buf );
|
||||
|
||||
InputStream in1 = new InflaterInputStream( bin );
|
||||
|
@ -402,10 +405,11 @@ public final class EscherDump {
|
|||
boolean isContainer = ( options & (short) 0x000F ) == (short) 0x000F;
|
||||
if ( isContainer && remainingBytes >= 0 )
|
||||
{ // Container
|
||||
if ( recordBytesRemaining <= (int) remainingBytes )
|
||||
if ( recordBytesRemaining <= (int) remainingBytes ) {
|
||||
out.println( " completed within" );
|
||||
else
|
||||
} else {
|
||||
out.println( " continued elsewhere" );
|
||||
}
|
||||
}
|
||||
else if ( remainingBytes >= 0 )
|
||||
// -> 0x0000 ... 0x0FFF
|
||||
|
@ -417,9 +421,9 @@ public final class EscherDump {
|
|||
HexDump.dump( in, out, 0, nDumpSize );
|
||||
remainingBytes -= nDumpSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else {
|
||||
out.println( " >> OVERRUN <<" );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,19 +17,18 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.hssf.usermodel.HSSFPictureData;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFPictureData;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
public final class EscherMetafileBlip extends EscherBlipRecord {
|
||||
private static final POILogger log = POILogFactory.getLogger(EscherMetafileBlip.class);
|
||||
|
@ -159,7 +158,9 @@ public final class EscherMetafileBlip extends EscherBlipRecord {
|
|||
@Override
|
||||
public int getRecordSize() {
|
||||
int size = 8 + 50 + raw_pictureData.length;
|
||||
if(remainingData != null) size += remainingData.length;
|
||||
if(remainingData != null) {
|
||||
size += remainingData.length;
|
||||
}
|
||||
if((getOptions() ^ getSignature()) == 0x10){
|
||||
size += field_2_UID.length;
|
||||
}
|
||||
|
@ -309,6 +310,26 @@ public final class EscherMetafileBlip extends EscherBlipRecord {
|
|||
field_6_fCompression = compressed ? 0 : (byte)0xFE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the filter byte - this is usually 0xFE
|
||||
*
|
||||
* @return the filter byte
|
||||
*/
|
||||
public byte getFilter() {
|
||||
return field_7_fFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the filter byte - this is usually 0xFE
|
||||
*
|
||||
* @param filter the filter byte
|
||||
*/
|
||||
public void setFilter(byte filter) {
|
||||
field_7_fFilter = filter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns any remaining bytes
|
||||
*
|
||||
|
@ -317,48 +338,7 @@ public final class EscherMetafileBlip extends EscherBlipRecord {
|
|||
public byte[] getRemainingData() {
|
||||
return remainingData;
|
||||
}
|
||||
|
||||
// filtering is always 254 according to available docs, so no point giving it a setter method.
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String extraData = "";//HexDump.toHex(field_pictureData, 32);
|
||||
return getClass().getName() + ":" + '\n' +
|
||||
" RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' +
|
||||
" Version: 0x" + HexDump.toHex( getVersion() ) + '\n' +
|
||||
" Instance: 0x" + HexDump.toHex( getInstance() ) + '\n' +
|
||||
" UID: 0x" + HexDump.toHex( field_1_UID ) + '\n' +
|
||||
(field_2_UID == null ? "" : (" UID2: 0x" + HexDump.toHex( field_2_UID ) + '\n')) +
|
||||
" Uncompressed Size: " + HexDump.toHex( field_2_cb ) + '\n' +
|
||||
" Bounds: " + getBounds() + '\n' +
|
||||
" Size in EMU: " + getSizeEMU() + '\n' +
|
||||
" Compressed Size: " + HexDump.toHex( field_5_cbSave ) + '\n' +
|
||||
" Compression: " + HexDump.toHex( field_6_fCompression ) + '\n' +
|
||||
" Filter: " + HexDump.toHex( field_7_fFilter ) + '\n' +
|
||||
" Extra Data:" + '\n' + extraData +
|
||||
(remainingData == null ? null : ("\n" +
|
||||
" Remaining Data: " + HexDump.toHex(remainingData, 32)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
String extraData = "";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<UID>0x").append(HexDump.toHex( field_1_UID ) + '\n' +
|
||||
(field_2_UID == null ? "" : (" UID2: 0x" + HexDump.toHex( field_2_UID ) + '\n'))).append("</UID>\n")
|
||||
.append(tab).append("\t").append("<UncompressedSize>0x").append(HexDump.toHex( field_2_cb )).append("</UncompressedSize>\n")
|
||||
.append(tab).append("\t").append("<Bounds>").append(getBounds()).append("</Bounds>\n")
|
||||
.append(tab).append("\t").append("<SizeInEMU>").append(getSizeEMU()).append("</SizeInEMU>\n")
|
||||
.append(tab).append("\t").append("<CompressedSize>0x").append(HexDump.toHex( field_5_cbSave )).append("</CompressedSize>\n")
|
||||
.append(tab).append("\t").append("<Compression>0x").append(HexDump.toHex( field_6_fCompression )).append("</Compression>\n")
|
||||
.append(tab).append("\t").append("<Filter>0x").append(HexDump.toHex( field_7_fFilter )).append("</Filter>\n")
|
||||
.append(tab).append("\t").append("<ExtraData>").append(extraData).append("</ExtraData>\n")
|
||||
.append(tab).append("\t").append("<RemainingData>0x").append(HexDump.toHex(remainingData, 32)).append("</RemainingData>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the blip signature
|
||||
*
|
||||
|
@ -399,12 +379,19 @@ public final class EscherMetafileBlip extends EscherBlipRecord {
|
|||
setCompressed(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the filter byte - usually this is 0xFE
|
||||
*
|
||||
* @param filter the filter byte
|
||||
*/
|
||||
public void setFilter(byte filter) {
|
||||
field_7_fFilter = filter;
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][]{
|
||||
// record, version, instance are directly fetched
|
||||
{ "UID", field_1_UID, "UID2", field_2_UID },
|
||||
{ "Uncompressed Size", field_2_cb },
|
||||
{ "Bounds", getBounds().toString() },
|
||||
{ "Size in EMU", getSizeEMU().toString() },
|
||||
{ "Compressed Size", field_5_cbSave },
|
||||
{ "Compression", field_6_fCompression },
|
||||
{ "Filter", field_7_fFilter },
|
||||
{ "Extra Data", "" },
|
||||
{ "Remaining Data", remainingData }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,9 +65,10 @@ public class EscherOptRecord extends AbstractEscherOptRecord
|
|||
@Override
|
||||
public void setVersion( short value )
|
||||
{
|
||||
if ( value != 0x3 )
|
||||
if ( value != 0x3 ) {
|
||||
throw new IllegalArgumentException( RECORD_DESCRIPTION
|
||||
+ " can have only '0x3' version" );
|
||||
}
|
||||
|
||||
super.setVersion( value );
|
||||
}
|
||||
|
|
|
@ -17,11 +17,6 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -29,6 +24,10 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
public final class EscherPictBlip extends EscherBlipRecord {
|
||||
private static final POILogger log = POILogFactory.getLogger(EscherPictBlip.class);
|
||||
|
||||
|
@ -260,39 +259,35 @@ public final class EscherPictBlip extends EscherBlipRecord {
|
|||
field_6_fCompression = compressed ? 0 : (byte)0xFE;
|
||||
}
|
||||
|
||||
// filtering is always 254 according to available docs, so no point giving it a setter method.
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String extraData = HexDump.toHex(getPicturedata(), 32);
|
||||
return getClass().getName() + ":" + '\n' +
|
||||
" RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' +
|
||||
" Version: 0x" + HexDump.toHex( getVersion() ) + '\n' +
|
||||
" Instance: 0x" + HexDump.toHex( getInstance() ) + '\n' +
|
||||
" UID: 0x" + HexDump.toHex( field_1_UID ) + '\n' +
|
||||
" Uncompressed Size: " + HexDump.toHex( field_2_cb ) + '\n' +
|
||||
" Bounds: " + getBounds() + '\n' +
|
||||
" Size in EMU: " + getSizeEMU() + '\n' +
|
||||
" Compressed Size: " + HexDump.toHex( field_5_cbSave ) + '\n' +
|
||||
" Compression: " + HexDump.toHex( field_6_fCompression ) + '\n' +
|
||||
" Filter: " + HexDump.toHex( field_7_fFilter ) + '\n' +
|
||||
" Extra Data:" + '\n' + extraData;
|
||||
/**
|
||||
* Gets the filter byte - this is usually 0xFE
|
||||
*
|
||||
* @return the filter byte
|
||||
*/
|
||||
public byte getFilter() {
|
||||
return field_7_fFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the filter byte - this is usually 0xFE
|
||||
*
|
||||
* @param filter the filter byte
|
||||
*/
|
||||
public void setFilter(byte filter) {
|
||||
field_7_fFilter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
String extraData = "";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<UID>0x").append(HexDump.toHex( field_1_UID )).append("</UID>\n")
|
||||
.append(tab).append("\t").append("<UncompressedSize>0x").append(HexDump.toHex( field_2_cb )).append("</UncompressedSize>\n")
|
||||
.append(tab).append("\t").append("<Bounds>").append(getBounds()).append("</Bounds>\n")
|
||||
.append(tab).append("\t").append("<SizeInEMU>").append(getSizeEMU()).append("</SizeInEMU>\n")
|
||||
.append(tab).append("\t").append("<CompressedSize>0x").append(HexDump.toHex( field_5_cbSave )).append("</CompressedSize>\n")
|
||||
.append(tab).append("\t").append("<Compression>0x").append(HexDump.toHex( field_6_fCompression )).append("</Compression>\n")
|
||||
.append(tab).append("\t").append("<Filter>0x").append(HexDump.toHex( field_7_fFilter )).append("</Filter>\n")
|
||||
.append(tab).append("\t").append("<ExtraData>").append(extraData).append("</ExtraData>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][]{
|
||||
{ "UID", field_1_UID },
|
||||
{ "Uncompressed Size", field_2_cb },
|
||||
{ "Bounds", getBounds().toString() },
|
||||
{ "Size in EMU", getSizeEMU().toString() },
|
||||
{ "Compressed Size", field_5_cbSave },
|
||||
{ "Compression", field_6_fCompression },
|
||||
{ "Filter", field_7_fFilter },
|
||||
{ "Extra Data", getPicturedata() },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,4 +107,8 @@ public abstract class EscherProperty {
|
|||
* @return the length of the part
|
||||
*/
|
||||
abstract public int serializeComplexPart( byte[] data, int pos );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
abstract public String toString();
|
||||
}
|
|
@ -68,7 +68,7 @@ public class EscherRGBProperty
|
|||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append("<").append(getClass().getSimpleName()).append(" id=\"0x").append(HexDump.toHex(getId()))
|
||||
.append("\" name=\"").append(getName()).append("\" blipId=\"")
|
||||
.append(isBlipId()).append("\" value=\"0x").append(HexDump.toHex(getRgbColor())).append("\"/>\n");
|
||||
.append(isBlipId()).append("\" value=\"0x").append(HexDump.toHex(getRgbColor())).append("\"/>");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,11 +48,11 @@ public abstract class EscherRecord implements Cloneable {
|
|||
|
||||
/**
|
||||
* Delegates to fillFields(byte[], int, EscherRecordFactory)
|
||||
*
|
||||
*
|
||||
* @param data they bytes to serialize from
|
||||
* @param f the escher record factory
|
||||
* @return The number of bytes written.
|
||||
*
|
||||
*
|
||||
* @see #fillFields(byte[], int, org.apache.poi.ddf.EscherRecordFactory)
|
||||
*/
|
||||
protected int fillFields( byte[] data, EscherRecordFactory f )
|
||||
|
@ -100,7 +100,7 @@ public abstract class EscherRecord implements Cloneable {
|
|||
|
||||
/**
|
||||
* Determine whether this is a container record by inspecting the option field.
|
||||
*
|
||||
*
|
||||
* @return true is this is a container field.
|
||||
*/
|
||||
public boolean isContainerRecord() {
|
||||
|
@ -110,7 +110,7 @@ public abstract class EscherRecord implements Cloneable {
|
|||
/**
|
||||
* Note that <code>options</code> is an internal field.
|
||||
* Use {@link #setInstance(short)} ()} and {@link #setVersion(short)} ()} to set the actual fields.
|
||||
*
|
||||
*
|
||||
* @return The options field for this record. All records have one.
|
||||
*/
|
||||
@Internal
|
||||
|
@ -122,10 +122,10 @@ public abstract class EscherRecord implements Cloneable {
|
|||
/**
|
||||
* Set the options this this record. Container records should have the
|
||||
* last nibble set to 0xF.<p>
|
||||
*
|
||||
*
|
||||
* Note that {@code options} is an internal field.
|
||||
* Use {@link #getInstance()} and {@link #getVersion()} to access actual fields.
|
||||
*
|
||||
*
|
||||
* @param options the record options
|
||||
*/
|
||||
@Internal
|
||||
|
@ -198,7 +198,7 @@ public abstract class EscherRecord implements Cloneable {
|
|||
|
||||
/**
|
||||
* Sets the record id for this record.
|
||||
*
|
||||
*
|
||||
* @param recordId the record id
|
||||
*/
|
||||
public void setRecordId( short recordId ) {
|
||||
|
@ -226,9 +226,9 @@ public abstract class EscherRecord implements Cloneable {
|
|||
|
||||
/**
|
||||
* Escher records may need to be clonable in the future.
|
||||
*
|
||||
*
|
||||
* @return the cloned object
|
||||
*
|
||||
*
|
||||
* @throws CloneNotSupportedException if the subclass hasn't implemented {@link Cloneable}
|
||||
*/
|
||||
@Override
|
||||
|
@ -238,7 +238,7 @@ public abstract class EscherRecord implements Cloneable {
|
|||
|
||||
/**
|
||||
* Returns the indexed child record.
|
||||
*
|
||||
*
|
||||
* @param index the index of the child within the child records
|
||||
* @return the indexed child record
|
||||
*/
|
||||
|
@ -255,20 +255,22 @@ public abstract class EscherRecord implements Cloneable {
|
|||
*/
|
||||
public void display(PrintWriter w, int indent)
|
||||
{
|
||||
for (int i = 0; i < indent * 4; i++) w.print(' ');
|
||||
for (int i = 0; i < indent * 4; i++) {
|
||||
w.print(' ');
|
||||
}
|
||||
w.println(getRecordName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses should return the short name for this escher record.
|
||||
*
|
||||
*
|
||||
* @return the short name for this escher record
|
||||
*/
|
||||
public abstract String getRecordName();
|
||||
|
||||
/**
|
||||
* Returns the instance part of the option record.
|
||||
*
|
||||
*
|
||||
* @return The instance part of the record
|
||||
*/
|
||||
public short getInstance()
|
||||
|
@ -278,7 +280,7 @@ public abstract class EscherRecord implements Cloneable {
|
|||
|
||||
/**
|
||||
* Sets the instance part of record
|
||||
*
|
||||
*
|
||||
* @param value instance part value
|
||||
*/
|
||||
public void setInstance( short value )
|
||||
|
@ -288,7 +290,7 @@ public abstract class EscherRecord implements Cloneable {
|
|||
|
||||
/**
|
||||
* Returns the version part of the option record.
|
||||
*
|
||||
*
|
||||
* @return The version part of the option record
|
||||
*/
|
||||
public short getVersion()
|
||||
|
@ -298,7 +300,7 @@ public abstract class EscherRecord implements Cloneable {
|
|||
|
||||
/**
|
||||
* Sets the version part of record
|
||||
*
|
||||
*
|
||||
* @param value version part value
|
||||
*/
|
||||
public void setVersion( short value )
|
||||
|
@ -306,23 +308,196 @@ public abstract class EscherRecord implements Cloneable {
|
|||
_options = fVersion.setShortValue( _options, value );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tab - each children must be a right of his parent
|
||||
* @return xml representation of this record
|
||||
*/
|
||||
public String toXml(String tab){
|
||||
return tab + "<" + getClass().getSimpleName() + ">\n" +
|
||||
tab + "\t" + "<RecordId>0x" + HexDump.toHex(_recordId) + "</RecordId>\n" +
|
||||
tab + "\t" + "<Options>" + _options + "</Options>\n" +
|
||||
tab + "</" + getClass().getSimpleName() + ">\n";
|
||||
}
|
||||
|
||||
protected String formatXmlRecordHeader(String className, String recordId, String version, String instance){
|
||||
return "<" + className + " recordId=\"0x" + recordId + "\" version=\"0x" +
|
||||
version + "\" instance=\"0x" + instance + "\" size=\"" + getRecordSize() + "\">\n";
|
||||
}
|
||||
|
||||
public String toXml(){
|
||||
return toXml("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tab - each children must be indented right relative to its parent
|
||||
* @return xml representation of this record
|
||||
*/
|
||||
public final String toXml(String tab){
|
||||
final String nl = System.getProperty( "line.separator" );
|
||||
String clsNm = getClass().getSimpleName();
|
||||
StringBuilder sb = new StringBuilder(1000);
|
||||
sb.append(tab).append("<").append(clsNm)
|
||||
.append(" recordId=\"0x").append(HexDump.toHex(getRecordId()))
|
||||
.append("\" version=\"0x").append(HexDump.toHex(getVersion()))
|
||||
.append("\" instance=\"0x").append(HexDump.toHex(getInstance()))
|
||||
.append("\" options=\"0x").append(HexDump.toHex(getOptions()))
|
||||
.append("\" recordSize=\"").append(getRecordSize());
|
||||
Object[][] attrList = getAttributeMap();
|
||||
if (attrList == null || attrList.length == 0) {
|
||||
sb.append("\" />").append(nl);
|
||||
} else {
|
||||
sb.append("\">").append(nl);
|
||||
String childTab = tab+" ";
|
||||
for (Object[] attrs : attrList) {
|
||||
String tagName = capitalizeAndTrim((String)attrs[0]);
|
||||
boolean hasValue = false;
|
||||
boolean lastChildComplex = false;
|
||||
for (int i=0; i<attrs.length; i+=2) {
|
||||
Object value = attrs[i+1];
|
||||
if (value == null) {
|
||||
// ignore null values
|
||||
continue;
|
||||
}
|
||||
if (!hasValue) {
|
||||
// only add tagname, when there was a value
|
||||
sb.append(childTab).append("<").append(tagName).append(">");
|
||||
}
|
||||
// add names for optional attributes
|
||||
String optName = capitalizeAndTrim((String)attrs[i+0]);
|
||||
if (i>0) {
|
||||
sb.append(nl).append(childTab).append(" <").append(optName).append(">");
|
||||
}
|
||||
lastChildComplex = appendValue(sb, value, true, childTab);
|
||||
if (i>0) {
|
||||
sb.append(nl).append(childTab).append(" </").append(optName).append(">");
|
||||
}
|
||||
hasValue = true;
|
||||
}
|
||||
if (hasValue) {
|
||||
if (lastChildComplex) {
|
||||
sb.append(nl).append(childTab);
|
||||
}
|
||||
sb.append("</").append(tagName).append(">").append(nl);
|
||||
}
|
||||
}
|
||||
sb.append(tab).append("</").append(clsNm).append(">");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
final String nl = System.getProperty( "line.separator" );
|
||||
StringBuilder sb = new StringBuilder(1000);
|
||||
sb.append(getClass().getName()).append(" (").append(getRecordName()).append("):").append(nl)
|
||||
.append(" RecordId: 0x").append(HexDump.toHex( getRecordId() )).append(nl)
|
||||
.append(" Version: 0x").append(HexDump.toHex( getVersion() )).append(nl)
|
||||
.append(" Instance: 0x").append(HexDump.toHex( getInstance() )).append(nl)
|
||||
.append(" Options: 0x").append(HexDump.toHex( getOptions() )).append(nl)
|
||||
.append(" Record Size: ").append( getRecordSize() );
|
||||
|
||||
Object[][] attrList = getAttributeMap();
|
||||
if (attrList != null && attrList.length > 0) {
|
||||
String childTab = " ";
|
||||
for (Object[] attrs : attrList) {
|
||||
for (int i=0; i<attrs.length; i+=2) {
|
||||
Object value = attrs[i+1];
|
||||
if (value == null) {
|
||||
// ignore null values
|
||||
continue;
|
||||
}
|
||||
String name = (String)attrs[i+0];
|
||||
sb.append(nl).append(childTab).append(name).append(": ");
|
||||
appendValue(sb, value, false, childTab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true, if value was a complex record, false otherwise
|
||||
*/
|
||||
private static boolean appendValue(StringBuilder sb, Object value, boolean toXML, String childTab) {
|
||||
final String nl = System.getProperty( "line.separator" );
|
||||
boolean isComplex = false;
|
||||
if (value instanceof String) {
|
||||
if (toXML) {
|
||||
escapeXML((String)value, sb);
|
||||
} else {
|
||||
sb.append((String)value);
|
||||
}
|
||||
} else if (value instanceof Byte) {
|
||||
sb.append("0x").append(HexDump.toHex((Byte)value));
|
||||
} else if (value instanceof Short) {
|
||||
sb.append("0x").append(HexDump.toHex((Short)value));
|
||||
} else if (value instanceof Integer) {
|
||||
sb.append("0x").append(HexDump.toHex((Integer)value));
|
||||
} else if (value instanceof byte[]) {
|
||||
sb.append(nl).append(HexDump.toHex((byte[])value, 32).replaceAll("(?m)^",childTab+" "));
|
||||
} else if (value instanceof Boolean) {
|
||||
sb.append(((Boolean)value).booleanValue());
|
||||
} else if (value instanceof EscherRecord) {
|
||||
EscherRecord er = (EscherRecord)value;
|
||||
if (toXML) {
|
||||
sb.append(nl).append(er.toXml(childTab+" "));
|
||||
} else {
|
||||
sb.append(er.toString().replaceAll("(?m)^",childTab));
|
||||
}
|
||||
isComplex = true;
|
||||
} else if (value instanceof EscherProperty) {
|
||||
EscherProperty ep = (EscherProperty)value;
|
||||
if (toXML) {
|
||||
sb.append(nl).append(ep.toXml(childTab+" "));
|
||||
} else {
|
||||
sb.append(ep.toString().replaceAll("(?m)^",childTab));
|
||||
}
|
||||
isComplex = true;
|
||||
} else {
|
||||
throw new IllegalArgumentException("unknown attribute type "+value.getClass().getSimpleName());
|
||||
}
|
||||
return isComplex;
|
||||
}
|
||||
|
||||
/**
|
||||
* For the purpose of providing toString() and toXml() a subclass can either override those methods
|
||||
* or provide a Object[][] array in the form {@code { { "Attribute Name (Header)", value, "optional attribute", value }, ... } }.<p>
|
||||
*
|
||||
* Null values won't be printed.<p>
|
||||
*
|
||||
* The attributes record, version, instance, options must not be returned.
|
||||
*
|
||||
* @return the attribute map
|
||||
*
|
||||
* @since POI 3.17-beta2
|
||||
*/
|
||||
@Internal
|
||||
protected abstract Object[][] getAttributeMap();
|
||||
|
||||
private static String capitalizeAndTrim(final String str) {
|
||||
if (str == null || str.length() == 0) {
|
||||
return str;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(str.length());
|
||||
boolean capitalizeNext = true;
|
||||
for (char ch : str.toCharArray()) {
|
||||
if (!Character.isLetterOrDigit(ch)) {
|
||||
capitalizeNext = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (capitalizeNext) {
|
||||
if (!Character.isLetter(ch)) {
|
||||
sb.append('_');
|
||||
} else {
|
||||
ch = Character.toTitleCase(ch);
|
||||
}
|
||||
capitalizeNext = false;
|
||||
}
|
||||
sb.append(ch);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static void escapeXML(String s, StringBuilder out) {
|
||||
if (s == null || s.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (char c : s.toCharArray()) {
|
||||
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
|
||||
out.append("&#");
|
||||
out.append((int) c);
|
||||
out.append(';');
|
||||
} else {
|
||||
out.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
* A simple property is of fixed length and as a property number in addition
|
||||
|
@ -93,13 +93,21 @@ public class EscherSimpleProperty extends EscherProperty
|
|||
@Override
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
if ( this == o ) return true;
|
||||
if ( !( o instanceof EscherSimpleProperty ) ) return false;
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( !( o instanceof EscherSimpleProperty ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final EscherSimpleProperty escherSimpleProperty = (EscherSimpleProperty) o;
|
||||
|
||||
if ( propertyValue != escherSimpleProperty.propertyValue ) return false;
|
||||
if ( getId() != escherSimpleProperty.getId() ) return false;
|
||||
if ( propertyValue != escherSimpleProperty.propertyValue ) {
|
||||
return false;
|
||||
}
|
||||
if ( getId() != escherSimpleProperty.getId() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -134,7 +142,7 @@ public class EscherSimpleProperty extends EscherProperty
|
|||
builder.append(tab).append("<").append(getClass().getSimpleName()).append(" id=\"0x").append(HexDump.toHex(getId()))
|
||||
.append("\" name=\"").append(getName()).append("\" blipId=\"")
|
||||
.append(isBlipId()).append("\" complex=\"").append(isComplex()).append("\" value=\"").append("0x")
|
||||
.append(HexDump.toHex(propertyValue)).append("\"/>\n");
|
||||
.append(HexDump.toHex(propertyValue)).append("\"/>");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,35 +101,6 @@ public class EscherSpRecord
|
|||
return "Sp";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the string representing this shape.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String nl = System.getProperty("line.separator");
|
||||
|
||||
return getClass().getName() + ":" + nl +
|
||||
" RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl +
|
||||
" Version: 0x" + HexDump.toHex(getVersion()) + nl +
|
||||
" ShapeType: 0x" + HexDump.toHex(getShapeType()) + nl +
|
||||
" ShapeId: " + field_1_shapeId + nl +
|
||||
" Flags: " + decodeFlags(field_2_flags) + " (0x" + HexDump.toHex(field_2_flags) + ")" + nl;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<ShapeType>0x").append(HexDump.toHex(getShapeType())).append("</ShapeType>\n")
|
||||
.append(tab).append("\t").append("<ShapeId>").append(field_1_shapeId).append("</ShapeId>\n")
|
||||
.append(tab).append("\t").append("<Flags>").append(decodeFlags(field_2_flags) + " (0x" + HexDump.toHex(field_2_flags) + ")").append("</Flags>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the shape flags into a more descriptive name.
|
||||
*/
|
||||
|
@ -242,4 +213,13 @@ public class EscherSpRecord
|
|||
{
|
||||
setInstance( value );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "ShapeType", getShapeType() },
|
||||
{ "ShapeId", field_1_shapeId },
|
||||
{ "Flags", decodeFlags(field_2_flags)+" (0x"+HexDump.toHex(field_2_flags)+")" }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.RecordFormatException;
|
||||
|
||||
|
@ -46,7 +45,9 @@ public class EscherSpgrRecord
|
|||
field_3_rectX2 = LittleEndian.getInt( data, pos + size );size+=4;
|
||||
field_4_rectY2 = LittleEndian.getInt( data, pos + size );size+=4;
|
||||
bytesRemaining -= size;
|
||||
if (bytesRemaining != 0) throw new RecordFormatException("Expected no remaining bytes but got " + bytesRemaining);
|
||||
if (bytesRemaining != 0) {
|
||||
throw new RecordFormatException("Expected no remaining bytes but got " + bytesRemaining);
|
||||
}
|
||||
// remainingData = new byte[bytesRemaining];
|
||||
// System.arraycopy( data, pos + size, remainingData, 0, bytesRemaining );
|
||||
return 8 + size + bytesRemaining;
|
||||
|
@ -86,33 +87,6 @@ public class EscherSpgrRecord
|
|||
return "Spgr";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the string representation of this record.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ":" + '\n' +
|
||||
" RecordId: 0x" + HexDump.toHex(RECORD_ID) + '\n' +
|
||||
" Version: 0x" + HexDump.toHex(getVersion()) + '\n' +
|
||||
" Instance: 0x" + HexDump.toHex(getInstance()) + '\n' +
|
||||
" RectX: " + field_1_rectX1 + '\n' +
|
||||
" RectY: " + field_2_rectY1 + '\n' +
|
||||
" RectWidth: " + field_3_rectX2 + '\n' +
|
||||
" RectHeight: " + field_4_rectY2 + '\n';
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<RectX>").append(field_1_rectX1).append("</RectX>\n")
|
||||
.append(tab).append("\t").append("<RectY>").append(field_2_rectY1).append("</RectY>\n")
|
||||
.append(tab).append("\t").append("<RectWidth>").append(field_3_rectX2).append("</RectWidth>\n")
|
||||
.append(tab).append("\t").append("<RectHeight>").append(field_4_rectY2).append("</RectHeight>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* The starting top-left coordinate of child records.
|
||||
*
|
||||
|
@ -191,4 +165,14 @@ public class EscherSpgrRecord
|
|||
public void setRectY2(int rectY2) {
|
||||
this.field_4_rectY2 = rectY2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "RectX", field_1_rectX1 },
|
||||
{ "RectY", field_2_rectY1 },
|
||||
{ "RectWidth", field_3_rectX2 },
|
||||
{ "RectHeight", field_4_rectY2 }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.RecordFormatException;
|
||||
|
||||
|
@ -46,8 +45,9 @@ public class EscherSplitMenuColorsRecord
|
|||
field_3_color3 = LittleEndian.getInt( data, pos + size );size+=4;
|
||||
field_4_color4 = LittleEndian.getInt( data, pos + size );size+=4;
|
||||
bytesRemaining -= size;
|
||||
if (bytesRemaining != 0)
|
||||
if (bytesRemaining != 0) {
|
||||
throw new RecordFormatException("Expecting no remaining data but got " + bytesRemaining + " byte(s).");
|
||||
}
|
||||
return 8 + size + bytesRemaining;
|
||||
}
|
||||
|
||||
|
@ -85,34 +85,6 @@ public class EscherSplitMenuColorsRecord
|
|||
return "SplitMenuColors";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a string representation of this record.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ":" + '\n' +
|
||||
" RecordId: 0x" + HexDump.toHex(RECORD_ID) + '\n' +
|
||||
" Version: 0x" + HexDump.toHex(getVersion()) + '\n' +
|
||||
" Instance: 0x" + HexDump.toHex(getInstance()) + '\n' +
|
||||
" Color1: 0x" + HexDump.toHex(field_1_color1) + '\n' +
|
||||
" Color2: 0x" + HexDump.toHex(field_2_color2) + '\n' +
|
||||
" Color3: 0x" + HexDump.toHex(field_3_color3) + '\n' +
|
||||
" Color4: 0x" + HexDump.toHex(field_4_color4) + '\n' +
|
||||
"";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<Color1>0x").append(HexDump.toHex(field_1_color1)).append("</Color1>\n")
|
||||
.append(tab).append("\t").append("<Color2>0x").append(HexDump.toHex(field_2_color2)).append("</Color2>\n")
|
||||
.append(tab).append("\t").append("<Color3>0x").append(HexDump.toHex(field_3_color3)).append("</Color3>\n")
|
||||
.append(tab).append("\t").append("<Color4>0x").append(HexDump.toHex(field_4_color4)).append("</Color4>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fill color
|
||||
*
|
||||
|
@ -184,4 +156,14 @@ public class EscherSplitMenuColorsRecord
|
|||
public void setColor4( int field_4_color4 ) {
|
||||
this.field_4_color4 = field_4_color4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "Color1", field_1_color1 },
|
||||
{ "Color2", field_2_color2 },
|
||||
{ "Color3", field_3_color3 },
|
||||
{ "Color4", field_4_color4 }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.RecordFormatException;
|
||||
|
||||
|
@ -65,8 +67,9 @@ public final class EscherTextboxRecord extends EscherRecord implements Cloneable
|
|||
|
||||
listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this );
|
||||
int size = pos - offset;
|
||||
if (size != getRecordSize())
|
||||
if (size != getRecordSize()) {
|
||||
throw new RecordFormatException(size + " bytes written but getRecordSize() reports " + getRecordSize());
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@ -130,54 +133,20 @@ public final class EscherTextboxRecord extends EscherRecord implements Cloneable
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String nl = System.getProperty( "line.separator" );
|
||||
|
||||
String theDumpHex = "";
|
||||
try
|
||||
{
|
||||
if (thedata.length != 0)
|
||||
{
|
||||
theDumpHex = " Extra Data:" + nl;
|
||||
theDumpHex += HexDump.dump(thedata, 0, 0);
|
||||
}
|
||||
protected Object[][] getAttributeMap() {
|
||||
int numCh = getChildRecords().size();
|
||||
List<Object> chLst = new ArrayList<Object>(numCh*2+2);
|
||||
chLst.add("children");
|
||||
chLst.add(numCh);
|
||||
for (EscherRecord er : getChildRecords()) {
|
||||
chLst.add(er.getRecordName());
|
||||
chLst.add(er);
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
theDumpHex = "Error!!";
|
||||
}
|
||||
|
||||
return getClass().getName() + ":" + nl +
|
||||
" isContainer: " + isContainerRecord() + nl +
|
||||
" version: 0x" + HexDump.toHex( getVersion() ) + nl +
|
||||
" instance: 0x" + HexDump.toHex( getInstance() ) + nl +
|
||||
" recordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
|
||||
" numchildren: " + getChildRecords().size() + nl +
|
||||
theDumpHex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
String theDumpHex = "";
|
||||
try
|
||||
{
|
||||
if (thedata.length != 0)
|
||||
{
|
||||
theDumpHex += HexDump.dump(thedata, 0, 0);
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
theDumpHex = "Error!!";
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<ExtraData>").append(theDumpHex).append("</ExtraData>\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
|
||||
return new Object[][] {
|
||||
{ "isContainer", isContainerRecord() },
|
||||
chLst.toArray(),
|
||||
{ "Extra Data", thedata }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.poi.ddf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
|
@ -130,48 +129,25 @@ public final class UnknownEscherRecord extends EscherRecord implements Cloneable
|
|||
return "Unknown 0x" + HexDump.toHex(getRecordId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer children = new StringBuffer();
|
||||
if (getChildRecords().size() > 0) {
|
||||
children.append( " children: " + '\n' );
|
||||
for (EscherRecord record : _childRecords) {
|
||||
children.append(record);
|
||||
children.append( '\n' );
|
||||
}
|
||||
}
|
||||
|
||||
String theDumpHex = HexDump.toHex(thedata, 32);
|
||||
|
||||
return getClass().getName() + ":" + '\n' +
|
||||
" isContainer: " + isContainerRecord() + '\n' +
|
||||
" version: 0x" + HexDump.toHex( getVersion() ) + '\n' +
|
||||
" instance: 0x" + HexDump.toHex( getInstance() ) + '\n' +
|
||||
" recordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' +
|
||||
" numchildren: " + getChildRecords().size() + '\n' +
|
||||
theDumpHex +
|
||||
children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXml(String tab) {
|
||||
String theDumpHex = HexDump.toHex(thedata, 32);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||
.append(tab).append("\t").append("<IsContainer>").append(isContainerRecord()).append("</IsContainer>\n")
|
||||
.append(tab).append("\t").append("<Numchildren>").append(HexDump.toHex(_childRecords.size())).append("</Numchildren>\n");
|
||||
for ( Iterator<EscherRecord> iterator = _childRecords.iterator(); iterator
|
||||
.hasNext(); )
|
||||
{
|
||||
EscherRecord record = iterator.next();
|
||||
builder.append(record.toXml(tab+"\t"));
|
||||
}
|
||||
builder.append(theDumpHex).append("\n");
|
||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public void addChildRecord(EscherRecord childRecord) {
|
||||
getChildRecords().add( childRecord );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
int numCh = getChildRecords().size();
|
||||
List<Object> chLst = new ArrayList<Object>(numCh*2+2);
|
||||
chLst.add("children");
|
||||
chLst.add(numCh);
|
||||
for (EscherRecord er : _childRecords) {
|
||||
chLst.add(er.getRecordName());
|
||||
chLst.add(er);
|
||||
}
|
||||
|
||||
return new Object[][] {
|
||||
{ "isContainer", isContainerRecord() },
|
||||
chLst.toArray(),
|
||||
{ "Extra Data", thedata }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
|
||||
package org.apache.poi.hslf.record;
|
||||
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.util.*;
|
||||
import org.apache.poi.ddf.EscherRecord;
|
||||
import org.apache.poi.ddf.EscherRecordFactory;
|
||||
import org.apache.poi.ddf.EscherSerializationListener;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
* An atom record that specifies whether a shape is a placeholder shape.
|
||||
|
@ -33,9 +35,10 @@ public class EscherPlaceholder extends EscherRecord {
|
|||
private byte placementId = 0;
|
||||
private byte size = 0;
|
||||
private short unused = 0;
|
||||
|
||||
|
||||
public EscherPlaceholder() {}
|
||||
|
||||
|
||||
@Override
|
||||
public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
|
||||
int bytesRemaining = readHeader( data, offset );
|
||||
|
||||
|
@ -43,14 +46,15 @@ public class EscherPlaceholder extends EscherRecord {
|
|||
placementId = data[offset+12];
|
||||
size = data[offset+13];
|
||||
unused = LittleEndian.getShort(data, offset+14);
|
||||
|
||||
|
||||
assert(bytesRemaining + 8 == 16);
|
||||
return bytesRemaining + 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int serialize(int offset, byte[] data, EscherSerializationListener listener) {
|
||||
listener.beforeRecordSerialize( offset, getRecordId(), this );
|
||||
|
||||
|
||||
LittleEndian.putShort(data, offset, getOptions());
|
||||
LittleEndian.putShort(data, offset+2, getRecordId());
|
||||
LittleEndian.putInt(data, offset+4, 8);
|
||||
|
@ -58,18 +62,28 @@ public class EscherPlaceholder extends EscherRecord {
|
|||
LittleEndian.putByte(data, offset+12, placementId);
|
||||
LittleEndian.putByte(data, offset+13, size);
|
||||
LittleEndian.putShort(data, offset+14, unused);
|
||||
|
||||
|
||||
listener.afterRecordSerialize( offset+getRecordSize(), getRecordId(), getRecordSize(), this );
|
||||
return getRecordSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecordSize() {
|
||||
return 8 + 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecordName() {
|
||||
return "ClientTextboxPlaceholder";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() {
|
||||
return new Object[][] {
|
||||
{ "position", position },
|
||||
{ "placementId", placementId },
|
||||
{ "placehoder size", size },
|
||||
{ "unused", unused }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,18 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.poifs.storage.RawDataUtil;
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class TestEscherBSERecord extends TestCase {
|
||||
public final class TestEscherBSERecord {
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
String data = "01 00 00 00 24 00 00 00 05 05 01 02 03 04 " +
|
||||
" 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00 01 00 00 00 " +
|
||||
|
@ -43,17 +50,16 @@ public final class TestEscherBSERecord extends TestCase {
|
|||
assertEquals( 0, r.getRemainingData().length );
|
||||
}
|
||||
|
||||
public void testSerialize() {
|
||||
@Test
|
||||
public void testSerialize() throws IOException {
|
||||
EscherBSERecord r = createRecord();
|
||||
|
||||
String exp64 = "H4sIAAAAAAAAAGNkYP+gwsDAwMrKyMTMwsrGzsHJxc3Dy8fPwMgAAkxAzAzEICkAgs9OoSwAAAA=";
|
||||
byte[] expected = RawDataUtil.decompress(exp64);
|
||||
|
||||
byte[] data = new byte[8 + 36];
|
||||
int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
|
||||
assertEquals( 44, bytesWritten );
|
||||
assertEquals( "[01, 00, 00, 00, 24, 00, 00, 00, 05, 05, 01, 02, 03, 04, " +
|
||||
"05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00, 01, 00, 00, 00, " +
|
||||
"00, 00, 02, 00, 00, 00, 03, 00, 00, 00, 04, 05, 06, 07]",
|
||||
HexDump.toHex(data));
|
||||
|
||||
assertEquals(data.length, bytesWritten);
|
||||
assertArrayEquals(expected, data);
|
||||
}
|
||||
|
||||
private EscherBSERecord createRecord() {
|
||||
|
@ -74,26 +80,31 @@ public final class TestEscherBSERecord extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
String nl = System.getProperty("line.separator");
|
||||
EscherBSERecord record = createRecord();
|
||||
String expected = "org.apache.poi.ddf.EscherBSERecord:" + '\n' +
|
||||
" RecordId: 0xF007" + '\n' +
|
||||
" Version: 0x0001" + '\n' +
|
||||
" Instance: 0x0000" + '\n' +
|
||||
" BlipTypeWin32: 5" + '\n' +
|
||||
" BlipTypeMacOS: 5" + '\n' +
|
||||
" SUID: [01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00]" + '\n' +
|
||||
" Tag: 1" + '\n' +
|
||||
" Size: 0" + '\n' +
|
||||
" Ref: 2" + '\n' +
|
||||
" Offset: 3" + '\n' +
|
||||
" Usage: 4" + '\n' +
|
||||
" Name: 5" + '\n' +
|
||||
" Unused2: 6" + '\n' +
|
||||
" Unused3: 7" + '\n' +
|
||||
" blipRecord: null" + '\n' +
|
||||
" Extra Data:" + '\n' +
|
||||
": 0";
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherBSERecord (BSE):" + nl +
|
||||
" RecordId: 0xF007" + nl +
|
||||
" Version: 0x0001" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x0001" + nl +
|
||||
" Record Size: 44" + nl +
|
||||
" BlipTypeWin32: 0x05" + nl +
|
||||
" BlipTypeMacOS: 0x05" + nl +
|
||||
" SUID: " + nl +
|
||||
" 00: 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00" + nl +
|
||||
" Tag: 0x0001" + nl +
|
||||
" Size: 0x00000000" + nl +
|
||||
" Ref: 0x00000002" + nl +
|
||||
" Offset: 0x00000003" + nl +
|
||||
" Usage: 0x04" + nl +
|
||||
" Name: 0x05" + nl +
|
||||
" Unused2: 0x06" + nl +
|
||||
" Unused3: 0x07" + nl +
|
||||
" Extra Data: " + nl +
|
||||
" : 0";
|
||||
String actual = record.toString();
|
||||
assertEquals( expected, actual );
|
||||
}
|
||||
|
|
|
@ -18,24 +18,21 @@
|
|||
package org.apache.poi.ddf;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.apache.poi.POIDataSamples;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test read/serialize of escher blip records
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class TestEscherBlipRecord extends TestCase {
|
||||
*/
|
||||
public final class TestEscherBlipRecord {
|
||||
private static final POIDataSamples _samples = POIDataSamples.getDDFInstance();
|
||||
|
||||
//test reading/serializing of a PNG blip
|
||||
@Test
|
||||
public void testReadPNG() {
|
||||
//provided in bug-44886
|
||||
byte[] data = _samples.readFile("Container.dat");
|
||||
|
@ -81,6 +78,7 @@ public final class TestEscherBlipRecord extends TestCase {
|
|||
}
|
||||
|
||||
//test reading/serializing of a PICT metafile
|
||||
@Test
|
||||
public void testReadPICT() {
|
||||
//provided in bug-44886
|
||||
byte[] data = _samples.readFile("Container.dat");
|
||||
|
@ -133,6 +131,7 @@ public final class TestEscherBlipRecord extends TestCase {
|
|||
}
|
||||
|
||||
//integral test: check that the read-write-read round trip is consistent
|
||||
@Test
|
||||
public void testContainer() {
|
||||
byte[] data = _samples.readFile("Container.dat");
|
||||
|
||||
|
@ -143,21 +142,10 @@ public final class TestEscherBlipRecord extends TestCase {
|
|||
assertArrayEquals(data, ser);
|
||||
}
|
||||
|
||||
private byte[] read(File file) {
|
||||
byte[] data = new byte[(int)file.length()];
|
||||
try {
|
||||
FileInputStream is = new FileInputStream(file);
|
||||
is.read(data);
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* The test data was created from pl031405.xls attached to Bugzilla #47143
|
||||
*/
|
||||
@Test
|
||||
public void test47143() {
|
||||
byte[] data = _samples.readFile("47143.dat");
|
||||
EscherBSERecord bse = new EscherBSERecord();
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public final class TestEscherBoolProperty extends TestCase {
|
||||
import org.junit.Test;
|
||||
|
||||
public final class TestEscherBoolProperty {
|
||||
@Test
|
||||
public void testToString() {
|
||||
EscherBoolProperty p = new EscherBoolProperty((short)1, 1);
|
||||
assertEquals("propNum: 1, RAW: 0x0001, propName: unknown, complex: false, blipId: false, value: 1 (0x00000001)", p.toString());
|
||||
|
|
|
@ -17,17 +17,20 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class TestEscherChildAnchorRecord extends TestCase {
|
||||
public final class TestEscherChildAnchorRecord {
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
EscherChildAnchorRecord r = createRecord();
|
||||
|
||||
byte[] data = new byte[8 + 16];
|
||||
int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
|
||||
assertEquals( 24, bytesWritten );
|
||||
assertEquals( data.length, bytesWritten );
|
||||
assertEquals( "[01, 00, " +
|
||||
"0F, F0, " +
|
||||
"10, 00, 00, 00, " +
|
||||
|
@ -37,6 +40,7 @@ public final class TestEscherChildAnchorRecord extends TestCase {
|
|||
"04, 00, 00, 00]", HexDump.toHex( data ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
String hexData = "01 00 " +
|
||||
"0F F0 " +
|
||||
|
@ -58,17 +62,21 @@ public final class TestEscherChildAnchorRecord extends TestCase {
|
|||
assertEquals( (short) 0x0001, r.getOptions() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString(){
|
||||
String nl = System.getProperty( "line.separator" );
|
||||
|
||||
String expected = "org.apache.poi.ddf.EscherChildAnchorRecord:" + nl +
|
||||
" RecordId: 0xF00F" + nl +
|
||||
" Version: 0x0001" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" X1: 1" + nl +
|
||||
" Y1: 2" + nl +
|
||||
" X2: 3" + nl +
|
||||
" Y2: 4" + nl;
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherChildAnchorRecord (ChildAnchor):" + nl +
|
||||
" RecordId: 0xF00F" + nl +
|
||||
" Version: 0x0001" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x0001" + nl +
|
||||
" Record Size: 24" + nl +
|
||||
" X1: 0x00000001" + nl +
|
||||
" Y1: 0x00000002" + nl +
|
||||
" X2: 0x00000003" + nl +
|
||||
" Y2: 0x00000004";
|
||||
assertEquals( expected, createRecord().toString() );
|
||||
}
|
||||
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestEscherClientAnchorRecord extends TestCase
|
||||
{
|
||||
public class TestEscherClientAnchorRecord {
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
EscherClientAnchorRecord r = createRecord();
|
||||
|
||||
|
@ -38,6 +40,7 @@ public class TestEscherClientAnchorRecord extends TestCase
|
|||
"FF, DD]", HexDump.toHex( data ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
String hexData = "01 00 " +
|
||||
"10 F0 " +
|
||||
|
@ -65,24 +68,27 @@ public class TestEscherClientAnchorRecord extends TestCase
|
|||
assertEquals( (byte) 0xDD, r.getRemainingData()[1] );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
String nl = System.getProperty("line.separator");
|
||||
|
||||
String expected = "org.apache.poi.ddf.EscherClientAnchorRecord:" + nl +
|
||||
" RecordId: 0xF010" + nl +
|
||||
" Version: 0x0001" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Flag: 77" + nl +
|
||||
" Col1: 55" + nl +
|
||||
" DX1: 33" + nl +
|
||||
" Row1: 88" + nl +
|
||||
" DY1: 11" + nl +
|
||||
" Col2: 44" + nl +
|
||||
" DX2: 22" + nl +
|
||||
" Row2: 99" + nl +
|
||||
" DY2: 66" + nl +
|
||||
" Extra Data:" + nl +
|
||||
"00000000 FF DD .." + nl;
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherClientAnchorRecord (ClientAnchor):" + nl +
|
||||
" RecordId: 0xF010" + nl +
|
||||
" Version: 0x0001" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x0001" + nl +
|
||||
" Record Size: 28" + nl +
|
||||
" Flag: 0x004D" + nl +
|
||||
" Col1: 0x0037" + nl +
|
||||
" DX1: 0x0021" + nl +
|
||||
" Row1: 0x0058" + nl +
|
||||
" DY1: 0x000B" + nl +
|
||||
" Col2: 0x002C" + nl +
|
||||
" DX2: 0x0016" + nl +
|
||||
" Row2: 0x0063" + nl +
|
||||
" DY2: 0x0042" + nl +
|
||||
" Extra Data: " + nl +
|
||||
" 0: FF, DD";
|
||||
assertEquals( expected, createRecord().toString() );
|
||||
}
|
||||
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestEscherClientDataRecord extends TestCase
|
||||
{
|
||||
public class TestEscherClientDataRecord {
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
EscherClientDataRecord r = createRecord();
|
||||
|
||||
|
@ -35,6 +37,7 @@ public class TestEscherClientDataRecord extends TestCase
|
|||
HexDump.toHex( data ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
String hexData = "02 00 " +
|
||||
"11 F0 " +
|
||||
|
@ -48,15 +51,19 @@ public class TestEscherClientDataRecord extends TestCase
|
|||
assertEquals( "[]", HexDump.toHex(r.getRemainingData()) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
String nl = System.getProperty("line.separator");
|
||||
|
||||
String expected = "org.apache.poi.ddf.EscherClientDataRecord:" + nl +
|
||||
" RecordId: 0xF011" + nl +
|
||||
" Version: 0x0002" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Extra Data:" + nl +
|
||||
"No Data" + nl ;
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherClientDataRecord (ClientData):" + nl +
|
||||
" RecordId: 0xF011" + nl +
|
||||
" Version: 0x0002" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x0002" + nl +
|
||||
" Record Size: 8" + nl +
|
||||
" Extra Data: " + nl +
|
||||
" : 0";
|
||||
assertEquals( expected, createRecord().toString() );
|
||||
}
|
||||
|
||||
|
|
|
@ -17,19 +17,24 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.poi.POIDataSamples;
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link EscherContainerRecord}
|
||||
*/
|
||||
public final class TestEscherContainerRecord extends TestCase {
|
||||
public final class TestEscherContainerRecord {
|
||||
private static final POIDataSamples _samples = POIDataSamples.getDDFInstance();
|
||||
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
EscherRecordFactory f = new DefaultEscherRecordFactory();
|
||||
byte[] data = HexRead.readFromString("0F 02 11 F1 00 00 00 00");
|
||||
|
@ -49,6 +54,7 @@ public final class TestEscherContainerRecord extends TestCase {
|
|||
assertEquals((short) 0xF222, c.getRecordId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
UnknownEscherRecord r = new UnknownEscherRecord();
|
||||
r.setOptions((short) 0x123F);
|
||||
|
@ -69,72 +75,79 @@ public final class TestEscherContainerRecord extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
EscherContainerRecord r = new EscherContainerRecord();
|
||||
r.setRecordId(EscherContainerRecord.SP_CONTAINER);
|
||||
r.setOptions((short) 0x000F);
|
||||
String nl = System.getProperty("line.separator");
|
||||
assertEquals("org.apache.poi.ddf.EscherContainerRecord (SpContainer):" + nl +
|
||||
" isContainer: true" + nl +
|
||||
" version: 0x000F" + nl +
|
||||
" instance: 0x0000" + nl +
|
||||
" recordId: 0xF004" + nl +
|
||||
" numchildren: 0" + nl
|
||||
, r.toString());
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherContainerRecord (SpContainer):" + nl +
|
||||
" RecordId: 0xF004" + nl +
|
||||
" Version: 0x000F" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x000F" + nl +
|
||||
" Record Size: 8" + nl +
|
||||
" isContainer: true" + nl +
|
||||
" children: 0x00000000";
|
||||
assertEquals(expected, r.toString());
|
||||
|
||||
EscherOptRecord r2 = new EscherOptRecord();
|
||||
// don't try to shoot in foot, please -- vlsergey
|
||||
// r2.setOptions((short) 0x9876);
|
||||
r2.setRecordId(EscherOptRecord.RECORD_ID);
|
||||
|
||||
String expected;
|
||||
r.addChildRecord(r2);
|
||||
expected = "org.apache.poi.ddf.EscherContainerRecord (SpContainer):" + nl +
|
||||
" isContainer: true" + nl +
|
||||
" version: 0x000F" + nl +
|
||||
" instance: 0x0000" + nl +
|
||||
" recordId: 0xF004" + nl +
|
||||
" numchildren: 1" + nl +
|
||||
" children: " + nl +
|
||||
" Child 0:" + nl +
|
||||
" org.apache.poi.ddf.EscherOptRecord:" + nl +
|
||||
" isContainer: false" + nl +
|
||||
" version: 0x0003" + nl +
|
||||
" instance: 0x0000" + nl +
|
||||
" recordId: 0xF00B" + nl +
|
||||
" numchildren: 0" + nl +
|
||||
" properties:" + nl +
|
||||
" " + nl;
|
||||
assertEquals(expected, r.toString());
|
||||
expected =
|
||||
"org.apache.poi.ddf.EscherContainerRecord (SpContainer):" + nl +
|
||||
" RecordId: 0xF004" + nl +
|
||||
" Version: 0x000F" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x000F" + nl +
|
||||
" Record Size: 16" + nl +
|
||||
" isContainer: true" + nl +
|
||||
" children: 0x00000001" + nl +
|
||||
" Child 0: org.apache.poi.ddf.EscherOptRecord (Opt):" + nl +
|
||||
" RecordId: 0xF00B" + nl +
|
||||
" Version: 0x0003" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x0003" + nl +
|
||||
" Record Size: 8" + nl +
|
||||
" isContainer: false" + nl +
|
||||
" numchildren: 0x00000000" + nl +
|
||||
" properties: 0x00000000";
|
||||
assertEquals(expected, r.toString());
|
||||
|
||||
r.addChildRecord(r2);
|
||||
expected = "org.apache.poi.ddf.EscherContainerRecord (SpContainer):" + nl +
|
||||
" isContainer: true" + nl +
|
||||
" version: 0x000F" + nl +
|
||||
" instance: 0x0000" + nl +
|
||||
" recordId: 0xF004" + nl +
|
||||
" numchildren: 2" + nl +
|
||||
" children: " + nl +
|
||||
" Child 0:" + nl +
|
||||
" org.apache.poi.ddf.EscherOptRecord:" + nl +
|
||||
" isContainer: false" + nl +
|
||||
" version: 0x0003" + nl +
|
||||
" instance: 0x0000" + nl +
|
||||
" recordId: 0xF00B" + nl +
|
||||
" numchildren: 0" + nl +
|
||||
" properties:" + nl +
|
||||
" " + nl +
|
||||
" Child 1:" + nl +
|
||||
" org.apache.poi.ddf.EscherOptRecord:" + nl +
|
||||
" isContainer: false" + nl +
|
||||
" version: 0x0003" + nl +
|
||||
" instance: 0x0000" + nl +
|
||||
" recordId: 0xF00B" + nl +
|
||||
" numchildren: 0" + nl +
|
||||
" properties:" + nl +
|
||||
" " + nl;
|
||||
expected =
|
||||
"org.apache.poi.ddf.EscherContainerRecord (SpContainer):" + nl +
|
||||
" RecordId: 0xF004" + nl +
|
||||
" Version: 0x000F" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x000F" + nl +
|
||||
" Record Size: 24" + nl +
|
||||
" isContainer: true" + nl +
|
||||
" children: 0x00000002" + nl +
|
||||
" Child 0: org.apache.poi.ddf.EscherOptRecord (Opt):" + nl +
|
||||
" RecordId: 0xF00B" + nl +
|
||||
" Version: 0x0003" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x0003" + nl +
|
||||
" Record Size: 8" + nl +
|
||||
" isContainer: false" + nl +
|
||||
" numchildren: 0x00000000" + nl +
|
||||
" properties: 0x00000000" + nl +
|
||||
" Child 1: org.apache.poi.ddf.EscherOptRecord (Opt):" + nl +
|
||||
" RecordId: 0xF00B" + nl +
|
||||
" Version: 0x0003" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x0003" + nl +
|
||||
" Record Size: 8" + nl +
|
||||
" isContainer: false" + nl +
|
||||
" numchildren: 0x00000000" + nl +
|
||||
" properties: 0x00000000";
|
||||
assertEquals(expected, r.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DummyEscherRecord extends EscherRecord {
|
||||
public DummyEscherRecord() { }
|
||||
|
@ -146,8 +159,11 @@ public final class TestEscherContainerRecord extends TestCase {
|
|||
public int getRecordSize() { return 10; }
|
||||
@Override
|
||||
public String getRecordName() { return ""; }
|
||||
@Override
|
||||
protected Object[][] getAttributeMap() { return null; }
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecordSize() {
|
||||
EscherContainerRecord r = new EscherContainerRecord();
|
||||
r.addChildRecord(new DummyEscherRecord());
|
||||
|
@ -158,6 +174,7 @@ public final class TestEscherContainerRecord extends TestCase {
|
|||
* We were having problems with reading too much data on an UnknownEscherRecord,
|
||||
* but hopefully we now read the correct size.
|
||||
*/
|
||||
@Test
|
||||
public void testBug44857() throws Exception {
|
||||
byte[] data = _samples.readFile("Container.dat");
|
||||
|
||||
|
@ -169,6 +186,7 @@ public final class TestEscherContainerRecord extends TestCase {
|
|||
/**
|
||||
* Ensure {@link EscherContainerRecord} doesn't spill its guts everywhere
|
||||
*/
|
||||
@Test
|
||||
public void testChildren() {
|
||||
EscherContainerRecord ecr = new EscherContainerRecord();
|
||||
List<EscherRecord> children0 = ecr.getChildRecords();
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class TestEscherDgRecord extends TestCase {
|
||||
public final class TestEscherDgRecord {
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
EscherDgRecord r = createRecord();
|
||||
|
||||
|
@ -36,6 +39,7 @@ public final class TestEscherDgRecord extends TestCase {
|
|||
HexDump.toHex( data ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
String hexData = "10 00 " +
|
||||
"08 F0 " +
|
||||
|
@ -51,13 +55,18 @@ public final class TestEscherDgRecord extends TestCase {
|
|||
assertEquals( 1025, r.getLastMSOSPID() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
String expected = "org.apache.poi.ddf.EscherDgRecord:" + '\n' +
|
||||
" RecordId: 0xF008" + '\n' +
|
||||
" Version: 0x0000" + '\n' +
|
||||
" Instance: 0x0001" + '\n' +
|
||||
" NumShapes: 2" + '\n' +
|
||||
" LastMSOSPID: 1025" + '\n';
|
||||
String nl = System.getProperty("line.separator");
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherDgRecord (Dg):" + nl +
|
||||
" RecordId: 0xF008" + nl +
|
||||
" Version: 0x0000" + nl +
|
||||
" Instance: 0x0001" + nl +
|
||||
" Options: 0x0010" + nl +
|
||||
" Record Size: 16" + nl +
|
||||
" NumShapes: 0x00000002" + nl +
|
||||
" LastMSOSPID: 0x00000401";
|
||||
assertEquals( expected, createRecord().toString() );
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class TestEscherDggRecord extends TestCase {
|
||||
public final class TestEscherDggRecord {
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
EscherDggRecord r = createRecord();
|
||||
|
||||
|
@ -39,6 +42,7 @@ public final class TestEscherDggRecord extends TestCase {
|
|||
HexDump.toHex( data ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
String hexData = "00 00 " +
|
||||
"06 F0 " +
|
||||
|
@ -62,17 +66,22 @@ public final class TestEscherDggRecord extends TestCase {
|
|||
assertEquals( 0x02, r.getFileIdClusters()[0].getNumShapeIdsUsed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
String expected = "org.apache.poi.ddf.EscherDggRecord:" + '\n' +
|
||||
" RecordId: 0xF006" + '\n' +
|
||||
" Version: 0x0000" + '\n' +
|
||||
" Instance: 0x0000" + '\n' +
|
||||
" ShapeIdMax: 1026" + '\n' +
|
||||
" NumIdClusters: 2" + '\n' +
|
||||
" NumShapesSaved: 2" + '\n' +
|
||||
" DrawingsSaved: 1" + '\n' +
|
||||
" DrawingGroupId1: 1" + '\n' +
|
||||
" NumShapeIdsUsed1: 2" + '\n';
|
||||
String nl = System.getProperty("line.separator");
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherDggRecord (Dgg):" + nl +
|
||||
" RecordId: 0xF006" + nl +
|
||||
" Version: 0x0000" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x0000" + nl +
|
||||
" Record Size: 32" + nl +
|
||||
" ShapeIdMax: 0x00000402" + nl +
|
||||
" NumIdClusters: 0x00000002" + nl +
|
||||
" NumShapesSaved: 0x00000002" + nl +
|
||||
" DrawingsSaved: 0x00000001" + nl +
|
||||
" FileId Clusters: 0x00000001" + nl +
|
||||
" Group1: 0x00000002";
|
||||
assertEquals( expected, createRecord().toString() );
|
||||
}
|
||||
|
||||
|
@ -90,6 +99,7 @@ public final class TestEscherDggRecord extends TestCase {
|
|||
return r;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecordSize() {
|
||||
EscherDggRecord r = new EscherDggRecord();
|
||||
r.setFileIdClusters(new EscherDggRecord.FileIdCluster[] { new EscherDggRecord.FileIdCluster(0,0) } );
|
||||
|
|
|
@ -18,13 +18,18 @@
|
|||
package org.apache.poi.ddf;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.poifs.storage.RawDataUtil;
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class TestEscherOptRecord extends TestCase {
|
||||
public final class TestEscherOptRecord {
|
||||
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
checkFillFieldsSimple();
|
||||
checkFillFieldsComplex();
|
||||
|
@ -74,6 +79,7 @@ public final class TestEscherOptRecord extends TestCase {
|
|||
assertEquals( prop3, r.getEscherProperty( 2 ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
checkSerializeSimple();
|
||||
checkSerializeComplex();
|
||||
|
@ -130,6 +136,7 @@ public final class TestEscherOptRecord extends TestCase {
|
|||
assertEquals( 26, bytesWritten );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
String nl = System.getProperty("line.separator");
|
||||
EscherOptRecord r = new EscherOptRecord();
|
||||
|
@ -138,21 +145,25 @@ public final class TestEscherOptRecord extends TestCase {
|
|||
r.setRecordId(EscherOptRecord.RECORD_ID);
|
||||
EscherProperty prop1 = new EscherBoolProperty((short)1, 1);
|
||||
r.addEscherProperty(prop1);
|
||||
String expected = "org.apache.poi.ddf.EscherOptRecord:" + nl +
|
||||
" isContainer: false" + nl +
|
||||
" version: 0x0003" + nl +
|
||||
" instance: 0x0001" + nl +
|
||||
" recordId: 0x" + HexDump.toHex(EscherOptRecord.RECORD_ID) + nl +
|
||||
" numchildren: 0" + nl +
|
||||
" properties:" + nl +
|
||||
" propNum: 1, RAW: 0x0001, propName: unknown, complex: false, blipId: false, value: 1 (0x00000001)" + nl;
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherOptRecord (Opt):" + nl +
|
||||
" RecordId: 0xF00B" + nl +
|
||||
" Version: 0x0003" + nl +
|
||||
" Instance: 0x0001" + nl +
|
||||
" Options: 0x0013" + nl +
|
||||
" Record Size: 14" + nl +
|
||||
" isContainer: false" + nl +
|
||||
" numchildren: 0x00000000" + nl +
|
||||
" properties: 0x00000001" + nl +
|
||||
" unknown: propNum: 1, RAW: 0x0001, propName: unknown, complex: false, blipId: false, value: 1 (0x00000001)";
|
||||
assertEquals( expected, r.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test serialisation of a particually complex example
|
||||
* Test serialization of a particularly complex example
|
||||
* This test is currently broken!
|
||||
*/
|
||||
@Test
|
||||
public void testComplexSerialise() {
|
||||
byte[] data = {
|
||||
0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00,
|
||||
|
@ -233,15 +244,13 @@ public final class TestEscherOptRecord extends TestCase {
|
|||
assertEquals(data.length, filled);
|
||||
assertEquals(data.length, r.getRecordSize());
|
||||
|
||||
// Serialise it
|
||||
// Serialize it
|
||||
byte[] dest = new byte[data.length];
|
||||
int written = r.serialize(0, dest);
|
||||
|
||||
// Check it serialised it back to the same data
|
||||
assertEquals(data.length, written);
|
||||
for(int i=0; i<data.length; i++) {
|
||||
assertEquals(data[i], dest[i]);
|
||||
}
|
||||
assertArrayEquals(data, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,43 +263,20 @@ public final class TestEscherOptRecord extends TestCase {
|
|||
*
|
||||
* See Bug 41946 for details.
|
||||
*/
|
||||
public void test41946() {
|
||||
String dataStr1 =
|
||||
"03 08 0B F0 00 03 00 00 81 00 30 65 01 00 82 00 98 B2 00 00 83 00 30 65 01 " +
|
||||
"00 84 00 98 B2 00 00 85 00 00 00 00 00 87 00 01 00 00 00 88 00 00 00 00 00 " +
|
||||
"89 00 00 00 00 00 BF 00 00 00 0F 00 0C 01 F4 00 00 10 0D 01 00 00 00 20 0E " +
|
||||
"01 00 00 00 20 80 01 00 00 00 00 81 01 04 00 00 08 82 01 00 00 01 00 83 01 " +
|
||||
"00 00 00 08 84 01 00 00 01 00 85 01 00 00 00 20 86 41 00 00 00 00 87 C1 00 " +
|
||||
"00 00 00 88 01 00 00 00 00 89 01 00 00 00 00 8A 01 00 00 00 00 8B 01 00 00 " +
|
||||
"00 00 8C 01 00 00 00 00 8D 01 00 00 00 00 8E 01 00 00 00 00 8F 01 00 00 00 " +
|
||||
"00 90 01 00 00 00 00 91 01 00 00 00 00 92 01 00 00 00 00 93 01 00 00 00 00 " +
|
||||
"94 01 00 00 00 00 95 01 00 00 00 00 96 01 00 00 00 00 97 C1 00 00 00 00 98 " +
|
||||
"01 00 00 00 00 99 01 00 00 00 00 9A 01 00 00 00 00 9B 01 00 00 00 00 9C 01 " +
|
||||
"03 00 00 40 BF 01 0C 00 1E 00 C0 01 01 00 00 08 C1 01 00 00 01 00 C2 01 FF " +
|
||||
"FF FF 00 C3 01 00 00 00 20 C4 01 00 00 00 00 C5 41 00 00 00 00 C6 C1 00 00 " +
|
||||
"00 00 C7 01 00 00 00 00 C8 01 00 00 00 00 C9 01 00 00 00 00 CA 01 00 00 00 " +
|
||||
"00 CB 01 35 25 00 00 CC 01 00 00 08 00 CD 01 00 00 00 00 CE 01 00 00 00 00 " +
|
||||
"CF C1 00 00 00 00 D7 01 02 00 00 00 FF 01 06 00 0E 00 00 02 00 00 00 00 01 " +
|
||||
"02 02 00 00 08 02 02 CB CB CB 00 03 02 00 00 00 20 04 02 00 00 01 00 05 02 " +
|
||||
"38 63 00 00 06 02 38 63 00 00 07 02 00 00 00 00 08 02 00 00 00 00 09 02 00 " +
|
||||
"00 01 00 0A 02 00 00 00 00 0B 02 00 00 00 00 0C 02 00 00 01 00 0D 02 00 00 " +
|
||||
"00 00 0E 02 00 00 00 00 0F 02 00 01 00 00 10 02 00 00 00 00 11 02 00 00 00 " +
|
||||
"00 3F 02 00 00 03 00 80 02 00 00 00 00 81 02 00 00 01 00 82 02 05 00 00 00 " +
|
||||
"83 02 9C 31 00 00 84 02 00 00 00 00 85 02 F0 F9 06 00 86 02 00 00 00 00 87 " +
|
||||
"02 F7 00 00 10 88 02 00 00 00 20 BF 02 01 00 0F 00 C0 02 00 00 00 00 C1 02 " +
|
||||
"00 00 00 00 C2 02 64 00 00 00 C3 02 00 00 00 00 C4 02 00 00 00 00 C5 02 00 " +
|
||||
"00 00 00 C6 02 00 00 00 00 C7 02 00 00 00 00 C8 02 00 00 00 00 C9 02 00 00 " +
|
||||
"00 00 CA 02 30 75 00 00 CB 02 D0 12 13 00 CC 02 30 ED EC FF CD 02 40 54 89 " +
|
||||
"00 CE 02 00 80 00 00 CF 02 00 80 FF FF D0 02 00 00 79 FF D1 02 32 00 00 00 " +
|
||||
"D2 02 20 4E 00 00 D3 02 50 C3 00 00 D4 02 00 00 00 00 D5 02 10 27 00 00 D6 " +
|
||||
"02 70 94 00 00 D7 02 B0 3C FF FF D8 02 00 00 00 00 D9 02 10 27 00 00 DA 02 " +
|
||||
"70 94 00 00 FF 02 16 00 1F 00 04 03 01 00 00 00 41 03 A8 29 01 00 42 03 00 " +
|
||||
"00 00 00 43 03 03 00 00 00 44 03 7C BE 01 00 45 03 00 00 00 00 7F 03 00 00 " +
|
||||
"0F 00 84 03 7C BE 01 00 85 03 00 00 00 00 86 03 7C BE 01 00 87 03 00 00 00 " +
|
||||
"00";
|
||||
@Test
|
||||
public void test41946() throws IOException {
|
||||
String data64 =
|
||||
"H4sIAAAAAAAAAB3SuW5TQRjF8TPfOOZCHMeARAluEKIzSEgUSCQsLaLgDYCehgIJCe8L+xIgQB6"+
|
||||
"AEvEAOI6zOwlhX54BpBRIiGqY+Vvy7x6d+3k8nmufje/ISzVVrjrVNftWapCb5JbSqyMX7ZJ72I"+
|
||||
"/vSRXcH6k0kW6Wi1hNquZyUlaP2amRmqxJbjHTnmbNQbLLfA9v4x28i/fwPj7Ah/gIH+MTnMGn+"+
|
||||
"Ayfs/4s+QW+xFc45+KPnuq7gg5q3sUqG7DDBRdC0JB9LjK5xG6XWW2FZhXXcB1H7sRhaSMto02a"+
|
||||
"LXzPp745iwaXV1FKUc7iJTMbjUbyqSnnLH37mJ28LOVxF5MZ7ubuHvI4FmgmyEWctPSQSuS9eDr"+
|
||||
"qVSXXmK/bWMwNmzsmNelbtvMvrza5Y3/jAl320zcXn+88/QAX7Ep0SF7EJVzGFVzFNVy3yvV4Mr"+
|
||||
"a9b782rPL7V9i0qUs9bZmq8WSiIWzHyRvhgx2P8x+tfEH6ZBeH0mdW+GKlI9JXuzYTz9DenArhO"+
|
||||
"/0P+p/0wQ7okHI+Hfe0f33U6YxPM2d9upzzN985nae55dM/tknTommTO+T/V9IPpAgDAAA=";
|
||||
|
||||
EscherOptRecord r = new EscherOptRecord();
|
||||
byte[] data = HexRead.readFromString( dataStr1 );
|
||||
byte[] data = RawDataUtil.decompress(data64);
|
||||
r.fillFields( data, 0, new DefaultEscherRecordFactory() );
|
||||
assertEquals( (short) 0xF00B, r.getRecordId() );
|
||||
|
||||
|
@ -306,6 +292,7 @@ public final class TestEscherOptRecord extends TestCase {
|
|||
* Test that EscherOptRecord can properly read/write array properties
|
||||
* with empty complex part.
|
||||
*/
|
||||
@Test
|
||||
public void testEmptyArrayProperty() {
|
||||
EscherOptRecord r = new EscherOptRecord();
|
||||
EscherArrayProperty p = new EscherArrayProperty((short)(EscherProperties.FILL__SHADECOLORS + 0x8000), new byte[0] );
|
||||
|
|
|
@ -17,18 +17,19 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public class TestEscherProperty extends TestCase
|
||||
{
|
||||
public class TestEscherProperty {
|
||||
/**
|
||||
* assure that EscherProperty.getName() returns correct name for complex properties
|
||||
* See Bugzilla 50401
|
||||
*/
|
||||
@Test
|
||||
public void testPropertyNames() throws Exception {
|
||||
EscherProperty p1 = new EscherSimpleProperty( EscherProperties.GROUPSHAPE__SHAPENAME, 0);
|
||||
assertEquals("groupshape.shapename", p1.getName());
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestEscherSpRecord extends TestCase
|
||||
{
|
||||
public class TestEscherSpRecord {
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
EscherSpRecord r = createRecord();
|
||||
|
||||
|
@ -37,6 +39,7 @@ public class TestEscherSpRecord extends TestCase
|
|||
HexDump.toHex( data ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
String hexData = "02 00 " +
|
||||
"0A F0 " +
|
||||
|
@ -52,15 +55,20 @@ public class TestEscherSpRecord extends TestCase
|
|||
assertEquals( 0x05, r.getFlags() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
String nl = System.getProperty("line.separator");
|
||||
|
||||
String expected = "org.apache.poi.ddf.EscherSpRecord:" + nl +
|
||||
" RecordId: 0xF00A" + nl +
|
||||
" Version: 0x0002" + nl +
|
||||
" ShapeType: 0x0000" + nl +
|
||||
" ShapeId: 1024" + nl +
|
||||
" Flags: GROUP|PATRIARCH (0x00000005)" + nl;
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherSpRecord (Sp):" + nl +
|
||||
" RecordId: 0xF00A" + nl +
|
||||
" Version: 0x0002" + nl +
|
||||
" Instance: 0x0000" + nl +
|
||||
" Options: 0x0002" + nl +
|
||||
" Record Size: 16" + nl +
|
||||
" ShapeType: 0x0000" + nl +
|
||||
" ShapeId: 0x00000400" + nl +
|
||||
" Flags: GROUP|PATRIARCH (0x00000005)";
|
||||
assertEquals( expected, createRecord().toString() );
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class TestEscherSpgrRecord extends TestCase {
|
||||
public final class TestEscherSpgrRecord {
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
EscherSpgrRecord r = createRecord();
|
||||
|
||||
|
@ -38,6 +41,7 @@ public final class TestEscherSpgrRecord extends TestCase {
|
|||
HexDump.toHex( data ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
String hexData = "10 00 " +
|
||||
"09 F0 " +
|
||||
|
@ -57,16 +61,20 @@ public final class TestEscherSpgrRecord extends TestCase {
|
|||
assertEquals( 4, r.getRectY2() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
|
||||
String expected = "org.apache.poi.ddf.EscherSpgrRecord:" + '\n' +
|
||||
" RecordId: 0xF009" + '\n' +
|
||||
" Version: 0x0000" + '\n' +
|
||||
" Instance: 0x0001" + '\n' +
|
||||
" RectX: 1" + '\n' +
|
||||
" RectY: 2" + '\n' +
|
||||
" RectWidth: 3" + '\n' +
|
||||
" RectHeight: 4" + '\n';
|
||||
String nl = System.getProperty("line.separator");
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherSpgrRecord (Spgr):" + nl +
|
||||
" RecordId: 0xF009" + nl +
|
||||
" Version: 0x0000" + nl +
|
||||
" Instance: 0x0001" + nl +
|
||||
" Options: 0x0010" + nl +
|
||||
" Record Size: 24" + nl +
|
||||
" RectX: 0x00000001" + nl +
|
||||
" RectY: 0x00000002" + nl +
|
||||
" RectWidth: 0x00000003" + nl +
|
||||
" RectHeight: 0x00000004";
|
||||
assertEquals( expected, createRecord().toString() );
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class TestEscherSplitMenuColorsRecord extends TestCase {
|
||||
public final class TestEscherSplitMenuColorsRecord {
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
EscherSplitMenuColorsRecord r = createRecord();
|
||||
|
||||
|
@ -38,6 +41,7 @@ public final class TestEscherSplitMenuColorsRecord extends TestCase {
|
|||
HexDump.toHex( data ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
String hexData = "40 00 " +
|
||||
"1E F1 " +
|
||||
|
@ -57,16 +61,20 @@ public final class TestEscherSplitMenuColorsRecord extends TestCase {
|
|||
assertEquals( 0x01, r.getColor4() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
String expected = "org.apache.poi.ddf.EscherSplitMenuColorsRecord:" + '\n' +
|
||||
" RecordId: 0xF11E" + '\n' +
|
||||
" Version: 0x0000" + '\n' +
|
||||
" Instance: 0x0004" + '\n' +
|
||||
" Color1: 0x00000402" + '\n' +
|
||||
" Color2: 0x00000002" + '\n' +
|
||||
" Color3: 0x00000002" + '\n' +
|
||||
" Color4: 0x00000001" + '\n' +
|
||||
"";
|
||||
String nl = System.getProperty("line.separator");
|
||||
String expected =
|
||||
"org.apache.poi.ddf.EscherSplitMenuColorsRecord (SplitMenuColors):" + nl +
|
||||
" RecordId: 0xF11E" + nl +
|
||||
" Version: 0x0000" + nl +
|
||||
" Instance: 0x0004" + nl +
|
||||
" Options: 0x0040" + nl +
|
||||
" Record Size: 24" + nl +
|
||||
" Color1: 0x00000402" + nl +
|
||||
" Color2: 0x00000002" + nl +
|
||||
" Color3: 0x00000002" + nl +
|
||||
" Color4: 0x00000001";
|
||||
assertEquals( expected, createRecord().toString() );
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,16 @@
|
|||
|
||||
package org.apache.poi.ddf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.apache.poi.util.HexDump;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public final class TestUnknownEscherRecord extends TestCase {
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class TestUnknownEscherRecord {
|
||||
@Test
|
||||
public void testFillFields() {
|
||||
String testData =
|
||||
"0F 02 " + // options
|
||||
|
@ -117,6 +122,7 @@ public final class TestUnknownEscherRecord extends TestCase {
|
|||
assertEquals( (short) 0xFFFF, r.getChild( 0 ).getRecordId() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialize() {
|
||||
UnknownEscherRecord r = new UnknownEscherRecord();
|
||||
r.setOptions( (short) 0x1234 );
|
||||
|
@ -137,20 +143,27 @@ public final class TestUnknownEscherRecord extends TestCase {
|
|||
assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00]", HexDump.toHex( data ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
UnknownEscherRecord r = new UnknownEscherRecord();
|
||||
r.setOptions( (short) 0x1234 );
|
||||
r.setRecordId( (short) 0xF112 );
|
||||
byte[] data = new byte[8];
|
||||
r.serialize( 0, data, new NullEscherSerializationListener() );
|
||||
|
||||
assertEquals( "org.apache.poi.ddf.UnknownEscherRecord:" + '\n' +
|
||||
" isContainer: false" + '\n' +
|
||||
" version: 0x0004" + '\n' +
|
||||
" instance: 0x0123" + '\n' +
|
||||
" recordId: 0xF112" + '\n' +
|
||||
" numchildren: 0" + '\n' +
|
||||
": 0"
|
||||
, r.toString() );
|
||||
String nl = System.getProperty("line.separator");
|
||||
String expected =
|
||||
"org.apache.poi.ddf.UnknownEscherRecord (Unknown 0xF112):" + nl +
|
||||
" RecordId: 0xF112" + nl +
|
||||
" Version: 0x0004" + nl +
|
||||
" Instance: 0x0123" + nl +
|
||||
" Options: 0x1234" + nl +
|
||||
" Record Size: 8" + nl +
|
||||
" isContainer: false" + nl +
|
||||
" children: 0x00000000" + nl +
|
||||
" Extra Data: " + nl +
|
||||
" : 0";
|
||||
|
||||
|
||||
assertEquals(expected, r.toString() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue