Some housekeeping

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352208 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Glen Stampoultzis 2002-03-12 10:53:02 +00:00
parent 3a4e33a099
commit bf1123e236

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
@ -60,16 +59,14 @@
*/ */
package org.apache.poi.hssf.usermodel; package org.apache.poi.hssf.usermodel;
import java.util.List; import org.apache.poi.hssf.model.Sheet;
import java.util.ArrayList; import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.RowRecord;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.hssf.record.CellValueRecordInterface;
/** /**
* High level representation of a row of a spreadsheet. * High level representation of a row of a spreadsheet.
* *
@ -173,7 +170,7 @@ public class HSSFRow
{ {
HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), column); HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), column);
addCell(cell, true); addCell(cell);
sheet.addValueRecord(getRowNum(), cell.getCellValueRecord()); sheet.addValueRecord(getRowNum(), cell.getCellValueRecord());
return cell; return cell;
} }
@ -195,7 +192,7 @@ public class HSSFRow
{ {
HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), column, type); HSSFCell cell = new HSSFCell(book, sheet, getRowNum(), column, type);
addCell(cell, true); addCell(cell);
sheet.addValueRecord(getRowNum(), cell.getCellValueRecord()); sheet.addValueRecord(getRowNum(), cell.getCellValueRecord());
return cell; return cell;
} }
@ -212,22 +209,10 @@ public class HSSFRow
sheet.removeValueRecord(getRowNum(), cval); sheet.removeValueRecord(getRowNum(), cval);
cells.remove(new Integer(cell.getCellNum())); cells.remove(new Integer(cell.getCellNum()));
/*
* for (int k = 0; k < cells.size(); k++)
* {
* HSSFCell hcell = ( HSSFCell ) cells.get(k);
*
* if (hcell.getCellNum() == cell.getCellNum())
* {
* cells.remove(k);
* }
* }
*/
if (cell.getCellNum() == lastcell) if (cell.getCellNum() == lastcell)
{ {
lastcell = findLastCell(lastcell); lastcell = findLastCell(lastcell);
} } else if (cell.getCellNum() == firstcell)
else if (cell.getCellNum() == firstcell)
{ {
firstcell = findFirstCell(firstcell); firstcell = findFirstCell(firstcell);
} }
@ -244,7 +229,7 @@ public class HSSFRow
{ {
HSSFCell hcell = new HSSFCell(book, sheet, getRowNum(), cell); HSSFCell hcell = new HSSFCell(book, sheet, getRowNum(), cell);
addCell(hcell, false); addCell(hcell);
// sheet.addValueRecord(getRowNum(),cell.getCellValueRecord()); // sheet.addValueRecord(getRowNum(),cell.getCellValueRecord());
return hcell; return hcell;
@ -278,7 +263,7 @@ public class HSSFRow
* used internally to add a cell. Pass anything in for dummy boolean. (possibly used in later versions) * used internally to add a cell. Pass anything in for dummy boolean. (possibly used in later versions)
*/ */
private void addCell(HSSFCell cell, boolean dummy) private void addCell(HSSFCell cell)
{ {
if (firstcell == -1) if (firstcell == -1)
{ {
@ -290,33 +275,6 @@ public class HSSFRow
} }
cells.put(new Integer(cell.getCellNum()), cell); cells.put(new Integer(cell.getCellNum()), cell);
/* if (cells.size() > 0)
{
if ((cell.getCellNum() < firstcell) || (firstcell == -1))
{
firstcell = cell.getCellNum();
}
if ((cell.getCellNum() > lastcell) || (lastcell == -1))
{
lastcell = cell.getCellNum();
}
for (int k = cells.size() - 1; k > -1; k--)
{
if ((cell.getCellNum() > (( HSSFCell ) cells.get(k))
.getCellNum()) || (k == 0))
{
cells.add(k, cell);
break;
}
}
}
else
{
firstcell = cell.getCellNum();
lastcell = cell.getCellNum();
cells.add(cell);
}
*/
if (cell.getCellNum() < row.getFirstCol()) if (cell.getCellNum() < row.getFirstCol())
{ {
row.setFirstCol(cell.getCellNum()); row.setFirstCol(cell.getCellNum());
@ -399,18 +357,6 @@ public class HSSFRow
return cells.size(); return cells.size();
} }
/**
* gets the phsyically defined cell at location (num) NOT its column number.
* That is to say if only columns 0,4,5 have values then index 2 would equal cell with a column number of 4.
* (though the order is not assured)
* @return HSSFCell physically defined at the given index.
*/
// public HSSFCell getPhysicalCellAt(int num)
// {
// return ( HSSFCell ) cells.get(num);
// }
/** /**
* set the row's height or set to ff (-1) for undefined/default-height. Set the height in "twips" or * set the row's height or set to ff (-1) for undefined/default-height. Set the height in "twips" or
* 1/20th of a point. * 1/20th of a point.