1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 32 33 public class DefaultRowHeightRecord 34 extends Record 35 { 36 public final static short sid = 0x225; 37 private short field_1_option_flags; 38 private short field_2_row_height; 39 40 public DefaultRowHeightRecord() 41 { 42 } 43 44 51 52 public DefaultRowHeightRecord(short id, short size, byte [] data) 53 { 54 super(id, size, data); 55 } 56 57 65 66 public DefaultRowHeightRecord(short id, short size, byte [] data, 67 int offset) 68 { 69 super(id, size, data, offset); 70 } 71 72 protected void validateSid(short id) 73 { 74 if (id != sid) 75 { 76 throw new RecordFormatException("NOT A DefaultRowHeight RECORD"); 77 } 78 } 79 80 protected void fillFields(byte [] data, short size, int offset) 81 { 82 field_1_option_flags = LittleEndian.getShort(data, 0 + offset); 83 field_2_row_height = LittleEndian.getShort(data, 2 + offset); 84 } 85 86 90 91 public void setOptionFlags(short flags) 92 { 93 field_1_option_flags = flags; 94 } 95 96 100 101 public void setRowHeight(short height) 102 { 103 field_2_row_height = height; 104 } 105 106 110 111 public short getOptionFlags() 112 { 113 return field_1_option_flags; 114 } 115 116 120 121 public short getRowHeight() 122 { 123 return field_2_row_height; 124 } 125 126 public String toString() 127 { 128 StringBuffer buffer = new StringBuffer (); 129 130 buffer.append("[DEFAULTROWHEIGHT]\n"); 131 buffer.append(" .optionflags = ") 132 .append(Integer.toHexString(getOptionFlags())).append("\n"); 133 buffer.append(" .rowheight = ") 134 .append(Integer.toHexString(getRowHeight())).append("\n"); 135 buffer.append("[/DEFAULTROWHEIGHT]\n"); 136 return buffer.toString(); 137 } 138 139 public int serialize(int offset, byte [] data) 140 { 141 LittleEndian.putShort(data, 0 + offset, sid); 142 LittleEndian.putShort(data, 2 + offset, ( short ) 0x4); 143 LittleEndian.putShort(data, 4 + offset, getOptionFlags()); 144 LittleEndian.putShort(data, 6 + offset, getRowHeight()); 145 return getRecordSize(); 146 } 147 148 public int getRecordSize() 149 { 150 return 8; 151 } 152 153 public short getSid() 154 { 155 return this.sid; 156 } 157 158 public Object clone() { 159 DefaultRowHeightRecord rec = new DefaultRowHeightRecord(); 160 rec.field_1_option_flags = field_1_option_flags; 161 rec.field_2_row_height = field_2_row_height; 162 return rec; 163 } 164 } 165 | Popular Tags |