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 EscherDgRecord 30 extends EscherRecord 31 { 32 public static final short RECORD_ID = (short) 0xF008; 33 public static final String RECORD_DESCRIPTION = "MsofbtDg"; 34 35 private int field_1_numShapes; 36 private int field_2_lastMSOSPID; 37 38 46 public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory ) 47 { 48 int bytesRemaining = readHeader( data, offset ); 49 int pos = offset + 8; 50 int size = 0; 51 field_1_numShapes = LittleEndian.getInt( data, pos + size ); size += 4; 52 field_2_lastMSOSPID = LittleEndian.getInt( data, pos + size ); size += 4; 53 return getRecordSize(); 57 } 58 59 68 public int serialize( int offset, byte[] data, EscherSerializationListener listener ) 69 { 70 listener.beforeRecordSerialize( offset, getRecordId(), this ); 71 72 LittleEndian.putShort( data, offset, getOptions() ); 73 LittleEndian.putShort( data, offset + 2, getRecordId() ); 74 LittleEndian.putInt( data, offset + 4, 8 ); 75 LittleEndian.putInt( data, offset + 8, field_1_numShapes ); 76 LittleEndian.putInt( data, offset + 12, field_2_lastMSOSPID ); 77 80 listener.afterRecordSerialize( offset + 16, getRecordId(), getRecordSize(), this ); 81 return getRecordSize(); 82 } 83 84 89 public int getRecordSize() 90 { 91 return 8 + 8; 92 } 93 94 public short getRecordId() 95 { 96 return RECORD_ID; 97 } 98 99 102 public String getRecordName() 103 { 104 return "Dg"; 105 } 106 107 110 public String toString() 111 { 112 String nl = System.getProperty("line.separator"); 113 114 return getClass().getName() + ":" + nl + 126 " RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl + 127 " Options: 0x" + HexDump.toHex(getOptions()) + nl + 128 " NumShapes: " + field_1_numShapes + nl + 129 " LastMSOSPID: " + field_2_lastMSOSPID + nl; 130 131 } 132 133 136 public int getNumShapes() 137 { 138 return field_1_numShapes; 139 } 140 141 144 public void setNumShapes( int field_1_numShapes ) 145 { 146 this.field_1_numShapes = field_1_numShapes; 147 } 148 149 152 public int getLastMSOSPID() 153 { 154 return field_2_lastMSOSPID; 155 } 156 157 160 public void setLastMSOSPID( int field_2_lastMSOSPID ) 161 { 162 this.field_2_lastMSOSPID = field_2_lastMSOSPID; 163 } 164 165 171 public short getDrawingGroupId() 172 { 173 return (short) ( getOptions() >> 4 ); 174 } 175 176 public void incrementShapeCount() 177 { 178 this.field_1_numShapes++; 179 } 180 } 181 | Popular Tags |