Fix inconsistent indents/whitespace

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691473 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2015-07-17 01:22:39 +00:00
parent 0cde71224d
commit 65acc41519

View File

@ -33,45 +33,44 @@ import org.apache.poi.ss.util.CellRangeAddress;
* The 'Conditional Formatting' facet of <tt>HSSFSheet</tt> * The 'Conditional Formatting' facet of <tt>HSSFSheet</tt>
*/ */
public final class HSSFSheetConditionalFormatting implements SheetConditionalFormatting { public final class HSSFSheetConditionalFormatting implements SheetConditionalFormatting {
private final HSSFSheet _sheet;
private final ConditionalFormattingTable _conditionalFormattingTable;
private final HSSFSheet _sheet; /* package */ HSSFSheetConditionalFormatting(HSSFSheet sheet) {
private final ConditionalFormattingTable _conditionalFormattingTable; _sheet = sheet;
_conditionalFormattingTable = sheet.getSheet().getConditionalFormattingTable();
}
/* package */ HSSFSheetConditionalFormatting(HSSFSheet sheet) { /**
_sheet = sheet; * A factory method allowing to create a conditional formatting rule
_conditionalFormattingTable = sheet.getSheet().getConditionalFormattingTable(); * with a cell comparison operator<p/>
} * TODO - formulas containing cell references are currently not parsed properly
*
/** * @param comparisonOperation - a constant value from
* A factory method allowing to create a conditional formatting rule * <tt>{@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator}</tt>: <p>
* with a cell comparison operator<p/> * <ul>
* TODO - formulas containing cell references are currently not parsed properly * <li>BETWEEN</li>
* * <li>NOT_BETWEEN</li>
* @param comparisonOperation - a constant value from * <li>EQUAL</li>
* <tt>{@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator}</tt>: <p> * <li>NOT_EQUAL</li>
* <ul> * <li>GT</li>
* <li>BETWEEN</li> * <li>LT</li>
* <li>NOT_BETWEEN</li> * <li>GE</li>
* <li>EQUAL</li> * <li>LE</li>
* <li>NOT_EQUAL</li> * </ul>
* <li>GT</li> * </p>
* <li>LT</li> * @param formula1 - formula for the valued, compared with the cell
* <li>GE</li> * @param formula2 - second formula (only used with
* <li>LE</li> * {@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator#BETWEEN}) and
* </ul> * {@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator#NOT_BETWEEN} operations)
* </p> */
* @param formula1 - formula for the valued, compared with the cell public HSSFConditionalFormattingRule createConditionalFormattingRule(
* @param formula2 - second formula (only used with byte comparisonOperation,
* {@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator#BETWEEN}) and String formula1,
* {@link org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator#NOT_BETWEEN} operations) String formula2) {
*/ CFRuleRecord rr = CFRuleRecord.create(_sheet, comparisonOperation, formula1, formula2);
public HSSFConditionalFormattingRule createConditionalFormattingRule( return new HSSFConditionalFormattingRule(_sheet, rr);
byte comparisonOperation, }
String formula1,
String formula2) {
CFRuleRecord rr = CFRuleRecord.create(_sheet, comparisonOperation, formula1, formula2);
return new HSSFConditionalFormattingRule(_sheet, rr);
}
public HSSFConditionalFormattingRule createConditionalFormattingRule( public HSSFConditionalFormattingRule createConditionalFormattingRule(
byte comparisonOperation, byte comparisonOperation,
@ -80,94 +79,94 @@ public final class HSSFSheetConditionalFormatting implements SheetConditionalFor
return new HSSFConditionalFormattingRule(_sheet, rr); return new HSSFConditionalFormattingRule(_sheet, rr);
} }
/** /**
* A factory method allowing to create a conditional formatting rule with a formula.<br> * A factory method allowing to create a conditional formatting rule with a formula.<br>
* *
* The formatting rules are applied by Excel when the value of the formula not equal to 0.<p/> * The formatting rules are applied by Excel when the value of the formula not equal to 0.<p/>
* TODO - formulas containing cell references are currently not parsed properly * TODO - formulas containing cell references are currently not parsed properly
* @param formula - formula for the valued, compared with the cell * @param formula - formula for the valued, compared with the cell
*/ */
public HSSFConditionalFormattingRule createConditionalFormattingRule(String formula) { public HSSFConditionalFormattingRule createConditionalFormattingRule(String formula) {
CFRuleRecord rr = CFRuleRecord.create(_sheet, formula); CFRuleRecord rr = CFRuleRecord.create(_sheet, formula);
return new HSSFConditionalFormattingRule(_sheet, rr); return new HSSFConditionalFormattingRule(_sheet, rr);
} }
/** /**
* A factory method allowing the creation of conditional formatting * A factory method allowing the creation of conditional formatting
* rules using an Icon Set / Multi-State formatting. * rules using an Icon Set / Multi-State formatting.
* The thresholds for it will be created, but will be empty * The thresholds for it will be created, but will be empty
* and require configuring with * and require configuring with
* {@link HSSFConditionalFormattingRule#getMultiStateFormatting()} * {@link HSSFConditionalFormattingRule#getMultiStateFormatting()}
* then * then
* {@link HSSFIconMultiStateFormatting#getThresholds()} * {@link HSSFIconMultiStateFormatting#getThresholds()}
*/ */
public HSSFConditionalFormattingRule createConditionalFormattingRule( public HSSFConditionalFormattingRule createConditionalFormattingRule(
IconSet iconSet) { IconSet iconSet) {
CFRule12Record rr = CFRule12Record.create(_sheet, iconSet); CFRule12Record rr = CFRule12Record.create(_sheet, iconSet);
return new HSSFConditionalFormattingRule(_sheet, rr); return new HSSFConditionalFormattingRule(_sheet, rr);
} }
// TODO Support types beyond CELL_VALUE_IS and FORMULA and ICONs // TODO Support types beyond CELL_VALUE_IS and FORMULA and ICONs
/**
* Adds a copy of HSSFConditionalFormatting object to the sheet
* <p>This method could be used to copy HSSFConditionalFormatting object
* from one sheet to another. For example:
* <pre>
* HSSFConditionalFormatting cf = sheet.getConditionalFormattingAt(index);
* newSheet.addConditionalFormatting(cf);
* </pre>
*
* @param cf HSSFConditionalFormatting object
* @return index of the new Conditional Formatting object
*/
public int addConditionalFormatting( HSSFConditionalFormatting cf ) {
CFRecordsAggregate cfraClone = cf.getCFRecordsAggregate().cloneCFAggregate();
return _conditionalFormattingTable.add(cfraClone); /**
} * Adds a copy of HSSFConditionalFormatting object to the sheet
* <p>This method could be used to copy HSSFConditionalFormatting object
* from one sheet to another. For example:
* <pre>
* HSSFConditionalFormatting cf = sheet.getConditionalFormattingAt(index);
* newSheet.addConditionalFormatting(cf);
* </pre>
*
* @param cf HSSFConditionalFormatting object
* @return index of the new Conditional Formatting object
*/
public int addConditionalFormatting( HSSFConditionalFormatting cf ) {
CFRecordsAggregate cfraClone = cf.getCFRecordsAggregate().cloneCFAggregate();
return _conditionalFormattingTable.add(cfraClone);
}
public int addConditionalFormatting( ConditionalFormatting cf ) { public int addConditionalFormatting( ConditionalFormatting cf ) {
return addConditionalFormatting((HSSFConditionalFormatting)cf); return addConditionalFormatting((HSSFConditionalFormatting)cf);
} }
/** /**
* @deprecated use <tt>CellRangeAddress</tt> instead of <tt>Region</tt> * @deprecated use <tt>CellRangeAddress</tt> instead of <tt>Region</tt>
*/ */
public int addConditionalFormatting(org.apache.poi.ss.util.Region[] regions, HSSFConditionalFormattingRule[] cfRules) { public int addConditionalFormatting(org.apache.poi.ss.util.Region[] regions, HSSFConditionalFormattingRule[] cfRules) {
return addConditionalFormatting(org.apache.poi.ss.util.Region.convertRegionsToCellRanges(regions), cfRules); return addConditionalFormatting(org.apache.poi.ss.util.Region.convertRegionsToCellRanges(regions), cfRules);
} }
/** /**
* Allows to add a new Conditional Formatting set to the sheet. * Allows to add a new Conditional Formatting set to the sheet.
* *
* @param regions - list of rectangular regions to apply conditional formatting rules * @param regions - list of rectangular regions to apply conditional formatting rules
* @param cfRules - set of up to three conditional formatting rules * @param cfRules - set of up to three conditional formatting rules
* *
* @return index of the newly created Conditional Formatting object * @return index of the newly created Conditional Formatting object
*/ */
public int addConditionalFormatting(CellRangeAddress[] regions, HSSFConditionalFormattingRule[] cfRules) { public int addConditionalFormatting(CellRangeAddress[] regions, HSSFConditionalFormattingRule[] cfRules) {
if (regions == null) { if (regions == null) {
throw new IllegalArgumentException("regions must not be null"); throw new IllegalArgumentException("regions must not be null");
} }
for(CellRangeAddress range : regions) range.validate(SpreadsheetVersion.EXCEL97); for(CellRangeAddress range : regions) range.validate(SpreadsheetVersion.EXCEL97);
if (cfRules == null) { if (cfRules == null) {
throw new IllegalArgumentException("cfRules must not be null"); throw new IllegalArgumentException("cfRules must not be null");
} }
if (cfRules.length == 0) { if (cfRules.length == 0) {
throw new IllegalArgumentException("cfRules must not be empty"); throw new IllegalArgumentException("cfRules must not be empty");
} }
if (cfRules.length > 3) { if (cfRules.length > 3) {
throw new IllegalArgumentException("Number of rules must not exceed 3"); throw new IllegalArgumentException("Number of rules must not exceed 3");
} }
CFRuleBase[] rules = new CFRuleBase[cfRules.length]; CFRuleBase[] rules = new CFRuleBase[cfRules.length];
for (int i = 0; i != cfRules.length; i++) { for (int i = 0; i != cfRules.length; i++) {
rules[i] = cfRules[i].getCfRuleRecord(); rules[i] = cfRules[i].getCfRuleRecord();
} }
CFRecordsAggregate cfra = new CFRecordsAggregate(regions, rules); CFRecordsAggregate cfra = new CFRecordsAggregate(regions, rules);
return _conditionalFormattingTable.add(cfra); return _conditionalFormattingTable.add(cfra);
} }
public int addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule[] cfRules) { public int addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule[] cfRules) {
HSSFConditionalFormattingRule[] hfRules; HSSFConditionalFormattingRule[] hfRules;
@ -179,70 +178,61 @@ public final class HSSFSheetConditionalFormatting implements SheetConditionalFor
return addConditionalFormatting(regions, hfRules); return addConditionalFormatting(regions, hfRules);
} }
public int addConditionalFormatting(CellRangeAddress[] regions, public int addConditionalFormatting(CellRangeAddress[] regions,
HSSFConditionalFormattingRule rule1) HSSFConditionalFormattingRule rule1) {
{ return addConditionalFormatting(regions, rule1 == null ?
return addConditionalFormatting(regions, null : new HSSFConditionalFormattingRule[] { rule1 }
rule1 == null ? null : new HSSFConditionalFormattingRule[] );
{ }
rule1
});
}
public int addConditionalFormatting(CellRangeAddress[] regions, public int addConditionalFormatting(CellRangeAddress[] regions,
ConditionalFormattingRule rule1) ConditionalFormattingRule rule1) {
{
return addConditionalFormatting(regions, (HSSFConditionalFormattingRule)rule1); return addConditionalFormatting(regions, (HSSFConditionalFormattingRule)rule1);
} }
public int addConditionalFormatting(CellRangeAddress[] regions, public int addConditionalFormatting(CellRangeAddress[] regions,
HSSFConditionalFormattingRule rule1, HSSFConditionalFormattingRule rule1,
HSSFConditionalFormattingRule rule2) HSSFConditionalFormattingRule rule2) {
{ return addConditionalFormatting(regions,
return addConditionalFormatting(regions, new HSSFConditionalFormattingRule[] { rule1, rule2 });
new HSSFConditionalFormattingRule[] }
{
rule1, rule2
});
}
public int addConditionalFormatting(CellRangeAddress[] regions, public int addConditionalFormatting(CellRangeAddress[] regions,
ConditionalFormattingRule rule1, ConditionalFormattingRule rule1,
ConditionalFormattingRule rule2) ConditionalFormattingRule rule2) {
{
return addConditionalFormatting(regions, return addConditionalFormatting(regions,
(HSSFConditionalFormattingRule)rule1, (HSSFConditionalFormattingRule)rule1,
(HSSFConditionalFormattingRule)rule2 (HSSFConditionalFormattingRule)rule2
); );
} }
/** /**
* gets Conditional Formatting object at a particular index * gets Conditional Formatting object at a particular index
* *
* @param index * @param index
* of the Conditional Formatting object to fetch * of the Conditional Formatting object to fetch
* @return Conditional Formatting object * @return Conditional Formatting object
*/ */
public HSSFConditionalFormatting getConditionalFormattingAt(int index) { public HSSFConditionalFormatting getConditionalFormattingAt(int index) {
CFRecordsAggregate cf = _conditionalFormattingTable.get(index); CFRecordsAggregate cf = _conditionalFormattingTable.get(index);
if (cf == null) { if (cf == null) {
return null; return null;
} }
return new HSSFConditionalFormatting(_sheet, cf); return new HSSFConditionalFormatting(_sheet, cf);
} }
/** /**
* @return number of Conditional Formatting objects of the sheet * @return number of Conditional Formatting objects of the sheet
*/ */
public int getNumConditionalFormattings() { public int getNumConditionalFormattings() {
return _conditionalFormattingTable.size(); return _conditionalFormattingTable.size();
} }
/** /**
* removes a Conditional Formatting object by index * removes a Conditional Formatting object by index
* @param index of a Conditional Formatting object to remove * @param index of a Conditional Formatting object to remove
*/ */
public void removeConditionalFormatting(int index) { public void removeConditionalFormatting(int index) {
_conditionalFormattingTable.remove(index); _conditionalFormattingTable.remove(index);
} }
} }