From: Nick Burch Date: Fri, 2 Jul 2010 21:29:32 +0000 (+0000) Subject: Fix deprecated warnings X-Git-Tag: REL_3_7_BETA2~38 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=adb08300e4b8bf219c5ee2503fe1af2a1ccb5818;p=poi.git Fix deprecated warnings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@960111 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java index 90b04a1d3a..0afd1a5971 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java @@ -147,7 +147,9 @@ public class XSSFRichTextString implements RichTextString { XSSFFont xssfFont = (XSSFFont)font; ArrayList runs = new ArrayList(); - CTRElt[] r = st.getRArray(); + CTRElt[] r = new CTRElt[st.getRList().size()]; + st.getRList().toArray(r); + int pos = 0; for (int i = 0; i < r.length; i++) { int rStart = pos; @@ -338,7 +340,7 @@ public class XSSFRichTextString implements RichTextString { return st.getT(); } StringBuffer buf = new StringBuffer(); - for(CTRElt r : st.getRArray()){ + for(CTRElt r : st.getRList()){ buf.append(r.getT()); } return buf.toString(); @@ -425,7 +427,7 @@ public class XSSFRichTextString implements RichTextString { protected void setStylesTableReference(StylesTable tbl){ styles = tbl; if(st.sizeOfRArray() > 0) { - for (CTRElt r : st.getRArray()) { + for (CTRElt r : st.getRList()) { CTRPrElt pr = r.getRPr(); if(pr != null){ String fontName = pr.getRFontArray(0).getVal(); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java index f43a05fadf..53747f5e3f 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -17,8 +17,6 @@ package org.apache.poi.xssf.usermodel; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.TreeMap; @@ -26,9 +24,9 @@ import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.util.CellReference; +import org.apache.poi.util.Internal; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; -import org.apache.poi.util.Internal; import org.apache.poi.xssf.model.CalculationChain; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow; @@ -65,7 +63,7 @@ public class XSSFRow implements Row, Comparable { _row = row; _sheet = sheet; _cells = new TreeMap(); - for (CTCell c : row.getCArray()) { + for (CTCell c : row.getCList()) { XSSFCell cell = new XSSFCell(this, c); _cells.put(cell.getColumnIndex(), cell); sheet.onReadCell(cell); @@ -394,10 +392,9 @@ public class XSSFRow implements Row, Comparable { if(_row.sizeOfCArray() != _cells.size()) isOrdered = false; else { int i = 0; - CTCell[] xcell = _row.getCArray(); for (XSSFCell cell : _cells.values()) { CTCell c1 = cell.getCTCell(); - CTCell c2 = xcell[i++]; + CTCell c2 = _row.getCArray(i++); String r1 = c1.getR(); String r2 = c2.getR(); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 6c13857f9c..26c4694055 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -202,7 +202,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { _rows = new TreeMap(); sharedFormulas = new HashMap(); arrayFormulas = new ArrayList(); - for (CTRow row : worksheet.getSheetData().getRowArray()) { + for (CTRow row : worksheet.getSheetData().getRowList()) { XSSFRow r = new XSSFRow(row, this); _rows.put(r.getRowNum(), r); } @@ -222,7 +222,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { getPackagePart().getRelationshipsByType(XSSFRelation.SHEET_HYPERLINKS.getRelation()); // Turn each one into a XSSFHyperlink - for(CTHyperlink hyperlink : worksheet.getHyperlinks().getHyperlinkArray()) { + for(CTHyperlink hyperlink : worksheet.getHyperlinks().getHyperlinkList()) { PackageRelationship hyperRel = null; if(hyperlink.getId() != null) { hyperRel = hyperRels.getRelationshipByID(hyperlink.getId()); @@ -575,7 +575,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { return new int[0]; } - CTBreak[] brkArray = worksheet.getColBreaks().getBrkArray(); + CTBreak[] brkArray = new CTBreak[worksheet.getColBreaks().getBrkList().size()]; + worksheet.getColBreaks().getBrkList().toArray(brkArray); + int[] breaks = new int[brkArray.length]; for (int i = 0 ; i < brkArray.length ; i++) { CTBreak brk = brkArray[i]; @@ -996,7 +998,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { return new int[0]; } - CTBreak[] brkArray = worksheet.getRowBreaks().getBrkArray(); + CTBreak[] brkArray = new CTBreak[worksheet.getRowBreaks().getBrkList().size()]; + worksheet.getRowBreaks().getBrkList().toArray(brkArray); + int[] breaks = new int[brkArray.length]; for (int i = 0 ; i < brkArray.length ; i++) { CTBreak brk = brkArray[i]; @@ -1172,9 +1176,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { private short getMaxOutlineLevelCols(){ CTCols ctCols=worksheet.getColsArray(0); - CTCol[]colArray=ctCols.getColArray(); short outlineLevel=0; - for(CTCol col: colArray){ + for(CTCol col: ctCols.getColList()){ outlineLevel=col.getOutlineLevel()>outlineLevel? col.getOutlineLevel(): outlineLevel; } return outlineLevel; @@ -1319,7 +1322,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { * Removes a page break at the indicated column */ public void removeColumnBreak(int column) { - CTBreak[] brkArray = getSheetTypeColumnBreaks().getBrkArray(); + CTBreak[] brkArray = new CTBreak[getSheetTypeColumnBreaks().getBrkList().size()]; + getSheetTypeColumnBreaks().getBrkList().toArray(brkArray); + for (int i = 0 ; i < brkArray.length ; i++) { if (brkArray[i].getId() == column) { getSheetTypeColumnBreaks().removeBrk(i); @@ -1371,7 +1376,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { */ public void removeRowBreak(int row) { CTPageBreak pgBreak = worksheet.isSetRowBreaks() ? worksheet.getRowBreaks() : worksheet.addNewRowBreaks(); - CTBreak[] brkArray = pgBreak.getBrkArray(); + CTBreak[] brkArray = new CTBreak[pgBreak.getBrkList().size()]; + pgBreak.getBrkList().toArray(brkArray); for (int i = 0 ; i < brkArray.length ; i++) { if (brkArray[i].getId() == row) { pgBreak.removeBrk(i); @@ -2144,7 +2150,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { if(sheetComments != null){ //TODO shift Note's anchor in the associated /xl/drawing/vmlDrawings#.vml CTCommentList lst = sheetComments.getCTComments().getCommentList(); - for (CTComment comment : lst.getCommentArray()) { + for (CTComment comment : lst.getCommentList()) { CellReference ref = new CellReference(comment.getRef()); if(ref.getRow() == rownum){ ref = new CellReference(rownum + n, ref.getCol()); @@ -2270,7 +2276,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { */ public void setSelected(boolean value) { CTSheetViews views = getSheetTypeSheetViews(); - for (CTSheetView view : views.getSheetViewArray()) { + for (CTSheetView view : views.getSheetViewList()) { view.setTabSelected(value); } } @@ -2346,10 +2352,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { */ private CTSheetView getDefaultSheetView() { CTSheetViews views = getSheetTypeSheetViews(); - if (views == null || views.getSheetViewArray() == null || views.getSheetViewArray().length <= 0) { + if (views == null || views.getSheetViewList() == null || views.getSheetViewList().size() <= 0) { return null; } - return views.getSheetViewArray(views.getSheetViewArray().length - 1); + return views.getSheetViewArray(views.getSheetViewList().size() - 1); } /** @@ -2421,10 +2427,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { protected void write(OutputStream out) throws IOException { - if(worksheet.getColsArray().length == 1) { + if(worksheet.getColsList().size() == 1) { CTCols col = worksheet.getColsArray(0); - CTCol[] cols = col.getColArray(); - if(cols.length == 0) { + if(col.getColList().size() == 0) { worksheet.setColsArray(null); } } @@ -2473,10 +2478,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { if(sheetData.sizeOfRowArray() != _rows.size()) isOrdered = false; else { int i = 0; - CTRow[] xrow = sheetData.getRowArray(); for (XSSFRow row : _rows.values()) { CTRow c1 = row.getCTRow(); - CTRow c2 = xrow[i++]; + CTRow c2 = sheetData.getRowArray(i++); if (c1.getR() != c2.getR()){ isOrdered = false; break; @@ -2880,8 +2884,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { List xssfValidations = new ArrayList(); CTDataValidations dataValidations = this.worksheet.getDataValidations(); if( dataValidations!=null && dataValidations.getCount() > 0 ) { - CTDataValidation[] dataValidationList = dataValidations.getDataValidationArray(); - for (CTDataValidation ctDataValidation : dataValidationList) { + for (CTDataValidation ctDataValidation : dataValidations.getDataValidationList()) { CellRangeAddressList addressList = new CellRangeAddressList(); @SuppressWarnings("unchecked") @@ -2909,7 +2912,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { if( dataValidations==null ) { dataValidations = worksheet.addNewDataValidations(); } - int currentCount = dataValidations.getDataValidationArray().length; + int currentCount = dataValidations.getDataValidationList().size(); CTDataValidation newval = dataValidations.addNewDataValidation(); newval.set(xssfDataValidation.getCtDdataValidation()); dataValidations.setCount(currentCount + 1); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 4c73e3496a..54f32fb1e7 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -217,7 +217,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable(shIdMap.size()); - for (CTSheet ctSheet : this.workbook.getSheets().getSheetArray()) { + for (CTSheet ctSheet : this.workbook.getSheets().getSheetList()) { XSSFSheet sh = shIdMap.get(ctSheet.getId()); if(sh == null) { logger.log(POILogger.WARN, "Sheet with name " + ctSheet.getName() + " and r:id " + ctSheet.getId()+ " was defined, but didn't exist in package, skipping"); @@ -231,7 +231,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable(); if(workbook.isSetDefinedNames()) { - for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameArray()) { + for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameList()) { namedRanges.add(new XSSFName(ctName, this)); } } @@ -873,7 +873,9 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable