1 16 17 package org.apache.poi.hssf.record; 18 19 import org.apache.poi.util.*; 20 21 26 public class LeftMarginRecord extends Record implements Margin 27 { 28 public final static short sid = 0x26; 29 private double field_1_margin; 30 31 public LeftMarginRecord() { } 32 33 41 public LeftMarginRecord( short id, short size, byte[] data ) 42 { super( id, size, data ); } 43 44 52 public LeftMarginRecord( short id, short size, byte[] data, int offset ) 53 { super( id, size, data, offset ); } 54 55 60 protected void validateSid( short id ) 61 { 62 if ( id != sid ) 63 { 64 throw new RecordFormatException( "Not a LeftMargin record" ); 65 } 66 } 67 68 protected void fillFields( byte[] data, short size, int offset ) 69 { 70 field_1_margin = LittleEndian.getDouble( data, 0x0 + offset ); 71 } 72 73 public String toString() 74 { 75 StringBuffer buffer = new StringBuffer (); 76 buffer.append( "[LeftMargin]\n" ); 77 buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" ); 78 buffer.append( "[/LeftMargin]\n" ); 79 return buffer.toString(); 80 } 81 82 public int serialize( int offset, byte[] data ) 83 { 84 LittleEndian.putShort( data, 0 + offset, sid ); 85 LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) ); 86 LittleEndian.putDouble( data, 4 + offset, field_1_margin ); 87 return getRecordSize(); 88 } 89 90 93 public int getRecordSize() { 94 return 4 + 8; 95 } 96 97 public short getSid() { 98 return this.sid; 99 } 100 101 104 public double getMargin() { 105 return field_1_margin; 106 } 107 108 111 public void setMargin( double field_1_margin ) 112 { 113 this.field_1_margin = field_1_margin; 114 } 115 116 public Object clone() 117 { 118 LeftMarginRecord rec = new LeftMarginRecord(); 119 rec.field_1_margin = this.field_1_margin; 120 return rec; 121 } 122 } | Popular Tags |