Replace some model.Sheet references with usermodel.HSSFSheet ones, to make more in keeping with xssf, and make merges easier
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@694946 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
592729a165
commit
5058c1f492
@ -89,7 +89,7 @@ public final class HSSFCell {
|
|||||||
public final static short ENCODING_UTF_16 = 1;
|
public final static short ENCODING_UTF_16 = 1;
|
||||||
|
|
||||||
private final HSSFWorkbook book;
|
private final HSSFWorkbook book;
|
||||||
private final Sheet sheet;
|
private final HSSFSheet sheet;
|
||||||
private int cellType;
|
private int cellType;
|
||||||
private HSSFRichTextString stringValue;
|
private HSSFRichTextString stringValue;
|
||||||
private CellValueRecordInterface record;
|
private CellValueRecordInterface record;
|
||||||
@ -111,7 +111,7 @@ public final class HSSFCell {
|
|||||||
*
|
*
|
||||||
* @see org.apache.poi.hssf.usermodel.HSSFRow#createCell(short)
|
* @see org.apache.poi.hssf.usermodel.HSSFRow#createCell(short)
|
||||||
*/
|
*/
|
||||||
protected HSSFCell(HSSFWorkbook book, Sheet sheet, int row, short col)
|
protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, int row, short col)
|
||||||
{
|
{
|
||||||
checkBounds(col);
|
checkBounds(col);
|
||||||
stringValue = null;
|
stringValue = null;
|
||||||
@ -121,10 +121,10 @@ public final class HSSFCell {
|
|||||||
// Relying on the fact that by default the cellType is set to 0 which
|
// Relying on the fact that by default the cellType is set to 0 which
|
||||||
// is different to CELL_TYPE_BLANK hence the following method call correctly
|
// is different to CELL_TYPE_BLANK hence the following method call correctly
|
||||||
// creates a new blank cell.
|
// creates a new blank cell.
|
||||||
short xfindex = sheet.getXFIndexForColAt(col);
|
short xfindex = sheet.getSheet().getXFIndexForColAt(col);
|
||||||
setCellType(CELL_TYPE_BLANK, false, row, col,xfindex);
|
setCellType(CELL_TYPE_BLANK, false, row, col,xfindex);
|
||||||
}
|
}
|
||||||
/* package */ Sheet getSheet() {
|
/* package */ HSSFSheet getSheet() {
|
||||||
return sheet;
|
return sheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ public final class HSSFCell {
|
|||||||
* Type of cell
|
* Type of cell
|
||||||
* @see org.apache.poi.hssf.usermodel.HSSFRow#createCell(short,int)
|
* @see org.apache.poi.hssf.usermodel.HSSFRow#createCell(short,int)
|
||||||
*/
|
*/
|
||||||
protected HSSFCell(HSSFWorkbook book, Sheet sheet, int row, short col,
|
protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, int row, short col,
|
||||||
int type)
|
int type)
|
||||||
{
|
{
|
||||||
checkBounds(col);
|
checkBounds(col);
|
||||||
@ -150,7 +150,7 @@ public final class HSSFCell {
|
|||||||
this.book = book;
|
this.book = book;
|
||||||
this.sheet = sheet;
|
this.sheet = sheet;
|
||||||
|
|
||||||
short xfindex = sheet.getXFIndexForColAt(col);
|
short xfindex = sheet.getSheet().getXFIndexForColAt(col);
|
||||||
setCellType(type,false,row,col,xfindex);
|
setCellType(type,false,row,col,xfindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ public final class HSSFCell {
|
|||||||
* @param sheet - Sheet record of the sheet containing this cell
|
* @param sheet - Sheet record of the sheet containing this cell
|
||||||
* @param cval - the Cell Value Record we wish to represent
|
* @param cval - the Cell Value Record we wish to represent
|
||||||
*/
|
*/
|
||||||
protected HSSFCell(HSSFWorkbook book, Sheet sheet, CellValueRecordInterface cval) {
|
protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, CellValueRecordInterface cval) {
|
||||||
record = cval;
|
record = cval;
|
||||||
cellType = determineType(cval);
|
cellType = determineType(cval);
|
||||||
stringValue = null;
|
stringValue = null;
|
||||||
@ -296,7 +296,7 @@ public final class HSSFCell {
|
|||||||
FormulaRecordAggregate frec;
|
FormulaRecordAggregate frec;
|
||||||
|
|
||||||
if (cellType != this.cellType) {
|
if (cellType != this.cellType) {
|
||||||
frec = sheet.createFormula(row, col);
|
frec = sheet.getSheet().createFormula(row, col);
|
||||||
} else {
|
} else {
|
||||||
frec = (FormulaRecordAggregate) record;
|
frec = (FormulaRecordAggregate) record;
|
||||||
frec.setRow(row);
|
frec.setRow(row);
|
||||||
@ -432,7 +432,7 @@ public final class HSSFCell {
|
|||||||
if (cellType != this.cellType &&
|
if (cellType != this.cellType &&
|
||||||
this.cellType!=-1 ) // Special Value to indicate an uninitialized Cell
|
this.cellType!=-1 ) // Special Value to indicate an uninitialized Cell
|
||||||
{
|
{
|
||||||
sheet.replaceValueRecord(record);
|
sheet.getSheet().replaceValueRecord(record);
|
||||||
}
|
}
|
||||||
this.cellType = cellType;
|
this.cellType = cellType;
|
||||||
}
|
}
|
||||||
@ -888,8 +888,8 @@ public final class HSSFCell {
|
|||||||
{
|
{
|
||||||
int row=record.getRow();
|
int row=record.getRow();
|
||||||
short col=record.getColumn();
|
short col=record.getColumn();
|
||||||
this.sheet.setActiveCellRow(row);
|
this.sheet.getSheet().setActiveCellRow(row);
|
||||||
this.sheet.setActiveCellCol(col);
|
this.sheet.getSheet().setActiveCellCol(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -954,7 +954,7 @@ public final class HSSFCell {
|
|||||||
*/
|
*/
|
||||||
public HSSFComment getCellComment(){
|
public HSSFComment getCellComment(){
|
||||||
if (comment == null) {
|
if (comment == null) {
|
||||||
comment = findCellComment(sheet, record.getRow(), record.getColumn());
|
comment = findCellComment(sheet.getSheet(), record.getRow(), record.getColumn());
|
||||||
}
|
}
|
||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
@ -966,7 +966,7 @@ public final class HSSFCell {
|
|||||||
* all comments after performing this action!
|
* all comments after performing this action!
|
||||||
*/
|
*/
|
||||||
public void removeCellComment() {
|
public void removeCellComment() {
|
||||||
HSSFComment comment = findCellComment(sheet, record.getRow(), record.getColumn());
|
HSSFComment comment = findCellComment(sheet.getSheet(), record.getRow(), record.getColumn());
|
||||||
this.comment = null;
|
this.comment = null;
|
||||||
|
|
||||||
if(comment == null) {
|
if(comment == null) {
|
||||||
@ -975,7 +975,7 @@ public final class HSSFCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Zap the underlying NoteRecord
|
// Zap the underlying NoteRecord
|
||||||
List sheetRecords = sheet.getRecords();
|
List sheetRecords = sheet.getSheet().getRecords();
|
||||||
sheetRecords.remove(comment.getNoteRecord());
|
sheetRecords.remove(comment.getNoteRecord());
|
||||||
|
|
||||||
// If we have a TextObjectRecord, is should
|
// If we have a TextObjectRecord, is should
|
||||||
@ -1054,7 +1054,7 @@ public final class HSSFCell {
|
|||||||
* @return hyperlink associated with this cell or null if not found
|
* @return hyperlink associated with this cell or null if not found
|
||||||
*/
|
*/
|
||||||
public HSSFHyperlink getHyperlink(){
|
public HSSFHyperlink getHyperlink(){
|
||||||
for (Iterator it = sheet.getRecords().iterator(); it.hasNext(); ) {
|
for (Iterator it = sheet.getSheet().getRecords().iterator(); it.hasNext(); ) {
|
||||||
RecordBase rec = (RecordBase) it.next();
|
RecordBase rec = (RecordBase) it.next();
|
||||||
if (rec instanceof HyperlinkRecord){
|
if (rec instanceof HyperlinkRecord){
|
||||||
HyperlinkRecord link = (HyperlinkRecord)rec;
|
HyperlinkRecord link = (HyperlinkRecord)rec;
|
||||||
@ -1090,8 +1090,8 @@ public final class HSSFCell {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int eofLoc = sheet.findFirstRecordLocBySid( EOFRecord.sid );
|
int eofLoc = sheet.getSheet().findFirstRecordLocBySid( EOFRecord.sid );
|
||||||
sheet.getRecords().add( eofLoc, link.record );
|
sheet.getSheet().getRecords().add( eofLoc, link.record );
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Only valid for formula cells
|
* Only valid for formula cells
|
||||||
|
@ -345,7 +345,7 @@ public class HSSFFormulaEvaluator {
|
|||||||
|
|
||||||
ValueEval result;
|
ValueEval result;
|
||||||
|
|
||||||
int sheetIndex = _workbook.findSheetIndex(srcCell.getSheet());
|
int sheetIndex = _workbook.getSheetIndex(srcCell.getSheet());
|
||||||
result = _cache.getValue(sheetIndex, srcRowNum, srcColNum);
|
result = _cache.getValue(sheetIndex, srcRowNum, srcColNum);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -20,7 +20,6 @@ package org.apache.poi.hssf.usermodel;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.apache.poi.hssf.model.Sheet;
|
|
||||||
import org.apache.poi.hssf.record.CellValueRecordInterface;
|
import org.apache.poi.hssf.record.CellValueRecordInterface;
|
||||||
import org.apache.poi.hssf.record.RowRecord;
|
import org.apache.poi.hssf.record.RowRecord;
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ public final class HSSFRow implements Comparable {
|
|||||||
/**
|
/**
|
||||||
* reference to containing Sheet
|
* reference to containing Sheet
|
||||||
*/
|
*/
|
||||||
private Sheet sheet;
|
private HSSFSheet sheet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new HSSFRow from scratch. Only HSSFSheet should do this.
|
* Creates new HSSFRow from scratch. Only HSSFSheet should do this.
|
||||||
@ -63,7 +62,7 @@ public final class HSSFRow implements Comparable {
|
|||||||
* @param rowNum the row number of this row (0 based)
|
* @param rowNum the row number of this row (0 based)
|
||||||
* @see org.apache.poi.hssf.usermodel.HSSFSheet#createRow(int)
|
* @see org.apache.poi.hssf.usermodel.HSSFSheet#createRow(int)
|
||||||
*/
|
*/
|
||||||
HSSFRow(HSSFWorkbook book, Sheet sheet, int rowNum)
|
HSSFRow(HSSFWorkbook book, HSSFSheet sheet, int rowNum)
|
||||||
{
|
{
|
||||||
this.rowNum = rowNum;
|
this.rowNum = rowNum;
|
||||||
this.book = book;
|
this.book = book;
|
||||||
@ -82,7 +81,7 @@ public final class HSSFRow implements Comparable {
|
|||||||
* @param record the low level api object this row should represent
|
* @param record the low level api object this row should represent
|
||||||
* @see org.apache.poi.hssf.usermodel.HSSFSheet#createRow(int)
|
* @see org.apache.poi.hssf.usermodel.HSSFSheet#createRow(int)
|
||||||
*/
|
*/
|
||||||
HSSFRow(HSSFWorkbook book, Sheet sheet, RowRecord record)
|
HSSFRow(HSSFWorkbook book, HSSFSheet sheet, RowRecord record)
|
||||||
{
|
{
|
||||||
this.book = book;
|
this.book = book;
|
||||||
this.sheet = sheet;
|
this.sheet = sheet;
|
||||||
@ -133,7 +132,7 @@ public final class HSSFRow implements Comparable {
|
|||||||
HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), (short)columnIndex, type);
|
HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), (short)columnIndex, type);
|
||||||
|
|
||||||
addCell(cell);
|
addCell(cell);
|
||||||
sheet.addValueRecord(getRowNum(), cell.getCellValueRecord());
|
sheet.getSheet().addValueRecord(getRowNum(), cell.getCellValueRecord());
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +159,7 @@ public final class HSSFRow implements Comparable {
|
|||||||
|
|
||||||
if(alsoRemoveRecords) {
|
if(alsoRemoveRecords) {
|
||||||
CellValueRecordInterface cval = cell.getCellValueRecord();
|
CellValueRecordInterface cval = cell.getCellValueRecord();
|
||||||
sheet.removeValueRecord(getRowNum(), cval);
|
sheet.getSheet().removeValueRecord(getRowNum(), cval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell.getCellNum()+1 == row.getLastCol()) {
|
if (cell.getCellNum()+1 == row.getLastCol()) {
|
||||||
@ -459,7 +458,7 @@ public final class HSSFRow implements Comparable {
|
|||||||
|
|
||||||
//The low-order 15 bits contain the row height.
|
//The low-order 15 bits contain the row height.
|
||||||
//The 0x8000 bit indicates that the row is standard height (optional)
|
//The 0x8000 bit indicates that the row is standard height (optional)
|
||||||
if ((height & 0x8000) != 0) height = sheet.getDefaultRowHeight();
|
if ((height & 0x8000) != 0) height = sheet.getSheet().getDefaultRowHeight();
|
||||||
else height &= 0x7FFF;
|
else height &= 0x7FFF;
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
|
@ -203,7 +203,7 @@ public final class HSSFSheet {
|
|||||||
*/
|
*/
|
||||||
public HSSFRow createRow(int rownum)
|
public HSSFRow createRow(int rownum)
|
||||||
{
|
{
|
||||||
HSSFRow row = new HSSFRow(workbook, sheet, rownum);
|
HSSFRow row = new HSSFRow(workbook, this, rownum);
|
||||||
|
|
||||||
addRow(row, true);
|
addRow(row, true);
|
||||||
return row;
|
return row;
|
||||||
@ -218,7 +218,7 @@ public final class HSSFSheet {
|
|||||||
|
|
||||||
private HSSFRow createRowFromRecord(RowRecord row)
|
private HSSFRow createRowFromRecord(RowRecord row)
|
||||||
{
|
{
|
||||||
HSSFRow hrow = new HSSFRow(workbook, sheet, row);
|
HSSFRow hrow = new HSSFRow(workbook, this, row);
|
||||||
|
|
||||||
addRow(hrow, false);
|
addRow(hrow, false);
|
||||||
return hrow;
|
return hrow;
|
||||||
|
Loading…
Reference in New Issue
Block a user