[bug-66614] remove limit on offset function params

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1910049 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2023-05-25 10:39:47 +00:00
parent dfe5dd150c
commit 2676dcc7f4
2 changed files with 3 additions and 10 deletions

View File

@ -17,6 +17,7 @@
package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.eval.AreaEval;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.EvaluationException;
@ -39,10 +40,6 @@ import org.apache.poi.ss.formula.eval.ValueEval;
* <b>width</b> (default same width as base reference) is the column count for the returned area reference.<br>
*/
public final class Offset implements Function {
// These values are specific to BIFF8
private static final int LAST_VALID_ROW_INDEX = 0xFFFF;
private static final int LAST_VALID_COLUMN_INDEX = 0xFF;
/**
* A one dimensional base + offset. Represents either a row range or a column range.
@ -199,10 +196,10 @@ public final class Offset implements Function {
LinearOffsetRange absRows = orRow.normaliseAndTranslate(baseRef.getFirstRowIndex());
LinearOffsetRange absCols = orCol.normaliseAndTranslate(baseRef.getFirstColumnIndex());
if(absRows.isOutOfBounds(0, LAST_VALID_ROW_INDEX)) {
if(absRows.isOutOfBounds(0, SpreadsheetVersion.EXCEL2007.getLastRowIndex())) {
throw new EvaluationException(ErrorEval.REF_INVALID);
}
if(absCols.isOutOfBounds(0, LAST_VALID_COLUMN_INDEX)) {
if(absCols.isOutOfBounds(0, SpreadsheetVersion.EXCEL2007.getLastColumnIndex())) {
throw new EvaluationException(ErrorEval.REF_INVALID);
}
return baseRef.offset(orRow.getFirstIndex(), orRow.getLastIndex(), orCol.getFirstIndex(), orCol.getLastIndex());

View File

@ -93,10 +93,6 @@ public class CellReference implements GenericRecord {
* digits or dot. (They can even end in dot).
*/
private static final Pattern NAMED_RANGE_NAME_PATTERN = Pattern.compile("[_A-Z][_.A-Z0-9]*", Pattern.CASE_INSENSITIVE);
//private static final String BIFF8_LAST_COLUMN = SpreadsheetVersion.EXCEL97.getLastColumnName();
//private static final int BIFF8_LAST_COLUMN_TEXT_LEN = BIFF8_LAST_COLUMN.length();
//private static final String BIFF8_LAST_ROW = String.valueOf(SpreadsheetVersion.EXCEL97.getMaxRows());
//private static final int BIFF8_LAST_ROW_TEXT_LEN = BIFF8_LAST_ROW.length();
// FIXME: _sheetName may be null, depending on the entry point.
// Perhaps it would be better to declare _sheetName is never null, using an empty string to represent a 2D reference.