revert usages of getXYZList() back to getXYZArray() in XSSF, also misc performance optimizations
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1022420 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
38b71f33e2
commit
8f59cfbb23
@ -78,11 +78,11 @@ public class CalculationChain extends POIXMLDocumentPart {
|
|||||||
* @param sheetId the sheet Id of a sheet the formula belongs to.
|
* @param sheetId the sheet Id of a sheet the formula belongs to.
|
||||||
* @param ref A1 style reference to the cell containing the formula.
|
* @param ref A1 style reference to the cell containing the formula.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation") // getXYZArray() array accessors are deprecated
|
||||||
public void removeItem(int sheetId, String ref){
|
public void removeItem(int sheetId, String ref){
|
||||||
//sheet Id of a sheet the cell belongs to
|
//sheet Id of a sheet the cell belongs to
|
||||||
int id = -1;
|
int id = -1;
|
||||||
CTCalcCell[] c = new CTCalcCell[chain.getCList().size()];
|
CTCalcCell[] c = chain.getCArray();
|
||||||
chain.getCList().toArray(c);
|
|
||||||
|
|
||||||
for (int i = 0; i < c.length; i++){
|
for (int i = 0; i < c.length; i++){
|
||||||
//If sheet Id is omitted, it is assumed to be the same as the value of the previous cell.
|
//If sheet Id is omitted, it is assumed to be the same as the value of the previous cell.
|
||||||
|
@ -116,7 +116,7 @@ public class CommentsTable extends POIXMLDocumentPart {
|
|||||||
// Create the cache if needed
|
// Create the cache if needed
|
||||||
if(commentRefs == null) {
|
if(commentRefs == null) {
|
||||||
commentRefs = new HashMap<String, CTComment>();
|
commentRefs = new HashMap<String, CTComment>();
|
||||||
for (CTComment comment : comments.getCommentList().getCommentList()) {
|
for (CTComment comment : comments.getCommentList().getCommentArray()) {
|
||||||
commentRefs.put(comment.getRef(), comment);
|
commentRefs.put(comment.getRef(), comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class SharedStringsTable extends POIXMLDocumentPart {
|
|||||||
*/
|
*/
|
||||||
private int uniqueCount;
|
private int uniqueCount;
|
||||||
|
|
||||||
public SstDocument _sstDoc;
|
private SstDocument _sstDoc;
|
||||||
|
|
||||||
public SharedStringsTable() {
|
public SharedStringsTable() {
|
||||||
super();
|
super();
|
||||||
@ -103,6 +103,7 @@ public class SharedStringsTable extends POIXMLDocumentPart {
|
|||||||
* @param is The input stream containing the XML document.
|
* @param is The input stream containing the XML document.
|
||||||
* @throws IOException if an error occurs while reading.
|
* @throws IOException if an error occurs while reading.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public void readFrom(InputStream is) throws IOException {
|
public void readFrom(InputStream is) throws IOException {
|
||||||
try {
|
try {
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
@ -110,7 +111,7 @@ public class SharedStringsTable extends POIXMLDocumentPart {
|
|||||||
CTSst sst = _sstDoc.getSst();
|
CTSst sst = _sstDoc.getSst();
|
||||||
count = (int)sst.getCount();
|
count = (int)sst.getCount();
|
||||||
uniqueCount = (int)sst.getUniqueCount();
|
uniqueCount = (int)sst.getUniqueCount();
|
||||||
for (CTRst st : sst.getSiList()) {
|
for (CTRst st : sst.getSiArray()) {
|
||||||
stmap.put(st.toString(), cnt);
|
stmap.put(st.toString(), cnt);
|
||||||
strings.add(st);
|
strings.add(st);
|
||||||
cnt++;
|
cnt++;
|
||||||
|
@ -106,38 +106,52 @@ public class StylesTable extends POIXMLDocumentPart {
|
|||||||
* @param is The input stream containing the XML document.
|
* @param is The input stream containing the XML document.
|
||||||
* @throws IOException if an error occurs while reading.
|
* @throws IOException if an error occurs while reading.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
protected void readFrom(InputStream is) throws IOException {
|
protected void readFrom(InputStream is) throws IOException {
|
||||||
try {
|
try {
|
||||||
doc = StyleSheetDocument.Factory.parse(is);
|
doc = StyleSheetDocument.Factory.parse(is);
|
||||||
|
|
||||||
|
CTStylesheet styleSheet = doc.getStyleSheet();
|
||||||
|
|
||||||
// Grab all the different bits we care about
|
// Grab all the different bits we care about
|
||||||
if(doc.getStyleSheet().getNumFmts() != null)
|
CTNumFmts ctfmts = styleSheet.getNumFmts();
|
||||||
for (CTNumFmt nfmt : doc.getStyleSheet().getNumFmts().getNumFmtList()) {
|
if( ctfmts != null){
|
||||||
|
for (CTNumFmt nfmt : ctfmts.getNumFmtArray()) {
|
||||||
numberFormats.put((int)nfmt.getNumFmtId(), nfmt.getFormatCode());
|
numberFormats.put((int)nfmt.getNumFmtId(), nfmt.getFormatCode());
|
||||||
}
|
}
|
||||||
if(doc.getStyleSheet().getFonts() != null){
|
}
|
||||||
|
|
||||||
|
CTFonts ctfonts = styleSheet.getFonts();
|
||||||
|
if(ctfonts != null){
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (CTFont font : doc.getStyleSheet().getFonts().getFontList()) {
|
for (CTFont font : ctfonts.getFontArray()) {
|
||||||
XSSFFont f = new XSSFFont(font, idx);
|
XSSFFont f = new XSSFFont(font, idx);
|
||||||
fonts.add(f);
|
fonts.add(f);
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(doc.getStyleSheet().getFills() != null)
|
CTFills ctfills = styleSheet.getFills();
|
||||||
for (CTFill fill : doc.getStyleSheet().getFills().getFillList()) {
|
if(ctfills != null){
|
||||||
|
for (CTFill fill : ctfills.getFillArray()) {
|
||||||
fills.add(new XSSFCellFill(fill));
|
fills.add(new XSSFCellFill(fill));
|
||||||
}
|
}
|
||||||
if(doc.getStyleSheet().getBorders() != null)
|
}
|
||||||
for (CTBorder border : doc.getStyleSheet().getBorders().getBorderList()) {
|
|
||||||
|
CTBorders ctborders = styleSheet.getBorders();
|
||||||
|
if(ctborders != null) {
|
||||||
|
for (CTBorder border : ctborders.getBorderArray()) {
|
||||||
borders.add(new XSSFCellBorder(border));
|
borders.add(new XSSFCellBorder(border));
|
||||||
}
|
}
|
||||||
CTCellXfs cellXfs = doc.getStyleSheet().getCellXfs();
|
}
|
||||||
if(cellXfs != null) xfs.addAll(cellXfs.getXfList());
|
|
||||||
|
|
||||||
CTCellStyleXfs cellStyleXfs = doc.getStyleSheet().getCellStyleXfs();
|
CTCellXfs cellXfs = styleSheet.getCellXfs();
|
||||||
if(cellStyleXfs != null) styleXfs.addAll(cellStyleXfs.getXfList());
|
if(cellXfs != null) xfs.addAll(Arrays.asList(cellXfs.getXfArray()));
|
||||||
|
|
||||||
CTDxfs styleDxfs = doc.getStyleSheet().getDxfs();
|
CTCellStyleXfs cellStyleXfs = styleSheet.getCellStyleXfs();
|
||||||
if(styleDxfs != null) dxfs.addAll(styleDxfs.getDxfList());
|
if(cellStyleXfs != null) styleXfs.addAll(Arrays.asList(cellStyleXfs.getXfArray()));
|
||||||
|
|
||||||
|
CTDxfs styleDxfs = styleSheet.getDxfs();
|
||||||
|
if(styleDxfs != null) dxfs.addAll(Arrays.asList(styleDxfs.getDxfArray()));
|
||||||
|
|
||||||
} catch (XmlException e) {
|
} catch (XmlException e) {
|
||||||
throw new IOException(e.getLocalizedMessage());
|
throw new IOException(e.getLocalizedMessage());
|
||||||
@ -328,6 +342,7 @@ public class StylesTable extends POIXMLDocumentPart {
|
|||||||
// Work on the current one
|
// Work on the current one
|
||||||
// Need to do this, as we don't handle
|
// Need to do this, as we don't handle
|
||||||
// all the possible entries yet
|
// all the possible entries yet
|
||||||
|
CTStylesheet styleSheet = doc.getStyleSheet();
|
||||||
|
|
||||||
// Formats
|
// Formats
|
||||||
CTNumFmts formats = CTNumFmts.Factory.newInstance();
|
CTNumFmts formats = CTNumFmts.Factory.newInstance();
|
||||||
@ -337,7 +352,7 @@ public class StylesTable extends POIXMLDocumentPart {
|
|||||||
ctFmt.setNumFmtId(fmt.getKey());
|
ctFmt.setNumFmtId(fmt.getKey());
|
||||||
ctFmt.setFormatCode(fmt.getValue());
|
ctFmt.setFormatCode(fmt.getValue());
|
||||||
}
|
}
|
||||||
doc.getStyleSheet().setNumFmts(formats);
|
styleSheet.setNumFmts(formats);
|
||||||
|
|
||||||
int idx;
|
int idx;
|
||||||
// Fonts
|
// Fonts
|
||||||
@ -347,7 +362,7 @@ public class StylesTable extends POIXMLDocumentPart {
|
|||||||
idx = 0;
|
idx = 0;
|
||||||
for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
|
for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
|
||||||
ctFonts.setFontArray(ctfnt);
|
ctFonts.setFontArray(ctfnt);
|
||||||
doc.getStyleSheet().setFonts(ctFonts);
|
styleSheet.setFonts(ctFonts);
|
||||||
|
|
||||||
// Fills
|
// Fills
|
||||||
CTFills ctFills = CTFills.Factory.newInstance();
|
CTFills ctFills = CTFills.Factory.newInstance();
|
||||||
@ -356,7 +371,7 @@ public class StylesTable extends POIXMLDocumentPart {
|
|||||||
idx = 0;
|
idx = 0;
|
||||||
for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
|
for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
|
||||||
ctFills.setFillArray(ctf);
|
ctFills.setFillArray(ctf);
|
||||||
doc.getStyleSheet().setFills(ctFills);
|
styleSheet.setFills(ctFills);
|
||||||
|
|
||||||
// Borders
|
// Borders
|
||||||
CTBorders ctBorders = CTBorders.Factory.newInstance();
|
CTBorders ctBorders = CTBorders.Factory.newInstance();
|
||||||
@ -365,7 +380,7 @@ public class StylesTable extends POIXMLDocumentPart {
|
|||||||
idx = 0;
|
idx = 0;
|
||||||
for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
|
for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
|
||||||
ctBorders.setBorderArray(ctb);
|
ctBorders.setBorderArray(ctb);
|
||||||
doc.getStyleSheet().setBorders(ctBorders);
|
styleSheet.setBorders(ctBorders);
|
||||||
|
|
||||||
// Xfs
|
// Xfs
|
||||||
if(xfs.size() > 0) {
|
if(xfs.size() > 0) {
|
||||||
@ -374,7 +389,7 @@ public class StylesTable extends POIXMLDocumentPart {
|
|||||||
ctXfs.setXfArray(
|
ctXfs.setXfArray(
|
||||||
xfs.toArray(new CTXf[xfs.size()])
|
xfs.toArray(new CTXf[xfs.size()])
|
||||||
);
|
);
|
||||||
doc.getStyleSheet().setCellXfs(ctXfs);
|
styleSheet.setCellXfs(ctXfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Style xfs
|
// Style xfs
|
||||||
@ -384,7 +399,7 @@ public class StylesTable extends POIXMLDocumentPart {
|
|||||||
ctSXfs.setXfArray(
|
ctSXfs.setXfArray(
|
||||||
styleXfs.toArray(new CTXf[styleXfs.size()])
|
styleXfs.toArray(new CTXf[styleXfs.size()])
|
||||||
);
|
);
|
||||||
doc.getStyleSheet().setCellStyleXfs(ctSXfs);
|
styleSheet.setCellStyleXfs(ctSXfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Style dxfs
|
// Style dxfs
|
||||||
@ -393,7 +408,7 @@ public class StylesTable extends POIXMLDocumentPart {
|
|||||||
ctDxfs.setCount(dxfs.size());
|
ctDxfs.setCount(dxfs.size());
|
||||||
ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[dxfs.size()])
|
ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[dxfs.size()])
|
||||||
);
|
);
|
||||||
doc.getStyleSheet().setDxfs(ctDxfs);
|
styleSheet.setDxfs(ctDxfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
|
@ -132,6 +132,7 @@ public class XSSFRichTextString implements RichTextString {
|
|||||||
* @param endIndex The end index to apply to font to (exclusive)
|
* @param endIndex The end index to apply to font to (exclusive)
|
||||||
* @param font The index of the font to use.
|
* @param font The index of the font to use.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public void applyFont(int startIndex, int endIndex, Font font) {
|
public void applyFont(int startIndex, int endIndex, Font font) {
|
||||||
if (startIndex > endIndex)
|
if (startIndex > endIndex)
|
||||||
throw new IllegalArgumentException("Start index must be less than end index.");
|
throw new IllegalArgumentException("Start index must be less than end index.");
|
||||||
@ -151,9 +152,7 @@ public class XSSFRichTextString implements RichTextString {
|
|||||||
XSSFFont xssfFont = (XSSFFont)font;
|
XSSFFont xssfFont = (XSSFFont)font;
|
||||||
ArrayList<CTRElt> runs = new ArrayList<CTRElt>();
|
ArrayList<CTRElt> runs = new ArrayList<CTRElt>();
|
||||||
|
|
||||||
CTRElt[] r = new CTRElt[st.getRList().size()];
|
CTRElt[] r = st.getRArray();
|
||||||
st.getRList().toArray(r);
|
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (int i = 0; i < r.length; i++) {
|
for (int i = 0; i < r.length; i++) {
|
||||||
int rStart = pos;
|
int rStart = pos;
|
||||||
@ -345,7 +344,7 @@ public class XSSFRichTextString implements RichTextString {
|
|||||||
return utfDecode(st.getT());
|
return utfDecode(st.getT());
|
||||||
}
|
}
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
for(CTRElt r : st.getRList()){
|
for(CTRElt r : st.getRArray()){
|
||||||
buf.append(r.getT());
|
buf.append(r.getT());
|
||||||
}
|
}
|
||||||
return utfDecode(buf.toString());
|
return utfDecode(buf.toString());
|
||||||
@ -429,10 +428,11 @@ public class XSSFRichTextString implements RichTextString {
|
|||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
protected void setStylesTableReference(StylesTable tbl){
|
protected void setStylesTableReference(StylesTable tbl){
|
||||||
styles = tbl;
|
styles = tbl;
|
||||||
if(st.sizeOfRArray() > 0) {
|
if(st.sizeOfRArray() > 0) {
|
||||||
for (CTRElt r : st.getRList()) {
|
for (CTRElt r : st.getRArray()) {
|
||||||
CTRPrElt pr = r.getRPr();
|
CTRPrElt pr = r.getRPr();
|
||||||
if(pr != null){
|
if(pr != null){
|
||||||
String fontName = pr.getRFontArray(0).getVal();
|
String fontName = pr.getRFontArray(0).getVal();
|
||||||
|
@ -59,11 +59,12 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
|
|||||||
* @param row the xml bean containing all cell definitions for this row.
|
* @param row the xml bean containing all cell definitions for this row.
|
||||||
* @param sheet the parent sheet.
|
* @param sheet the parent sheet.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
protected XSSFRow(CTRow row, XSSFSheet sheet) {
|
protected XSSFRow(CTRow row, XSSFSheet sheet) {
|
||||||
_row = row;
|
_row = row;
|
||||||
_sheet = sheet;
|
_sheet = sheet;
|
||||||
_cells = new TreeMap<Integer, XSSFCell>();
|
_cells = new TreeMap<Integer, XSSFCell>();
|
||||||
for (CTCell c : row.getCList()) {
|
for (CTCell c : row.getCArray()) {
|
||||||
XSSFCell cell = new XSSFCell(this, c);
|
XSSFCell cell = new XSSFCell(this, c);
|
||||||
_cells.put(cell.getColumnIndex(), cell);
|
_cells.put(cell.getColumnIndex(), cell);
|
||||||
sheet.onReadCell(cell);
|
sheet.onReadCell(cell);
|
||||||
|
@ -170,11 +170,12 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
hyperlinks = new ArrayList<XSSFHyperlink>();
|
hyperlinks = new ArrayList<XSSFHyperlink>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
private void initRows(CTWorksheet worksheet) {
|
private void initRows(CTWorksheet worksheet) {
|
||||||
_rows = new TreeMap<Integer, XSSFRow>();
|
_rows = new TreeMap<Integer, XSSFRow>();
|
||||||
sharedFormulas = new HashMap<Integer, CTCellFormula>();
|
sharedFormulas = new HashMap<Integer, CTCellFormula>();
|
||||||
arrayFormulas = new ArrayList<CellRangeAddress>();
|
arrayFormulas = new ArrayList<CellRangeAddress>();
|
||||||
for (CTRow row : worksheet.getSheetData().getRowList()) {
|
for (CTRow row : worksheet.getSheetData().getRowArray()) {
|
||||||
XSSFRow r = new XSSFRow(row, this);
|
XSSFRow r = new XSSFRow(row, this);
|
||||||
_rows.put(r.getRowNum(), r);
|
_rows.put(r.getRowNum(), r);
|
||||||
}
|
}
|
||||||
@ -194,7 +195,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
getPackagePart().getRelationshipsByType(XSSFRelation.SHEET_HYPERLINKS.getRelation());
|
getPackagePart().getRelationshipsByType(XSSFRelation.SHEET_HYPERLINKS.getRelation());
|
||||||
|
|
||||||
// Turn each one into a XSSFHyperlink
|
// Turn each one into a XSSFHyperlink
|
||||||
for(CTHyperlink hyperlink : worksheet.getHyperlinks().getHyperlinkList()) {
|
for(CTHyperlink hyperlink : worksheet.getHyperlinks().getHyperlinkArray()) {
|
||||||
PackageRelationship hyperRel = null;
|
PackageRelationship hyperRel = null;
|
||||||
if(hyperlink.getId() != null) {
|
if(hyperlink.getId() != null) {
|
||||||
hyperRel = hyperRels.getRelationshipByID(hyperlink.getId());
|
hyperRel = hyperRels.getRelationshipByID(hyperlink.getId());
|
||||||
@ -547,8 +548,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
return new int[0];
|
return new int[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
CTBreak[] brkArray = new CTBreak[worksheet.getColBreaks().getBrkList().size()];
|
CTBreak[] brkArray = worksheet.getColBreaks().getBrkArray();
|
||||||
worksheet.getColBreaks().getBrkList().toArray(brkArray);
|
|
||||||
|
|
||||||
int[] breaks = new int[brkArray.length];
|
int[] breaks = new int[brkArray.length];
|
||||||
for (int i = 0 ; i < brkArray.length ; i++) {
|
for (int i = 0 ; i < brkArray.length ; i++) {
|
||||||
@ -1003,9 +1003,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
return new int[0];
|
return new int[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
CTBreak[] brkArray = new CTBreak[worksheet.getRowBreaks().getBrkList().size()];
|
CTBreak[] brkArray = worksheet.getRowBreaks().getBrkArray();
|
||||||
worksheet.getRowBreaks().getBrkList().toArray(brkArray);
|
|
||||||
|
|
||||||
int[] breaks = new int[brkArray.length];
|
int[] breaks = new int[brkArray.length];
|
||||||
for (int i = 0 ; i < brkArray.length ; i++) {
|
for (int i = 0 ; i < brkArray.length ; i++) {
|
||||||
CTBreak brk = brkArray[i];
|
CTBreak brk = brkArray[i];
|
||||||
@ -1182,7 +1180,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
private short getMaxOutlineLevelCols() {
|
private short getMaxOutlineLevelCols() {
|
||||||
CTCols ctCols = worksheet.getColsArray(0);
|
CTCols ctCols = worksheet.getColsArray(0);
|
||||||
short outlineLevel = 0;
|
short outlineLevel = 0;
|
||||||
for(CTCol col: ctCols.getColList()){
|
for (CTCol col : ctCols.getColArray()) {
|
||||||
outlineLevel = col.getOutlineLevel() > outlineLevel ? col.getOutlineLevel() : outlineLevel;
|
outlineLevel = col.getOutlineLevel() > outlineLevel ? col.getOutlineLevel() : outlineLevel;
|
||||||
}
|
}
|
||||||
return outlineLevel;
|
return outlineLevel;
|
||||||
@ -1327,9 +1325,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* Removes a page break at the indicated column
|
* Removes a page break at the indicated column
|
||||||
*/
|
*/
|
||||||
public void removeColumnBreak(int column) {
|
public void removeColumnBreak(int column) {
|
||||||
CTBreak[] brkArray = new CTBreak[getSheetTypeColumnBreaks().getBrkList().size()];
|
CTBreak[] brkArray = getSheetTypeColumnBreaks().getBrkArray();
|
||||||
getSheetTypeColumnBreaks().getBrkList().toArray(brkArray);
|
|
||||||
|
|
||||||
for (int i = 0 ; i < brkArray.length ; i++) {
|
for (int i = 0 ; i < brkArray.length ; i++) {
|
||||||
if (brkArray[i].getId() == column) {
|
if (brkArray[i].getId() == column) {
|
||||||
getSheetTypeColumnBreaks().removeBrk(i);
|
getSheetTypeColumnBreaks().removeBrk(i);
|
||||||
@ -1385,8 +1381,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*/
|
*/
|
||||||
public void removeRowBreak(int row) {
|
public void removeRowBreak(int row) {
|
||||||
CTPageBreak pgBreak = worksheet.isSetRowBreaks() ? worksheet.getRowBreaks() : worksheet.addNewRowBreaks();
|
CTPageBreak pgBreak = worksheet.isSetRowBreaks() ? worksheet.getRowBreaks() : worksheet.addNewRowBreaks();
|
||||||
CTBreak[] brkArray = new CTBreak[pgBreak.getBrkList().size()];
|
CTBreak[] brkArray = pgBreak.getBrkArray();
|
||||||
pgBreak.getBrkList().toArray(brkArray);
|
|
||||||
for (int i = 0 ; i < brkArray.length ; i++) {
|
for (int i = 0 ; i < brkArray.length ; i++) {
|
||||||
if (brkArray[i].getId() == row) {
|
if (brkArray[i].getId() == row) {
|
||||||
pgBreak.removeBrk(i);
|
pgBreak.removeBrk(i);
|
||||||
@ -2159,7 +2154,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
if(sheetComments != null){
|
if(sheetComments != null){
|
||||||
//TODO shift Note's anchor in the associated /xl/drawing/vmlDrawings#.vml
|
//TODO shift Note's anchor in the associated /xl/drawing/vmlDrawings#.vml
|
||||||
CTCommentList lst = sheetComments.getCTComments().getCommentList();
|
CTCommentList lst = sheetComments.getCTComments().getCommentList();
|
||||||
for (CTComment comment : lst.getCommentList()) {
|
for (CTComment comment : lst.getCommentArray()) {
|
||||||
CellReference ref = new CellReference(comment.getRef());
|
CellReference ref = new CellReference(comment.getRef());
|
||||||
if(ref.getRow() == rownum){
|
if(ref.getRow() == rownum){
|
||||||
ref = new CellReference(rownum + n, ref.getCol());
|
ref = new CellReference(rownum + n, ref.getCol());
|
||||||
@ -2285,7 +2280,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*/
|
*/
|
||||||
public void setSelected(boolean value) {
|
public void setSelected(boolean value) {
|
||||||
CTSheetViews views = getSheetTypeSheetViews();
|
CTSheetViews views = getSheetTypeSheetViews();
|
||||||
for (CTSheetView view : views.getSheetViewList()) {
|
for (CTSheetView view : views.getSheetViewArray()) {
|
||||||
view.setTabSelected(value);
|
view.setTabSelected(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2361,10 +2356,11 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*/
|
*/
|
||||||
private CTSheetView getDefaultSheetView() {
|
private CTSheetView getDefaultSheetView() {
|
||||||
CTSheetViews views = getSheetTypeSheetViews();
|
CTSheetViews views = getSheetTypeSheetViews();
|
||||||
if (views == null || views.getSheetViewList() == null || views.getSheetViewList().size() <= 0) {
|
int sz = views == null ? 0 : views.sizeOfSheetViewArray();
|
||||||
|
if (sz == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return views.getSheetViewArray(views.getSheetViewList().size() - 1);
|
return views.getSheetViewArray(sz - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2438,9 +2434,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
|
|
||||||
protected void write(OutputStream out) throws IOException {
|
protected void write(OutputStream out) throws IOException {
|
||||||
|
|
||||||
if(worksheet.getColsList().size() == 1) {
|
if(worksheet.sizeOfColsArray() == 1) {
|
||||||
CTCols col = worksheet.getColsArray(0);
|
CTCols col = worksheet.getColsArray(0);
|
||||||
if(col.getColList().size() == 0) {
|
if(col.sizeOfColArray() == 0) {
|
||||||
worksheet.setColsArray(null);
|
worksheet.setColsArray(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2895,7 +2891,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
List<XSSFDataValidation> xssfValidations = new ArrayList<XSSFDataValidation>();
|
List<XSSFDataValidation> xssfValidations = new ArrayList<XSSFDataValidation>();
|
||||||
CTDataValidations dataValidations = this.worksheet.getDataValidations();
|
CTDataValidations dataValidations = this.worksheet.getDataValidations();
|
||||||
if( dataValidations!=null && dataValidations.getCount() > 0 ) {
|
if( dataValidations!=null && dataValidations.getCount() > 0 ) {
|
||||||
for (CTDataValidation ctDataValidation : dataValidations.getDataValidationList()) {
|
for (CTDataValidation ctDataValidation : dataValidations.getDataValidationArray()) {
|
||||||
CellRangeAddressList addressList = new CellRangeAddressList();
|
CellRangeAddressList addressList = new CellRangeAddressList();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -2923,7 +2919,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
if( dataValidations==null ) {
|
if( dataValidations==null ) {
|
||||||
dataValidations = worksheet.addNewDataValidations();
|
dataValidations = worksheet.addNewDataValidations();
|
||||||
}
|
}
|
||||||
int currentCount = dataValidations.getDataValidationList().size();
|
int currentCount = dataValidations.sizeOfDataValidationArray();
|
||||||
CTDataValidation newval = dataValidations.addNewDataValidation();
|
CTDataValidation newval = dataValidations.addNewDataValidation();
|
||||||
newval.set(xssfDataValidation.getCtDdataValidation());
|
newval.set(xssfDataValidation.getCtDdataValidation());
|
||||||
dataValidations.setCount(currentCount + 1);
|
dataValidations.setCount(currentCount + 1);
|
||||||
|
@ -199,6 +199,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation") // getXYZArray() array accessors are deprecated
|
||||||
protected void onDocumentRead() throws IOException {
|
protected void onDocumentRead() throws IOException {
|
||||||
try {
|
try {
|
||||||
WorkbookDocument doc = WorkbookDocument.Factory.parse(getPackagePart().getInputStream());
|
WorkbookDocument doc = WorkbookDocument.Factory.parse(getPackagePart().getInputStream());
|
||||||
@ -224,7 +225,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
|
|
||||||
// Load individual sheets. The order of sheets is defined by the order of CTSheet elements in the workbook
|
// Load individual sheets. The order of sheets is defined by the order of CTSheet elements in the workbook
|
||||||
sheets = new ArrayList<XSSFSheet>(shIdMap.size());
|
sheets = new ArrayList<XSSFSheet>(shIdMap.size());
|
||||||
for (CTSheet ctSheet : this.workbook.getSheets().getSheetList()) {
|
for (CTSheet ctSheet : this.workbook.getSheets().getSheetArray()) {
|
||||||
XSSFSheet sh = shIdMap.get(ctSheet.getId());
|
XSSFSheet sh = shIdMap.get(ctSheet.getId());
|
||||||
if(sh == null) {
|
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");
|
logger.log(POILogger.WARN, "Sheet with name " + ctSheet.getName() + " and r:id " + ctSheet.getId()+ " was defined, but didn't exist in package, skipping");
|
||||||
@ -238,7 +239,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
// Process the named ranges
|
// Process the named ranges
|
||||||
namedRanges = new ArrayList<XSSFName>();
|
namedRanges = new ArrayList<XSSFName>();
|
||||||
if(workbook.isSetDefinedNames()) {
|
if(workbook.isSetDefinedNames()) {
|
||||||
for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameList()) {
|
for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameArray()) {
|
||||||
namedRanges.add(new XSSFName(ctName, this));
|
namedRanges.add(new XSSFName(ctName, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -881,12 +882,9 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
public void setActiveSheet(int index) {
|
public void setActiveSheet(int index) {
|
||||||
|
|
||||||
validateSheetIndex(index);
|
validateSheetIndex(index);
|
||||||
//activeTab (Active Sheet Index) Specifies an unsignedInt that contains the index to the active sheet in this book view.
|
|
||||||
CTBookView[] arrayBook = new CTBookView[workbook.getBookViews().getWorkbookViewList().size()];
|
|
||||||
workbook.getBookViews().getWorkbookViewList().toArray(arrayBook);
|
|
||||||
|
|
||||||
for (int i = 0; i < arrayBook.length; i++) {
|
for (CTBookView arrayBook : workbook.getBookViews().getWorkbookViewArray()) {
|
||||||
workbook.getBookViews().getWorkbookViewArray(i).setActiveTab(index);
|
arrayBook.setActiveTab(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1163,7 +1161,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
|
|
||||||
private void saveCalculationChain(){
|
private void saveCalculationChain(){
|
||||||
if(calcChain != null){
|
if(calcChain != null){
|
||||||
int count = calcChain.getCTCalcChain().getCList().size();
|
int count = calcChain.getCTCalcChain().sizeOfCArray();
|
||||||
if(count == 0){
|
if(count == 0){
|
||||||
removeRelation(calcChain);
|
removeRelation(calcChain);
|
||||||
calcChain = null;
|
calcChain = null;
|
||||||
@ -1230,9 +1228,9 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param excludeSheetIdx the sheet to exclude from the check or -1 to include all sheets in the check.
|
* @param excludeSheetIdx the sheet to exclude from the check or -1 to include all sheets in the check.
|
||||||
* @return true if the sheet contains the name, false otherwise.
|
* @return true if the sheet contains the name, false otherwise.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation") // getXYZArray() array accessors are deprecated
|
||||||
private boolean containsSheet(String name, int excludeSheetIdx) {
|
private boolean containsSheet(String name, int excludeSheetIdx) {
|
||||||
CTSheet[] ctSheetArray = new CTSheet[workbook.getSheets().getSheetList().size()];
|
CTSheet[] ctSheetArray = workbook.getSheets().getSheetArray();
|
||||||
workbook.getSheets().getSheetList().toArray(ctSheetArray);
|
|
||||||
|
|
||||||
if (name.length() > MAX_SENSITIVE_SHEET_NAME_LEN) {
|
if (name.length() > MAX_SENSITIVE_SHEET_NAME_LEN) {
|
||||||
name = name.substring(0, MAX_SENSITIVE_SHEET_NAME_LEN);
|
name = name.substring(0, MAX_SENSITIVE_SHEET_NAME_LEN);
|
||||||
|
@ -53,16 +53,14 @@ public class ColumnHelper {
|
|||||||
cleanColumns();
|
cleanColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public void cleanColumns() {
|
public void cleanColumns() {
|
||||||
this.newCols = CTCols.Factory.newInstance();
|
this.newCols = CTCols.Factory.newInstance();
|
||||||
CTCols[] colsArray = new CTCols[worksheet.getColsList().size()];
|
CTCols[] colsArray = worksheet.getColsArray();
|
||||||
worksheet.getColsList().toArray(colsArray);
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (i = 0; i < colsArray.length; i++) {
|
for (i = 0; i < colsArray.length; i++) {
|
||||||
CTCols cols = colsArray[i];
|
CTCols cols = colsArray[i];
|
||||||
CTCol[] colArray = new CTCol[cols.getColList().size()];
|
CTCol[] colArray = cols.getColArray();
|
||||||
cols.getColList().toArray(colArray);
|
|
||||||
for (int y = 0; y < colArray.length; y++) {
|
for (int y = 0; y < colArray.length; y++) {
|
||||||
CTCol col = colArray[y];
|
CTCol col = colArray[y];
|
||||||
newCols = addCleanColIntoCols(newCols, col);
|
newCols = addCleanColIntoCols(newCols, col);
|
||||||
@ -75,9 +73,9 @@ public class ColumnHelper {
|
|||||||
worksheet.setColsArray(0, newCols);
|
worksheet.setColsArray(0, newCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public static void sortColumns(CTCols newCols) {
|
public static void sortColumns(CTCols newCols) {
|
||||||
CTCol[] colArray = new CTCol[newCols.getColList().size()];
|
CTCol[] colArray = newCols.getColArray();
|
||||||
newCols.getColList().toArray(colArray);
|
|
||||||
Arrays.sort(colArray, new CTColComparator());
|
Arrays.sort(colArray, new CTColComparator());
|
||||||
newCols.setColArray(colArray);
|
newCols.setColArray(colArray);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import org.apache.poi.hssf.record.PasswordRecord;
|
|||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public final class TestXSSFSheet extends BaseTestSheet {
|
public final class TestXSSFSheet extends BaseTestSheet {
|
||||||
|
|
||||||
public TestXSSFSheet() {
|
public TestXSSFSheet() {
|
||||||
@ -291,7 +292,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
sheet.groupColumn(10, 11);
|
sheet.groupColumn(10, 11);
|
||||||
CTCols cols = sheet.getCTWorksheet().getColsArray(0);
|
CTCols cols = sheet.getCTWorksheet().getColsArray(0);
|
||||||
assertEquals(2, cols.sizeOfColArray());
|
assertEquals(2, cols.sizeOfColArray());
|
||||||
CTCol[] colArray = cols.getColList().toArray(new CTCol[2]);
|
CTCol[] colArray = cols.getColArray();
|
||||||
assertNotNull(colArray);
|
assertNotNull(colArray);
|
||||||
assertEquals(2 + 1, colArray[0].getMin()); // 1 based
|
assertEquals(2 + 1, colArray[0].getMin()); // 1 based
|
||||||
assertEquals(7 + 1, colArray[0].getMax()); // 1 based
|
assertEquals(7 + 1, colArray[0].getMax()); // 1 based
|
||||||
@ -301,7 +302,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
sheet.groupColumn(1, 2);
|
sheet.groupColumn(1, 2);
|
||||||
cols = sheet.getCTWorksheet().getColsArray(0);
|
cols = sheet.getCTWorksheet().getColsArray(0);
|
||||||
assertEquals(4, cols.sizeOfColArray());
|
assertEquals(4, cols.sizeOfColArray());
|
||||||
colArray = cols.getColList().toArray(new CTCol[0]);
|
colArray = cols.getColArray();
|
||||||
assertEquals(2, colArray[1].getOutlineLevel());
|
assertEquals(2, colArray[1].getOutlineLevel());
|
||||||
|
|
||||||
//three level
|
//three level
|
||||||
@ -309,17 +310,17 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
sheet.groupColumn(2, 3);
|
sheet.groupColumn(2, 3);
|
||||||
cols = sheet.getCTWorksheet().getColsArray(0);
|
cols = sheet.getCTWorksheet().getColsArray(0);
|
||||||
assertEquals(7, cols.sizeOfColArray());
|
assertEquals(7, cols.sizeOfColArray());
|
||||||
colArray = cols.getColList().toArray(new CTCol[0]);
|
colArray = cols.getColArray();
|
||||||
assertEquals(3, colArray[1].getOutlineLevel());
|
assertEquals(3, colArray[1].getOutlineLevel());
|
||||||
assertEquals(3, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
|
assertEquals(3, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
|
||||||
|
|
||||||
sheet.ungroupColumn(8, 10);
|
sheet.ungroupColumn(8, 10);
|
||||||
colArray = cols.getColList().toArray(new CTCol[0]);
|
colArray = cols.getColArray();
|
||||||
//assertEquals(3, colArray[1].getOutlineLevel());
|
//assertEquals(3, colArray[1].getOutlineLevel());
|
||||||
|
|
||||||
sheet.ungroupColumn(4, 6);
|
sheet.ungroupColumn(4, 6);
|
||||||
sheet.ungroupColumn(2, 2);
|
sheet.ungroupColumn(2, 2);
|
||||||
colArray = cols.getColList().toArray(new CTCol[0]);
|
colArray = cols.getColArray();
|
||||||
assertEquals(4, colArray.length);
|
assertEquals(4, colArray.length);
|
||||||
assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
|
assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
|
||||||
}
|
}
|
||||||
@ -701,7 +702,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
XSSFSheet xs = sheet;
|
XSSFSheet xs = sheet;
|
||||||
CTWorksheet cts = xs.getCTWorksheet();
|
CTWorksheet cts = xs.getCTWorksheet();
|
||||||
|
|
||||||
CTCols[] cols_s = cts.getColsList().toArray(new CTCols[1]);
|
CTCols[] cols_s = cts.getColsArray();
|
||||||
assertEquals(1, cols_s.length);
|
assertEquals(1, cols_s.length);
|
||||||
CTCols cols = cols_s[0];
|
CTCols cols = cols_s[0];
|
||||||
assertEquals(1, cols.sizeOfColArray());
|
assertEquals(1, cols.sizeOfColArray());
|
||||||
@ -716,7 +717,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
// Now set another
|
// Now set another
|
||||||
sheet.setColumnWidth(3, 33 * 256);
|
sheet.setColumnWidth(3, 33 * 256);
|
||||||
|
|
||||||
cols_s = cts.getColsList().toArray(new CTCols[1]);
|
cols_s = cts.getColsArray();
|
||||||
assertEquals(1, cols_s.length);
|
assertEquals(1, cols_s.length);
|
||||||
cols = cols_s[0];
|
cols = cols_s[0];
|
||||||
assertEquals(2, cols.sizeOfColArray());
|
assertEquals(2, cols.sizeOfColArray());
|
||||||
@ -922,7 +923,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
row3.createCell(5);
|
row3.createCell(5);
|
||||||
|
|
||||||
|
|
||||||
CTRow[] xrow = sheetData.getRowList().toArray(new CTRow[3]);
|
CTRow[] xrow = sheetData.getRowArray();
|
||||||
assertEquals(3, xrow.length);
|
assertEquals(3, xrow.length);
|
||||||
|
|
||||||
//rows are unsorted: {2, 1, 0}
|
//rows are unsorted: {2, 1, 0}
|
||||||
@ -938,7 +939,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
assertEquals(1, xrow[2].getR());
|
assertEquals(1, xrow[2].getR());
|
||||||
assertTrue(xrow[2].equals(row3.getCTRow()));
|
assertTrue(xrow[2].equals(row3.getCTRow()));
|
||||||
|
|
||||||
CTCell[] xcell = xrow[2].getCList().toArray(new CTCell[4]);
|
CTCell[] xcell = xrow[2].getCArray();
|
||||||
assertEquals("D1", xcell[0].getR());
|
assertEquals("D1", xcell[0].getR());
|
||||||
assertEquals("A1", xcell[1].getR());
|
assertEquals("A1", xcell[1].getR());
|
||||||
assertEquals("C1", xcell[2].getR());
|
assertEquals("C1", xcell[2].getR());
|
||||||
@ -954,14 +955,14 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
||||||
sheet = workbook.getSheetAt(0);
|
sheet = workbook.getSheetAt(0);
|
||||||
wsh = sheet.getCTWorksheet();
|
wsh = sheet.getCTWorksheet();
|
||||||
xrow = sheetData.getRowList().toArray(new CTRow[3]);
|
xrow = sheetData.getRowArray();
|
||||||
assertEquals(3, xrow.length);
|
assertEquals(3, xrow.length);
|
||||||
|
|
||||||
//rows are sorted: {0, 1, 2}
|
//rows are sorted: {0, 1, 2}
|
||||||
assertEquals(4, xrow[0].sizeOfCArray());
|
assertEquals(4, xrow[0].sizeOfCArray());
|
||||||
assertEquals(1, xrow[0].getR());
|
assertEquals(1, xrow[0].getR());
|
||||||
//cells are now sorted
|
//cells are now sorted
|
||||||
xcell = xrow[0].getCList().toArray(new CTCell[4]);
|
xcell = xrow[0].getCArray();
|
||||||
assertEquals("A1", xcell[0].getR());
|
assertEquals("A1", xcell[0].getR());
|
||||||
assertEquals("C1", xcell[1].getR());
|
assertEquals("C1", xcell[1].getR());
|
||||||
assertEquals("D1", xcell[2].getR());
|
assertEquals("D1", xcell[2].getR());
|
||||||
|
Loading…
Reference in New Issue
Block a user