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.syntax;
22
23 import org.millscript.office.excel.RecordSyntax;
24 import org.millscript.office.excel.RecordTokenizer;
25 import org.millscript.office.excel.records.CF;
26 import org.millscript.office.excel.versions.BIFF8;
27 import org.millscript.office.excel.versions.BIFF8X;
28
29 /**
30 *
31 */
32 public class CFRecordSyntax extends RecordSyntax implements BIFF8, BIFF8X {
33
34 /**
35 *
36 */
37 public static class Options {
38
39 private final int options;
40
41 public Options( final int o ) {
42 this.options = o;
43 }
44
45 public boolean containsBorderFormatting() {
46 return 0 != ( this.options & 0x10000000 );
47 }
48
49 public boolean containsFontFormatting() {
50 return 0 != ( this.options & 0x04000000 );
51 }
52
53 public boolean containsPatternFormatting() {
54 return 0 != ( this.options & 0x20000000 );
55 }
56
57 }
58
59 /**
60 * @see org.millscript.office.excel.RecordSyntax#newRecord(RecordTokenizer)
61 */
62 @Override
63 public CF newRecord( final RecordTokenizer tokenizer ) {
64 final CF cf = new CF();
65
66 cf.setType(
67 CF.Type.getType( tokenizer.readUnsignedByte() )
68 );
69
70 cf.setComparisonOperator(
71 CF.ComparisonOperator.getComparisonOperator( tokenizer.readUnsignedByte() )
72 );
73
74 final int firstFormulaSize = tokenizer.readUnsigned2Byte();
75 final int secondFormulaSize = tokenizer.readUnsigned2Byte();
76
77 final Options options = new Options( tokenizer.read4ByteInt() );
78
79 tokenizer.skipBytes( 2 );
80
81 if ( options.containsFontFormatting() ) {
82 cf.setFontFormattingBlock( tokenizer.readBytes( 118 ) );
83 }
84
85 if ( options.containsBorderFormatting() ) {
86 cf.setBorderFormattingBlock( tokenizer.readBytes( 8 ) );
87 }
88
89 if ( options.containsPatternFormatting() ) {
90 cf.setPatternFormattingBlock( tokenizer.readBytes( 4 ) );
91 }
92
93 cf.setFirstFormulaExpr(
94 tokenizer.readFormula( firstFormulaSize, 0 )
95 );
96
97 cf.setSecondFormulaExpr(
98 tokenizer.readFormula( secondFormulaSize, 0 )
99 );
100
101 return cf;
102 }
103
104 }