View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript-Excel: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2005 Open World Ltd, Kevin Rogers
4   //
5   // This file is part of MillScript-Excel.
6   //
7   // MillScript-Excel is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript-Excel is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript-Excel; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
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 }