You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 20:56:49 UTC
svn commit: r1890120 [24/43] - in /poi/trunk/poi/src:
main/java/org/apache/poi/ main/java/org/apache/poi/ddf/
main/java/org/apache/poi/extractor/ main/java/org/apache/poi/hpsf/
main/java/org/apache/poi/hssf/ main/java/org/apache/poi/hssf/dev/
main/java...
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefNPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefNPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefNPtg.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefNPtg.java Sat May 22 20:56:44 2021
@@ -21,14 +21,14 @@ import org.apache.poi.ss.util.CellRefere
import org.apache.poi.util.LittleEndianInput;
public final class RefNPtg extends Ref2DPtgBase {
- public static final byte sid = 0x2C;
+ public static final byte sid = 0x2C;
- public RefNPtg(LittleEndianInput in) {
- super(in);
- }
+ public RefNPtg(LittleEndianInput in) {
+ super(in);
+ }
public RefNPtg(RefNPtg other) {
- super(other);
+ super(other);
}
@Override
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtg.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtg.java Sat May 22 20:56:44 2021
@@ -24,39 +24,39 @@ import org.apache.poi.util.LittleEndianI
* ReferencePtg - handles references (such as A1, A2, IA4)
*/
public final class RefPtg extends Ref2DPtgBase {
- public static final byte sid = 0x24;
+ public static final byte sid = 0x24;
- /**
- * Takes in a String representation of a cell reference and fills out the
- * numeric fields.
- */
- public RefPtg(String cellref) {
- super(new CellReference(cellref));
- }
-
- public RefPtg(RefPtg other) {
- super(other);
- }
-
- public RefPtg(int row, int column, boolean isRowRelative, boolean isColumnRelative) {
- super(row, column, isRowRelative, isColumnRelative);
- }
-
- public RefPtg(LittleEndianInput in) {
- super(in);
- }
-
- public RefPtg(CellReference cr) {
- super(cr);
- }
-
- @Override
- public byte getSid() {
- return sid;
- }
-
- @Override
- public RefPtg copy() {
- return new RefPtg(this);
- }
+ /**
+ * Takes in a String representation of a cell reference and fills out the
+ * numeric fields.
+ */
+ public RefPtg(String cellref) {
+ super(new CellReference(cellref));
+ }
+
+ public RefPtg(RefPtg other) {
+ super(other);
+ }
+
+ public RefPtg(int row, int column, boolean isRowRelative, boolean isColumnRelative) {
+ super(row, column, isRowRelative, isColumnRelative);
+ }
+
+ public RefPtg(LittleEndianInput in) {
+ super(in);
+ }
+
+ public RefPtg(CellReference cr) {
+ super(cr);
+ }
+
+ @Override
+ public byte getSid() {
+ return sid;
+ }
+
+ @Override
+ public RefPtg copy() {
+ return new RefPtg(this);
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java Sat May 22 20:56:44 2021
@@ -32,105 +32,105 @@ import org.apache.poi.util.LittleEndianO
*/
public abstract class RefPtgBase extends OperandPtg {
- /**
- * YK: subclasses of RefPtgBase are used by the FormulaParser and FormulaEvaluator accross HSSF and XSSF.
- * The bit mask should accommodate the maximum number of avaiable columns, i.e. 0x3FFF.
- *
- * @see org.apache.poi.ss.SpreadsheetVersion
- */
- private static final BitField column = BitFieldFactory.getInstance(0x3FFF);
-
- private static final BitField rowRelative = BitFieldFactory.getInstance(0x8000);
- private static final BitField colRelative = BitFieldFactory.getInstance(0x4000);
-
-
- /** The row index - zero based unsigned 16 bit value */
- private int field_1_row;
- /**
- * Field 2 - lower 8 bits is the zero based unsigned byte column index - bit
- * 16 - isRowRelative - bit 15 - isColumnRelative
- */
- private int field_2_col;
-
- protected RefPtgBase() {}
-
- protected RefPtgBase(RefPtgBase other) {
- super(other);
- field_1_row = other.field_1_row;
- field_2_col = other.field_2_col;
- }
-
- protected RefPtgBase(CellReference c) {
- setRow(c.getRow());
- setColumn(c.getCol());
- setColRelative(!c.isColAbsolute());
- setRowRelative(!c.isRowAbsolute());
- }
-
- protected final void readCoordinates(LittleEndianInput in) {
- field_1_row = in.readUShort();
- field_2_col = in.readUShort();
- }
-
- protected final void writeCoordinates(LittleEndianOutput out) {
- out.writeShort(field_1_row);
- out.writeShort(field_2_col);
- }
-
- public final void setRow(int rowIndex) {
- field_1_row = rowIndex;
- }
-
- /**
- * @return the row number as an int
- */
- public final int getRow() {
- return field_1_row;
- }
-
- public final boolean isRowRelative() {
- return rowRelative.isSet(field_2_col);
- }
-
- public final void setRowRelative(boolean rel) {
- field_2_col = rowRelative.setBoolean(field_2_col, rel);
- }
-
- public final boolean isColRelative() {
- return colRelative.isSet(field_2_col);
- }
-
- public final void setColRelative(boolean rel) {
- field_2_col = colRelative.setBoolean(field_2_col, rel);
- }
-
- public final void setColumn(int col) {
- field_2_col = column.setValue(field_2_col, col);
- }
-
- public final int getColumn() {
- return column.getValue(field_2_col);
- }
-
- protected String formatReferenceAsString() {
- // Only make cell references as needed. Memory is an issue
- CellReference cr = new CellReference(getRow(), getColumn(), !isRowRelative(), !isColRelative());
- return cr.formatAsString();
- }
+ /**
+ * YK: subclasses of RefPtgBase are used by the FormulaParser and FormulaEvaluator accross HSSF and XSSF.
+ * The bit mask should accommodate the maximum number of avaiable columns, i.e. 0x3FFF.
+ *
+ * @see org.apache.poi.ss.SpreadsheetVersion
+ */
+ private static final BitField column = BitFieldFactory.getInstance(0x3FFF);
+
+ private static final BitField rowRelative = BitFieldFactory.getInstance(0x8000);
+ private static final BitField colRelative = BitFieldFactory.getInstance(0x4000);
+
+
+ /** The row index - zero based unsigned 16 bit value */
+ private int field_1_row;
+ /**
+ * Field 2 - lower 8 bits is the zero based unsigned byte column index - bit
+ * 16 - isRowRelative - bit 15 - isColumnRelative
+ */
+ private int field_2_col;
+
+ protected RefPtgBase() {}
+
+ protected RefPtgBase(RefPtgBase other) {
+ super(other);
+ field_1_row = other.field_1_row;
+ field_2_col = other.field_2_col;
+ }
+
+ protected RefPtgBase(CellReference c) {
+ setRow(c.getRow());
+ setColumn(c.getCol());
+ setColRelative(!c.isColAbsolute());
+ setRowRelative(!c.isRowAbsolute());
+ }
+
+ protected final void readCoordinates(LittleEndianInput in) {
+ field_1_row = in.readUShort();
+ field_2_col = in.readUShort();
+ }
+
+ protected final void writeCoordinates(LittleEndianOutput out) {
+ out.writeShort(field_1_row);
+ out.writeShort(field_2_col);
+ }
+
+ public final void setRow(int rowIndex) {
+ field_1_row = rowIndex;
+ }
+
+ /**
+ * @return the row number as an int
+ */
+ public final int getRow() {
+ return field_1_row;
+ }
+
+ public final boolean isRowRelative() {
+ return rowRelative.isSet(field_2_col);
+ }
+
+ public final void setRowRelative(boolean rel) {
+ field_2_col = rowRelative.setBoolean(field_2_col, rel);
+ }
+
+ public final boolean isColRelative() {
+ return colRelative.isSet(field_2_col);
+ }
+
+ public final void setColRelative(boolean rel) {
+ field_2_col = colRelative.setBoolean(field_2_col, rel);
+ }
+
+ public final void setColumn(int col) {
+ field_2_col = column.setValue(field_2_col, col);
+ }
+
+ public final int getColumn() {
+ return column.getValue(field_2_col);
+ }
+
+ protected String formatReferenceAsString() {
+ // Only make cell references as needed. Memory is an issue
+ CellReference cr = new CellReference(getRow(), getColumn(), !isRowRelative(), !isColRelative());
+ return cr.formatAsString();
+ }
- @Override
+ @Override
public final byte getDefaultOperandClass() {
- return Ptg.CLASS_REF;
- }
+ return Ptg.CLASS_REF;
+ }
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "row", this::getRow,
- "rowRelative", this::isRowRelative,
- "column", this::getColumn,
- "colRelative", this::isColRelative,
- "formatReference", this::formatReferenceAsString
- );
- }
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "row", this::getRow,
+ "rowRelative", this::isRowRelative,
+ "column", this::getColumn,
+ "colRelative", this::isColRelative,
+ "formatReference", this::formatReferenceAsString
+ );
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/ScalarConstantPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/ScalarConstantPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/ScalarConstantPtg.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/ScalarConstantPtg.java Sat May 22 20:56:44 2021
@@ -22,13 +22,13 @@ package org.apache.poi.ss.formula.ptg;
* Common superclass of all {@link Ptg Ptgs} that represent simple constant values.
*/
public abstract class ScalarConstantPtg extends Ptg {
- @Override
- public final boolean isBaseToken() {
- return true;
- }
+ @Override
+ public final boolean isBaseToken() {
+ return true;
+ }
- @Override
+ @Override
public final byte getDefaultOperandClass() {
- return Ptg.CLASS_VALUE;
- }
+ return Ptg.CLASS_VALUE;
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/StringPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/StringPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/StringPtg.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/StringPtg.java Sat May 22 20:56:44 2021
@@ -43,13 +43,13 @@ public final class StringPtg extends Sca
/** Create a StringPtg from a stream */
public StringPtg(LittleEndianInput in) {
- int nChars = in.readUByte(); // Note - nChars is 8-bit
- _is16bitUnicode = (in.readByte() & 0x01) != 0;
- if (_is16bitUnicode) {
- field_3_string = StringUtil.readUnicodeLE(in, nChars);
- } else {
- field_3_string = StringUtil.readCompressedUnicode(in, nChars);
- }
+ int nChars = in.readUByte(); // Note - nChars is 8-bit
+ _is16bitUnicode = (in.readByte() & 0x01) != 0;
+ if (_is16bitUnicode) {
+ field_3_string = StringUtil.readUnicodeLE(in, nChars);
+ } else {
+ field_3_string = StringUtil.readCompressedUnicode(in, nChars);
+ }
}
/**
@@ -78,9 +78,9 @@ public final class StringPtg extends Sca
out.writeByte(field_3_string.length()); // Note - nChars is 8-bit
out.writeByte(_is16bitUnicode ? 0x01 : 0x00);
if (_is16bitUnicode) {
- StringUtil.putUnicodeLE(field_3_string, out);
+ StringUtil.putUnicodeLE(field_3_string, out);
} else {
- StringUtil.putCompressedUnicode(field_3_string, out);
+ StringUtil.putCompressedUnicode(field_3_string, out);
}
}
@@ -90,7 +90,7 @@ public final class StringPtg extends Sca
}
public int getSize() {
- return 3 + field_3_string.length() * (_is16bitUnicode ? 2 : 1);
+ return 3 + field_3_string.length() * (_is16bitUnicode ? 2 : 1);
}
public String toFormulaString() {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/SubtractPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/SubtractPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/SubtractPtg.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/SubtractPtg.java Sat May 22 20:56:44 2021
@@ -23,7 +23,7 @@ public final class SubtractPtg extends V
public static final SubtractPtg instance = new SubtractPtg();
private SubtractPtg() {
- // enforce singleton
+ // enforce singleton
}
@Override
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnaryMinusPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnaryMinusPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnaryMinusPtg.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnaryMinusPtg.java Sat May 22 20:56:44 2021
@@ -28,7 +28,7 @@ public final class UnaryMinusPtg extends
public static final UnaryMinusPtg instance = new UnaryMinusPtg();
private UnaryMinusPtg() {
- // enforce singleton
+ // enforce singleton
}
@Override
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnaryPlusPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnaryPlusPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnaryPlusPtg.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnaryPlusPtg.java Sat May 22 20:56:44 2021
@@ -28,7 +28,7 @@ public final class UnaryPlusPtg extends
public static final UnaryPlusPtg instance = new UnaryPlusPtg();
private UnaryPlusPtg() {
- // enforce singleton
+ // enforce singleton
}
@Override
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnionPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnionPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnionPtg.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/UnionPtg.java Sat May 22 20:56:44 2021
@@ -26,7 +26,7 @@ public final class UnionPtg extends Oper
public static final UnionPtg instance = new UnionPtg();
private UnionPtg() {
- // enforce singleton
+ // enforce singleton
}
@Override
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/ValueOperatorPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/ValueOperatorPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/ValueOperatorPtg.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/ptg/ValueOperatorPtg.java Sat May 22 20:56:44 2021
@@ -26,34 +26,34 @@ import org.apache.poi.util.LittleEndianO
*/
public abstract class ValueOperatorPtg extends OperationPtg {
- protected ValueOperatorPtg() {}
+ protected ValueOperatorPtg() {}
- /**
- * All Operator {@code Ptg}s are base tokens (i.e. are not RVA classified)
- */
- @Override
- public final boolean isBaseToken() {
- return true;
- }
+ /**
+ * All Operator {@code Ptg}s are base tokens (i.e. are not RVA classified)
+ */
+ @Override
+ public final boolean isBaseToken() {
+ return true;
+ }
- @Override
+ @Override
public final byte getDefaultOperandClass() {
- return Ptg.CLASS_VALUE;
- }
+ return Ptg.CLASS_VALUE;
+ }
- @Override
- public void write(LittleEndianOutput out) {
- out.writeByte(getSid());
- }
-
- @Override
- public final int getSize() {
- return 1;
- }
-
- @Override
- public final String toFormulaString() {
- // TODO - prune this method out of the hierarchy
- throw new RuntimeException("toFormulaString(String[] operands) should be used for subclasses of OperationPtgs");
- }
+ @Override
+ public void write(LittleEndianOutput out) {
+ out.writeByte(getSid());
+ }
+
+ @Override
+ public final int getSize() {
+ return 1;
+ }
+
+ @Override
+ public final String toFormulaString() {
+ // TODO - prune this method out of the hierarchy
+ throw new RuntimeException("toFormulaString(String[] operands) should be used for subclasses of OperationPtgs");
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/udf/IndexedUDFFinder.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/udf/IndexedUDFFinder.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/udf/IndexedUDFFinder.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/udf/IndexedUDFFinder.java Sat May 22 20:56:44 2021
@@ -6,7 +6,7 @@
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/BuiltinFormats.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/BuiltinFormats.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/BuiltinFormats.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/BuiltinFormats.java Sat May 22 20:56:44 2021
@@ -61,12 +61,12 @@ package org.apache.poi.ss.usermodel;
* 0x31 "text" - Alias for "@"<br>
*/
public final class BuiltinFormats {
- /**
- * The first user-defined number format starts at 164.
- */
- public static final int FIRST_USER_DEFINED_FORMAT_INDEX = 164;
+ /**
+ * The first user-defined number format starts at 164.
+ */
+ public static final int FIRST_USER_DEFINED_FORMAT_INDEX = 164;
- private static final String[] _formats = {
+ private static final String[] _formats = {
"General",
"0",
"0.00",
@@ -112,7 +112,7 @@ public final class BuiltinFormats {
"#,##0_);[Red](#,##0)",
"#,##0.00_);(#,##0.00)",
"#,##0.00_);[Red](#,##0.00)",
- "_(* #,##0_);_(* (#,##0);_(* \"-\"_);_(@_)",
+ "_(* #,##0_);_(* (#,##0);_(* \"-\"_);_(@_)",
"_(\"$\"* #,##0_);_(\"$\"* (#,##0);_(\"$\"* \"-\"_);_(@_)",
"_(* #,##0.00_);_(* (#,##0.00);_(* \"-\"??_);_(@_)",
"_(\"$\"* #,##0.00_);_(\"$\"* (#,##0.00);_(\"$\"* \"-\"??_);_(@_)",
@@ -121,46 +121,46 @@ public final class BuiltinFormats {
"mm:ss.0",
"##0.0E+0",
"@"
- };
+ };
- /**
- * @return array of built-in data formats
- */
- public static String[] getAll() {
- return _formats.clone();
- }
-
- /**
- * Get the format string that matches the given format index
- *
- * @param index of a built in format
- * @return string represented at index of format or {@code null} if there is not a built-in format at that index
- */
- public static String getBuiltinFormat(int index) {
- if (index < 0 || index >=_formats.length) {
- return null;
- }
- return _formats[index];
- }
-
- /**
- * Get the format index that matches the given format string.<br>
- * Automatically converts "text" to excel's format string to represent text.
- *
- * @param pFmt string matching a built-in format
- * @return index of format or -1 if undefined.
- */
- public static int getBuiltinFormat(String pFmt) {
- String fmt = "TEXT".equalsIgnoreCase(pFmt) ? "@" : pFmt;
-
- int i = -1;
- for (String f : _formats) {
- i++;
- if (f.equals(fmt)) {
- return i;
- }
- }
+ /**
+ * @return array of built-in data formats
+ */
+ public static String[] getAll() {
+ return _formats.clone();
+ }
+
+ /**
+ * Get the format string that matches the given format index
+ *
+ * @param index of a built in format
+ * @return string represented at index of format or {@code null} if there is not a built-in format at that index
+ */
+ public static String getBuiltinFormat(int index) {
+ if (index < 0 || index >=_formats.length) {
+ return null;
+ }
+ return _formats[index];
+ }
+
+ /**
+ * Get the format index that matches the given format string.<br>
+ * Automatically converts "text" to excel's format string to represent text.
+ *
+ * @param pFmt string matching a built-in format
+ * @return index of format or -1 if undefined.
+ */
+ public static int getBuiltinFormat(String pFmt) {
+ String fmt = "TEXT".equalsIgnoreCase(pFmt) ? "@" : pFmt;
+
+ int i = -1;
+ for (String f : _formats) {
+ i++;
+ if (f.equals(fmt)) {
+ return i;
+ }
+ }
- return -1;
- }
+ return -1;
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/CellBase.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/CellBase.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/CellBase.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/CellBase.java Sat May 22 20:56:44 2021
@@ -127,7 +127,7 @@ public abstract class CellBase implement
/**
* Implementation-specific setting the formula. Formula is not null.
* Shall not change the value.
- *
+ *
* @param formula The text of the formula to set.
*/
protected abstract void setCellFormulaImpl(String formula);
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/CellValue.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/CellValue.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/CellValue.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/CellValue.java Sat May 22 20:56:44 2021
@@ -25,98 +25,98 @@ import org.apache.poi.ss.formula.eval.Er
* or Number or boolean type.
*/
public final class CellValue {
- public static final CellValue TRUE = new CellValue(CellType.BOOLEAN, 0.0, true, null, 0);
- public static final CellValue FALSE = new CellValue(CellType.BOOLEAN, 0.0, false, null, 0);
+ public static final CellValue TRUE = new CellValue(CellType.BOOLEAN, 0.0, true, null, 0);
+ public static final CellValue FALSE = new CellValue(CellType.BOOLEAN, 0.0, false, null, 0);
- private final CellType _cellType;
- private final double _numberValue;
- private final boolean _booleanValue;
- private final String _textValue;
- private final int _errorCode;
-
- private CellValue(CellType cellType, double numberValue, boolean booleanValue,
- String textValue, int errorCode) {
- _cellType = cellType;
- _numberValue = numberValue;
- _booleanValue = booleanValue;
- _textValue = textValue;
- _errorCode = errorCode;
- }
-
-
- public CellValue(double numberValue) {
- this(CellType.NUMERIC, numberValue, false, null, 0);
- }
-
- public static CellValue valueOf(boolean booleanValue) {
- return booleanValue ? TRUE : FALSE;
- }
-
- public CellValue(String stringValue) {
- this(CellType.STRING, 0.0, false, stringValue, 0);
- }
-
- public static CellValue getError(int errorCode) {
- return new CellValue(CellType.ERROR, 0.0, false, null, errorCode);
- }
-
-
- /**
- * @return Returns the booleanValue.
- */
- public boolean getBooleanValue() {
- return _booleanValue;
- }
-
- /**
- * @return Returns the numberValue.
- */
- public double getNumberValue() {
- return _numberValue;
- }
-
- /**
- * @return Returns the stringValue.
- */
- public String getStringValue() {
- return _textValue;
- }
-
- /**
- * Return the cell type.
- *
- * @return the cell type
- */
- public CellType getCellType() {
- return _cellType;
- }
-
- /**
- * @return Returns the errorValue.
- */
- public byte getErrorValue() {
- return (byte) _errorCode;
- }
-
- public String toString() {
- return getClass().getName() + " [" +
- formatAsString() +
- "]";
- }
-
- public String formatAsString() {
- switch (_cellType) {
- case NUMERIC:
- return String.valueOf(_numberValue);
- case STRING:
- return '"' + _textValue + '"';
- case BOOLEAN:
- return _booleanValue ? "TRUE" : "FALSE";
- case ERROR:
- return ErrorEval.getText(_errorCode);
- default:
- return "<error unexpected cell type " + _cellType + ">";
- }
-
- }
+ private final CellType _cellType;
+ private final double _numberValue;
+ private final boolean _booleanValue;
+ private final String _textValue;
+ private final int _errorCode;
+
+ private CellValue(CellType cellType, double numberValue, boolean booleanValue,
+ String textValue, int errorCode) {
+ _cellType = cellType;
+ _numberValue = numberValue;
+ _booleanValue = booleanValue;
+ _textValue = textValue;
+ _errorCode = errorCode;
+ }
+
+
+ public CellValue(double numberValue) {
+ this(CellType.NUMERIC, numberValue, false, null, 0);
+ }
+
+ public static CellValue valueOf(boolean booleanValue) {
+ return booleanValue ? TRUE : FALSE;
+ }
+
+ public CellValue(String stringValue) {
+ this(CellType.STRING, 0.0, false, stringValue, 0);
+ }
+
+ public static CellValue getError(int errorCode) {
+ return new CellValue(CellType.ERROR, 0.0, false, null, errorCode);
+ }
+
+
+ /**
+ * @return Returns the booleanValue.
+ */
+ public boolean getBooleanValue() {
+ return _booleanValue;
+ }
+
+ /**
+ * @return Returns the numberValue.
+ */
+ public double getNumberValue() {
+ return _numberValue;
+ }
+
+ /**
+ * @return Returns the stringValue.
+ */
+ public String getStringValue() {
+ return _textValue;
+ }
+
+ /**
+ * Return the cell type.
+ *
+ * @return the cell type
+ */
+ public CellType getCellType() {
+ return _cellType;
+ }
+
+ /**
+ * @return Returns the errorValue.
+ */
+ public byte getErrorValue() {
+ return (byte) _errorCode;
+ }
+
+ public String toString() {
+ return getClass().getName() + " [" +
+ formatAsString() +
+ "]";
+ }
+
+ public String formatAsString() {
+ switch (_cellType) {
+ case NUMERIC:
+ return String.valueOf(_numberValue);
+ case STRING:
+ return '"' + _textValue + '"';
+ case BOOLEAN:
+ return _booleanValue ? "TRUE" : "FALSE";
+ case ERROR:
+ return ErrorEval.getText(_errorCode);
+ default:
+ return "<error unexpected cell type " + _cellType + ">";
+ }
+
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java Sat May 22 20:56:44 2021
@@ -145,8 +145,8 @@ public class DataFormatter {
*/
private static final Pattern colorPattern =
Pattern.compile("(\\[BLACK])|(\\[BLUE])|(\\[CYAN])|(\\[GREEN])|" +
- "(\\[MAGENTA])|(\\[RED])|(\\[WHITE])|(\\[YELLOW])|" +
- "(\\[COLOR\\s*\\d])|(\\[COLOR\\s*[0-5]\\d])", Pattern.CASE_INSENSITIVE);
+ "(\\[MAGENTA])|(\\[RED])|(\\[WHITE])|(\\[YELLOW])|" +
+ "(\\[COLOR\\s*\\d])|(\\[COLOR\\s*[0-5]\\d])", Pattern.CASE_INSENSITIVE);
/**
* A regex to identify a fraction pattern.
@@ -472,7 +472,7 @@ public class DataFormatter {
formatStr = formatStr.replace("\\/","/"); // weird: m\\/d\\/yyyy
formatStr = formatStr.replace(";@", "");
formatStr = formatStr.replace("\"/\"", "/"); // "/" is escaped for no reason in: mm"/"dd"/"yyyy
- formatStr = formatStr.replace("\"\"", "'"); // replace Excel quoting with Java style quoting
+ formatStr = formatStr.replace("\"\"", "'"); // replace Excel quoting with Java style quoting
formatStr = formatStr.replace("\\T","'T'"); // Quote the T is iso8601 style dates
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidation.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidation.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidation.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidation.java Sat May 22 20:56:44 2021
@@ -20,133 +20,133 @@ import org.apache.poi.ss.util.CellRangeA
public interface DataValidation {
- /**
- * Error style constants for error box
- */
- public static final class ErrorStyle {
- /** STOP style */
- public static final int STOP = 0x00;
- /** WARNING style */
- public static final int WARNING = 0x01;
- /** INFO style */
- public static final int INFO = 0x02;
- }
-
- public abstract DataValidationConstraint getValidationConstraint();
-
- /**
- * Sets the error style for error box
- * @see ErrorStyle
- */
- public abstract void setErrorStyle(int error_style);
-
- /**o
- * @return the error style of error box
- * @see ErrorStyle
- */
- public abstract int getErrorStyle();
-
- /**
- * Sets if this object allows empty as a valid value
- *
- * @param allowed <code>true</code> if this object should treats empty as valid value , <code>false</code>
- * otherwise
- */
- public abstract void setEmptyCellAllowed(boolean allowed);
-
- /**
- * Retrieve the settings for empty cells allowed
- *
- * @return True if this object should treats empty as valid value , false
- * otherwise
- */
- public abstract boolean getEmptyCellAllowed();
-
- /**
- * Useful for list validation objects .
- *
- * @param suppress
- * True if a list should display the values into a drop down list ,
- * false otherwise . In other words , if a list should display
- * the arrow sign on its right side
- */
- public abstract void setSuppressDropDownArrow(boolean suppress);
-
- /**
- * Useful only list validation objects . This method always returns false if
- * the object isn't a list validation object
- *
- * @return <code>true</code> if a list should display the values into a drop down list ,
- * <code>false</code> otherwise .
- */
- public abstract boolean getSuppressDropDownArrow();
-
- /**
- * Sets the behaviour when a cell which belongs to this object is selected
- *
- * @param show <code>true</code> if an prompt box should be displayed , <code>false</code> otherwise
- */
- public abstract void setShowPromptBox(boolean show);
-
- /**
- * @return <code>true</code> if an prompt box should be displayed , <code>false</code> otherwise
- */
- public abstract boolean getShowPromptBox();
-
- /**
- * Sets the behaviour when an invalid value is entered
- *
- * @param show <code>true</code> if an error box should be displayed , <code>false</code> otherwise
- */
- public abstract void setShowErrorBox(boolean show);
-
- /**
- * @return <code>true</code> if an error box should be displayed , <code>false</code> otherwise
- */
- public abstract boolean getShowErrorBox();
-
- /**
- * Sets the title and text for the prompt box . Prompt box is displayed when
- * the user selects a cell which belongs to this validation object . In
- * order for a prompt box to be displayed you should also use method
- * setShowPromptBox( boolean show )
- *
- * @param title The prompt box's title
- * @param text The prompt box's text
- */
- public abstract void createPromptBox(String title, String text);
-
- /**
- * @return Prompt box's title or <code>null</code>
- */
- public abstract String getPromptBoxTitle();
-
- /**
- * @return Prompt box's text or <code>null</code>
- */
- public abstract String getPromptBoxText();
-
- /**
- * Sets the title and text for the error box . Error box is displayed when
- * the user enters an invalid value int o a cell which belongs to this
- * validation object . In order for an error box to be displayed you should
- * also use method setShowErrorBox( boolean show )
- *
- * @param title The error box's title
- * @param text The error box's text
- */
- public abstract void createErrorBox(String title, String text);
-
- /**
- * @return Error box's title or <code>null</code>
- */
- public abstract String getErrorBoxTitle();
-
- /**
- * @return Error box's text or <code>null</code>
- */
- public abstract String getErrorBoxText();
+ /**
+ * Error style constants for error box
+ */
+ public static final class ErrorStyle {
+ /** STOP style */
+ public static final int STOP = 0x00;
+ /** WARNING style */
+ public static final int WARNING = 0x01;
+ /** INFO style */
+ public static final int INFO = 0x02;
+ }
+
+ public abstract DataValidationConstraint getValidationConstraint();
+
+ /**
+ * Sets the error style for error box
+ * @see ErrorStyle
+ */
+ public abstract void setErrorStyle(int error_style);
+
+ /**o
+ * @return the error style of error box
+ * @see ErrorStyle
+ */
+ public abstract int getErrorStyle();
+
+ /**
+ * Sets if this object allows empty as a valid value
+ *
+ * @param allowed <code>true</code> if this object should treats empty as valid value , <code>false</code>
+ * otherwise
+ */
+ public abstract void setEmptyCellAllowed(boolean allowed);
+
+ /**
+ * Retrieve the settings for empty cells allowed
+ *
+ * @return True if this object should treats empty as valid value , false
+ * otherwise
+ */
+ public abstract boolean getEmptyCellAllowed();
+
+ /**
+ * Useful for list validation objects .
+ *
+ * @param suppress
+ * True if a list should display the values into a drop down list ,
+ * false otherwise . In other words , if a list should display
+ * the arrow sign on its right side
+ */
+ public abstract void setSuppressDropDownArrow(boolean suppress);
+
+ /**
+ * Useful only list validation objects . This method always returns false if
+ * the object isn't a list validation object
+ *
+ * @return <code>true</code> if a list should display the values into a drop down list ,
+ * <code>false</code> otherwise .
+ */
+ public abstract boolean getSuppressDropDownArrow();
+
+ /**
+ * Sets the behaviour when a cell which belongs to this object is selected
+ *
+ * @param show <code>true</code> if an prompt box should be displayed , <code>false</code> otherwise
+ */
+ public abstract void setShowPromptBox(boolean show);
+
+ /**
+ * @return <code>true</code> if an prompt box should be displayed , <code>false</code> otherwise
+ */
+ public abstract boolean getShowPromptBox();
+
+ /**
+ * Sets the behaviour when an invalid value is entered
+ *
+ * @param show <code>true</code> if an error box should be displayed , <code>false</code> otherwise
+ */
+ public abstract void setShowErrorBox(boolean show);
+
+ /**
+ * @return <code>true</code> if an error box should be displayed , <code>false</code> otherwise
+ */
+ public abstract boolean getShowErrorBox();
+
+ /**
+ * Sets the title and text for the prompt box . Prompt box is displayed when
+ * the user selects a cell which belongs to this validation object . In
+ * order for a prompt box to be displayed you should also use method
+ * setShowPromptBox( boolean show )
+ *
+ * @param title The prompt box's title
+ * @param text The prompt box's text
+ */
+ public abstract void createPromptBox(String title, String text);
+
+ /**
+ * @return Prompt box's title or <code>null</code>
+ */
+ public abstract String getPromptBoxTitle();
+
+ /**
+ * @return Prompt box's text or <code>null</code>
+ */
+ public abstract String getPromptBoxText();
+
+ /**
+ * Sets the title and text for the error box . Error box is displayed when
+ * the user enters an invalid value int o a cell which belongs to this
+ * validation object . In order for an error box to be displayed you should
+ * also use method setShowErrorBox( boolean show )
+ *
+ * @param title The error box's title
+ * @param text The error box's text
+ */
+ public abstract void createErrorBox(String title, String text);
+
+ /**
+ * @return Error box's title or <code>null</code>
+ */
+ public abstract String getErrorBoxTitle();
+
+ /**
+ * @return Error box's text or <code>null</code>
+ */
+ public abstract String getErrorBoxText();
- public abstract CellRangeAddressList getRegions();
+ public abstract CellRangeAddressList getRegions();
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidationConstraint.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidationConstraint.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidationConstraint.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidationConstraint.java Sat May 22 20:56:44 2021
@@ -19,106 +19,106 @@ package org.apache.poi.ss.usermodel;
public interface DataValidationConstraint {
- /**
- * @return data validation type of this constraint
- * @see ValidationType
- */
- public abstract int getValidationType();
-
- /**
- * @return the operator used for this constraint
- * @see OperatorType
- */
- public abstract int getOperator();
-
- /**
- * Sets the comparison operator for this constraint
- * @see OperatorType
- */
- public abstract void setOperator(int operator);
-
- /**
- * If validation type is {@link ValidationType#LIST}
- * and <code>formula1</code> was comma-separated literal values rather than a range or named range,
- * returns list of literal values.
- * Otherwise returns <code>null</code>.
- */
- public abstract String[] getExplicitListValues();
-
- public abstract void setExplicitListValues(String[] explicitListValues);
-
- /**
- * @return the formula for expression 1. May be <code>null</code>
- */
- public abstract String getFormula1();
-
- /**
- * Sets a formula for expression 1.
- */
- public abstract void setFormula1(String formula1);
-
- /**
- * @return the formula for expression 2. May be <code>null</code>
- */
- public abstract String getFormula2();
-
- /**
- * Sets a formula for expression 2.
- */
- public abstract void setFormula2(String formula2);
-
- /**
- * ValidationType enum
- */
- public static final class ValidationType {
- private ValidationType() {
- // no instances of this class
- }
- /** 'Any value' type - value not restricted */
- public static final int ANY = 0x00;
- /** Integer ('Whole number') type */
- public static final int INTEGER = 0x01;
- /** Decimal type */
- public static final int DECIMAL = 0x02;
- /** List type ( combo box type ) */
- public static final int LIST = 0x03;
- /** Date type */
- public static final int DATE = 0x04;
- /** Time type */
- public static final int TIME = 0x05;
- /** String length type */
- public static final int TEXT_LENGTH = 0x06;
- /** Formula ( 'Custom' ) type */
- public static final int FORMULA = 0x07;
- }
- /**
- * Condition operator enum
- */
- public static final class OperatorType {
- private OperatorType() {
- // no instances of this class
- }
-
- public static final int BETWEEN = 0x00;
- public static final int NOT_BETWEEN = 0x01;
- public static final int EQUAL = 0x02;
- public static final int NOT_EQUAL = 0x03;
- public static final int GREATER_THAN = 0x04;
- public static final int LESS_THAN = 0x05;
- public static final int GREATER_OR_EQUAL = 0x06;
- public static final int LESS_OR_EQUAL = 0x07;
- /** default value to supply when the operator type is not used */
- public static final int IGNORED = BETWEEN;
-
- /* package */ public static void validateSecondArg(int comparisonOperator, String paramValue) {
- switch (comparisonOperator) {
- case BETWEEN:
- case NOT_BETWEEN:
- if (paramValue == null) {
- throw new IllegalArgumentException("expr2 must be supplied for 'between' comparisons");
- }
- // all other operators don't need second arg
- }
- }
- }
+ /**
+ * @return data validation type of this constraint
+ * @see ValidationType
+ */
+ public abstract int getValidationType();
+
+ /**
+ * @return the operator used for this constraint
+ * @see OperatorType
+ */
+ public abstract int getOperator();
+
+ /**
+ * Sets the comparison operator for this constraint
+ * @see OperatorType
+ */
+ public abstract void setOperator(int operator);
+
+ /**
+ * If validation type is {@link ValidationType#LIST}
+ * and <code>formula1</code> was comma-separated literal values rather than a range or named range,
+ * returns list of literal values.
+ * Otherwise returns <code>null</code>.
+ */
+ public abstract String[] getExplicitListValues();
+
+ public abstract void setExplicitListValues(String[] explicitListValues);
+
+ /**
+ * @return the formula for expression 1. May be <code>null</code>
+ */
+ public abstract String getFormula1();
+
+ /**
+ * Sets a formula for expression 1.
+ */
+ public abstract void setFormula1(String formula1);
+
+ /**
+ * @return the formula for expression 2. May be <code>null</code>
+ */
+ public abstract String getFormula2();
+
+ /**
+ * Sets a formula for expression 2.
+ */
+ public abstract void setFormula2(String formula2);
+
+ /**
+ * ValidationType enum
+ */
+ public static final class ValidationType {
+ private ValidationType() {
+ // no instances of this class
+ }
+ /** 'Any value' type - value not restricted */
+ public static final int ANY = 0x00;
+ /** Integer ('Whole number') type */
+ public static final int INTEGER = 0x01;
+ /** Decimal type */
+ public static final int DECIMAL = 0x02;
+ /** List type ( combo box type ) */
+ public static final int LIST = 0x03;
+ /** Date type */
+ public static final int DATE = 0x04;
+ /** Time type */
+ public static final int TIME = 0x05;
+ /** String length type */
+ public static final int TEXT_LENGTH = 0x06;
+ /** Formula ( 'Custom' ) type */
+ public static final int FORMULA = 0x07;
+ }
+ /**
+ * Condition operator enum
+ */
+ public static final class OperatorType {
+ private OperatorType() {
+ // no instances of this class
+ }
+
+ public static final int BETWEEN = 0x00;
+ public static final int NOT_BETWEEN = 0x01;
+ public static final int EQUAL = 0x02;
+ public static final int NOT_EQUAL = 0x03;
+ public static final int GREATER_THAN = 0x04;
+ public static final int LESS_THAN = 0x05;
+ public static final int GREATER_OR_EQUAL = 0x06;
+ public static final int LESS_OR_EQUAL = 0x07;
+ /** default value to supply when the operator type is not used */
+ public static final int IGNORED = BETWEEN;
+
+ /* package */ public static void validateSecondArg(int comparisonOperator, String paramValue) {
+ switch (comparisonOperator) {
+ case BETWEEN:
+ case NOT_BETWEEN:
+ if (paramValue == null) {
+ throw new IllegalArgumentException("expr2 must be supplied for 'between' comparisons");
+ }
+ // all other operators don't need second arg
+ }
+ }
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidationHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidationHelper.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidationHelper.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DataValidationHelper.java Sat May 22 20:56:44 2021
@@ -20,23 +20,23 @@ import org.apache.poi.ss.util.CellRangeA
public interface DataValidationHelper {
- DataValidationConstraint createFormulaListConstraint(String listFormula);
+ DataValidationConstraint createFormulaListConstraint(String listFormula);
- DataValidationConstraint createExplicitListConstraint(String[] listOfValues);
+ DataValidationConstraint createExplicitListConstraint(String[] listOfValues);
- DataValidationConstraint createNumericConstraint(int validationType,int operatorType, String formula1, String formula2);
+ DataValidationConstraint createNumericConstraint(int validationType,int operatorType, String formula1, String formula2);
- DataValidationConstraint createTextLengthConstraint(int operatorType, String formula1, String formula2);
+ DataValidationConstraint createTextLengthConstraint(int operatorType, String formula1, String formula2);
- DataValidationConstraint createDecimalConstraint(int operatorType, String formula1, String formula2);
+ DataValidationConstraint createDecimalConstraint(int operatorType, String formula1, String formula2);
- DataValidationConstraint createIntegerConstraint(int operatorType, String formula1, String formula2);
+ DataValidationConstraint createIntegerConstraint(int operatorType, String formula1, String formula2);
- DataValidationConstraint createDateConstraint(int operatorType, String formula1, String formula2,String dateFormat);
+ DataValidationConstraint createDateConstraint(int operatorType, String formula1, String formula2,String dateFormat);
- DataValidationConstraint createTimeConstraint(int operatorType, String formula1, String formula2);
+ DataValidationConstraint createTimeConstraint(int operatorType, String formula1, String formula2);
- DataValidationConstraint createCustomConstraint(String formula);
+ DataValidationConstraint createCustomConstraint(String formula);
- DataValidation createValidation(DataValidationConstraint constraint,CellRangeAddressList cellRangeAddressList);
+ DataValidation createValidation(DataValidationConstraint constraint,CellRangeAddressList cellRangeAddressList);
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DateUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DateUtil.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DateUtil.java [UTF-8] (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/DateUtil.java [UTF-8] Sat May 22 20:56:44 2021
@@ -499,7 +499,7 @@ public class DateUtil {
* @return Java representation of the date in UTC, or null if date is not a valid Excel date
*/
public static Calendar getJavaCalendarUTC(double date, boolean use1904windowing) {
- return getJavaCalendar(date, use1904windowing, LocaleUtil.TIMEZONE_UTC, false);
+ return getJavaCalendar(date, use1904windowing, LocaleUtil.TIMEZONE_UTC, false);
}
@@ -750,7 +750,7 @@ public class DateUtil {
* we infer it is a date if it is formatted as such.
* Format is determined from applicable conditional formatting, if
* any, or cell style.
- * @param cell The cell to look at
+ * @param cell The cell to look at
* @param cfEvaluator if available, or null
* @return true if it looks like a date
* @see #isADateFormat(int, String)
@@ -850,7 +850,7 @@ public class DateUtil {
*
* @return days number of days in years prior to yr.
* @param yr a year (1900 < yr < 4000)
- * @param use1904windowing Should 1900 or 1904 date windowing be used?
+ * @param use1904windowing Should 1900 or 1904 date windowing be used?
* @exception IllegalArgumentException if year is outside of range.
*/
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Drawing.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Drawing.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Drawing.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Drawing.java Sat May 22 20:56:44 2021
@@ -20,40 +20,40 @@ package org.apache.poi.ss.usermodel;
* High level representation of spreadsheet drawing.
*/
public interface Drawing<T extends Shape> extends ShapeContainer<T> {
- /**
- * Creates a picture.
- * @param anchor the client anchor describes how this picture is
- * attached to the sheet.
- * @param pictureIndex the index of the picture in the workbook collection
- * of pictures.
- *
- * @return the newly created picture.
- */
- Picture createPicture(ClientAnchor anchor, int pictureIndex);
+ /**
+ * Creates a picture.
+ * @param anchor the client anchor describes how this picture is
+ * attached to the sheet.
+ * @param pictureIndex the index of the picture in the workbook collection
+ * of pictures.
+ *
+ * @return the newly created picture.
+ */
+ Picture createPicture(ClientAnchor anchor, int pictureIndex);
- /**
- * Creates a comment.
- * @param anchor the client anchor describes how this comment is attached
- * to the sheet.
- * @return the newly created comment.
- */
- Comment createCellComment(ClientAnchor anchor);
+ /**
+ * Creates a comment.
+ * @param anchor the client anchor describes how this comment is attached
+ * to the sheet.
+ * @return the newly created comment.
+ */
+ Comment createCellComment(ClientAnchor anchor);
- /**
- * Creates a new client anchor and sets the top-left and bottom-right
- * coordinates of the anchor.
- *
- * @param dx1 the x coordinate in EMU within the first cell.
- * @param dy1 the y coordinate in EMU within the first cell.
- * @param dx2 the x coordinate in EMU within the second cell.
- * @param dy2 the y coordinate in EMU within the second cell.
- * @param col1 the column (0 based) of the first cell.
- * @param row1 the row (0 based) of the first cell.
- * @param col2 the column (0 based) of the second cell.
- * @param row2 the row (0 based) of the second cell.
- * @return the newly created client anchor
- */
- ClientAnchor createAnchor(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2);
+ /**
+ * Creates a new client anchor and sets the top-left and bottom-right
+ * coordinates of the anchor.
+ *
+ * @param dx1 the x coordinate in EMU within the first cell.
+ * @param dy1 the y coordinate in EMU within the first cell.
+ * @param dx2 the x coordinate in EMU within the second cell.
+ * @param dy2 the y coordinate in EMU within the second cell.
+ * @param col1 the column (0 based) of the first cell.
+ * @param row1 the row (0 based) of the first cell.
+ * @param col2 the column (0 based) of the second cell.
+ * @param row2 the row (0 based) of the second cell.
+ * @return the newly created client anchor
+ */
+ ClientAnchor createAnchor(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2);
/**
* Adds a new OLE Package Shape
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java Sat May 22 20:56:44 2021
@@ -36,17 +36,17 @@ public interface FormulaEvaluator {
* of the evaluate~ methods of this class
*/
void clearAllCachedResultValues();
- /**
- * Should be called to tell the cell value cache that the specified (value or formula) cell
- * has changed.
- * Failure to call this method after changing cell values will cause incorrect behaviour
- * of the evaluate~ methods of this class
- */
+ /**
+ * Should be called to tell the cell value cache that the specified (value or formula) cell
+ * has changed.
+ * Failure to call this method after changing cell values will cause incorrect behaviour
+ * of the evaluate~ methods of this class
+ */
void notifySetFormula(Cell cell);
- /**
- * Should be called to tell the cell value cache that the specified cell has just become a
- * formula cell, or the formula text has changed
- */
+ /**
+ * Should be called to tell the cell value cache that the specified cell has just become a
+ * formula cell, or the formula text has changed
+ */
void notifyDeleteCell(Cell cell);
/**
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Name.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Name.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Name.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Name.java Sat May 22 20:56:44 2021
@@ -149,7 +149,7 @@ public interface Name {
*
* @return true if this name is a function name
*/
- boolean isFunctionName();
+ boolean isFunctionName();
/**
* Checks if this name points to a cell that no longer exists
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java Sat May 22 20:56:44 2021
@@ -88,16 +88,16 @@ public interface SheetConditionalFormatt
* </p>
*
* @param comparisonOperation - MUST be a constant value from
- * {@link ComparisonOperator}:
+ * {@link ComparisonOperator}:
* <ul>
- * <li>BETWEEN</li>
- * <li>NOT_BETWEEN</li>
- * <li>EQUAL</li>
- * <li>NOT_EQUAL</li>
- * <li>GT</li>
- * <li>LT</li>
- * <li>GE</li>
- * <li>LE</li>
+ * <li>BETWEEN</li>
+ * <li>NOT_BETWEEN</li>
+ * <li>EQUAL</li>
+ * <li>NOT_EQUAL</li>
+ * <li>GT</li>
+ * <li>LT</li>
+ * <li>GE</li>
+ * <li>LE</li>
* </ul>
* @param formula1 - formula for the valued, compared with the cell
* @param formula2 - second formula (only used with
@@ -116,7 +116,7 @@ public interface SheetConditionalFormatt
* </p>
*
* @param comparisonOperation MUST be a constant value from
- * {@link ComparisonOperator} except BETWEEN and NOT_BETWEEN
+ * {@link ComparisonOperator} except BETWEEN and NOT_BETWEEN
*
* @param formula the formula to determine if the conditional formatting is applied
*/
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Workbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Workbook.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Workbook.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Workbook.java Sat May 22 20:56:44 2021
@@ -420,25 +420,25 @@ public interface Workbook extends Closea
*/
void removePrintArea(int sheetIndex);
- /**
- * Retrieves the current policy on what to do when
- * getting missing or blank cells from a row.
+ /**
+ * Retrieves the current policy on what to do when
+ * getting missing or blank cells from a row.
* <p>
- * The default is to return blank and null cells.
- * {@link MissingCellPolicy}
+ * The default is to return blank and null cells.
+ * {@link MissingCellPolicy}
* </p>
- */
- MissingCellPolicy getMissingCellPolicy();
+ */
+ MissingCellPolicy getMissingCellPolicy();
/**
- * Sets the policy on what to do when
- * getting missing or blank cells from a row.
+ * Sets the policy on what to do when
+ * getting missing or blank cells from a row.
*
- * This will then apply to all calls to
- * {@link Row#getCell(int)} }. See
- * {@link MissingCellPolicy}
- */
- void setMissingCellPolicy(MissingCellPolicy missingCellPolicy);
+ * This will then apply to all calls to
+ * {@link Row#getCell(int)} }. See
+ * {@link MissingCellPolicy}
+ */
+ void setMissingCellPolicy(MissingCellPolicy missingCellPolicy);
/**
* Returns the instance of DataFormat for this workbook.
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddress.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddress.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddress.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddress.java Sat May 22 20:56:44 2021
@@ -31,52 +31,52 @@ import org.apache.poi.util.LittleEndianO
* Note - {@link SelectionRecord} uses the BIFF5 version of this structure
*/
public class CellRangeAddress extends CellRangeAddressBase {
- public static final int ENCODED_SIZE = 8;
+ public static final int ENCODED_SIZE = 8;
- /**
- * Creates new cell range. Indexes are zero-based.
- *
- * @param firstRow Index of first row
- * @param lastRow Index of last row (inclusive), must be equal to or larger than {@code firstRow}
- * @param firstCol Index of first column
- * @param lastCol Index of last column (inclusive), must be equal to or larger than {@code firstCol}
- */
- public CellRangeAddress(int firstRow, int lastRow, int firstCol, int lastCol) {
- super(firstRow, lastRow, firstCol, lastCol);
-
- if (lastRow < firstRow || lastCol < firstCol) {
- throw new IllegalArgumentException("Invalid cell range, having lastRow < firstRow || lastCol < firstCol, " +
- "had rows " + lastRow + " >= " + firstRow + " or cells " + lastCol + " >= " + firstCol);
- }
- }
-
- public void serialize(LittleEndianOutput out) {
- out.writeShort(getFirstRow());
- out.writeShort(getLastRow());
- out.writeShort(getFirstColumn());
- out.writeShort(getLastColumn());
- }
-
- public CellRangeAddress(RecordInputStream in) {
- super(readUShortAndCheck(in), in.readUShort(), in.readUShort(), in.readUShort());
- }
-
- private static int readUShortAndCheck(RecordInputStream in) {
- if (in.remaining() < ENCODED_SIZE) {
- // Ran out of data
- throw new RuntimeException("Ran out of data reading CellRangeAddress");
- }
- return in.readUShort();
- }
-
- @Override
- public CellRangeAddress copy() {
- return new CellRangeAddress(getFirstRow(), getLastRow(), getFirstColumn(), getLastColumn());
- }
-
- public static int getEncodedSize(int numberOfItems) {
- return numberOfItems * ENCODED_SIZE;
- }
+ /**
+ * Creates new cell range. Indexes are zero-based.
+ *
+ * @param firstRow Index of first row
+ * @param lastRow Index of last row (inclusive), must be equal to or larger than {@code firstRow}
+ * @param firstCol Index of first column
+ * @param lastCol Index of last column (inclusive), must be equal to or larger than {@code firstCol}
+ */
+ public CellRangeAddress(int firstRow, int lastRow, int firstCol, int lastCol) {
+ super(firstRow, lastRow, firstCol, lastCol);
+
+ if (lastRow < firstRow || lastCol < firstCol) {
+ throw new IllegalArgumentException("Invalid cell range, having lastRow < firstRow || lastCol < firstCol, " +
+ "had rows " + lastRow + " >= " + firstRow + " or cells " + lastCol + " >= " + firstCol);
+ }
+ }
+
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(getFirstRow());
+ out.writeShort(getLastRow());
+ out.writeShort(getFirstColumn());
+ out.writeShort(getLastColumn());
+ }
+
+ public CellRangeAddress(RecordInputStream in) {
+ super(readUShortAndCheck(in), in.readUShort(), in.readUShort(), in.readUShort());
+ }
+
+ private static int readUShortAndCheck(RecordInputStream in) {
+ if (in.remaining() < ENCODED_SIZE) {
+ // Ran out of data
+ throw new RuntimeException("Ran out of data reading CellRangeAddress");
+ }
+ return in.readUShort();
+ }
+
+ @Override
+ public CellRangeAddress copy() {
+ return new CellRangeAddress(getFirstRow(), getLastRow(), getFirstColumn(), getLastColumn());
+ }
+
+ public static int getEncodedSize(int numberOfItems) {
+ return numberOfItems * ENCODED_SIZE;
+ }
/**
* @return the text format of this range. Single cell ranges are formatted
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddressBase.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddressBase.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddressBase.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddressBase.java Sat May 22 20:56:44 2021
@@ -6,7 +6,7 @@
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -54,101 +54,101 @@ public abstract class CellRangeAddressBa
/** a cell or range is completely inside another range, without touching any edges (a cell in this position can't be in any others) */
INSIDE
}
- private int _firstRow;
- private int _firstCol;
- private int _lastRow;
- private int _lastCol;
-
- protected CellRangeAddressBase(int firstRow, int lastRow, int firstCol, int lastCol) {
- _firstRow = firstRow;
- _lastRow = lastRow;
- _firstCol = firstCol;
- _lastCol = lastCol;
- }
-
- /**
- * Validate the range limits against the supplied version of Excel
- *
- * @param ssVersion the version of Excel to validate against
- * @throws IllegalArgumentException if the range limits are outside of the allowed range
- */
- public void validate(SpreadsheetVersion ssVersion) {
- validateRow(_firstRow, ssVersion);
- validateRow(_lastRow, ssVersion);
- validateColumn(_firstCol, ssVersion);
- validateColumn(_lastCol, ssVersion);
- }
- /**
- * Runs a bounds check for row numbers
- */
- private static void validateRow(int row, SpreadsheetVersion ssVersion) {
- int maxrow = ssVersion.getLastRowIndex();
- if (row > maxrow) throw new IllegalArgumentException("Maximum row number is " + maxrow);
- if (row < 0) throw new IllegalArgumentException("Minumum row number is 0");
- }
-
- /**
- * Runs a bounds check for column numbers
- */
- private static void validateColumn(int column, SpreadsheetVersion ssVersion) {
- int maxcol = ssVersion.getLastColumnIndex();
- if (column > maxcol) throw new IllegalArgumentException("Maximum column number is " + maxcol);
- if (column < 0) throw new IllegalArgumentException("Minimum column number is 0");
- }
-
-
- //TODO use the correct SpreadsheetVersion
- public final boolean isFullColumnRange() {
- return (_firstRow == 0 && _lastRow == SpreadsheetVersion.EXCEL97.getLastRowIndex())
- || (_firstRow == -1 && _lastRow == -1);
- }
- //TODO use the correct SpreadsheetVersion
- public final boolean isFullRowRange() {
- return (_firstCol == 0 && _lastCol == SpreadsheetVersion.EXCEL97.getLastColumnIndex())
- || (_firstCol == -1 && _lastCol == -1);
- }
-
- /**
- * @return column number for the upper left hand corner
- */
- public final int getFirstColumn() {
- return _firstCol;
- }
-
- /**
- * @return row number for the upper left hand corner
- */
- public final int getFirstRow() {
- return _firstRow;
- }
-
- /**
- * @return column number for the lower right hand corner
- */
- public final int getLastColumn() {
- return _lastCol;
- }
-
- /**
- * @return row number for the lower right hand corner
- */
- public final int getLastRow() {
- return _lastRow;
- }
-
- /**
- * Determines if the given coordinates lie within the bounds
- * of this range.
- *
- * @param rowInd The row, 0-based.
- * @param colInd The column, 0-based.
- * @return True if the coordinates lie within the bounds, false otherwise.
- * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap
- */
- public boolean isInRange(int rowInd, int colInd) {
- return _firstRow <= rowInd && rowInd <= _lastRow && //containsRow
- _firstCol <= colInd && colInd <= _lastCol; //containsColumn
- }
+ private int _firstRow;
+ private int _firstCol;
+ private int _lastRow;
+ private int _lastCol;
+
+ protected CellRangeAddressBase(int firstRow, int lastRow, int firstCol, int lastCol) {
+ _firstRow = firstRow;
+ _lastRow = lastRow;
+ _firstCol = firstCol;
+ _lastCol = lastCol;
+ }
+
+ /**
+ * Validate the range limits against the supplied version of Excel
+ *
+ * @param ssVersion the version of Excel to validate against
+ * @throws IllegalArgumentException if the range limits are outside of the allowed range
+ */
+ public void validate(SpreadsheetVersion ssVersion) {
+ validateRow(_firstRow, ssVersion);
+ validateRow(_lastRow, ssVersion);
+ validateColumn(_firstCol, ssVersion);
+ validateColumn(_lastCol, ssVersion);
+ }
+ /**
+ * Runs a bounds check for row numbers
+ */
+ private static void validateRow(int row, SpreadsheetVersion ssVersion) {
+ int maxrow = ssVersion.getLastRowIndex();
+ if (row > maxrow) throw new IllegalArgumentException("Maximum row number is " + maxrow);
+ if (row < 0) throw new IllegalArgumentException("Minumum row number is 0");
+ }
+
+ /**
+ * Runs a bounds check for column numbers
+ */
+ private static void validateColumn(int column, SpreadsheetVersion ssVersion) {
+ int maxcol = ssVersion.getLastColumnIndex();
+ if (column > maxcol) throw new IllegalArgumentException("Maximum column number is " + maxcol);
+ if (column < 0) throw new IllegalArgumentException("Minimum column number is 0");
+ }
+
+
+ //TODO use the correct SpreadsheetVersion
+ public final boolean isFullColumnRange() {
+ return (_firstRow == 0 && _lastRow == SpreadsheetVersion.EXCEL97.getLastRowIndex())
+ || (_firstRow == -1 && _lastRow == -1);
+ }
+ //TODO use the correct SpreadsheetVersion
+ public final boolean isFullRowRange() {
+ return (_firstCol == 0 && _lastCol == SpreadsheetVersion.EXCEL97.getLastColumnIndex())
+ || (_firstCol == -1 && _lastCol == -1);
+ }
+
+ /**
+ * @return column number for the upper left hand corner
+ */
+ public final int getFirstColumn() {
+ return _firstCol;
+ }
+
+ /**
+ * @return row number for the upper left hand corner
+ */
+ public final int getFirstRow() {
+ return _firstRow;
+ }
+
+ /**
+ * @return column number for the lower right hand corner
+ */
+ public final int getLastColumn() {
+ return _lastCol;
+ }
+
+ /**
+ * @return row number for the lower right hand corner
+ */
+ public final int getLastRow() {
+ return _lastRow;
+ }
+
+ /**
+ * Determines if the given coordinates lie within the bounds
+ * of this range.
+ *
+ * @param rowInd The row, 0-based.
+ * @param colInd The column, 0-based.
+ * @return True if the coordinates lie within the bounds, false otherwise.
+ * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap
+ */
+ public boolean isInRange(int rowInd, int colInd) {
+ return _firstRow <= rowInd && rowInd <= _lastRow && //containsRow
+ _firstCol <= colInd && colInd <= _lastCol; //containsColumn
+ }
/**
* Determines if the given {@link CellReference} lies within the bounds
@@ -160,9 +160,9 @@ public abstract class CellRangeAddressBa
* @return True if the reference lies within the bounds, false otherwise.
* @see #intersects(CellRangeAddressBase) for checking if two ranges overlap
*/
- public boolean isInRange(CellReference ref) {
- return isInRange(ref.getRow(), ref.getCol());
- }
+ public boolean isInRange(CellReference ref) {
+ return isInRange(ref.getRow(), ref.getCol());
+ }
/**
* Determines if the given {@link CellAddress} lies within the bounds
@@ -178,213 +178,213 @@ public abstract class CellRangeAddressBa
return isInRange(ref.getRow(), ref.getColumn());
}
- /**
- * Determines if the given {@link Cell} lies within the bounds
- * of this range.
- * <p>NOTE: It is up to the caller to ensure the reference is
- * for the correct sheet, since this instance doesn't have a sheet reference.
- *
- * @param cell the Cell to check
- * @return True if the cell lies within the bounds, false otherwise.
- * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap
- */
- public boolean isInRange(Cell cell) {
- return isInRange(cell.getRowIndex(), cell.getColumnIndex());
- }
-
- /**
- * Check if the row is in the specified cell range
- *
- * @param rowInd the row to check
- * @return true if the range contains the row [rowInd]
- */
- public boolean containsRow(int rowInd) {
- return _firstRow <= rowInd && rowInd <= _lastRow;
- }
-
- /**
- * Check if the column is in the specified cell range
- *
- * @param colInd the column to check
- * @return true if the range contains the column [colInd]
- */
- public boolean containsColumn(int colInd) {
- return _firstCol <= colInd && colInd <= _lastCol;
- }
-
- /**
- * Determines whether or not this CellRangeAddress and the specified CellRangeAddress intersect.
- *
- * @param other a candidate cell range address to check for intersection with this range
- * @return returns true if this range and other range have at least 1 cell in common
- * @see #isInRange(int, int) for checking if a single cell intersects
- */
- public boolean intersects(CellRangeAddressBase other) {
- return this._firstRow <= other._lastRow &&
- this._firstCol <= other._lastCol &&
- other._firstRow <= this._lastRow &&
- other._firstCol <= this._lastCol;
- }
-
- /**
- * Useful for logic like table/range styling, where some elements apply based on relative position in a range.
- * @return set of {@link CellPosition}s occupied by the given coordinates. Empty if the coordinates are not in the range, never null.
- * @since 3.17 beta 1
- */
- public Set<CellPosition> getPosition(int rowInd, int colInd) {
- Set<CellPosition> positions = EnumSet.noneOf(CellPosition.class);
- if (rowInd > getFirstRow() && rowInd < getLastRow() && colInd > getFirstColumn() && colInd < getLastColumn()) {
- positions.add(CellPosition.INSIDE);
- return positions; // entirely inside, matches no boundaries
- }
- // check edges
- if (rowInd == getFirstRow()) positions.add(CellPosition.TOP);
- if (rowInd == getLastRow()) positions.add(CellPosition.BOTTOM);
- if (colInd == getFirstColumn()) positions.add(CellPosition.LEFT);
- if (colInd == getLastColumn()) positions.add(CellPosition.RIGHT);
-
- return positions;
- }
-
- /**
- * @param firstCol column number for the upper left hand corner
- */
- public final void setFirstColumn(int firstCol) {
- _firstCol = firstCol;
- }
-
- /**
- * @param firstRow row number for the upper left hand corner
- */
- public final void setFirstRow(int firstRow) {
- _firstRow = firstRow;
- }
-
- /**
- * @param lastCol column number for the lower right hand corner
- */
- public final void setLastColumn(int lastCol) {
- _lastCol = lastCol;
- }
-
- /**
- * @param lastRow row number for the lower right hand corner
- */
- public final void setLastRow(int lastRow) {
- _lastRow = lastRow;
- }
- /**
- * @return the size of the range (number of cells in the area).
- */
- public int getNumberOfCells() {
- return (_lastRow - _firstRow + 1) * (_lastCol - _firstCol + 1);
- }
-
- /**
- * Returns an iterator over the CellAddresses in this cell range in row-major order.
- * @since POI 4.0.0
- */
- @Override
- public Iterator<CellAddress> iterator() {
- return new RowMajorCellAddressIterator(this);
- }
-
- /**
- * Iterates over the cell addresses in a cell range in row major order
- *
- * The iterator is unaffected by changes to the CellRangeAddressBase instance
- * after the iterator is created.
- */
- private static class RowMajorCellAddressIterator implements Iterator<CellAddress> {
- private final int firstRow, firstCol, lastRow, lastCol;
- private int r, c;
-
- public RowMajorCellAddressIterator(CellRangeAddressBase ref) {
- r = firstRow = ref.getFirstRow();
- c = firstCol = ref.getFirstColumn();
- lastRow = ref.getLastRow();
- lastCol = ref.getLastColumn();
-
- // whole row and whole column ranges currently not supported
- if (firstRow < 0) throw new IllegalStateException("First row cannot be negative.");
- if (firstCol < 0) throw new IllegalStateException("First column cannot be negative.");
-
- // avoid infinite iteration
- if (firstRow > lastRow) throw new IllegalStateException("First row cannot be greater than last row.");
- if (firstCol > lastCol) throw new IllegalStateException("First column cannot be greater than last column.");
- }
-
- @Override
- public boolean hasNext() {
- return r <= lastRow && c <= lastCol;
- }
-
- @Override
- public CellAddress next() {
- if (hasNext()) {
- final CellAddress addr = new CellAddress(r, c);
- // row major order
- if (c < lastCol) {
- c++;
- }
- else { //c >= lastCol, end of row reached
- c = firstCol; //CR
- r++; //LF
- }
- return addr;
- }
- throw new NoSuchElementException();
- }
- }
-
- @Override
- public final String toString() {
- CellAddress crA = new CellAddress(_firstRow, _firstCol);
- CellAddress crB = new CellAddress(_lastRow, _lastCol);
- return getClass().getName() + " [" + crA.formatAsString() + ":" + crB.formatAsString() +"]";
- }
-
- // In case _firstRow > _lastRow or _firstCol > _lastCol
- protected int getMinRow() {
- return Math.min(_firstRow, _lastRow);
- }
- protected int getMaxRow() {
- return Math.max(_firstRow, _lastRow);
- }
- protected int getMinColumn() {
- return Math.min(_firstCol, _lastCol);
- }
- protected int getMaxColumn() {
- return Math.max(_firstCol, _lastCol);
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof CellRangeAddressBase) {
- CellRangeAddressBase o = (CellRangeAddressBase) other;
- return ((getMinRow() == o.getMinRow()) &&
- (getMaxRow() == o.getMaxRow()) &&
- (getMinColumn() == o.getMinColumn()) &&
- (getMaxColumn() == o.getMaxColumn()));
- }
- return false;
- }
+ /**
+ * Determines if the given {@link Cell} lies within the bounds
+ * of this range.
+ * <p>NOTE: It is up to the caller to ensure the reference is
+ * for the correct sheet, since this instance doesn't have a sheet reference.
+ *
+ * @param cell the Cell to check
+ * @return True if the cell lies within the bounds, false otherwise.
+ * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap
+ */
+ public boolean isInRange(Cell cell) {
+ return isInRange(cell.getRowIndex(), cell.getColumnIndex());
+ }
+
+ /**
+ * Check if the row is in the specified cell range
+ *
+ * @param rowInd the row to check
+ * @return true if the range contains the row [rowInd]
+ */
+ public boolean containsRow(int rowInd) {
+ return _firstRow <= rowInd && rowInd <= _lastRow;
+ }
+
+ /**
+ * Check if the column is in the specified cell range
+ *
+ * @param colInd the column to check
+ * @return true if the range contains the column [colInd]
+ */
+ public boolean containsColumn(int colInd) {
+ return _firstCol <= colInd && colInd <= _lastCol;
+ }
+
+ /**
+ * Determines whether or not this CellRangeAddress and the specified CellRangeAddress intersect.
+ *
+ * @param other a candidate cell range address to check for intersection with this range
+ * @return returns true if this range and other range have at least 1 cell in common
+ * @see #isInRange(int, int) for checking if a single cell intersects
+ */
+ public boolean intersects(CellRangeAddressBase other) {
+ return this._firstRow <= other._lastRow &&
+ this._firstCol <= other._lastCol &&
+ other._firstRow <= this._lastRow &&
+ other._firstCol <= this._lastCol;
+ }
+
+ /**
+ * Useful for logic like table/range styling, where some elements apply based on relative position in a range.
+ * @return set of {@link CellPosition}s occupied by the given coordinates. Empty if the coordinates are not in the range, never null.
+ * @since 3.17 beta 1
+ */
+ public Set<CellPosition> getPosition(int rowInd, int colInd) {
+ Set<CellPosition> positions = EnumSet.noneOf(CellPosition.class);
+ if (rowInd > getFirstRow() && rowInd < getLastRow() && colInd > getFirstColumn() && colInd < getLastColumn()) {
+ positions.add(CellPosition.INSIDE);
+ return positions; // entirely inside, matches no boundaries
+ }
+ // check edges
+ if (rowInd == getFirstRow()) positions.add(CellPosition.TOP);
+ if (rowInd == getLastRow()) positions.add(CellPosition.BOTTOM);
+ if (colInd == getFirstColumn()) positions.add(CellPosition.LEFT);
+ if (colInd == getLastColumn()) positions.add(CellPosition.RIGHT);
+
+ return positions;
+ }
+
+ /**
+ * @param firstCol column number for the upper left hand corner
+ */
+ public final void setFirstColumn(int firstCol) {
+ _firstCol = firstCol;
+ }
+
+ /**
+ * @param firstRow row number for the upper left hand corner
+ */
+ public final void setFirstRow(int firstRow) {
+ _firstRow = firstRow;
+ }
+
+ /**
+ * @param lastCol column number for the lower right hand corner
+ */
+ public final void setLastColumn(int lastCol) {
+ _lastCol = lastCol;
+ }
+
+ /**
+ * @param lastRow row number for the lower right hand corner
+ */
+ public final void setLastRow(int lastRow) {
+ _lastRow = lastRow;
+ }
+ /**
+ * @return the size of the range (number of cells in the area).
+ */
+ public int getNumberOfCells() {
+ return (_lastRow - _firstRow + 1) * (_lastCol - _firstCol + 1);
+ }
+
+ /**
+ * Returns an iterator over the CellAddresses in this cell range in row-major order.
+ * @since POI 4.0.0
+ */
+ @Override
+ public Iterator<CellAddress> iterator() {
+ return new RowMajorCellAddressIterator(this);
+ }
- @Override
- public int hashCode() {
+ /**
+ * Iterates over the cell addresses in a cell range in row major order
+ *
+ * The iterator is unaffected by changes to the CellRangeAddressBase instance
+ * after the iterator is created.
+ */
+ private static class RowMajorCellAddressIterator implements Iterator<CellAddress> {
+ private final int firstRow, firstCol, lastRow, lastCol;
+ private int r, c;
+
+ public RowMajorCellAddressIterator(CellRangeAddressBase ref) {
+ r = firstRow = ref.getFirstRow();
+ c = firstCol = ref.getFirstColumn();
+ lastRow = ref.getLastRow();
+ lastCol = ref.getLastColumn();
+
+ // whole row and whole column ranges currently not supported
+ if (firstRow < 0) throw new IllegalStateException("First row cannot be negative.");
+ if (firstCol < 0) throw new IllegalStateException("First column cannot be negative.");
+
+ // avoid infinite iteration
+ if (firstRow > lastRow) throw new IllegalStateException("First row cannot be greater than last row.");
+ if (firstCol > lastCol) throw new IllegalStateException("First column cannot be greater than last column.");
+ }
+
+ @Override
+ public boolean hasNext() {
+ return r <= lastRow && c <= lastCol;
+ }
+
+ @Override
+ public CellAddress next() {
+ if (hasNext()) {
+ final CellAddress addr = new CellAddress(r, c);
+ // row major order
+ if (c < lastCol) {
+ c++;
+ }
+ else { //c >= lastCol, end of row reached
+ c = firstCol; //CR
+ r++; //LF
+ }
+ return addr;
+ }
+ throw new NoSuchElementException();
+ }
+ }
+
+ @Override
+ public final String toString() {
+ CellAddress crA = new CellAddress(_firstRow, _firstCol);
+ CellAddress crB = new CellAddress(_lastRow, _lastCol);
+ return getClass().getName() + " [" + crA.formatAsString() + ":" + crB.formatAsString() +"]";
+ }
+
+ // In case _firstRow > _lastRow or _firstCol > _lastCol
+ protected int getMinRow() {
+ return Math.min(_firstRow, _lastRow);
+ }
+ protected int getMaxRow() {
+ return Math.max(_firstRow, _lastRow);
+ }
+ protected int getMinColumn() {
+ return Math.min(_firstCol, _lastCol);
+ }
+ protected int getMaxColumn() {
+ return Math.max(_firstCol, _lastCol);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof CellRangeAddressBase) {
+ CellRangeAddressBase o = (CellRangeAddressBase) other;
+ return ((getMinRow() == o.getMinRow()) &&
+ (getMaxRow() == o.getMaxRow()) &&
+ (getMinColumn() == o.getMinColumn()) &&
+ (getMaxColumn() == o.getMaxColumn()));
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
return (getMinColumn() +
(getMaxColumn() << 8) +
(getMinRow() << 16) +
(getMaxRow() << 24));
- }
+ }
- @Override
- public Map<String, Supplier<?>> getGenericProperties() {
- return GenericRecordUtil.getGenericProperties(
- "firstRow", this::getFirstRow,
- "firstCol", this::getFirstColumn,
- "lastRow", this::getLastRow,
- "lastCol", this::getLastColumn
- );
- }
+ @Override
+ public Map<String, Supplier<?>> getGenericProperties() {
+ return GenericRecordUtil.getGenericProperties(
+ "firstRow", this::getFirstRow,
+ "firstCol", this::getFirstColumn,
+ "lastRow", this::getLastRow,
+ "lastCol", this::getLastColumn
+ );
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org