Changed CRLF to LF in .java base src files. Minor reformatting fixes.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@776377 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e6a53dc85b
commit
bae270a565
@ -44,7 +44,7 @@ public final class HSSFFormulaParser {
|
||||
* Convenience method for parsing cell formulas. see {@link #parse(String, HSSFWorkbook, int)}
|
||||
*/
|
||||
public static Ptg[] parse(String formula, HSSFWorkbook workbook) {
|
||||
return parse(formula, workbook, FormulaType.CELL);
|
||||
return parse(formula, workbook, FormulaType.CELL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,19 +55,19 @@ public final class HSSFFormulaParser {
|
||||
return parse(formula, workbook, formulaType, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param formula the formula to parse
|
||||
* @param workbook the parent workbook
|
||||
* @param formulaType a constant from {@link FormulaType}
|
||||
* @param sheetIndex the 0-based index of the sheet this formula belongs to.
|
||||
* The sheet index is required to resolve sheet-level names. <code>-1</code> means that
|
||||
* the scope of the name will be ignored and the parser will match named ranges only by name
|
||||
*
|
||||
* @return the parsed formula tokens
|
||||
*/
|
||||
public static Ptg[] parse(String formula, HSSFWorkbook workbook, int formulaType, int sheetIndex) {
|
||||
return FormulaParser.parse(formula, createParsingWorkbook(workbook), formulaType, sheetIndex);
|
||||
}
|
||||
/**
|
||||
* @param formula the formula to parse
|
||||
* @param workbook the parent workbook
|
||||
* @param formulaType a constant from {@link FormulaType}
|
||||
* @param sheetIndex the 0-based index of the sheet this formula belongs to.
|
||||
* The sheet index is required to resolve sheet-level names. <code>-1</code> means that
|
||||
* the scope of the name will be ignored and the parser will match named ranges only by name
|
||||
*
|
||||
* @return the parsed formula tokens
|
||||
*/
|
||||
public static Ptg[] parse(String formula, HSSFWorkbook workbook, int formulaType, int sheetIndex) {
|
||||
return FormulaParser.parse(formula, createParsingWorkbook(workbook), formulaType, sheetIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static method to convert an array of {@link Ptg}s in RPN order
|
||||
|
@ -227,7 +227,7 @@ public final class ContinuableRecordOutput implements LittleEndianOutput {
|
||||
/**
|
||||
* Allows optimised usage of {@link ContinuableRecordOutput} for sizing purposes only.
|
||||
*/
|
||||
private static final LittleEndianOutput NOPOutput = new DelayableLittleEndianOutput() {
|
||||
private static final LittleEndianOutput NOPOutput = new DelayableLittleEndianOutput() {
|
||||
|
||||
public LittleEndianOutput createDelayedOutput(int size) {
|
||||
return this;
|
||||
@ -253,5 +253,5 @@ public final class ContinuableRecordOutput implements LittleEndianOutput {
|
||||
public void writeShort(int v) {
|
||||
// does nothing
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import org.apache.poi.ss.formula.WorkbookEvaluator;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellValue;
|
||||
import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
|
||||
/**
|
||||
* Evaluates formula cells.<p/>
|
||||
@ -277,11 +278,11 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator {
|
||||
for(int i=0; i<wb.getNumberOfSheets(); i++) {
|
||||
HSSFSheet sheet = wb.getSheetAt(i);
|
||||
|
||||
for (Iterator rit = sheet.rowIterator(); rit.hasNext();) {
|
||||
HSSFRow r = (HSSFRow)rit.next();
|
||||
for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();) {
|
||||
Row r = rit.next();
|
||||
|
||||
for (Iterator cit = r.cellIterator(); cit.hasNext();) {
|
||||
HSSFCell c = (HSSFCell)cit.next();
|
||||
for (Iterator<Cell> cit = r.cellIterator(); cit.hasNext();) {
|
||||
Cell c = cit.next();
|
||||
if (c.getCellType() == HSSFCell.CELL_TYPE_FORMULA)
|
||||
evaluator.evaluateFormulaCell(c);
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
package org.apache.poi.hssf.usermodel;
|
||||
|
||||
import org.apache.poi.hssf.model.Sheet;
|
||||
import org.apache.poi.hssf.record.CFRuleRecord;
|
||||
import org.apache.poi.hssf.record.aggregates.CFRecordsAggregate;
|
||||
import org.apache.poi.hssf.record.aggregates.ConditionalFormattingTable;
|
||||
@ -32,13 +31,13 @@ import org.apache.poi.ss.SpreadsheetVersion;
|
||||
*/
|
||||
public final class HSSFSheetConditionalFormatting {
|
||||
|
||||
private final HSSFSheet _sheet;
|
||||
private final HSSFSheet _sheet;
|
||||
private final ConditionalFormattingTable _conditionalFormattingTable;
|
||||
|
||||
/* package */ HSSFSheetConditionalFormatting(HSSFSheet sheet) {
|
||||
_sheet = sheet;
|
||||
_conditionalFormattingTable = sheet.getSheet().getConditionalFormattingTable();
|
||||
}
|
||||
/* package */ HSSFSheetConditionalFormatting(HSSFSheet sheet) {
|
||||
_sheet = sheet;
|
||||
_conditionalFormattingTable = sheet.getSheet().getConditionalFormattingTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* A factory method allowing to create a conditional formatting rule
|
||||
@ -81,7 +80,7 @@ public final class HSSFSheetConditionalFormatting {
|
||||
* @param formula - formula for the valued, compared with the cell
|
||||
*/
|
||||
public HSSFConditionalFormattingRule createConditionalFormattingRule(String formula) {
|
||||
HSSFWorkbook wb = _sheet.getWorkbook();
|
||||
HSSFWorkbook wb = _sheet.getWorkbook();
|
||||
CFRuleRecord rr = CFRuleRecord.create(_sheet, formula);
|
||||
return new HSSFConditionalFormattingRule(wb, rr);
|
||||
}
|
||||
@ -121,9 +120,9 @@ public final class HSSFSheetConditionalFormatting {
|
||||
if (regions == 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");
|
||||
}
|
||||
if (cfRules.length == 0) {
|
||||
|
@ -29,40 +29,40 @@ import org.apache.poi.ss.util.CellReference;
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public enum SpreadsheetVersion {
|
||||
/**
|
||||
* Excel97 format aka BIFF8
|
||||
* <ul>
|
||||
* <li>The total number of available columns is 256 (2^8)</li>
|
||||
* <li>The total number of available rows is 64k (2^16)</li>
|
||||
* <li>The maximum number of arguments to a function is 30</li>
|
||||
* <li>Number of conditional format conditions on a cell is 3</li>
|
||||
* </ul>
|
||||
*/
|
||||
/**
|
||||
* Excel97 format aka BIFF8
|
||||
* <ul>
|
||||
* <li>The total number of available columns is 256 (2^8)</li>
|
||||
* <li>The total number of available rows is 64k (2^16)</li>
|
||||
* <li>The maximum number of arguments to a function is 30</li>
|
||||
* <li>Number of conditional format conditions on a cell is 3</li>
|
||||
* </ul>
|
||||
*/
|
||||
EXCEL97(0x10000, 0x0100, 30, 3),
|
||||
|
||||
/**
|
||||
* Excel2007
|
||||
*
|
||||
* <ul>
|
||||
* <li>The total number of available columns is 16K (2^14)</li>
|
||||
* <li>The total number of available rows is 1M (2^20)</li>
|
||||
* <li>The maximum number of arguments to a function is 255</li>
|
||||
* <li>Number of conditional format conditions on a cell is unlimited
|
||||
* (actually limited by available memory in Excel)</li>
|
||||
* <ul>
|
||||
*/
|
||||
EXCEL2007(0x100000, 0x4000, 255, Integer.MAX_VALUE);
|
||||
/**
|
||||
* Excel2007
|
||||
*
|
||||
* <ul>
|
||||
* <li>The total number of available columns is 16K (2^14)</li>
|
||||
* <li>The total number of available rows is 1M (2^20)</li>
|
||||
* <li>The maximum number of arguments to a function is 255</li>
|
||||
* <li>Number of conditional format conditions on a cell is unlimited
|
||||
* (actually limited by available memory in Excel)</li>
|
||||
* <ul>
|
||||
*/
|
||||
EXCEL2007(0x100000, 0x4000, 255, Integer.MAX_VALUE);
|
||||
|
||||
private final int _maxRows;
|
||||
private final int _maxColumns;
|
||||
private final int _maxFunctionArgs;
|
||||
private final int _maxCondFormats;
|
||||
private final int _maxCondFormats;
|
||||
|
||||
private SpreadsheetVersion(int maxRows, int maxColumns, int maxFunctionArgs, int maxCondFormats) {
|
||||
_maxRows = maxRows;
|
||||
_maxColumns = maxColumns;
|
||||
_maxFunctionArgs = maxFunctionArgs;
|
||||
_maxCondFormats = maxCondFormats;
|
||||
_maxCondFormats = maxCondFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,12 +72,12 @@ public enum SpreadsheetVersion {
|
||||
return _maxRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the last (maximum) valid row index, equals to <code> getMaxRows() - 1 </code>
|
||||
*/
|
||||
public int getLastRowIndex() {
|
||||
return _maxRows - 1;
|
||||
}
|
||||
/**
|
||||
* @return the last (maximum) valid row index, equals to <code> getMaxRows() - 1 </code>
|
||||
*/
|
||||
public int getLastRowIndex() {
|
||||
return _maxRows - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum number of usable columns in each spreadsheet
|
||||
@ -86,35 +86,34 @@ public enum SpreadsheetVersion {
|
||||
return _maxColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the last (maximum) valid column index, equals to <code> getMaxColumns() - 1 </code>
|
||||
*/
|
||||
public int getLastColumnIndex() {
|
||||
return _maxColumns - 1;
|
||||
}
|
||||
/**
|
||||
* @return the last (maximum) valid column index, equals to <code> getMaxColumns() - 1 </code>
|
||||
*/
|
||||
public int getLastColumnIndex() {
|
||||
return _maxColumns - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum number arguments that can be passed to a multi-arg
|
||||
* function (e.g. COUNTIF)
|
||||
* @return the maximum number arguments that can be passed to a multi-arg function (e.g. COUNTIF)
|
||||
*/
|
||||
public int getMaxFunctionArgs() {
|
||||
return _maxFunctionArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the maximum number of conditional format conditions on a cell
|
||||
*/
|
||||
public int getMaxConditionalFormats() {
|
||||
return _maxCondFormats;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return the maximum number of conditional format conditions on a cell
|
||||
*/
|
||||
public int getMaxConditionalFormats() {
|
||||
return _maxCondFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the last valid column index in a ALPHA-26 representation
|
||||
* ( <code>IV</code> or <code>XFD</code>).
|
||||
*/
|
||||
public String getLastColumnName() {
|
||||
return CellReference.convertNumToColString(getLastColumnIndex());
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return the last valid column index in a ALPHA-26 representation
|
||||
* (<code>IV</code> or <code>XFD</code>).
|
||||
*/
|
||||
public String getLastColumnName() {
|
||||
return CellReference.convertNumToColString(getLastColumnIndex());
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public interface FormulaParsingWorkbook {
|
||||
/**
|
||||
* named range name matching is case insensitive
|
||||
*/
|
||||
EvaluationName getName(String name, int sheetIndex);
|
||||
EvaluationName getName(String name, int sheetIndex);
|
||||
|
||||
NameXPtg getNameXPtg(String name);
|
||||
|
||||
@ -46,10 +46,10 @@ public interface FormulaParsingWorkbook {
|
||||
*/
|
||||
int getExternalSheetIndex(String workbookName, String sheetName);
|
||||
|
||||
/**
|
||||
* Returns an enum holding spreadhseet properties specific to an Excel version (
|
||||
* max column and row numbers, max arguments to a function, etc.)
|
||||
*/
|
||||
SpreadsheetVersion getSpreadsheetVersion();
|
||||
/**
|
||||
* Returns an enum holding spreadhseet properties specific to an Excel version (
|
||||
* max column and row numbers, max arguments to a function, etc.)
|
||||
*/
|
||||
SpreadsheetVersion getSpreadsheetVersion();
|
||||
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class FormulaRenderer {
|
||||
|
||||
if (ptg instanceof WorkbookDependentFormula) {
|
||||
WorkbookDependentFormula optg = (WorkbookDependentFormula) ptg;
|
||||
stack.push(optg.toFormulaString(book));
|
||||
stack.push(optg.toFormulaString(book));
|
||||
continue;
|
||||
}
|
||||
if (! (ptg instanceof OperationPtg)) {
|
||||
|
@ -28,13 +28,13 @@ public final class FormulaType {
|
||||
private FormulaType() {
|
||||
// no instances of this class
|
||||
}
|
||||
public static final int CELL = 0;
|
||||
public static final int SHARED = 1;
|
||||
public static final int ARRAY =2;
|
||||
public static final int CONDFORMAT = 3;
|
||||
public static final int NAMEDRANGE = 4;
|
||||
// this constant is currently very specific. The exact differences from general data
|
||||
// validation formulas or conditional format formulas is not known yet
|
||||
public static final int DATAVALIDATION_LIST = 5;
|
||||
public static final int CELL = 0;
|
||||
public static final int SHARED = 1;
|
||||
public static final int ARRAY =2;
|
||||
public static final int CONDFORMAT = 3;
|
||||
public static final int NAMEDRANGE = 4;
|
||||
// this constant is currently very specific. The exact differences from general data
|
||||
// validation formulas or conditional format formulas is not known yet
|
||||
public static final int DATAVALIDATION_LIST = 5;
|
||||
|
||||
}
|
||||
|
@ -92,8 +92,8 @@ final class ForkedEvaluationWorkbook implements EvaluationWorkbook {
|
||||
|
||||
public Ptg[] getFormulaTokens(EvaluationCell cell) {
|
||||
if (cell instanceof ForkedEvaluationCell) {
|
||||
// doesn't happen yet because formulas cannot be modified from the master workbook
|
||||
throw new RuntimeException("Updated formulas not supported yet");
|
||||
// doesn't happen yet because formulas cannot be modified from the master workbook
|
||||
throw new RuntimeException("Updated formulas not supported yet");
|
||||
}
|
||||
return _masterBook.getFormulaTokens(cell);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user