whitespace (tabs to spaces)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/xssf_structured_references@1747638 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f17c9a9c25
commit
95df2cc417
@ -36,9 +36,9 @@ public final class Area3DPxg extends AreaPtgBase implements Pxg3D {
|
|||||||
private String firstSheetName;
|
private String firstSheetName;
|
||||||
private String lastSheetName;
|
private String lastSheetName;
|
||||||
|
|
||||||
public Area3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, String arearef) {
|
public Area3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, String arearef) {
|
||||||
this(externalWorkbookNumber, sheetName, new AreaReference(arearef));
|
this(externalWorkbookNumber, sheetName, new AreaReference(arearef));
|
||||||
}
|
}
|
||||||
public Area3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, AreaReference arearef) {
|
public Area3DPxg(int externalWorkbookNumber, SheetIdentifier sheetName, AreaReference arearef) {
|
||||||
super(arearef);
|
super(arearef);
|
||||||
this.externalWorkbookNumber = externalWorkbookNumber;
|
this.externalWorkbookNumber = externalWorkbookNumber;
|
||||||
@ -57,8 +57,8 @@ public final class Area3DPxg extends AreaPtgBase implements Pxg3D {
|
|||||||
this(-1, sheetName, arearef);
|
this(-1, sheetName, arearef);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append(getClass().getName());
|
sb.append(getClass().getName());
|
||||||
sb.append(" [");
|
sb.append(" [");
|
||||||
@ -76,8 +76,8 @@ public final class Area3DPxg extends AreaPtgBase implements Pxg3D {
|
|||||||
sb.append(formatReferenceAsString());
|
sb.append(formatReferenceAsString());
|
||||||
sb.append("]");
|
sb.append("]");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExternalWorkbookNumber() {
|
public int getExternalWorkbookNumber() {
|
||||||
return externalWorkbookNumber;
|
return externalWorkbookNumber;
|
||||||
}
|
}
|
||||||
|
@ -31,272 +31,272 @@ import org.apache.poi.util.LittleEndianOutput;
|
|||||||
* @author Jason Height (jheight at chariot dot net dot au)
|
* @author Jason Height (jheight at chariot dot net dot au)
|
||||||
*/
|
*/
|
||||||
public abstract class AreaPtgBase extends OperandPtg implements AreaI {
|
public abstract class AreaPtgBase extends OperandPtg implements AreaI {
|
||||||
/**
|
/**
|
||||||
* TODO - (May-2008) fix subclasses of AreaPtg 'AreaN~' which are used in shared formulas.
|
* TODO - (May-2008) fix subclasses of AreaPtg 'AreaN~' which are used in shared formulas.
|
||||||
* see similar comment in ReferencePtg
|
* see similar comment in ReferencePtg
|
||||||
*/
|
*/
|
||||||
protected final RuntimeException notImplemented() {
|
protected final RuntimeException notImplemented() {
|
||||||
return new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
return new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** zero based, unsigned 16 bit */
|
/** zero based, unsigned 16 bit */
|
||||||
private int field_1_first_row;
|
private int field_1_first_row;
|
||||||
/** zero based, unsigned 16 bit */
|
/** zero based, unsigned 16 bit */
|
||||||
private int field_2_last_row;
|
private int field_2_last_row;
|
||||||
/** zero based, unsigned 8 bit */
|
/** zero based, unsigned 8 bit */
|
||||||
private int field_3_first_column; //BitFields: (first row relative, first col relative, first column number)
|
private int field_3_first_column; //BitFields: (first row relative, first col relative, first column number)
|
||||||
/** zero based, unsigned 8 bit */
|
/** zero based, unsigned 8 bit */
|
||||||
private int field_4_last_column; //BitFields: (last row relative, last col relative, last column number)
|
private int field_4_last_column; //BitFields: (last row relative, last col relative, last column number)
|
||||||
|
|
||||||
private final static BitField rowRelative = BitFieldFactory.getInstance(0x8000);
|
private final static BitField rowRelative = BitFieldFactory.getInstance(0x8000);
|
||||||
private final static BitField colRelative = BitFieldFactory.getInstance(0x4000);
|
private final static BitField colRelative = BitFieldFactory.getInstance(0x4000);
|
||||||
private final static BitField columnMask = BitFieldFactory.getInstance(0x3FFF);
|
private final static BitField columnMask = BitFieldFactory.getInstance(0x3FFF);
|
||||||
|
|
||||||
protected AreaPtgBase() {
|
protected AreaPtgBase() {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AreaPtgBase(AreaReference ar) {
|
protected AreaPtgBase(AreaReference ar) {
|
||||||
CellReference firstCell = ar.getFirstCell();
|
CellReference firstCell = ar.getFirstCell();
|
||||||
CellReference lastCell = ar.getLastCell();
|
CellReference lastCell = ar.getLastCell();
|
||||||
setFirstRow(firstCell.getRow());
|
setFirstRow(firstCell.getRow());
|
||||||
setFirstColumn(firstCell.getCol() == -1 ? 0 : firstCell.getCol());
|
setFirstColumn(firstCell.getCol() == -1 ? 0 : firstCell.getCol());
|
||||||
setLastRow(lastCell.getRow());
|
setLastRow(lastCell.getRow());
|
||||||
setLastColumn(lastCell.getCol() == -1 ? 0xFF : lastCell.getCol());
|
setLastColumn(lastCell.getCol() == -1 ? 0xFF : lastCell.getCol());
|
||||||
setFirstColRelative(!firstCell.isColAbsolute());
|
setFirstColRelative(!firstCell.isColAbsolute());
|
||||||
setLastColRelative(!lastCell.isColAbsolute());
|
setLastColRelative(!lastCell.isColAbsolute());
|
||||||
setFirstRowRelative(!firstCell.isRowAbsolute());
|
setFirstRowRelative(!firstCell.isRowAbsolute());
|
||||||
setLastRowRelative(!lastCell.isRowAbsolute());
|
setLastRowRelative(!lastCell.isRowAbsolute());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AreaPtgBase(int firstRow, int lastRow, int firstColumn, int lastColumn,
|
protected AreaPtgBase(int firstRow, int lastRow, int firstColumn, int lastColumn,
|
||||||
boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) {
|
boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) {
|
||||||
|
|
||||||
if (lastRow >= firstRow) {
|
if (lastRow >= firstRow) {
|
||||||
setFirstRow(firstRow);
|
setFirstRow(firstRow);
|
||||||
setLastRow(lastRow);
|
setLastRow(lastRow);
|
||||||
setFirstRowRelative(firstRowRelative);
|
setFirstRowRelative(firstRowRelative);
|
||||||
setLastRowRelative(lastRowRelative);
|
setLastRowRelative(lastRowRelative);
|
||||||
} else {
|
} else {
|
||||||
setFirstRow(lastRow);
|
setFirstRow(lastRow);
|
||||||
setLastRow(firstRow);
|
setLastRow(firstRow);
|
||||||
setFirstRowRelative(lastRowRelative);
|
setFirstRowRelative(lastRowRelative);
|
||||||
setLastRowRelative(firstRowRelative);
|
setLastRowRelative(firstRowRelative);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastColumn >= firstColumn) {
|
if (lastColumn >= firstColumn) {
|
||||||
setFirstColumn(firstColumn);
|
setFirstColumn(firstColumn);
|
||||||
setLastColumn(lastColumn);
|
setLastColumn(lastColumn);
|
||||||
setFirstColRelative(firstColRelative);
|
setFirstColRelative(firstColRelative);
|
||||||
setLastColRelative(lastColRelative);
|
setLastColRelative(lastColRelative);
|
||||||
} else {
|
} else {
|
||||||
setFirstColumn(lastColumn);
|
setFirstColumn(lastColumn);
|
||||||
setLastColumn(firstColumn);
|
setLastColumn(firstColumn);
|
||||||
setFirstColRelative(lastColRelative);
|
setFirstColRelative(lastColRelative);
|
||||||
setLastColRelative(firstColRelative);
|
setLastColRelative(firstColRelative);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort the first and last row and columns in-place to the preferred (top left:bottom right) order
|
* Sort the first and last row and columns in-place to the preferred (top left:bottom right) order
|
||||||
* Note: Sort only occurs when an instance is constructed or when this method is called.
|
* Note: Sort only occurs when an instance is constructed or when this method is called.
|
||||||
*
|
*
|
||||||
* <p>For example, <code>$E5:B$10</code> becomes <code>B5:$E$10</code></p>
|
* <p>For example, <code>$E5:B$10</code> becomes <code>B5:$E$10</code></p>
|
||||||
*/
|
*/
|
||||||
public void sortTopLeftToBottomRight() {
|
public void sortTopLeftToBottomRight() {
|
||||||
if (getFirstRow() > getLastRow()) {
|
if (getFirstRow() > getLastRow()) {
|
||||||
//swap first row and last row numbers and relativity
|
//swap first row and last row numbers and relativity
|
||||||
//Note: cannot just swap the fields because row relativity is stored in fields 3 and 4
|
//Note: cannot just swap the fields because row relativity is stored in fields 3 and 4
|
||||||
final int firstRow = getFirstRow();
|
final int firstRow = getFirstRow();
|
||||||
final boolean firstRowRel = isFirstRowRelative();
|
final boolean firstRowRel = isFirstRowRelative();
|
||||||
setFirstRow(getLastRow());
|
setFirstRow(getLastRow());
|
||||||
setFirstRowRelative(isLastRowRelative());
|
setFirstRowRelative(isLastRowRelative());
|
||||||
setLastRow(firstRow);
|
setLastRow(firstRow);
|
||||||
setLastRowRelative(firstRowRel);
|
setLastRowRelative(firstRowRel);
|
||||||
}
|
}
|
||||||
if (getFirstColumn() > getLastColumn()) {
|
if (getFirstColumn() > getLastColumn()) {
|
||||||
//swap first column and last column numbers and relativity
|
//swap first column and last column numbers and relativity
|
||||||
//Note: cannot just swap the fields because row relativity is stored in fields 3 and 4
|
//Note: cannot just swap the fields because row relativity is stored in fields 3 and 4
|
||||||
final int firstCol = getFirstColumn();
|
final int firstCol = getFirstColumn();
|
||||||
final boolean firstColRel = isFirstColRelative();
|
final boolean firstColRel = isFirstColRelative();
|
||||||
setFirstColumn(getLastColumn());
|
setFirstColumn(getLastColumn());
|
||||||
setFirstColRelative(isLastColRelative());
|
setFirstColRelative(isLastColRelative());
|
||||||
setLastColumn(firstCol);
|
setLastColumn(firstCol);
|
||||||
setLastColRelative(firstColRel);
|
setLastColRelative(firstColRel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void readCoordinates(LittleEndianInput in) {
|
protected final void readCoordinates(LittleEndianInput in) {
|
||||||
field_1_first_row = in.readUShort();
|
field_1_first_row = in.readUShort();
|
||||||
field_2_last_row = in.readUShort();
|
field_2_last_row = in.readUShort();
|
||||||
field_3_first_column = in.readUShort();
|
field_3_first_column = in.readUShort();
|
||||||
field_4_last_column = in.readUShort();
|
field_4_last_column = in.readUShort();
|
||||||
}
|
}
|
||||||
protected final void writeCoordinates(LittleEndianOutput out) {
|
protected final void writeCoordinates(LittleEndianOutput out) {
|
||||||
out.writeShort(field_1_first_row);
|
out.writeShort(field_1_first_row);
|
||||||
out.writeShort(field_2_last_row);
|
out.writeShort(field_2_last_row);
|
||||||
out.writeShort(field_3_first_column);
|
out.writeShort(field_3_first_column);
|
||||||
out.writeShort(field_4_last_column);
|
out.writeShort(field_4_last_column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the first row in the area
|
* @return the first row in the area
|
||||||
*/
|
*/
|
||||||
public final int getFirstRow() {
|
public final int getFirstRow() {
|
||||||
return field_1_first_row;
|
return field_1_first_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets the first row
|
* sets the first row
|
||||||
* @param rowIx number (0-based)
|
* @param rowIx number (0-based)
|
||||||
*/
|
*/
|
||||||
public final void setFirstRow(int rowIx) {
|
public final void setFirstRow(int rowIx) {
|
||||||
field_1_first_row = rowIx;
|
field_1_first_row = rowIx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return last row in the range (x2 in x1,y1-x2,y2)
|
* @return last row in the range (x2 in x1,y1-x2,y2)
|
||||||
*/
|
*/
|
||||||
public final int getLastRow() {
|
public final int getLastRow() {
|
||||||
return field_2_last_row;
|
return field_2_last_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rowIx last row number in the area
|
* @param rowIx last row number in the area
|
||||||
*/
|
*/
|
||||||
public final void setLastRow(int rowIx) {
|
public final void setLastRow(int rowIx) {
|
||||||
field_2_last_row = rowIx;
|
field_2_last_row = rowIx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the first column number in the area.
|
* @return the first column number in the area.
|
||||||
*/
|
*/
|
||||||
public final int getFirstColumn() {
|
public final int getFirstColumn() {
|
||||||
return columnMask.getValue(field_3_first_column);
|
return columnMask.getValue(field_3_first_column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the first column number + the options bit settings unstripped
|
* @return the first column number + the options bit settings unstripped
|
||||||
*/
|
*/
|
||||||
public final short getFirstColumnRaw() {
|
public final short getFirstColumnRaw() {
|
||||||
return (short) field_3_first_column; // TODO
|
return (short) field_3_first_column; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether or not the first row is a relative reference or not.
|
* @return whether or not the first row is a relative reference or not.
|
||||||
*/
|
*/
|
||||||
public final boolean isFirstRowRelative() {
|
public final boolean isFirstRowRelative() {
|
||||||
return rowRelative.isSet(field_3_first_column);
|
return rowRelative.isSet(field_3_first_column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets the first row to relative or not
|
* sets the first row to relative or not
|
||||||
* @param rel is relative or not.
|
* @param rel is relative or not.
|
||||||
*/
|
*/
|
||||||
public final void setFirstRowRelative(boolean rel) {
|
public final void setFirstRowRelative(boolean rel) {
|
||||||
field_3_first_column=rowRelative.setBoolean(field_3_first_column,rel);
|
field_3_first_column=rowRelative.setBoolean(field_3_first_column,rel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return isrelative first column to relative or not
|
* @return isrelative first column to relative or not
|
||||||
*/
|
*/
|
||||||
public final boolean isFirstColRelative() {
|
public final boolean isFirstColRelative() {
|
||||||
return colRelative.isSet(field_3_first_column);
|
return colRelative.isSet(field_3_first_column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set whether the first column is relative
|
* set whether the first column is relative
|
||||||
*/
|
*/
|
||||||
public final void setFirstColRelative(boolean rel) {
|
public final void setFirstColRelative(boolean rel) {
|
||||||
field_3_first_column=colRelative.setBoolean(field_3_first_column,rel);
|
field_3_first_column=colRelative.setBoolean(field_3_first_column,rel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the first column in the area
|
* set the first column in the area
|
||||||
*/
|
*/
|
||||||
public final void setFirstColumn(int colIx) {
|
public final void setFirstColumn(int colIx) {
|
||||||
field_3_first_column=columnMask.setValue(field_3_first_column, colIx);
|
field_3_first_column=columnMask.setValue(field_3_first_column, colIx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the first column irrespective of the bitmasks
|
* set the first column irrespective of the bitmasks
|
||||||
*/
|
*/
|
||||||
public final void setFirstColumnRaw(int column) {
|
public final void setFirstColumnRaw(int column) {
|
||||||
field_3_first_column = column;
|
field_3_first_column = column;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return lastcolumn in the area
|
* @return lastcolumn in the area
|
||||||
*/
|
*/
|
||||||
public final int getLastColumn() {
|
public final int getLastColumn() {
|
||||||
return columnMask.getValue(field_4_last_column);
|
return columnMask.getValue(field_4_last_column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return last column and bitmask (the raw field)
|
* @return last column and bitmask (the raw field)
|
||||||
*/
|
*/
|
||||||
public final short getLastColumnRaw() {
|
public final short getLastColumnRaw() {
|
||||||
return (short) field_4_last_column;
|
return (short) field_4_last_column;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return last row relative or not
|
* @return last row relative or not
|
||||||
*/
|
*/
|
||||||
public final boolean isLastRowRelative() {
|
public final boolean isLastRowRelative() {
|
||||||
return rowRelative.isSet(field_4_last_column);
|
return rowRelative.isSet(field_4_last_column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set whether the last row is relative or not
|
* set whether the last row is relative or not
|
||||||
* @param rel <code>true</code> if the last row relative, else
|
* @param rel <code>true</code> if the last row relative, else
|
||||||
* <code>false</code>
|
* <code>false</code>
|
||||||
*/
|
*/
|
||||||
public final void setLastRowRelative(boolean rel) {
|
public final void setLastRowRelative(boolean rel) {
|
||||||
field_4_last_column=rowRelative.setBoolean(field_4_last_column,rel);
|
field_4_last_column=rowRelative.setBoolean(field_4_last_column,rel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return lastcol relative or not
|
* @return lastcol relative or not
|
||||||
*/
|
*/
|
||||||
public final boolean isLastColRelative() {
|
public final boolean isLastColRelative() {
|
||||||
return colRelative.isSet(field_4_last_column);
|
return colRelative.isSet(field_4_last_column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set whether the last column should be relative or not
|
* set whether the last column should be relative or not
|
||||||
*/
|
*/
|
||||||
public final void setLastColRelative(boolean rel) {
|
public final void setLastColRelative(boolean rel) {
|
||||||
field_4_last_column=colRelative.setBoolean(field_4_last_column,rel);
|
field_4_last_column=colRelative.setBoolean(field_4_last_column,rel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the last column in the area
|
* set the last column in the area
|
||||||
*/
|
*/
|
||||||
public final void setLastColumn(int colIx) {
|
public final void setLastColumn(int colIx) {
|
||||||
field_4_last_column=columnMask.setValue(field_4_last_column, colIx);
|
field_4_last_column=columnMask.setValue(field_4_last_column, colIx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the last column irrespective of the bitmasks
|
* set the last column irrespective of the bitmasks
|
||||||
*/
|
*/
|
||||||
public final void setLastColumnRaw(short column) {
|
public final void setLastColumnRaw(short column) {
|
||||||
field_4_last_column = column;
|
field_4_last_column = column;
|
||||||
}
|
}
|
||||||
protected final String formatReferenceAsString() {
|
protected final String formatReferenceAsString() {
|
||||||
CellReference topLeft = new CellReference(getFirstRow(),getFirstColumn(),!isFirstRowRelative(),!isFirstColRelative());
|
CellReference topLeft = new CellReference(getFirstRow(),getFirstColumn(),!isFirstRowRelative(),!isFirstColRelative());
|
||||||
CellReference botRight = new CellReference(getLastRow(),getLastColumn(),!isLastRowRelative(),!isLastColRelative());
|
CellReference botRight = new CellReference(getLastRow(),getLastColumn(),!isLastRowRelative(),!isLastColRelative());
|
||||||
|
|
||||||
if(AreaReference.isWholeColumnReference(SpreadsheetVersion.EXCEL97, topLeft, botRight)) {
|
if(AreaReference.isWholeColumnReference(SpreadsheetVersion.EXCEL97, topLeft, botRight)) {
|
||||||
return (new AreaReference(topLeft, botRight)).formatAsString();
|
return (new AreaReference(topLeft, botRight)).formatAsString();
|
||||||
}
|
}
|
||||||
return topLeft.formatAsString() + ":" + botRight.formatAsString();
|
return topLeft.formatAsString() + ":" + botRight.formatAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toFormulaString() {
|
public String toFormulaString() {
|
||||||
return formatReferenceAsString();
|
return formatReferenceAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getDefaultOperandClass() {
|
public byte getDefaultOperandClass() {
|
||||||
return Ptg.CLASS_REF;
|
return Ptg.CLASS_REF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
|||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CTTable getCTTable(){
|
public CTTable getCTTable() {
|
||||||
return ctTable;
|
return ctTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user