org.apache.poi.hssf.record
Class CFRuleBase

java.lang.Object
  extended by org.apache.poi.hssf.record.RecordBase
      extended by org.apache.poi.hssf.record.Record
          extended by org.apache.poi.hssf.record.StandardRecord
              extended by org.apache.poi.hssf.record.CFRuleBase
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
CFRule12Record, CFRuleRecord

public abstract class CFRuleBase
extends StandardRecord
implements java.lang.Cloneable

Conditional Formatting Rules. This can hold old-style rules

This is for the older-style Excel conditional formattings, new-style (Excel 2007+) also make use of CFRule12Record for their rules.


Nested Class Summary
static class CFRuleBase.ComparisonOperator
           
 
Field Summary
protected  BorderFormatting _borderFormatting
           
protected  FontFormatting _fontFormatting
           
protected  PatternFormatting _patternFormatting
           
static byte CONDITION_TYPE_CELL_VALUE_IS
           
static byte CONDITION_TYPE_COLOR_SCALE
           
static byte CONDITION_TYPE_DATA_BAR
           
static byte CONDITION_TYPE_FILTER
           
static byte CONDITION_TYPE_FORMULA
           
static byte CONDITION_TYPE_ICON_SET
           
protected  short formatting_not_used
           
protected  int formatting_options
           
protected static POILogger logger
           
static int TEMPLATE_ABOVE_AVERAGE
           
static int TEMPLATE_ABOVE_OR_EQUAL_TO_AVERAGE
           
static int TEMPLATE_BELOW_AVERAGE
           
static int TEMPLATE_BELOW_OR_EQUAL_TO_AVERAGE
           
static int TEMPLATE_CELL_VALUE
           
static int TEMPLATE_COLOR_SCALE_FORMATTING
           
static int TEMPLATE_CONTAINS_BLANKS
           
static int TEMPLATE_CONTAINS_ERRORS
           
static int TEMPLATE_CONTAINS_NO_BLANKS
           
static int TEMPLATE_CONTAINS_NO_ERRORS
           
static int TEMPLATE_CONTAINS_TEXT
           
static int TEMPLATE_DATA_BAR_FORMATTING
           
static int TEMPLATE_DUPLICATE_VALUES
           
static int TEMPLATE_FILTER
           
static int TEMPLATE_FORMULA
           
static int TEMPLATE_ICON_SET_FORMATTING
           
static int TEMPLATE_LAST_7_DAYS
           
static int TEMPLATE_LAST_MONTH
           
static int TEMPLATE_LAST_WEEK
           
static int TEMPLATE_NEXT_MONTH
           
static int TEMPLATE_NEXT_WEEK
           
static int TEMPLATE_THIS_MONTH
           
static int TEMPLATE_THIS_WEEK
           
static int TEMPLATE_TODAY
           
static int TEMPLATE_TOMORROW
           
static int TEMPLATE_UNIQUE_VALUES
           
static int TEMPLATE_YESTERDAY
           
 
Constructor Summary
protected CFRuleBase()
           
protected CFRuleBase(byte conditionType, byte comparisonOperation)
          Creates new CFRuleRecord
protected CFRuleBase(byte conditionType, byte comparisonOperation, Ptg[] formula1, Ptg[] formula2)
           
 
Method Summary
abstract  CFRuleBase clone()
           
 boolean containsAlignFormattingBlock()
           
 boolean containsBorderFormattingBlock()
           
 boolean containsFontFormattingBlock()
           
 boolean containsPatternFormattingBlock()
           
 boolean containsProtectionFormattingBlock()
           
protected  void copyTo(CFRuleBase rec)
           
 BorderFormatting getBorderFormatting()
           
 byte getComparisonOperation()
           
 byte getConditionType()
           
 FontFormatting getFontFormatting()
           
protected  int getFormattingBlockSize()
           
protected  Formula getFormula1()
           
protected  Formula getFormula2()
           
protected static int getFormulaSize(Formula formula)
           
 int getOptions()
          get the option flags
 Ptg[] getParsedExpression1()
          get the stack of the 1st expression as a list
 Ptg[] getParsedExpression2()
          get the stack of the 2nd expression as a list
 PatternFormatting getPatternFormatting()
           
 boolean isBottomBorderModified()
           
 boolean isBottomLeftTopRightBorderModified()
           
 boolean isLeftBorderModified()
           
 boolean isPatternBackgroundColorModified()
           
 boolean isPatternColorModified()
           
 boolean isPatternStyleModified()
           
 boolean isRightBorderModified()
           
 boolean isTopBorderModified()
           
 boolean isTopLeftBottomRightBorderModified()
           
static Ptg[] parseFormula(java.lang.String formula, HSSFSheet sheet)
          TODO - parse conditional format formulas properly i.e.
protected  int readFormatOptions(RecordInputStream in)
           
protected  void serializeFormattingBlock(LittleEndianOutput out)
           
 void setAlignFormattingUnchanged()
           
 void setBorderFormatting(BorderFormatting borderFormatting)
           
 void setBottomBorderModified(boolean modified)
           
 void setBottomLeftTopRightBorderModified(boolean modified)
           
 void setComparisonOperation(byte operation)
           
protected  void setConditionType(byte condition_type)
           
 void setFontFormatting(FontFormatting fontFormatting)
           
protected  void setFormula1(Formula formula1)
           
protected  void setFormula2(Formula formula2)
           
 void setLeftBorderModified(boolean modified)
           
 void setParsedExpression1(Ptg[] ptgs)
           
 void setParsedExpression2(Ptg[] ptgs)
           
 void setPatternBackgroundColorModified(boolean modified)
           
 void setPatternColorModified(boolean modified)
           
 void setPatternFormatting(PatternFormatting patternFormatting)
           
 void setPatternStyleModified(boolean modified)
           
 void setProtectionFormattingUnchanged()
           
 void setRightBorderModified(boolean modified)
           
 void setTopBorderModified(boolean modified)
           
 void setTopLeftBottomRightBorderModified(boolean modified)
           
 
Methods inherited from class org.apache.poi.hssf.record.StandardRecord
getDataSize, getRecordSize, serialize, serialize
 
Methods inherited from class org.apache.poi.hssf.record.Record
cloneViaReserialise, getSid, serialize, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static final POILogger logger

CONDITION_TYPE_CELL_VALUE_IS

public static final byte CONDITION_TYPE_CELL_VALUE_IS
See Also:
Constant Field Values

CONDITION_TYPE_FORMULA

public static final byte CONDITION_TYPE_FORMULA
See Also:
Constant Field Values

CONDITION_TYPE_COLOR_SCALE

public static final byte CONDITION_TYPE_COLOR_SCALE
See Also:
Constant Field Values

CONDITION_TYPE_DATA_BAR

public static final byte CONDITION_TYPE_DATA_BAR
See Also:
Constant Field Values

CONDITION_TYPE_FILTER

public static final byte CONDITION_TYPE_FILTER
See Also:
Constant Field Values

CONDITION_TYPE_ICON_SET

public static final byte CONDITION_TYPE_ICON_SET
See Also:
Constant Field Values

TEMPLATE_CELL_VALUE

public static final int TEMPLATE_CELL_VALUE
See Also:
Constant Field Values

TEMPLATE_FORMULA

public static final int TEMPLATE_FORMULA
See Also:
Constant Field Values

TEMPLATE_COLOR_SCALE_FORMATTING

public static final int TEMPLATE_COLOR_SCALE_FORMATTING
See Also:
Constant Field Values

TEMPLATE_DATA_BAR_FORMATTING

public static final int TEMPLATE_DATA_BAR_FORMATTING
See Also:
Constant Field Values

TEMPLATE_ICON_SET_FORMATTING

public static final int TEMPLATE_ICON_SET_FORMATTING
See Also:
Constant Field Values

TEMPLATE_FILTER

public static final int TEMPLATE_FILTER
See Also:
Constant Field Values

TEMPLATE_UNIQUE_VALUES

public static final int TEMPLATE_UNIQUE_VALUES
See Also:
Constant Field Values

TEMPLATE_CONTAINS_TEXT

public static final int TEMPLATE_CONTAINS_TEXT
See Also:
Constant Field Values

TEMPLATE_CONTAINS_BLANKS

public static final int TEMPLATE_CONTAINS_BLANKS
See Also:
Constant Field Values

TEMPLATE_CONTAINS_NO_BLANKS

public static final int TEMPLATE_CONTAINS_NO_BLANKS
See Also:
Constant Field Values

TEMPLATE_CONTAINS_ERRORS

public static final int TEMPLATE_CONTAINS_ERRORS
See Also:
Constant Field Values

TEMPLATE_CONTAINS_NO_ERRORS

public static final int TEMPLATE_CONTAINS_NO_ERRORS
See Also:
Constant Field Values

TEMPLATE_TODAY

public static final int TEMPLATE_TODAY
See Also:
Constant Field Values

TEMPLATE_TOMORROW

public static final int TEMPLATE_TOMORROW
See Also:
Constant Field Values

TEMPLATE_YESTERDAY

public static final int TEMPLATE_YESTERDAY
See Also:
Constant Field Values

TEMPLATE_LAST_7_DAYS

public static final int TEMPLATE_LAST_7_DAYS
See Also:
Constant Field Values

TEMPLATE_LAST_MONTH

public static final int TEMPLATE_LAST_MONTH
See Also:
Constant Field Values

TEMPLATE_NEXT_MONTH

public static final int TEMPLATE_NEXT_MONTH
See Also:
Constant Field Values

TEMPLATE_THIS_WEEK

public static final int TEMPLATE_THIS_WEEK
See Also:
Constant Field Values

TEMPLATE_NEXT_WEEK

public static final int TEMPLATE_NEXT_WEEK
See Also:
Constant Field Values

TEMPLATE_LAST_WEEK

public static final int TEMPLATE_LAST_WEEK
See Also:
Constant Field Values

TEMPLATE_THIS_MONTH

public static final int TEMPLATE_THIS_MONTH
See Also:
Constant Field Values

TEMPLATE_ABOVE_AVERAGE

public static final int TEMPLATE_ABOVE_AVERAGE
See Also:
Constant Field Values

TEMPLATE_BELOW_AVERAGE

public static final int TEMPLATE_BELOW_AVERAGE
See Also:
Constant Field Values

TEMPLATE_DUPLICATE_VALUES

public static final int TEMPLATE_DUPLICATE_VALUES
See Also:
Constant Field Values

TEMPLATE_ABOVE_OR_EQUAL_TO_AVERAGE

public static final int TEMPLATE_ABOVE_OR_EQUAL_TO_AVERAGE
See Also:
Constant Field Values

TEMPLATE_BELOW_OR_EQUAL_TO_AVERAGE

public static final int TEMPLATE_BELOW_OR_EQUAL_TO_AVERAGE
See Also:
Constant Field Values

formatting_options

protected int formatting_options

formatting_not_used

protected short formatting_not_used

_fontFormatting

protected FontFormatting _fontFormatting

_borderFormatting

protected BorderFormatting _borderFormatting

_patternFormatting

protected PatternFormatting _patternFormatting
Constructor Detail

CFRuleBase

protected CFRuleBase(byte conditionType,
                     byte comparisonOperation)
Creates new CFRuleRecord

Parameters:
conditionType - the condition type
comparisonOperation - the comparison operation

CFRuleBase

protected CFRuleBase(byte conditionType,
                     byte comparisonOperation,
                     Ptg[] formula1,
                     Ptg[] formula2)

CFRuleBase

protected CFRuleBase()
Method Detail

readFormatOptions

protected int readFormatOptions(RecordInputStream in)

getConditionType

public byte getConditionType()

setConditionType

protected void setConditionType(byte condition_type)

setComparisonOperation

public void setComparisonOperation(byte operation)

getComparisonOperation

public byte getComparisonOperation()

containsFontFormattingBlock

public boolean containsFontFormattingBlock()

setFontFormatting

public void setFontFormatting(FontFormatting fontFormatting)

getFontFormatting

public FontFormatting getFontFormatting()

containsAlignFormattingBlock

public boolean containsAlignFormattingBlock()

setAlignFormattingUnchanged

public void setAlignFormattingUnchanged()

containsBorderFormattingBlock

public boolean containsBorderFormattingBlock()

setBorderFormatting

public void setBorderFormatting(BorderFormatting borderFormatting)

getBorderFormatting

public BorderFormatting getBorderFormatting()

containsPatternFormattingBlock

public boolean containsPatternFormattingBlock()

setPatternFormatting

public void setPatternFormatting(PatternFormatting patternFormatting)

getPatternFormatting

public PatternFormatting getPatternFormatting()

containsProtectionFormattingBlock

public boolean containsProtectionFormattingBlock()

setProtectionFormattingUnchanged

public void setProtectionFormattingUnchanged()

getOptions

public int getOptions()
get the option flags

Returns:
bit mask

isLeftBorderModified

public boolean isLeftBorderModified()

setLeftBorderModified

public void setLeftBorderModified(boolean modified)

isRightBorderModified

public boolean isRightBorderModified()

setRightBorderModified

public void setRightBorderModified(boolean modified)

isTopBorderModified

public boolean isTopBorderModified()

setTopBorderModified

public void setTopBorderModified(boolean modified)

isBottomBorderModified

public boolean isBottomBorderModified()

setBottomBorderModified

public void setBottomBorderModified(boolean modified)

isTopLeftBottomRightBorderModified

public boolean isTopLeftBottomRightBorderModified()

setTopLeftBottomRightBorderModified

public void setTopLeftBottomRightBorderModified(boolean modified)

isBottomLeftTopRightBorderModified

public boolean isBottomLeftTopRightBorderModified()

setBottomLeftTopRightBorderModified

public void setBottomLeftTopRightBorderModified(boolean modified)

isPatternStyleModified

public boolean isPatternStyleModified()

setPatternStyleModified

public void setPatternStyleModified(boolean modified)

isPatternColorModified

public boolean isPatternColorModified()

setPatternColorModified

public void setPatternColorModified(boolean modified)

isPatternBackgroundColorModified

public boolean isPatternBackgroundColorModified()

setPatternBackgroundColorModified

public void setPatternBackgroundColorModified(boolean modified)

getFormattingBlockSize

protected int getFormattingBlockSize()

serializeFormattingBlock

protected void serializeFormattingBlock(LittleEndianOutput out)

getParsedExpression1

public Ptg[] getParsedExpression1()
get the stack of the 1st expression as a list

Returns:
list of tokens (casts stack to a list and returns it!) this method can return null is we are unable to create Ptgs from existing excel file callers should check for null!

setParsedExpression1

public void setParsedExpression1(Ptg[] ptgs)

getFormula1

protected Formula getFormula1()

setFormula1

protected void setFormula1(Formula formula1)

getParsedExpression2

public Ptg[] getParsedExpression2()
get the stack of the 2nd expression as a list

Returns:
array of Ptgs, possibly null

setParsedExpression2

public void setParsedExpression2(Ptg[] ptgs)

getFormula2

protected Formula getFormula2()

setFormula2

protected void setFormula2(Formula formula2)

getFormulaSize

protected static int getFormulaSize(Formula formula)
Parameters:
formula - must not be null
Returns:
encoded size of the formula tokens (does not include 2 bytes for ushort length)

parseFormula

public static Ptg[] parseFormula(java.lang.String formula,
                                 HSSFSheet sheet)
TODO - parse conditional format formulas properly i.e. produce tRefN and tAreaN instead of tRef and tArea this call will produce the wrong results if the formula contains any cell references One approach might be to apply the inverse of SharedFormulaRecord.convertSharedFormulas(Stack, int, int) Note - two extra parameters (rowIx & colIx) will be required. They probably come from one of the Region objects.

Parameters:
formula - The formula to parse, excluding the leading equals sign.
sheet - The sheet that the formula is on.
Returns:
null if formula was null.

copyTo

protected void copyTo(CFRuleBase rec)

clone

public abstract CFRuleBase clone()
Overrides:
clone in class Record