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:
Nick Burch 2008-09-13 13:46:45 +00:00
parent 691a92311e
commit a596cc0ecd
4 changed files with 26 additions and 27 deletions

View File

@ -89,7 +89,7 @@ public final class HSSFCell {
public final static short ENCODING_UTF_16 = 1;
private final HSSFWorkbook book;
private final Sheet sheet;
private final HSSFSheet sheet;
private int cellType;
private HSSFRichTextString stringValue;
private CellValueRecordInterface record;
@ -111,7 +111,7 @@ public final class HSSFCell {
*
* @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);
stringValue = null;
@ -121,10 +121,10 @@ public final class HSSFCell {
// 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
// creates a new blank cell.
short xfindex = sheet.getXFIndexForColAt(col);
short xfindex = sheet.getSheet().getXFIndexForColAt(col);
setCellType(CELL_TYPE_BLANK, false, row, col,xfindex);
}
/* package */ Sheet getSheet() {
/* package */ HSSFSheet getSheet() {
return sheet;
}
@ -141,7 +141,7 @@ public final class HSSFCell {
* Type of cell
* @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)
{
checkBounds(col);
@ -150,7 +150,7 @@ public final class HSSFCell {
this.book = book;
this.sheet = sheet;
short xfindex = sheet.getXFIndexForColAt(col);
short xfindex = sheet.getSheet().getXFIndexForColAt(col);
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 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;
cellType = determineType(cval);
stringValue = null;
@ -296,7 +296,7 @@ public final class HSSFCell {
FormulaRecordAggregate frec;
if (cellType != this.cellType) {
frec = sheet.createFormula(row, col);
frec = sheet.getSheet().createFormula(row, col);
} else {
frec = (FormulaRecordAggregate) record;
frec.setRow(row);
@ -432,7 +432,7 @@ public final class HSSFCell {
if (cellType != this.cellType &&
this.cellType!=-1 ) // Special Value to indicate an uninitialized Cell
{
sheet.replaceValueRecord(record);
sheet.getSheet().replaceValueRecord(record);
}
this.cellType = cellType;
}
@ -888,8 +888,8 @@ public final class HSSFCell {
{
int row=record.getRow();
short col=record.getColumn();
this.sheet.setActiveCellRow(row);
this.sheet.setActiveCellCol(col);
this.sheet.getSheet().setActiveCellRow(row);
this.sheet.getSheet().setActiveCellCol(col);
}
/**
@ -954,7 +954,7 @@ public final class HSSFCell {
*/
public HSSFComment getCellComment(){
if (comment == null) {
comment = findCellComment(sheet, record.getRow(), record.getColumn());
comment = findCellComment(sheet.getSheet(), record.getRow(), record.getColumn());
}
return comment;
}
@ -966,7 +966,7 @@ public final class HSSFCell {
* all comments after performing this action!
*/
public void removeCellComment() {
HSSFComment comment = findCellComment(sheet, record.getRow(), record.getColumn());
HSSFComment comment = findCellComment(sheet.getSheet(), record.getRow(), record.getColumn());
this.comment = null;
if(comment == null) {
@ -975,7 +975,7 @@ public final class HSSFCell {
}
// Zap the underlying NoteRecord
List sheetRecords = sheet.getRecords();
List sheetRecords = sheet.getSheet().getRecords();
sheetRecords.remove(comment.getNoteRecord());
// 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
*/
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();
if (rec instanceof HyperlinkRecord){
HyperlinkRecord link = (HyperlinkRecord)rec;
@ -1090,8 +1090,8 @@ public final class HSSFCell {
break;
}
int eofLoc = sheet.findFirstRecordLocBySid( EOFRecord.sid );
sheet.getRecords().add( eofLoc, link.record );
int eofLoc = sheet.getSheet().findFirstRecordLocBySid( EOFRecord.sid );
sheet.getSheet().getRecords().add( eofLoc, link.record );
}
/**
* Only valid for formula cells

View File

@ -345,7 +345,7 @@ public class HSSFFormulaEvaluator {
ValueEval result;
int sheetIndex = _workbook.findSheetIndex(srcCell.getSheet());
int sheetIndex = _workbook.getSheetIndex(srcCell.getSheet());
result = _cache.getValue(sheetIndex, srcRowNum, srcColNum);
if (result != null) {
return result;

View File

@ -20,7 +20,6 @@ package org.apache.poi.hssf.usermodel;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.RowRecord;
@ -53,7 +52,7 @@ public final class HSSFRow implements Comparable {
/**
* reference to containing Sheet
*/
private Sheet sheet;
private HSSFSheet sheet;
/**
* 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)
* @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.book = book;
@ -82,7 +81,7 @@ public final class HSSFRow implements Comparable {
* @param record the low level api object this row should represent
* @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.sheet = sheet;
@ -133,7 +132,7 @@ public final class HSSFRow implements Comparable {
HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), (short)columnIndex, type);
addCell(cell);
sheet.addValueRecord(getRowNum(), cell.getCellValueRecord());
sheet.getSheet().addValueRecord(getRowNum(), cell.getCellValueRecord());
return cell;
}
@ -160,7 +159,7 @@ public final class HSSFRow implements Comparable {
if(alsoRemoveRecords) {
CellValueRecordInterface cval = cell.getCellValueRecord();
sheet.removeValueRecord(getRowNum(), cval);
sheet.getSheet().removeValueRecord(getRowNum(), cval);
}
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 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;
return height;

View File

@ -203,7 +203,7 @@ public final class HSSFSheet {
*/
public HSSFRow createRow(int rownum)
{
HSSFRow row = new HSSFRow(workbook, sheet, rownum);
HSSFRow row = new HSSFRow(workbook, this, rownum);
addRow(row, true);
return row;
@ -218,7 +218,7 @@ public final class HSSFSheet {
private HSSFRow createRowFromRecord(RowRecord row)
{
HSSFRow hrow = new HSSFRow(workbook, sheet, row);
HSSFRow hrow = new HSSFRow(workbook, this, row);
addRow(hrow, false);
return hrow;