Fix inconsistent whitespace/formatting
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691049 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2eb88db1b0
commit
894029a48f
@ -35,182 +35,179 @@ import org.apache.poi.ss.usermodel.ConditionalFormattingRule;
|
|||||||
* and the formatting settings such as font, border and pattern.
|
* and the formatting settings such as font, border and pattern.
|
||||||
*/
|
*/
|
||||||
public final class HSSFConditionalFormattingRule implements ConditionalFormattingRule {
|
public final class HSSFConditionalFormattingRule implements ConditionalFormattingRule {
|
||||||
private static final byte CELL_COMPARISON = CFRuleRecord.CONDITION_TYPE_CELL_VALUE_IS;
|
private static final byte CELL_COMPARISON = CFRuleRecord.CONDITION_TYPE_CELL_VALUE_IS;
|
||||||
|
|
||||||
private final CFRuleBase cfRuleRecord;
|
private final CFRuleBase cfRuleRecord;
|
||||||
private final HSSFWorkbook workbook;
|
private final HSSFWorkbook workbook;
|
||||||
|
|
||||||
HSSFConditionalFormattingRule(HSSFWorkbook pWorkbook, CFRuleBase pRuleRecord) {
|
HSSFConditionalFormattingRule(HSSFWorkbook pWorkbook, CFRuleBase pRuleRecord) {
|
||||||
if (pWorkbook == null) {
|
if (pWorkbook == null) {
|
||||||
throw new IllegalArgumentException("pWorkbook must not be null");
|
throw new IllegalArgumentException("pWorkbook must not be null");
|
||||||
}
|
}
|
||||||
if (pRuleRecord == null) {
|
if (pRuleRecord == null) {
|
||||||
throw new IllegalArgumentException("pRuleRecord must not be null");
|
throw new IllegalArgumentException("pRuleRecord must not be null");
|
||||||
}
|
}
|
||||||
workbook = pWorkbook;
|
workbook = pWorkbook;
|
||||||
cfRuleRecord = pRuleRecord;
|
cfRuleRecord = pRuleRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRuleBase getCfRuleRecord()
|
CFRuleBase getCfRuleRecord()
|
||||||
{
|
{
|
||||||
return cfRuleRecord;
|
return cfRuleRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HSSFFontFormatting getFontFormatting(boolean create)
|
private HSSFFontFormatting getFontFormatting(boolean create)
|
||||||
{
|
{
|
||||||
FontFormatting fontFormatting = cfRuleRecord.getFontFormatting();
|
FontFormatting fontFormatting = cfRuleRecord.getFontFormatting();
|
||||||
if ( fontFormatting != null)
|
if ( fontFormatting != null)
|
||||||
{
|
{
|
||||||
cfRuleRecord.setFontFormatting(fontFormatting);
|
cfRuleRecord.setFontFormatting(fontFormatting);
|
||||||
return new HSSFFontFormatting(cfRuleRecord, workbook);
|
return new HSSFFontFormatting(cfRuleRecord, workbook);
|
||||||
}
|
}
|
||||||
else if( create )
|
else if( create )
|
||||||
{
|
{
|
||||||
fontFormatting = new FontFormatting();
|
fontFormatting = new FontFormatting();
|
||||||
cfRuleRecord.setFontFormatting(fontFormatting);
|
cfRuleRecord.setFontFormatting(fontFormatting);
|
||||||
return new HSSFFontFormatting(cfRuleRecord, workbook);
|
return new HSSFFontFormatting(cfRuleRecord, workbook);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return - font formatting object if defined, <code>null</code> otherwise
|
* @return - font formatting object if defined, <code>null</code> otherwise
|
||||||
*/
|
*/
|
||||||
public HSSFFontFormatting getFontFormatting()
|
public HSSFFontFormatting getFontFormatting()
|
||||||
{
|
{
|
||||||
return getFontFormatting(false);
|
return getFontFormatting(false);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* create a new font formatting structure if it does not exist,
|
* create a new font formatting structure if it does not exist,
|
||||||
* otherwise just return existing object.
|
* otherwise just return existing object.
|
||||||
* @return - font formatting object, never returns <code>null</code>.
|
* @return - font formatting object, never returns <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public HSSFFontFormatting createFontFormatting()
|
public HSSFFontFormatting createFontFormatting()
|
||||||
{
|
{
|
||||||
return getFontFormatting(true);
|
return getFontFormatting(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HSSFBorderFormatting getBorderFormatting(boolean create)
|
private HSSFBorderFormatting getBorderFormatting(boolean create)
|
||||||
{
|
{
|
||||||
BorderFormatting borderFormatting = cfRuleRecord.getBorderFormatting();
|
BorderFormatting borderFormatting = cfRuleRecord.getBorderFormatting();
|
||||||
if ( borderFormatting != null)
|
if ( borderFormatting != null)
|
||||||
{
|
{
|
||||||
cfRuleRecord.setBorderFormatting(borderFormatting);
|
cfRuleRecord.setBorderFormatting(borderFormatting);
|
||||||
return new HSSFBorderFormatting(cfRuleRecord);
|
return new HSSFBorderFormatting(cfRuleRecord);
|
||||||
}
|
}
|
||||||
else if( create )
|
else if( create )
|
||||||
{
|
{
|
||||||
borderFormatting = new BorderFormatting();
|
borderFormatting = new BorderFormatting();
|
||||||
cfRuleRecord.setBorderFormatting(borderFormatting);
|
cfRuleRecord.setBorderFormatting(borderFormatting);
|
||||||
return new HSSFBorderFormatting(cfRuleRecord);
|
return new HSSFBorderFormatting(cfRuleRecord);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return - border formatting object if defined, <code>null</code> otherwise
|
* @return - border formatting object if defined, <code>null</code> otherwise
|
||||||
*/
|
*/
|
||||||
public HSSFBorderFormatting getBorderFormatting()
|
public HSSFBorderFormatting getBorderFormatting()
|
||||||
{
|
{
|
||||||
return getBorderFormatting(false);
|
return getBorderFormatting(false);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* create a new border formatting structure if it does not exist,
|
* create a new border formatting structure if it does not exist,
|
||||||
* otherwise just return existing object.
|
* otherwise just return existing object.
|
||||||
* @return - border formatting object, never returns <code>null</code>.
|
* @return - border formatting object, never returns <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public HSSFBorderFormatting createBorderFormatting()
|
public HSSFBorderFormatting createBorderFormatting()
|
||||||
{
|
{
|
||||||
return getBorderFormatting(true);
|
return getBorderFormatting(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HSSFPatternFormatting getPatternFormatting(boolean create)
|
private HSSFPatternFormatting getPatternFormatting(boolean create)
|
||||||
{
|
{
|
||||||
PatternFormatting patternFormatting = cfRuleRecord.getPatternFormatting();
|
PatternFormatting patternFormatting = cfRuleRecord.getPatternFormatting();
|
||||||
if ( patternFormatting != null)
|
if ( patternFormatting != null)
|
||||||
{
|
{
|
||||||
cfRuleRecord.setPatternFormatting(patternFormatting);
|
cfRuleRecord.setPatternFormatting(patternFormatting);
|
||||||
return new HSSFPatternFormatting(cfRuleRecord, workbook);
|
return new HSSFPatternFormatting(cfRuleRecord, workbook);
|
||||||
}
|
}
|
||||||
else if( create )
|
else if( create )
|
||||||
{
|
{
|
||||||
patternFormatting = new PatternFormatting();
|
patternFormatting = new PatternFormatting();
|
||||||
cfRuleRecord.setPatternFormatting(patternFormatting);
|
cfRuleRecord.setPatternFormatting(patternFormatting);
|
||||||
return new HSSFPatternFormatting(cfRuleRecord, workbook);
|
return new HSSFPatternFormatting(cfRuleRecord, workbook);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return - pattern formatting object if defined, <code>null</code> otherwise
|
* @return - pattern formatting object if defined, <code>null</code> otherwise
|
||||||
*/
|
*/
|
||||||
public HSSFPatternFormatting getPatternFormatting()
|
public HSSFPatternFormatting getPatternFormatting()
|
||||||
{
|
{
|
||||||
return getPatternFormatting(false);
|
return getPatternFormatting(false);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* create a new pattern formatting structure if it does not exist,
|
* create a new pattern formatting structure if it does not exist,
|
||||||
* otherwise just return existing object.
|
* otherwise just return existing object.
|
||||||
* @return - pattern formatting object, never returns <code>null</code>.
|
* @return - pattern formatting object, never returns <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public HSSFPatternFormatting createPatternFormatting()
|
public HSSFPatternFormatting createPatternFormatting()
|
||||||
{
|
{
|
||||||
return getPatternFormatting(true);
|
return getPatternFormatting(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return - the conditiontype for the cfrule
|
|
||||||
*/
|
|
||||||
public byte getConditionType() {
|
|
||||||
return cfRuleRecord.getConditionType();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return - the conditiontype for the cfrule
|
* @return - the conditiontype for the cfrule
|
||||||
*/
|
*/
|
||||||
public ConditionType getConditionTypeType() {
|
public byte getConditionType() {
|
||||||
return ConditionType.forId(getConditionType());
|
return cfRuleRecord.getConditionType();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @return - the conditiontype for the cfrule
|
||||||
|
*/
|
||||||
|
public ConditionType getConditionTypeType() {
|
||||||
|
return ConditionType.forId(getConditionType());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return - the comparisionoperatation for the cfrule
|
* @return - the comparisionoperatation for the cfrule
|
||||||
*/
|
*/
|
||||||
public byte getComparisonOperation() {
|
public byte getComparisonOperation() {
|
||||||
return cfRuleRecord.getComparisonOperation();
|
return cfRuleRecord.getComparisonOperation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFormula1()
|
public String getFormula1()
|
||||||
{
|
{
|
||||||
return toFormulaString(cfRuleRecord.getParsedExpression1());
|
return toFormulaString(cfRuleRecord.getParsedExpression1());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFormula2()
|
public String getFormula2() {
|
||||||
{
|
byte conditionType = cfRuleRecord.getConditionType();
|
||||||
byte conditionType = cfRuleRecord.getConditionType();
|
if (conditionType == CELL_COMPARISON) {
|
||||||
if (conditionType == CELL_COMPARISON) {
|
byte comparisonOperation = cfRuleRecord.getComparisonOperation();
|
||||||
byte comparisonOperation = cfRuleRecord.getComparisonOperation();
|
switch(comparisonOperation) {
|
||||||
switch(comparisonOperation)
|
case ComparisonOperator.BETWEEN:
|
||||||
{
|
case ComparisonOperator.NOT_BETWEEN:
|
||||||
case ComparisonOperator.BETWEEN:
|
return toFormulaString(cfRuleRecord.getParsedExpression2());
|
||||||
case ComparisonOperator.NOT_BETWEEN:
|
}
|
||||||
return toFormulaString(cfRuleRecord.getParsedExpression2());
|
}
|
||||||
}
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String toFormulaString(Ptg[] parsedExpression)
|
private String toFormulaString(Ptg[] parsedExpression) {
|
||||||
{
|
if(parsedExpression ==null) {
|
||||||
if(parsedExpression ==null) {
|
return null;
|
||||||
return null;
|
}
|
||||||
}
|
return HSSFFormulaParser.toFormulaString(workbook, parsedExpression);
|
||||||
return HSSFFormulaParser.toFormulaString(workbook, parsedExpression);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,25 +25,23 @@ import org.apache.poi.ss.usermodel.Color;
|
|||||||
/**
|
/**
|
||||||
* High level representation for Conditional Formatting settings
|
* High level representation for Conditional Formatting settings
|
||||||
*/
|
*/
|
||||||
public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.PatternFormatting
|
public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.PatternFormatting {
|
||||||
{
|
|
||||||
private final HSSFWorkbook workbook;
|
private final HSSFWorkbook workbook;
|
||||||
private final CFRuleBase cfRuleRecord;
|
private final CFRuleBase cfRuleRecord;
|
||||||
private final PatternFormatting patternFormatting;
|
private final PatternFormatting patternFormatting;
|
||||||
|
|
||||||
protected HSSFPatternFormatting(CFRuleBase cfRuleRecord, HSSFWorkbook workbook)
|
|
||||||
{
|
|
||||||
this.workbook = workbook;
|
|
||||||
this.cfRuleRecord = cfRuleRecord;
|
|
||||||
this.patternFormatting = cfRuleRecord.getPatternFormatting();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected PatternFormatting getPatternFormattingBlock()
|
protected HSSFPatternFormatting(CFRuleBase cfRuleRecord, HSSFWorkbook workbook) {
|
||||||
{
|
this.workbook = workbook;
|
||||||
return patternFormatting;
|
this.cfRuleRecord = cfRuleRecord;
|
||||||
}
|
this.patternFormatting = cfRuleRecord.getPatternFormatting();
|
||||||
|
}
|
||||||
|
|
||||||
public HSSFColor getFillBackgroundColorColor() {
|
protected PatternFormatting getPatternFormattingBlock()
|
||||||
|
{
|
||||||
|
return patternFormatting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HSSFColor getFillBackgroundColorColor() {
|
||||||
return workbook.getCustomPalette().getColor(getFillBackgroundColor());
|
return workbook.getCustomPalette().getColor(getFillBackgroundColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,40 +50,40 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillBackgroundColor()
|
* @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillBackgroundColor()
|
||||||
*/
|
*/
|
||||||
public short getFillBackgroundColor()
|
public short getFillBackgroundColor()
|
||||||
{
|
{
|
||||||
return (short)patternFormatting.getFillBackgroundColor();
|
return (short)patternFormatting.getFillBackgroundColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillForegroundColor()
|
* @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillForegroundColor()
|
||||||
*/
|
*/
|
||||||
public short getFillForegroundColor()
|
public short getFillForegroundColor()
|
||||||
{
|
{
|
||||||
return (short)patternFormatting.getFillForegroundColor();
|
return (short)patternFormatting.getFillForegroundColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillPattern()
|
* @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillPattern()
|
||||||
*/
|
*/
|
||||||
public short getFillPattern()
|
public short getFillPattern()
|
||||||
{
|
{
|
||||||
return (short)patternFormatting.getFillPattern();
|
return (short)patternFormatting.getFillPattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFillBackgroundColor(Color bg) {
|
public void setFillBackgroundColor(Color bg) {
|
||||||
if (bg != null && !(bg instanceof HSSFColor)) {
|
if (bg != null && !(bg instanceof HSSFColor)) {
|
||||||
throw new IllegalArgumentException("Only HSSFColor objects are supported");
|
throw new IllegalArgumentException("Only HSSFColor objects are supported");
|
||||||
}
|
}
|
||||||
HSSFColor hcolor = (HSSFColor)bg;
|
HSSFColor hcolor = (HSSFColor)bg;
|
||||||
if (hcolor == null) {
|
if (hcolor == null) {
|
||||||
setFillBackgroundColor((short)0);
|
setFillBackgroundColor((short)0);
|
||||||
} else {
|
} else {
|
||||||
setFillBackgroundColor(hcolor.getIndex());
|
setFillBackgroundColor(hcolor.getIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFillForegroundColor(Color fg) {
|
public void setFillForegroundColor(Color fg) {
|
||||||
if (fg != null && !(fg instanceof HSSFColor)) {
|
if (fg != null && !(fg instanceof HSSFColor)) {
|
||||||
@ -100,41 +98,41 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bg
|
* @param bg
|
||||||
* @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillBackgroundColor(int)
|
* @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillBackgroundColor(int)
|
||||||
*/
|
*/
|
||||||
public void setFillBackgroundColor(short bg)
|
public void setFillBackgroundColor(short bg)
|
||||||
{
|
{
|
||||||
patternFormatting.setFillBackgroundColor(bg);
|
patternFormatting.setFillBackgroundColor(bg);
|
||||||
if( bg != 0)
|
if( bg != 0)
|
||||||
{
|
{
|
||||||
cfRuleRecord.setPatternBackgroundColorModified(true);
|
cfRuleRecord.setPatternBackgroundColorModified(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fg
|
* @param fg
|
||||||
* @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillForegroundColor(int)
|
* @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillForegroundColor(int)
|
||||||
*/
|
*/
|
||||||
public void setFillForegroundColor(short fg)
|
public void setFillForegroundColor(short fg)
|
||||||
{
|
{
|
||||||
patternFormatting.setFillForegroundColor(fg);
|
patternFormatting.setFillForegroundColor(fg);
|
||||||
if( fg != 0)
|
if( fg != 0)
|
||||||
{
|
{
|
||||||
cfRuleRecord.setPatternColorModified(true);
|
cfRuleRecord.setPatternColorModified(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fp
|
* @param fp
|
||||||
* @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillPattern(int)
|
* @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillPattern(int)
|
||||||
*/
|
*/
|
||||||
public void setFillPattern(short fp)
|
public void setFillPattern(short fp)
|
||||||
{
|
{
|
||||||
patternFormatting.setFillPattern(fp);
|
patternFormatting.setFillPattern(fp);
|
||||||
if( fp != 0)
|
if( fp != 0)
|
||||||
{
|
{
|
||||||
cfRuleRecord.setPatternStyleModified(true);
|
cfRuleRecord.setPatternStyleModified(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user