1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.millscript.office.excel.records.substructures;
22
23 import org.millscript.office.excel.RecordTokenizer;
24
25 /**
26 *
27 */
28 public class CellAttributes {
29
30 private boolean cellIsLocked;
31
32 private boolean formulaIsHidden;
33
34 private boolean hasLeftBlackBorder;
35
36 private boolean hasRightBlackBorder;
37
38 private boolean hasTopBlackBorder;
39
40 private boolean hasBottomBlackBorder;
41
42 private boolean hasShadedBlackBorder;
43
44 private XF_HOR_ALIGN horizontalAlignment;
45
46 private byte indexToFontRecord;
47
48 private byte indexToFormatRecord;
49
50 /**
51 * The index to the XF record for this cell. If this is <code>-1</code> it
52 * means that an <code>IXFE</code> record is required.
53 */
54 private byte indexToXFRecord;
55
56 /**
57 * @param tokenizer
58 */
59 public CellAttributes( final RecordTokenizer tokenizer ) {
60
61 final byte cellProtectionAndXFIndex = tokenizer.readByte();
62 this.indexToXFRecord = (byte) ( cellProtectionAndXFIndex & 0x3F );
63
64
65
66 if ( this.indexToXFRecord == 0x3F ) {
67 this.indexToXFRecord = -1;
68 }
69 this.cellIsLocked = ( 1 == ( cellProtectionAndXFIndex & 0x40 ) );
70 this.formulaIsHidden = ( 1 == ( cellProtectionAndXFIndex & 0x80 ) );
71
72 final byte formatAndFontIndicies = tokenizer.readByte();
73 this.indexToFormatRecord = (byte) ( formatAndFontIndicies & 0x3F );
74 this.indexToFontRecord = (byte) ( formatAndFontIndicies & 0xC0 );
75
76 final byte cellStyle = tokenizer.readByte();
77 this.horizontalAlignment = XF_HOR_ALIGN.getXFHorAlign( cellStyle & 0x07 );
78 this.hasLeftBlackBorder = ( 1 == ( cellStyle & 0x08 ) );
79 this.hasRightBlackBorder = ( 1 == ( cellStyle & 0x10 ) );
80 this.hasTopBlackBorder = ( 1 == ( cellStyle & 0x20 ) );
81 this.hasBottomBlackBorder = ( 1 == ( cellStyle & 0x40 ) );
82 this.hasShadedBlackBorder = ( 1 == ( cellStyle & 0x80 ) );
83 }
84
85 /**
86 * @return Returns the indexToXFRecord.
87 */
88 public byte getIndexToXFRecord() {
89 return indexToXFRecord;
90 }
91
92 }