poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gl...@apache.org
Subject cvs commit: jakarta-poi .cvsignore build.xml
Date Sun, 18 Apr 2004 13:02:49 GMT
glens       2004/04/18 06:02:48

  Modified:    src/java/org/apache/poi/hssf/model Sheet.java
               src/java/org/apache/poi/hssf/record/aggregates
                        ValueRecordsAggregate.java
               src/java/org/apache/poi/hssf/usermodel HSSFCell.java
               src/testcases/org/apache/poi/hssf/record/aggregates
                        TestValueRecordsAggregate.java
               src/testcases/org/apache/poi/hssf/usermodel
                        TestHSSFSheet.java
               .        .cvsignore build.xml
  Added:       src/java/org/apache/poi/util DoubleList2d.java
                        IntList2d.java List2d.java
               src/testcases/org/apache/poi/util TestDoubleList2d.java
                        TestIntList2d.java TestList2d.java
  Log:
  Some fixes to the branch.  Lots left to do.  Boolean records aren't supported at all.  Empty
spreadsheets have issues but this is a start on getting things healthy again.
  
  Revision  Changes    Path
  1.45      +1 -1      jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java
  
  Index: Sheet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- Sheet.java	9 Apr 2004 13:05:18 -0000	1.44
  +++ Sheet.java	18 Apr 2004 13:02:48 -0000	1.45
  @@ -398,8 +398,8 @@
                   (DefaultColWidthRecord) retval.createDefaultColWidth();
           records.add( retval.defaultcolwidth);
           retval.dims    = ( DimensionsRecord ) retval.createDimensions();
  -        retval.dimsloc = records.size()-1;
           records.add(retval.dims);
  +        retval.dimsloc = records.size()-1;
           records.add(retval.windowTwo = retval.createWindowTwo());
           retval.setLoc(records.size() - 1);
           retval.selection = 
  
  
  
  1.15      +207 -145  jakarta-poi/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java
  
  Index: ValueRecordsAggregate.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ValueRecordsAggregate.java	9 Apr 2004 13:05:18 -0000	1.14
  +++ ValueRecordsAggregate.java	18 Apr 2004 13:02:48 -0000	1.15
  @@ -18,16 +18,16 @@
   
   package org.apache.poi.hssf.record.aggregates;
   
  -import org.apache.poi.hssf.usermodel.HSSFCell; //kludge shouldn't refer to this
  -
   import org.apache.poi.hssf.record.*;
   import org.apache.poi.hssf.record.formula.Ptg;
  -import org.apache.poi.util.DoubleList;
  +import org.apache.poi.hssf.usermodel.HSSFCell;
  +import org.apache.poi.util.DoubleList2d;
   import org.apache.poi.util.IntList;
  +import org.apache.poi.util.IntList2d;
  +import org.apache.poi.util.List2d;
   
   import java.util.Iterator;
   import java.util.List;
  -import java.util.ArrayList;
   
   /**
    *
  @@ -42,29 +42,23 @@
       extends Record
   {
       public final static short sid       = -1000;
  -    int                       firstcell = -1;
  -    int                       lastcell  = -1;
  -    //TreeMap                   records   = null;
   
       private final static int DEFAULT_ROWS=10000;
       private final static int DEFAULT_COLS=256;
   
  -    List celltype = null;  //array of HSSFCEll.CELL_TYPE_XXX tells us which arrays to use
  -    List xfs      = null;  // array of style types.  Index of XF record
  -    List numericcells = null; // numeric and Shared string indicies.  
  -    List formulaptgs = null; // array of arrays of PTGS
  -    List stringvals = null;  // array of actual string/formula string vals
  -    IntList populatedRows = null;  //indicies of populated rows
  -    int physCells; //physical number of cells
  +    IntList2d    celltype      = null;
  +    IntList2d    xfs           = null; // array of style types.  Index of XF record
  +    DoubleList2d numericcells  = null; // numeric and Shared string indicies.
  +    List2d       formulaptgs   = null; // array of arrays of FormulaRecordAggregate
  +    List2d       stringvals    = null; // array of actual string/formula string vals
  +    IntList      populatedRows = null; //indicies of populated rows
  +    int          physCells;            //physical number of cells
   
       public CellValueRecordInterface getCell(int row, short col) {
           return constructRecord(row, col);
  -
       }
   
       public int getRecordSize() {
  -        //throw new RuntimeException("Not Implemented getRecordSize");
  -
           int size = 0;
           Iterator irecs = getIterator();
   
  @@ -73,7 +67,6 @@
           }
   
           return size;
  -//        return size;
       }
   
       public int serialize(int offset, byte [] data)
  @@ -82,13 +75,13 @@
       }
   
       public ValueRecordsAggregate() {
  -        celltype = new ArrayList(DEFAULT_ROWS);
  -        xfs      = new ArrayList(DEFAULT_ROWS);
  -        numericcells = new ArrayList(DEFAULT_ROWS);
  -        formulaptgs  = new ArrayList(DEFAULT_ROWS);
  -        stringvals   = new ArrayList(DEFAULT_ROWS);
  -        populatedRows = new IntList(DEFAULT_ROWS);
  -        physCells = 0;
  +        celltype      = new IntList2d();
  +        xfs           = new IntList2d();
  +        numericcells  = new DoubleList2d();
  +        formulaptgs   = new List2d();
  +        stringvals    = new List2d();
  +        populatedRows = new IntList();
  +        physCells     = 0;
       }
   
       public Iterator getIterator() {
  @@ -119,11 +112,19 @@
       }
   
       /** Returns true if the row has cells attached to it */
  -    public boolean rowHasCells(int row) {
  -      if (row >= celltype.size())
  +    public boolean rowHasCells(int row)
  +    {
  +        if (row == -1)
  +            return false;
  +
  +        int col = 0;
  +        while (celltype.isAllocated( col, row))
  +        {
  +            if (celltype.get( col, row ) != 0)
  +                return true;
  +            col++;
  +        }
           return false;
  -      IntList ctRow = (IntList) celltype.get(row);
  -      return ((ctRow != null) && (ctRow.size() > 0));
       }
   
       /** Serializes the cells that are allocated to a certain row range*/
  @@ -144,7 +145,7 @@
   
       public int construct(int offset, List records)
       {
  -        int k = 0;
  +        int k;
   
           FormulaRecordAggregate lastFormulaAggregate = null;
   
  @@ -183,7 +184,6 @@
       public int getPhysicalNumberOfCellsInRow(int row) {
           int count = -1;
           int col = -1;
  -        boolean firsttime = true;
   
           while (col > 0 || count == -1) {
               col = findNextPopulatedCell(row,col);
  @@ -193,11 +193,11 @@
       }
   
       public void setValue(int row, short cell, double val) {
  -        ((DoubleList)numericcells.get(row)).set(cell, val);
  +        numericcells.set(cell, row, val);
       }
   
       public void setStyle(int row, short cell, short xf) {
  -        ((IntList)xfs.get(row)).set(cell, xf);
  +        xfs.set(cell, row, xf);
       }
   
   
  @@ -214,101 +214,100 @@
       }
   
       public void removeCell(CellValueRecordInterface cell) {
  +        if (cell == null)
  +            return;
  +
           int rownum = cell.getRow();
           int colnum = cell.getColumn();
  -        int xf     = cell.getXFIndex();
  -        int type   = determineType(cell);
   
  -        if (rownum < celltype.size() && colnum < ((IntList)celltype.get(rownum)).size())
{
  -            IntList ctRow = (IntList)celltype.get(rownum);
  -            if (ctRow.size()-1 == colnum) {
  -                ctRow.remove(colnum);
  -                if (ctRow.size() == 0 && celltype.size()-1 == rownum) {
  -                    celltype.remove(rownum);
  -                    int remp = populatedRows.indexOf(rownum);
  -                    System.err.println("remp == "+remp);
  -                    populatedRows.removeValue(rownum);
  -                }
  -            } else {
  -                ctRow.set(colnum,-1);
  -            }
  +        if (celltype.get( colnum, rownum ) != 0)
  +        {
  +            celltype.set( colnum, rownum, 0 );
  +            if (rowHasCells( rownum ))
  +                populatedRows.removeValue( populatedRows.indexOf( rownum ) );
               physCells--;
  -        } else {
  -          //this cell doesn't exist...
  -            throw new RuntimeException("Tried to remove a cell that does not exist r,c="+rownum+","+colnum);
  +        }
  +        else
  +        {
  +            //this cell doesn't exist...  the old code falls through so lets make this
fall through too.
           }
       }
   
  -    public void insertCell(CellValueRecordInterface cell) {
  +    public void insertCell( CellValueRecordInterface cell )
  +    {
           int rownum = cell.getRow();
           int colnum = cell.getColumn();
           int xf     = cell.getXFIndex();
           int type   = determineType(cell);
   
  -        if (celltype.size() < rownum+1) {
  +        if (!populatedRows.contains( rownum ))
  +        {
               populatedRows.add(rownum); //this means we must never have had this row inserted
           }
   
  -        ensureRows(rownum);
  +//        ensureRows(rownum);
   
  -        IntList ctRow = (IntList)celltype.get(rownum);
  -        IntList xfRow = (IntList)xfs.get(rownum);
  +//        IntList ctRow = (IntList)celltype.get(rownum);
  +//        IntList xfRow = (IntList)xfs.get(rownum);
   
  +//        adjustIntList(ctRow, colnum+1);
  +//        adjustIntList(xfRow, colnum+1);
   
  -        adjustIntList(ctRow, colnum+1);
  -        adjustIntList(xfRow, colnum+1);
  -
  -        ctRow.set(colnum, type);
  -        xfRow.set(colnum, xf);
  +        celltype.set(colnum, rownum, type);
  +        xfs.set( colnum, rownum, xf);
   
           insertCell(cell, type);
       }
   
       CellValueRecordInterface constructRecord(int row, int col) {
  -        if (celltype.size() < row || ((IntList)celltype.get(row)).size() < col) {
  -            throw new ArrayIndexOutOfBoundsException("constructRecord called with row =
"+row+
  -                      "and col ="+col+" but there are only "+celltype.size()+" rows and
"+
  -                      ((IntList)celltype.get(row)).size()+" cols!!");
  -        }
   
  -        CellValueRecordInterface retval = null;
  -        int type = ((IntList)celltype.get(row)).get(col);
  +        if (celltype.get( col, row) == 0)
  +            throw new ArrayIndexOutOfBoundsException("No cell at position col" + col +
", row " + row + ".");
  +//        if (celltype.size() < row || ((IntList)celltype.get(row)).size() < col)
{
  +//            throw new ArrayIndexOutOfBoundsException("constructRecord called with row
= "+row+
  +//                      "and col ="+col+" but there are only "+celltype.size()+" rows and
"+
  +//                      ((IntList)celltype.get(row)).size()+" cols!!");
  +//        }
   
  +        CellValueRecordInterface retval;
  +        int type = celltype.get( col, row );
   
           switch (type) {
               case HSSFCell.CELL_TYPE_NUMERIC:
                   NumberRecord nrecord = new NumberRecord();
                   nrecord.setColumn((short)col);
                   nrecord.setRow(row);
  -                nrecord.setValue(((DoubleList)numericcells.get(row)).get(col));
  -                nrecord.setXFIndex((short)((IntList)xfs.get(row)).get(col));
  +                nrecord.setValue( numericcells.get( col, row));
  +                nrecord.setXFIndex((short)xfs.get( col, row ));
  +//                nrecord.setXFIndex((short)((IntList)xfs.get(row)).get(col));
                   retval = nrecord;
                   break;
               case HSSFCell.CELL_TYPE_STRING:
                   LabelSSTRecord srecord = new LabelSSTRecord();
                   srecord.setColumn((short)col);
                   srecord.setRow(row);
  -                srecord.setSSTIndex((int)((DoubleList)numericcells.get(row)).get(col));
  -                srecord.setXFIndex((short)((IntList)xfs.get(row)).get(col));
  +                srecord.setSSTIndex((int) numericcells.get( col, row));
  +                srecord.setXFIndex((short)xfs.get( col, row ));
                   retval=srecord;
                   break;
               case HSSFCell.CELL_TYPE_BLANK:
                   BlankRecord brecord = new BlankRecord();
                   brecord.setColumn((short)col);
                   brecord.setRow(row);
  -                brecord.setXFIndex((short)((IntList)xfs.get(row)).get(col));
  +                brecord.setXFIndex((short)xfs.get( col, row ));
                   retval=brecord;
                   break;
               case HSSFCell.CELL_TYPE_FORMULA:
  +                /*
                   FormulaRecord fr = new FormulaRecord();
                   fr.setColumn((short)col);
                   fr.setOptions((short)2);
   
                   fr.setRow(row);
  -                fr.setXFIndex((short)((IntList)xfs.get(row)).get(col));
  +                fr.setXFIndex((short)xfs.get( col, row ));
                   StringRecord        st = null;
  -                String strval = (String)((List)stringvals.get(row)).get(col);
  -                List expressionlist =  (List)((List)formulaptgs.get(row)).get(col);
  +                String strval = (String)stringvals.get( col, row );
  +                List expressionlist =  (List) formulaptgs.get( col, row);
                   fr.setParsedExpression(expressionlist);
                   fr.setExpressionLength(calculatePtgSize(expressionlist));
                   if (strval != null) {
  @@ -319,7 +318,9 @@
   
                   retval= frarecord;
                   break;
  -
  +                */
  +                retval = (CellValueRecordInterface) formulaptgs.get( col, row );
  +                break;
               default:
                   throw new RuntimeException("UnImplemented Celltype "+type);
           }
  @@ -327,7 +328,8 @@
           return retval;
       }
   
  -    private short calculatePtgSize(List expressionlist) {
  +    private short calculatePtgSize(List expressionlist)
  +    {
           short retval = 0;
           Iterator iter = expressionlist.iterator();
           while (iter.hasNext()) {
  @@ -336,42 +338,49 @@
           return retval;
       }
   
  -    private void insertCell(CellValueRecordInterface cell, int type) {
  +    private void insertCell(CellValueRecordInterface cell, int type)
  +    {
           int rownum = cell.getRow();
           int colnum = cell.getColumn();
   
  -        DoubleList  nmRow = (DoubleList)numericcells.get(rownum);
  +//        DoubleList  nmRow = (DoubleList)numericcells.get(rownum);
   
           switch (type) {
               case HSSFCell.CELL_TYPE_NUMERIC:
                   NumberRecord nrecord = (NumberRecord)cell;
  -                adjustDoubleList(nmRow, colnum+1);
  -                nmRow.set(colnum,nrecord.getValue());
  +//                adjustDoubleList(nmRow, colnum+1);
  +                numericcells.set(colnum, rownum, nrecord.getValue());
                   physCells++;
                   break;
               case HSSFCell.CELL_TYPE_STRING:
                   LabelSSTRecord srecord = (LabelSSTRecord)cell;
  -                adjustDoubleList(nmRow, colnum+1);
  -                nmRow.set(colnum,srecord.getSSTIndex());
  +//                adjustDoubleList(nmRow, colnum+1);
  +                numericcells.set(colnum, rownum, srecord.getSSTIndex());
  +//                nmRow.set(colnum,srecord.getSSTIndex());
                   physCells++;
                   break;
               case HSSFCell.CELL_TYPE_FORMULA:
  -                List ptRow = (List)formulaptgs.get(rownum);
  -                List stRow = (List)stringvals.get(rownum);
                   FormulaRecordAggregate frarecord = (FormulaRecordAggregate)cell;
  -                adjustDoubleList(nmRow, colnum+1);
  -                adjustObjectList(ptRow, colnum+1);
  -                adjustStringList(stRow, colnum+1);
  -                nmRow.set(colnum,frarecord.getFormulaRecord().getValue());
  -                ptRow.set(colnum,frarecord.getFormulaRecord().getParsedExpression());
  +                formulaptgs.set( colnum, rownum, frarecord);
  +                physCells++;
  +                break;
  +                /*
  +//                List ptRow = (List)formulaptgs.get(rownum);
  +//                List stRow = (List)stringvals.get(rownum);
  +                FormulaRecordAggregate frarecord = (FormulaRecordAggregate)cell;
  +//                adjustDoubleList(nmRow, colnum+1);
  +//                adjustObjectList(ptRow, colnum+1);
  +//                adjustStringList(stRow, colnum+1);
  +                numericcells.set(colnum, rownum, frarecord.getFormulaRecord().getValue());
  +                formulaptgs.set( colnum, rownum, frarecord.getFormulaRecord().getParsedExpression()
);
                   StringRecord str = frarecord.getStringRecord();
  -                if (str != null) {
  -                    stRow.set(colnum,str.getString());
  -                } else {
  -                    stRow.set(colnum,null);
  -                }
  +                if ( str != null )
  +                    stringvals.set( colnum, rownum, str.getString() );
  +                else
  +                    stringvals.set( colnum, rownum, null );
                   physCells++;
                   break;
  +                */
               case HSSFCell.CELL_TYPE_BLANK:
                   //BlankRecord brecord = (BlankRecord)cell;
                   physCells++;
  @@ -418,52 +427,67 @@
           return retval;
       }
   
  -    private void ensureRows(int rownum) {
  -        adjustRows(celltype, rownum+1, IntList.class);
  -        adjustRows(xfs, rownum+1, IntList.class);
  -        adjustRows(numericcells, rownum+1, DoubleList.class);
  -        adjustRows(formulaptgs, rownum+1, ArrayList.class);
  -        adjustRows(stringvals, rownum+1, ArrayList.class);
  -
  -    }
  -
  -    private void adjustRows(List list, int size, Class theclass) {
  -        while (list.size() < size) {
  -            try {
  -                list.add(theclass.newInstance());
  -            } catch (Exception e) {
  -                throw new RuntimeException("Could Not Instantiate Row in adjustRows");
  -            }
  -        }
  -    }
  -
  -    private void adjustIntList(IntList list, int size) {
  -        while (list.size() < size) {
  -            list.add(-1);
  -        }
  -    }
  -
  -    private void adjustDoubleList(DoubleList list, int size) {
  -        while (list.size() < size) {
  -            list.add(-1);
  -        }
  -    }
  -
  -    private void adjustObjectList(List list, int size) {
  -        while (list.size() < size) {
  -            list.add(new ArrayList());
  -        }
  -    }
  +//    private void ensureRows(int rownum) {
  +        //adjustRows(celltype, rownum+1, IntList.class);
  +//        adjustRows(xfs, rownum+1, IntList.class);
  +//        adjustRows(numericcells, rownum+1, DoubleList.class);
  +//        adjustRows(formulaptgs, rownum+1, ArrayList.class);
  +//        adjustRows(stringvals, rownum+1, ArrayList.class);
  +
  +//    }
  +
  +//    private void adjustRows(List list, int size, Class theclass) {
  +//        while (list.size() < size) {
  +//            try {
  +//                list.add(theclass.newInstance());
  +//            } catch (Exception e) {
  +//                throw new RuntimeException("Could Not Instantiate Row in adjustRows");
  +//            }
  +//        }
  +//    }
  +
  +//    private void adjustIntList(IntList list, int size) {
  +//        while (list.size() < size) {
  +//            list.add(-1);
  +//        }
  +//    }
  +//
  +//    private void adjustDoubleList(DoubleList list, int size) {
  +//        while (list.size() < size) {
  +//            list.add(-1);
  +//        }
  +//    }
  +//
  +//    private void adjustObjectList(List list, int size) {
  +//        while (list.size() < size) {
  +//            list.add(new ArrayList());
  +//        }
  +//    }
  +
  +//    private void adjustStringList(List list, int size) {
  +//        while (list.size() < size) {
  +//            list.add(new String());
  +//        }
  +//    }
  +
  +    /**
  +     * Find the next populated cell in the row starting from but not
  +     * including the current column
  +     *
  +     * @return the next valid column number
  +     */
  +    protected int findNextPopulatedCell(int row, int col) {
   
  -    private void adjustStringList(List list, int size) {
  -        while (list.size() < size) {
  -            list.add(new String());
  +        int currentCol = col + 1;
  +        while (celltype.isAllocated( currentCol, row ))
  +        {
  +            if (celltype.get( currentCol, row) > 0)
  +                return currentCol;
  +            currentCol++;
           }
  -    }
  -
  -
  -    protected int findNextPopulatedCell(int row, int col) {
  +        return -1;
   
  +        /*
           IntList ctRow = (IntList) celltype.get(row);
           int retval = -1;
           if (ctRow.size() > col+1) {
  @@ -483,6 +507,7 @@
   
           }  //end if (ctRow.size()...
           return retval;
  +        */
       }
   
   
  @@ -509,7 +534,6 @@
       private int popindex;
       private int row;
       private int rowlimit;
  -    private int col;
       CellValueRecordInterface current = null;
       CellValueRecordInterface next    = null;
   
  @@ -527,7 +551,32 @@
           this.rowlimit = endRow;
           this.popindex = vra.populatedRows.indexOf(row);
           if (this.popindex == -1) {
  -          hasNext = false;
  +            if (vra.populatedRows.size() == 0)
  +                hasNext = false;
  +            else
  +            {
  +                int lastRow = vra.populatedRows.get(vra.populatedRows.size()-1);
  +                if (lastRow == -1)
  +                {
  +                    hasNext = false;
  +                }
  +                else
  +                {
  +                    for (int i = row; i <= lastRow; i++)
  +                    {
  +                        this.popindex = vra.populatedRows.indexOf(i);
  +                        if (popindex != -1)
  +                            break;
  +                    }
  +                }
  +                if (popindex == -1)
  +                    hasNext = false;
  +                else
  +                {
  +                    next = findNextCell(null);
  +                    hasNext = (next != null);
  +                }
  +            }
           } else if (vra.getPhysicalNumberOfCells() > 0) {
               next = findNextCell(null);
               hasNext = (next != null);
  @@ -553,7 +602,7 @@
       }
   
       private CellValueRecordInterface findNextCell(CellValueRecordInterface current) {
  -        IntList ctRow = null;
  +//        IntList ctRow = null;
           int rowNum = -1;
           int colNum = -1;
           int newCol = -1;
  @@ -563,11 +612,24 @@
               wasntFirst = true;
               rowNum = current.getRow();
               colNum = current.getColumn();
  -            ctRow = ((IntList)vra.celltype.get(rowNum));
  +//            ctRow = ((IntList)vra.celltype.get(rowNum));
           }
   
           //if popindex = row iwth no cells, fast forward till we get to one with size >
0
  -        while ((ctRow == null || ctRow.size() == 0) && vra.populatedRows.size()
> popindex) {
  +        while (!vra.rowHasCells( rowNum ) && vra.populatedRows.size() > popindex)
{
  +            if (wasntFirst == true) {
  +                throw new RuntimeException("CANT HAPPEN WASNTFIRST BUT WE'RE FASTFORWARDING!");
  +            }
  +            rowNum = vra.populatedRows.get(popindex);
  +            if (!vra.rowHasCells( rowNum )) {
  +                if ((rowlimit == -1)||(rowNum<=rowlimit)) {
  +                    popindex++;
  +                } else {
  +                    this.hasNext = false;
  +                }
  +            }
  +        }
  +        /*while ((ctRow == null || ctRow.size() == 0) && vra.populatedRows.size()
> popindex) {
               if (wasntFirst == true) {
                   throw new RuntimeException("CANT HAPPEN WASNTFIRST BUT WE'RE FASTFORWARDING!");
               }
  @@ -580,7 +642,7 @@
                       this.hasNext = false;
                   }
               }
  -        }
  +        } */
   
           if (rowNum == -1) {
               return null;
  
  
  
  1.27      +8 -6      jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
  
  Index: HSSFCell.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- HSSFCell.java	9 Apr 2004 13:05:24 -0000	1.26
  +++ HSSFCell.java	18 Apr 2004 13:02:48 -0000	1.27
  @@ -71,7 +71,7 @@
        * @see #getCellType()
        */
   
  -    public final static int          CELL_TYPE_NUMERIC           = 0;
  +    public final static int          CELL_TYPE_NUMERIC           = 1;
   
       /**
        * String Cell type (1)
  @@ -79,7 +79,7 @@
        * @see #getCellType()
        */
   
  -    public final static int          CELL_TYPE_STRING            = 1;
  +    public final static int          CELL_TYPE_STRING            = 2;
   
       /**
        * Formula Cell type (2)
  @@ -87,7 +87,7 @@
        * @see #getCellType()
        */
   
  -    public final static int          CELL_TYPE_FORMULA           = 2;
  +    public final static int          CELL_TYPE_FORMULA           = 3;
   
       /**
        * Blank Cell type (3)
  @@ -95,7 +95,7 @@
        * @see #getCellType()
        */
   
  -    public final static int          CELL_TYPE_BLANK             = 3;
  +    public final static int          CELL_TYPE_BLANK             = 4;
   
       /**
        * Boolean Cell type (4)
  @@ -103,7 +103,7 @@
        * @see #getCellType()
        */
   
  -    public final static int          CELL_TYPE_BOOLEAN           = 4;
  +    public final static int          CELL_TYPE_BOOLEAN           = 5;
   
       /**
        * Error Cell type (5)
  @@ -111,9 +111,11 @@
        * @see #getCellType()
        */
   
  -    public final static int          CELL_TYPE_ERROR             = 5;
  +    public final static int          CELL_TYPE_ERROR             = 6;
  +
       public final static short        ENCODING_COMPRESSED_UNICODE = 0;
       public final static short        ENCODING_UTF_16             = 1;
  +
       private short                    cellNum;
       private int                      cellType;
       private HSSFCellStyle            cellStyle;
  
  
  
  1.1                  jakarta-poi/src/java/org/apache/poi/util/DoubleList2d.java
  
  Index: DoubleList2d.java
  ===================================================================
  package org.apache.poi.util;
  
  import java.util.List;
  import java.util.ArrayList;
  
  /**
   * Provides an interface for interacting with 2d arrays of doubles.  This
   * implementation will return 0 for items not yet allocated and automatically
   * increase the array size for set operations.  You never get an index out of
   * bounds.
   *
   * @author Glen Stampoultzis (glens at apache.org)
   * @version $Id: DoubleList2d.java,v 1.1 2004/04/18 13:02:48 glens Exp $
   */
  public class DoubleList2d
  {
      // Implemented using a List of DoubleList's.
      List rows = new ArrayList();
  
      public double get(int col, int row)
      {
          if (row >= rows.size())
          {
              return 0;
          }
          else
          {
              DoubleList cols = (DoubleList) rows.get(row);
              if (col >= cols.size())
                  return 0;
              else
                  return cols.get( col );
          }
      }
  
      public void set(int col, int row, double value)
      {
          resizeRows(row);
          resizeCols(row,col);
          DoubleList cols = (DoubleList) rows.get( row );
          cols.set( col, value );
      }
  
      private void resizeRows( int row )
      {
          while (rows.size() <= row)
              rows.add( new DoubleList() );
      }
  
      private void resizeCols( int row, int col )
      {
          DoubleList cols = (DoubleList) rows.get( row );
          while (cols.size() <= col)
              cols.add(0);
      }
  
  
  }
  
  
  
  1.1                  jakarta-poi/src/java/org/apache/poi/util/IntList2d.java
  
  Index: IntList2d.java
  ===================================================================
  package org.apache.poi.util;
  
  import java.util.List;
  import java.util.ArrayList;
  
  /**
   * Provides an interface for interacting with 2d arrays of integers.  This
   * implementation will return 0 for items not yet allocated and automatically
   * increase the array size for set operations.  You never get an index out of
   * bounds.
   *
   * @author Glen Stampoultzis (glens at apache.org)
   * @version $Id: IntList2d.java,v 1.1 2004/04/18 13:02:48 glens Exp $
   */
  public class IntList2d
  {
      // Implemented using a List of IntList's.
      List rows = new ArrayList();
  
      public int get(int col, int row)
      {
          if (row >= rows.size())
          {
              return 0;
          }
          else
          {
              IntList cols = (IntList) rows.get(row);
              if (col >= cols.size())
                  return 0;
              else
                  return cols.get( col );
          }
      }
  
      public void set(int col, int row, int value)
      {
          resizeRows(row);
          resizeCols(row,col);
          IntList cols = (IntList) rows.get( row );
          cols.set( col, value );
      }
  
      private void resizeRows( int row )
      {
          while (rows.size() <= row)
              rows.add( new IntList() );
      }
  
      private void resizeCols( int row, int col )
      {
          IntList cols = (IntList) rows.get( row );
          while (cols.size() <= col)
              cols.add(0);
      }
  
      public boolean isAllocated( int col, int row )
      {
          if (row < rows.size())
          {
              IntList cols = (IntList) rows.get( row );
              return ( col < cols.size() );
          }
          else
          {
              return false;
          }
      }
  
  
  
  }
  
  
  
  1.1                  jakarta-poi/src/java/org/apache/poi/util/List2d.java
  
  Index: List2d.java
  ===================================================================
  package org.apache.poi.util;
  
  import java.util.List;
  import java.util.ArrayList;
  
  /**
   * Provides an interface for interacting with 2d arrays of objects.  This
   * implementation will return null for items not yet allocated and automatically
   * increase the array size for set operations.  You never get an index out of
   * bounds.
   *
   * @author Glen Stampoultzis (glens at apache.org)
   * @version $Id: List2d.java,v 1.1 2004/04/18 13:02:48 glens Exp $
   */
  public class List2d
  {
      // Implemented using a List of List's.
      List rows = new ArrayList();
  
      public Object get(int col, int row)
      {
          if (row >= rows.size())
          {
              return null;
          }
          else
          {
              List cols = (List) rows.get(row);
              if (col >= cols.size())
                  return null;
              else
                  return cols.get( col );
          }
      }
  
      public void set(int col, int row, Object value)
      {
          resizeRows(row);
          resizeCols(row,col);
          List cols = (List) rows.get( row );
          cols.set( col, value );
      }
  
      private void resizeRows( int row )
      {
          while (rows.size() <= row)
              rows.add( new ArrayList() );
      }
  
      private void resizeCols( int row, int col )
      {
          List cols = (List) rows.get( row );
          while (cols.size() <= col)
              cols.add(null);
      }
  
  
  }
  
  
  
  1.4       +14 -13    jakarta-poi/src/testcases/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java
  
  Index: TestValueRecordsAggregate.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestValueRecordsAggregate.java	12 Apr 2004 13:46:40 -0000	1.3
  +++ TestValueRecordsAggregate.java	18 Apr 2004 13:02:48 -0000	1.4
  @@ -144,27 +144,28 @@
   //
   //    }
   
  -    public void testSerialize() throws Exception
  +    public void testSerializeCellRow() throws Exception
       {
           byte[] actualArray = new byte[36];
           byte[] expectedArray = new byte[]
           {
  -            (byte)0x06, (byte)0x00, (byte)0x16, (byte)0x00,
  -            (byte)0x01, (byte)0x00, (byte)0x01, (byte)0x00,
  -            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
  -            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
  -            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
  -            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
  -            (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x02,
  -            (byte)0x06, (byte)0x00, (byte)0x02, (byte)0x00,
  -            (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x00,
  +            (byte)0x06,(byte)0x00,(byte)0x16,(byte)0x00,
  +            (byte)0x01,(byte)0x00,(byte)0x01,(byte)0x00,
  +            (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
  +            (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
  +            (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
  +            (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
  +            (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
  +            (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
  +            (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
  +
           };
           List records = testData();
           valueRecord.construct( 0, records );
  -        int bytesWritten = valueRecord.serialize( 0, actualArray );
  -        assertEquals( 36, bytesWritten );
  +        int bytesWritten = valueRecord.serializeCellRow( 1, 0, actualArray );
  +        assertEquals( 26, bytesWritten );
           for (int i = 0; i < 36; i++)
  -            assertEquals( expectedArray[i], actualArray[i] );
  +            assertEquals( "wrong value at offset " + i, expectedArray[i], actualArray[i]
);
       }
   
       public static void main( String[] args )
  
  
  
  1.20      +1 -0      jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
  
  Index: TestHSSFSheet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- TestHSSFSheet.java	9 Apr 2004 13:05:36 -0000	1.19
  +++ TestHSSFSheet.java	18 Apr 2004 13:02:48 -0000	1.20
  @@ -169,6 +169,7 @@
           FileOutputStream stream = new FileOutputStream(tempFile);
           workbook.write(stream);
           stream.close();
  +        System.out.println( "tempFile.getCanonicalPath() = " + tempFile.getCanonicalPath()
);
   
           FileInputStream readStream = new FileInputStream(tempFile);
           workbook = new HSSFWorkbook(readStream);
  
  
  
  1.1                  jakarta-poi/src/testcases/org/apache/poi/util/TestDoubleList2d.java
  
  Index: TestDoubleList2d.java
  ===================================================================
  package org.apache.poi.util;
  
  import junit.framework.TestCase;
  
  /**
   * @version $Id: TestDoubleList2d.java,v 1.1 2004/04/18 13:02:48 glens Exp $
   */
  public class TestDoubleList2d
          extends TestCase
  {
      public void testAccess()
              throws Exception
      {
          DoubleList2d array = new DoubleList2d();
          assertEquals( 0, array.get( 0, 0 ), 0.00001 );
          assertEquals( 0, array.get( 1, 1 ), 0.00001 );
          assertEquals( 0, array.get( 100, 100 ), 0.00001 );
          array.set( 100, 100, 999 );
          assertEquals( 999, array.get( 100, 100 ), 0.00001 );
          assertEquals( 0, array.get( 0, 0 ), 0.00001 );
          array.set( 0, 0, 999 );
          assertEquals( 999, array.get( 0, 0 ), 0.00001 );
  
          try
          {
              array.get( -1, -1 );
              fail();
          }
          catch ( ArrayIndexOutOfBoundsException e )
          {
              // pass
          }
      }
  }
  
  
  
  1.1                  jakarta-poi/src/testcases/org/apache/poi/util/TestIntList2d.java
  
  Index: TestIntList2d.java
  ===================================================================
  package org.apache.poi.util;
  
  import junit.framework.TestCase;
  
  /**
   * @version $Id: TestIntList2d.java,v 1.1 2004/04/18 13:02:48 glens Exp $
   */
  public class TestIntList2d
          extends TestCase
  {
      public void testAccess()
              throws Exception
      {
          IntList2d array = new IntList2d();
          assertEquals( 0, array.get( 0, 0 ) );
          assertEquals( 0, array.get( 1, 1 ) );
          assertEquals( 0, array.get( 100, 100 ) );
          array.set( 100, 100, 999 );
          assertEquals( 999, array.get( 100, 100 ) );
          assertEquals( 0, array.get( 0, 0 ) );
          array.set( 0, 0, 999 );
          assertEquals( 999, array.get( 0, 0 ) );
  
          assertTrue(array.isAllocated( 0, 0 ) );
          assertTrue(array.isAllocated( 100, 100 ) );
          assertFalse(array.isAllocated( 200, 200 ) );
  
          try
          {
              assertEquals( 0, array.get( -1, -1 ) );
              fail();
          }
          catch ( ArrayIndexOutOfBoundsException e )
          {
              // pass
          }
      }
  }
  
  
  
  1.1                  jakarta-poi/src/testcases/org/apache/poi/util/TestList2d.java
  
  Index: TestList2d.java
  ===================================================================
  package org.apache.poi.util;
  
  import junit.framework.TestCase;
  
  /**
   * @version $Id: TestList2d.java,v 1.1 2004/04/18 13:02:48 glens Exp $
   */
  public class TestList2d
          extends TestCase
  {
      public void testAccess()
              throws Exception
      {
          Object objectA = new Object();
          Object objectB = new Object();
  
          List2d array = new List2d();
          assertNull( array.get( 0, 0 ) );
          assertNull( array.get( 1, 1 ) );
          assertNull( array.get( 100, 100 ) );
          array.set( 100, 100, objectA );
          assertSame( objectA, array.get( 100, 100 ) );
          assertNull( array.get( 0, 0 ) );
          array.set( 0, 0, objectB );
          assertSame( objectB, array.get( 0, 0 ) );
  
          try
          {
              array.get( -1, -1 );
              fail();
          }
          catch ( ArrayIndexOutOfBoundsException e )
          {
              // pass
          }
      }
  }
  
  
  
  1.14      +1 -0      jakarta-poi/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/.cvsignore,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- .cvsignore	9 Apr 2004 11:45:38 -0000	1.13
  +++ .cvsignore	18 Apr 2004 13:02:48 -0000	1.14
  @@ -10,3 +10,4 @@
   build
   .classpath
   .project
  +workbook.xls
  
  
  
  1.57      +4 -0      jakarta-poi/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/build.xml,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- build.xml	9 Apr 2004 13:05:39 -0000	1.56
  +++ build.xml	18 Apr 2004 13:02:48 -0000	1.57
  @@ -91,6 +91,7 @@
       <path id="main.classpath">
           <pathelement location="${main.jar1.dir}"/>
           <pathelement location="${main.jar2.dir}"/>
  +        <pathelement location="${main.resource1.dir}"/>
       </path>
   
       <path id="scratchpad.classpath">
  @@ -216,6 +217,9 @@
       </target>
   
       <target name="compile-main" depends="init">
  +        <copy todir="${main.output.dir}">
  +            <fileset dir="${main.resource1.dir}"/>
  +        </copy>
           <javac srcdir="${main.src}" destdir="${main.output.dir}" debug="on">
               <classpath refid="main.classpath"/>
           </javac>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org


Mime
View raw message