1 2 17 18 package org.apache.poi.ddf; 19 20 import org.apache.poi.util.HexDump; 21 import org.apache.poi.util.LittleEndian; 22 23 29 public class EscherSpRecord 30 extends EscherRecord 31 { 32 public static final short RECORD_ID = (short) 0xF00A; 33 public static final String RECORD_DESCRIPTION = "MsofbtSp"; 34 35 public static final int FLAG_GROUP = 0x0001; 36 public static final int FLAG_CHILD = 0x0002; 37 public static final int FLAG_PATRIARCH = 0x0004; 38 public static final int FLAG_DELETED = 0x0008; 39 public static final int FLAG_OLESHAPE = 0x0010; 40 public static final int FLAG_HAVEMASTER = 0x0020; 41 public static final int FLAG_FLIPHORIZ = 0x0040; 42 public static final int FLAG_FLIPVERT = 0x0080; 43 public static final int FLAG_CONNECTOR = 0x0100; 44 public static final int FLAG_HAVEANCHOR = 0x0200; 45 public static final int FLAG_BACKGROUND = 0x0400; 46 public static final int FLAG_HASSHAPETYPE = 0x0800; 47 48 private int field_1_shapeId; 49 private int field_2_flags; 50 51 59 public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory ) 60 { 61 int bytesRemaining = readHeader( data, offset ); 62 int pos = offset + 8; 63 int size = 0; 64 field_1_shapeId = LittleEndian.getInt( data, pos + size ); size += 4; 65 field_2_flags = LittleEndian.getInt( data, pos + size ); size += 4; 66 return getRecordSize(); 70 } 71 72 82 public int serialize( int offset, byte[] data, EscherSerializationListener listener ) 83 { 84 listener.beforeRecordSerialize( offset, getRecordId(), this ); 85 LittleEndian.putShort( data, offset, getOptions() ); 86 LittleEndian.putShort( data, offset + 2, getRecordId() ); 87 int remainingBytes = 8; 88 LittleEndian.putInt( data, offset + 4, remainingBytes ); 89 LittleEndian.putInt( data, offset + 8, field_1_shapeId ); 90 LittleEndian.putInt( data, offset + 12, field_2_flags ); 91 listener.afterRecordSerialize( offset + getRecordSize(), getRecordId(), getRecordSize(), this ); 94 return 8 + 8; 95 } 96 97 102 public int getRecordSize() 103 { 104 return 8 + 8; 105 } 106 107 110 public short getRecordId() 111 { 112 return RECORD_ID; 113 } 114 115 118 public String getRecordName() 119 { 120 return "Sp"; 121 } 122 123 126 public String toString() 127 { 128 String nl = System.getProperty("line.separator"); 129 130 return getClass().getName() + ":" + nl + 131 " RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl + 132 " Options: 0x" + HexDump.toHex(getOptions()) + nl + 133 " ShapeId: " + field_1_shapeId + nl + 134 " Flags: " + decodeFlags(field_2_flags) + " (0x" + HexDump.toHex(field_2_flags) + ")" + nl; 135 136 } 137 138 141 private String decodeFlags( int flags ) 142 { 143 StringBuffer result = new StringBuffer (); 144 result.append( ( flags & FLAG_GROUP ) != 0 ? "|GROUP" : "" ); 145 result.append( ( flags & FLAG_CHILD ) != 0 ? "|CHILD" : "" ); 146 result.append( ( flags & FLAG_PATRIARCH ) != 0 ? "|PATRIARCH" : "" ); 147 result.append( ( flags & FLAG_DELETED ) != 0 ? "|DELETED" : "" ); 148 result.append( ( flags & FLAG_OLESHAPE ) != 0 ? "|OLESHAPE" : "" ); 149 result.append( ( flags & FLAG_HAVEMASTER ) != 0 ? "|HAVEMASTER" : "" ); 150 result.append( ( flags & FLAG_FLIPHORIZ ) != 0 ? "|FLIPHORIZ" : "" ); 151 result.append( ( flags & FLAG_FLIPVERT ) != 0 ? "|FLIPVERT" : "" ); 152 result.append( ( flags & FLAG_CONNECTOR ) != 0 ? "|CONNECTOR" : "" ); 153 result.append( ( flags & FLAG_HAVEANCHOR ) != 0 ? "|HAVEANCHOR" : "" ); 154 result.append( ( flags & FLAG_BACKGROUND ) != 0 ? "|BACKGROUND" : "" ); 155 result.append( ( flags & FLAG_HASSHAPETYPE ) != 0 ? "|HASSHAPETYPE" : "" ); 156 157 result.deleteCharAt(0); 158 return result.toString(); 159 } 160 161 164 public int getShapeId() 165 { 166 return field_1_shapeId; 167 } 168 169 172 public void setShapeId( int field_1_shapeId ) 173 { 174 this.field_1_shapeId = field_1_shapeId; 175 } 176 177 193 public int getFlags() 194 { 195 return field_2_flags; 196 } 197 198 214 public void setFlags( int field_2_flags ) 215 { 216 this.field_2_flags = field_2_flags; 217 } 218 } 219 | Popular Tags |