View | Details | Raw Unified | Return to bug 57840
Collapse All | Expand All

(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java (-5 / +5 lines)
Lines 72-78 Link Here
72
        _cells = new TreeMap<Integer, XSSFCell>();
72
        _cells = new TreeMap<Integer, XSSFCell>();
73
        for (CTCell c : row.getCArray()) {
73
        for (CTCell c : row.getCArray()) {
74
            XSSFCell cell = new XSSFCell(this, c);
74
            XSSFCell cell = new XSSFCell(this, c);
75
            _cells.put(cell.getColumnIndex(), cell);
75
            _cells.put(new Integer(cell.getColumnIndex()), cell);
76
            sheet.onReadCell(cell);
76
            sheet.onReadCell(cell);
77
        }
77
        }
78
    }
78
    }
Lines 198-204 Link Here
198
     */
198
     */
199
    public XSSFCell createCell(int columnIndex, int type) {
199
    public XSSFCell createCell(int columnIndex, int type) {
200
        CTCell ctCell;
200
        CTCell ctCell;
201
        XSSFCell prev = _cells.get(columnIndex);
201
        XSSFCell prev = _cells.get(new Integer(columnIndex));
202
        if(prev != null){
202
        if(prev != null){
203
            ctCell = prev.getCTCell();
203
            ctCell = prev.getCTCell();
204
            ctCell.set(CTCell.Factory.newInstance());
204
            ctCell.set(CTCell.Factory.newInstance());
Lines 210-216 Link Here
210
        if (type != Cell.CELL_TYPE_BLANK) {
210
        if (type != Cell.CELL_TYPE_BLANK) {
211
        	xcell.setCellType(type);
211
        	xcell.setCellType(type);
212
        }
212
        }
213
        _cells.put(columnIndex, xcell);
213
        _cells.put(new Integer(columnIndex), xcell);
214
        return xcell;
214
        return xcell;
215
    }
215
    }
216
216
Lines 236-242 Link Here
236
    public XSSFCell getCell(int cellnum, MissingCellPolicy policy) {
236
    public XSSFCell getCell(int cellnum, MissingCellPolicy policy) {
237
    	if(cellnum < 0) throw new IllegalArgumentException("Cell index must be >= 0");
237
    	if(cellnum < 0) throw new IllegalArgumentException("Cell index must be >= 0");
238
238
239
        XSSFCell cell = _cells.get(cellnum);
239
        XSSFCell cell = _cells.get(new Integer(cellnum));
240
    	if(policy == RETURN_NULL_AND_BLANK) {
240
    	if(policy == RETURN_NULL_AND_BLANK) {
241
    		return cell;
241
    		return cell;
242
    	}
242
    	}
Lines 455-461 Link Here
455
        if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
455
        if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
456
           _sheet.getWorkbook().onDeleteFormula(xcell);
456
           _sheet.getWorkbook().onDeleteFormula(xcell);
457
        }
457
        }
458
        _cells.remove(cell.getColumnIndex());
458
        _cells.remove(new Integer(cell.getColumnIndex()));
459
    }
459
    }
460
460
461
    /**
461
    /**
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (-10 / +10 lines)
Lines 222-228 Link Here
222
        arrayFormulas = new ArrayList<CellRangeAddress>();
222
        arrayFormulas = new ArrayList<CellRangeAddress>();
223
        for (CTRow row : worksheetParam.getSheetData().getRowArray()) {
223
        for (CTRow row : worksheetParam.getSheetData().getRowArray()) {
224
            XSSFRow r = new XSSFRow(row, this);
224
            XSSFRow r = new XSSFRow(row, this);
225
            _rows.put(r.getRowNum(), r);
225
            _rows.put(new Integer(r.getRowNum()), r);
226
        }
226
        }
227
    }
227
    }
228
228
Lines 693-699 Link Here
693
    @Override
693
    @Override
694
    public XSSFRow createRow(int rownum) {
694
    public XSSFRow createRow(int rownum) {
695
        CTRow ctRow;
695
        CTRow ctRow;
696
        XSSFRow prev = _rows.get(rownum);
696
        XSSFRow prev = _rows.get(new Integer(rownum));
697
        if(prev != null){
697
        if(prev != null){
698
            // the Cells in an existing row are invalidated on-purpose, in order to clean up correctly, we
698
            // the Cells in an existing row are invalidated on-purpose, in order to clean up correctly, we
699
            // need to call the remove, so things like ArrayFormulas and CalculationChain updates are done 
699
            // need to call the remove, so things like ArrayFormulas and CalculationChain updates are done 
Lines 713-725 Link Here
713
            } else {
713
            } else {
714
                // get number of rows where row index < rownum
714
                // get number of rows where row index < rownum
715
                // --> this tells us where our row should go
715
                // --> this tells us where our row should go
716
                int idx = _rows.headMap(rownum).size();
716
                int idx = _rows.headMap(new Integer(rownum)).size();
717
                ctRow = worksheet.getSheetData().insertNewRow(idx);
717
                ctRow = worksheet.getSheetData().insertNewRow(idx);
718
            }
718
            }
719
        }
719
        }
720
        XSSFRow r = new XSSFRow(ctRow, this);
720
        XSSFRow r = new XSSFRow(ctRow, this);
721
        r.setRowNum(rownum);
721
        r.setRowNum(rownum);
722
        _rows.put(rownum, r);
722
        _rows.put(new Integer(rownum), r);
723
        return r;
723
        return r;
724
    }
724
    }
725
725
Lines 1377-1383 Link Here
1377
     */
1377
     */
1378
    @Override
1378
    @Override
1379
    public XSSFRow getRow(int rownum) {
1379
    public XSSFRow getRow(int rownum) {
1380
        return _rows.get(rownum);
1380
        return _rows.get(new Integer(rownum));
1381
    }
1381
    }
1382
    
1382
    
1383
    /**
1383
    /**
Lines 1406-1412 Link Here
1406
            }
1406
            }
1407
        }
1407
        }
1408
        else {
1408
        else {
1409
            rows.addAll(_rows.subMap(startRowNum, endRowNum+1).values());
1409
            rows.addAll(_rows.subMap(new Integer(startRowNum), new Integer(endRowNum+1)).values());
1410
        }
1410
        }
1411
        return rows;
1411
        return rows;
1412
    }
1412
    }
Lines 1876-1883 Link Here
1876
            row.removeCell(cell);
1876
            row.removeCell(cell);
1877
        }
1877
        }
1878
1878
1879
        int idx = _rows.headMap(row.getRowNum()).size();
1879
        int idx = _rows.headMap(new Integer(row.getRowNum())).size();
1880
        _rows.remove(row.getRowNum());
1880
        _rows.remove(new Integer(row.getRowNum()));
1881
        worksheet.getSheetData().removeRow(idx);
1881
        worksheet.getSheetData().removeRow(idx);
1882
1882
1883
        // also remove any comment located in that row
1883
        // also remove any comment located in that row
Lines 2893-2899 Link Here
2893
            // check if we should remove this row as it will be overwritten by the data later
2893
            // check if we should remove this row as it will be overwritten by the data later
2894
            if (shouldRemoveRow(startRow, endRow, n, rownum)) {
2894
            if (shouldRemoveRow(startRow, endRow, n, rownum)) {
2895
                // remove row from worksheet.getSheetData row array
2895
                // remove row from worksheet.getSheetData row array
2896
                int idx = _rows.headMap(row.getRowNum()).size();
2896
                int idx = _rows.headMap(new Integer(row.getRowNum())).size();
2897
                worksheet.getSheetData().removeRow(idx);
2897
                worksheet.getSheetData().removeRow(idx);
2898
2898
2899
                // remove row from _rows
2899
                // remove row from _rows
Lines 3012-3018 Link Here
3012
        //rebuild the _rows map
3012
        //rebuild the _rows map
3013
        SortedMap<Integer, XSSFRow> map = new TreeMap<Integer, XSSFRow>();
3013
        SortedMap<Integer, XSSFRow> map = new TreeMap<Integer, XSSFRow>();
3014
        for(XSSFRow r : _rows.values()) {
3014
        for(XSSFRow r : _rows.values()) {
3015
            map.put(r.getRowNum(), r);
3015
            map.put(new Integer(r.getRowNum()), r);
3016
        }
3016
        }
3017
        _rows = map;
3017
        _rows = map;
3018
    }
3018
    }

Return to bug 57840