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;
22
23 import org.millscript.millscript.expr.Expr;
24 import org.millscript.office.excel.Record;
25 import org.millscript.office.excel.alerts.BIFFAlert;
26 import org.millscript.office.excel.blocks.ConditionalFormattingTable;
27
28 /**
29 *
30 */
31 public class CF extends Record implements ConditionalFormattingTable {
32
33 /**
34 *
35 */
36 public enum ComparisonOperator {
37
38 NO_COMPARISON, BETWEEN, NOT_BETWEEN, EQUAL, NOT_EQUAL, GREATER_THAN, LESS_THAN, GREATER_OR_EQUAL, LESS_OR_EQUAL;
39
40 public static ComparisonOperator getComparisonOperator( final int operator ) {
41 switch ( operator ) {
42 case 0x00:
43 return NO_COMPARISON;
44 case 0x01:
45 return BETWEEN;
46 case 0x02:
47 return NOT_BETWEEN;
48 case 0x03:
49 return EQUAL;
50 case 0x04:
51 return NOT_EQUAL;
52 case 0x05:
53 return GREATER_THAN;
54 case 0x06:
55 return LESS_THAN;
56 case 0x07:
57 return GREATER_OR_EQUAL;
58 case 0x08:
59 return LESS_OR_EQUAL;
60 default:
61 throw new BIFFAlert(
62 "Unknown comparison operator for CF record"
63 ).culprit( "operator", operator ).mishap();
64 }
65 }
66
67 }
68
69 /**
70 *
71 */
72 public enum Type {
73
74 COMPARE_CONTENTS, EVALUATE_FORMULA;
75
76 public static Type getType( final int type ) {
77 switch ( type ) {
78 case 0x01:
79 return COMPARE_CONTENTS;
80 case 0x02:
81 return EVALUATE_FORMULA;
82 default:
83 throw new BIFFAlert(
84 "Unknown type for CF record"
85 ).culprit( "type", type ).mishap();
86 }
87 }
88
89 }
90
91 private byte[] borderFormattingBlock;
92
93 private ComparisonOperator comparisonOperator;
94
95 private Expr< ? > firstFormulaExpr;
96
97 private byte[] fontFormattingBlock;
98
99 private byte[] patternFormattingBlock;
100
101 private Expr< ? > secondFormulaExpr;
102
103 private Type type;
104
105 /**
106 * @param data The borderFormattingBlock to set.
107 */
108 public void setBorderFormattingBlock( final byte[] data ) {
109 this.borderFormattingBlock = data;
110 }
111
112 /**
113 * @param operator The comparisonOperator to set.
114 */
115 public void setComparisonOperator( final ComparisonOperator operator ) {
116 this.comparisonOperator = operator;
117 }
118
119 /**
120 * @param expr The firstFormulaExpr to set.
121 */
122 public void setFirstFormulaExpr( final Expr< ? > expr ) {
123 this.firstFormulaExpr = expr;
124 }
125
126 /**
127 * @param data The fontFormattingBlock to set.
128 */
129 public void setFontFormattingBlock( final byte[] data ) {
130 this.fontFormattingBlock = data;
131 }
132
133 /**
134 * @param data The patternFormattingBlock to set.
135 */
136 public void setPatternFormattingBlock( final byte[] data ) {
137 this.patternFormattingBlock = data;
138 }
139
140 /**
141 * @param expr The secondFormulaExpr to set.
142 */
143 public void setSecondFormulaExpr( final Expr< ? > expr ) {
144 this.secondFormulaExpr = expr;
145 }
146
147 /**
148 * @param t The type to set.
149 */
150 public void setType( final Type t ) {
151 this.type = t;
152 }
153
154 }