Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,32 @@ Licensed to the Apache Software Foundation (ASF) under one or more
* @since 3.16-beta3
*/
@Internal
class XSSFBCellRange {
public class XSSFBCellRange {

//TODO: Convert this to generate an AreaReference
public static final int length = 4 * LittleEndianConsts.INT_SIZE;

private int firstRow;
private int lastRow;
private int firstCol;
private int lastCol;

public XSSFBCellRange(int firstRow, int lastRow, int firstCol, int lastCol) {
this.firstRow = firstRow;
this.lastRow = lastRow;
this.firstCol = firstCol;
this.lastCol = lastCol;
}

XSSFBCellRange() {
}

public static final int length = 4* LittleEndianConsts.INT_SIZE;
/**
* Parses an RfX cell range from the data starting at the offset.
* This performs no range checking.
* @param data raw bytes
* @param offset offset at which to start reading from data
* @param cellRange to overwrite. If null, a new cellRange will be created.
* @return a mutable cell range.
* @param cellRange to update. If null, a new cellRange will be created.
* @return the updated or new cell range
*/
public static XSSFBCellRange parse(byte[] data, int offset, XSSFBCellRange cellRange) {
if (cellRange == null) {
Expand All @@ -46,14 +61,11 @@ public static XSSFBCellRange parse(byte[] data, int offset, XSSFBCellRange cellR
cellRange.lastRow = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); offset += LittleEndianConsts.INT_SIZE;
cellRange.firstCol = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset)); offset += LittleEndianConsts.INT_SIZE;
cellRange.lastCol = XSSFBUtils.castToInt(LittleEndian.getUInt(data, offset));

return cellRange;
}

int firstRow;
int lastRow;
int firstCol;
int lastCol;


public int getFirstRow() { return firstRow; }
public int getLastRow() { return lastRow; }
public int getFirstCol() { return firstCol; }
public int getLastCol() { return lastCol; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ public void handleRecord(int id, byte[] data) throws XSSFBParseException {
int offset = 0;
authorId = XSSFBUtils.castToInt(LittleEndian.getUInt(data)); offset += LittleEndianConsts.INT_SIZE;
cellRange = XSSFBCellRange.parse(data, offset, cellRange);
offset+= XSSFBCellRange.length;
//for strict parsing; confirm that firstRow==lastRow and firstCol==colLats (2.4.28)
cellAddress = new CellAddress(cellRange.firstRow, cellRange.firstCol);
cellAddress = new CellAddress(cellRange.getFirstRow(), cellRange.getFirstCol());
break;
case BrtCommentText:
XSSFBRichStr xssfbRichStr = XSSFBRichStr.build(data, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void handleRecord(int recordType, byte[] data) throws XSSFBParseException
xlWideStringBuffer.setLength(0);
/*offset +=*/ XSSFBUtils.readXLWideString(data, offset, xlWideStringBuffer);
String display = xlWideStringBuffer.toString();
CellRangeAddress cellRangeAddress = new CellRangeAddress(hyperlinkCellRange.firstRow, hyperlinkCellRange.lastRow, hyperlinkCellRange.firstCol, hyperlinkCellRange.lastCol);
CellRangeAddress cellRangeAddress = new CellRangeAddress(hyperlinkCellRange.getFirstRow(), hyperlinkCellRange.getLastRow(), hyperlinkCellRange.getFirstCol(), hyperlinkCellRange.getLastCol());

String url = relIdToHyperlink.get(relId);
if (location.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
* @since 3.16-beta3
*/
@Internal
class XSSFBRichStr {
public class XSSFBRichStr {

public static XSSFBRichStr build(byte[] bytes, int offset) throws XSSFBParseException {
byte first = bytes[offset];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class XSSFBUtils {
* @return number of bytes read
* @throws XSSFBParseException if there was an exception during reading
*/
static int readXLNullableWideString(byte[] data, int offset, StringBuilder sb) throws XSSFBParseException {
public static int readXLNullableWideString(byte[] data, int offset, StringBuilder sb) throws XSSFBParseException {
long numChars = LittleEndian.getUInt(data, offset);
if (numChars < 0) {
throw new XSSFBParseException("too few chars to read");
Expand Down Expand Up @@ -85,14 +85,14 @@ public static int readXLWideString(byte[] data, int offset, StringBuilder sb) th
return numBytes;
}

static int castToInt(long val) {
public static int castToInt(long val) {
if (val < Integer.MAX_VALUE && val > Integer.MIN_VALUE) {
return (int)val;
}
throw new POIXMLException("val ("+val+") can't be cast to int");
}

static short castToShort(int val) {
public static short castToShort(int val) {
if (val < Short.MAX_VALUE && val > Short.MIN_VALUE) {
return (short)val;
}
Expand All @@ -101,7 +101,7 @@ static short castToShort(int val) {
}

//TODO: move to LittleEndian?
static int get24BitInt( byte[] data, int offset) {
public static int get24BitInt(byte[] data, int offset) {
int i = offset;
int b0 = data[i++] & 0xFF;
int b1 = data[i++] & 0xFF;
Expand Down