Index: org/apache/poi/hssf/dev/HSSF.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/dev/HSSF.java,v retrieving revision 1.6 diff -u -r1.6 HSSF.java --- org/apache/poi/hssf/dev/HSSF.java 23 Aug 2004 08:52:26 -0000 1.6 +++ org/apache/poi/hssf/dev/HSSF.java 25 Nov 2005 11:11:36 -0000 @@ -183,7 +183,7 @@ public HSSF(String infile, String outfile, boolean write) throws IOException { - this.filename = filename; + this.filename = infile; POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename)); Index: org/apache/poi/hssf/model/Sheet.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java,v retrieving revision 1.60 diff -u -r1.60 Sheet.java --- org/apache/poi/hssf/model/Sheet.java 2 Sep 2005 03:48:29 -0000 1.60 +++ org/apache/poi/hssf/model/Sheet.java 25 Nov 2005 11:11:40 -0000 @@ -936,10 +936,13 @@ public void addValueRecord(int row, CellValueRecordInterface col) { checkCells(); - log.logFormatted(POILogger.DEBUG, "add value record row,loc %,%", new int[] + if(log.check(POILogger.DEBUG)) { - row, loc - }); + log.logFormatted(POILogger.DEBUG, "add value record row,loc %,%", new int[] + { + row, loc + }); + } DimensionsRecord d = ( DimensionsRecord ) records.get(getDimsLoc()); if (col.getColumn() > d.getLastCol()) @@ -1764,9 +1767,10 @@ if (columns != null) { - for ( Iterator iterator = columns.getIterator(); iterator.hasNext(); ) + int count=columns.getNumColumns(); + for ( int k=0;k cell.getRow()){ - return 1; - } - return -1; - } - public int getRow() { return row;} - public short getColumn() { return 0;} - public void setColumn(short col){} - public void setXFIndex(short xf){} - public short getXFIndex(){return 0;} - public boolean isBefore(CellValueRecordInterface i){ return false; } - public boolean isAfter(CellValueRecordInterface i){ return false; } - public boolean isEqual(CellValueRecordInterface i){ return false; } - public Object clone(){ return null;} - } - - /** - * Iterates the cell records that exist between the startRow and endRow (inclusive). - * - * User must ensure that hasNext & next are called insequence for correct - * operation. Could fix, but since this is only used internally to the - * ValueRecordsAggregate class there doesnt seem much point. - */ - private class RowCellIterator implements Iterator { - private int startRow; - private int endRow; - private Iterator internalIterator; - private CellValueRecordInterface atCell; - - public class RowCellComparator extends RowComparator { - public int compareTo(Object obj) { - CellValueRecordInterface cell = (CellValueRecordInterface) obj; - - if (getRow() == cell.getRow() && cell.getColumn() == 0) { - return 0; - } - else if (getRow() < cell.getRow()) { - return -1; - } - else if (getRow() > cell.getRow()){ - return 1; - } - if (cell.getColumn() > 0) - { - return -1; - } - if (cell.getColumn() < 0) - { - return 1; - } - return -1; - } - } - - private RowCellComparator rowCellCompare; - - - public RowCellIterator(int startRow, int endRow) { - this.startRow = startRow; - this.endRow = endRow; - rowCellCompare = new RowCellComparator(); - rowCellCompare.setRow(startRow); - } - - public boolean hasNext() { - if (internalIterator == null) { - internalIterator = records.tailMap(rowCellCompare).values().iterator(); - } - if (internalIterator.hasNext()) { - atCell = (CellValueRecordInterface) internalIterator.next(); - return (atCell.getRow() <= endRow); - } else return false; - } - - public Object next() { - return atCell; - } - - public void remove() { - //Do Nothing (Not called) - } - } - - //Only need a single instance of this class, but the row fields - //will probably change each use. Instance is only used in the rowHasCells method. - public final RowComparator compareRow = new RowComparator(); - /** Creates a new instance of ValueRecordsAggregate */ public ValueRecordsAggregate() { - records = new TreeMap(); + records = new CellValueRecordInterface[30][]; // We start with 30 Rows. } - public void insertCell(CellValueRecordInterface cell) - { - Object o = records.put(cell, cell); + public void insertCell(CellValueRecordInterface cell) { + short column = cell.getColumn(); + int row = cell.getRow(); + if (row >= records.length) { + CellValueRecordInterface[][] oldRecords = records; + int newSize = oldRecords.length * 2; + if(newSize= rowCells.length) { + CellValueRecordInterface[] oldRowCells = rowCells; + int newSize = oldRowCells.length * 2; + if(newSize257) newSize=257; // activate? + rowCells = new CellValueRecordInterface[newSize]; + System.arraycopy(oldRowCells, 0, rowCells, 0, oldRowCells.length); + records[row] = rowCells; + } + rowCells[column] = cell; - if ((cell.getColumn() < firstcell) || (firstcell == -1)) - { - firstcell = cell.getColumn(); - } - if ((cell.getColumn() > lastcell) || (lastcell == -1)) - { - lastcell = cell.getColumn(); - } + if ((column < firstcell) || (firstcell == -1)) { + firstcell = column; + } + if ((column > lastcell) || (lastcell == -1)) { + lastcell = column; } + } public void removeCell(CellValueRecordInterface cell) { - records.remove(cell); + short column = cell.getColumn(); + int row = cell.getRow(); + if(row>=records.length) return; + CellValueRecordInterface[] rowCells=records[row]; + if(rowCells==null) return; + if(column>=rowCells.length) return; + rowCells[column]=null; } public int getPhysicalNumberOfCells() { - return records.size(); + int count=0; + for(int r=0;r=cells.length) + { + HSSFCell[] oldCells=cells; + int newSize=oldCells.length*2; + if(newSize row.getLastCol()) + if (column > row.getLastCol()) { - row.setLastCol(cell.getCellNum()); + row.setLastCol(column); } } @@ -261,17 +268,8 @@ public HSSFCell getCell(short cellnum) { - -/* for (int k = 0; k < cells.size(); k++) - { - HSSFCell cell = ( HSSFCell ) cells.get(k); - - if (cell.getCellNum() == cellnum) - { - return cell; - } - }*/ - return (HSSFCell) cells.get(new Integer(cellnum)); + if(cellnum>=cells.length) return null; + return cells[cellnum]; } /** @@ -309,11 +307,12 @@ public int getPhysicalNumberOfCells() { - if (cells == null) - { - return 0; // shouldn't be possible but it is due to missing API support for BLANK/MULBLANK - } - return cells.size(); + int count=0; + for(int i=0;i