From f39e6bea7450a06165c7ff8cdad2144e6ac03719 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Thu, 28 Aug 2014 00:08:41 +0000 Subject: [PATCH] Bug 56854 - XMLBeans performance when using getXXXList() and other proxy methods git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1620997 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/POIXMLProperties.java | 8 +- .../poi/POIXMLPropertiesTextExtractor.java | 7 +- .../org/apache/poi/xslf/XSLFSlideShow.java | 18 ++- .../extractor/XSLFPowerPointExtractor.java | 3 +- .../poi/xslf/model/geom/CustomGeometry.java | 16 ++- .../poi/xslf/usermodel/DrawingTable.java | 9 +- .../poi/xslf/usermodel/DrawingTableRow.java | 9 +- .../poi/xslf/usermodel/DrawingTextBody.java | 9 +- .../poi/xslf/usermodel/RenderableShape.java | 41 +++--- .../poi/xslf/usermodel/XMLSlideShow.java | 17 +-- .../xslf/usermodel/XSLFCommentAuthors.java | 7 +- .../poi/xslf/usermodel/XSLFComments.java | 2 +- .../xslf/usermodel/XSLFCommonSlideData.java | 17 +-- .../poi/xslf/usermodel/XSLFFreeformShape.java | 13 +- .../poi/xslf/usermodel/XSLFPictureShape.java | 2 +- .../apache/poi/xslf/usermodel/XSLFTable.java | 6 +- .../poi/xslf/usermodel/XSLFTableRow.java | 14 +- .../poi/xslf/usermodel/XSLFTableStyles.java | 18 +-- .../poi/xslf/usermodel/XSLFTextShape.java | 19 +-- .../eventusermodel/XSSFSheetXMLHandler.java | 6 +- .../apache/poi/xssf/model/CommentsTable.java | 19 +-- .../org/apache/poi/xssf/model/MapInfo.java | 7 +- .../apache/poi/xssf/model/SingleXmlCells.java | 3 +- .../apache/poi/xssf/usermodel/XSSFChart.java | 30 +++-- .../usermodel/XSSFPivotCacheDefinition.java | 2 +- .../poi/xssf/usermodel/XSSFPivotTable.java | 26 ++-- .../apache/poi/xssf/usermodel/XSSFSheet.java | 8 +- .../XSSFSheetConditionalFormatting.java | 21 +-- .../apache/poi/xssf/usermodel/XSSFTable.java | 9 +- .../poi/xssf/usermodel/XSSFWorkbook.java | 3 +- .../xssf/usermodel/helpers/ColumnHelper.java | 126 ++++++++---------- .../usermodel/helpers/XSSFRowShifter.java | 28 ++-- .../apache/poi/xssf/util/CTColComparator.java | 38 +++--- .../poi/xwpf/model/XWPFCommentsDecorator.java | 4 +- .../xwpf/model/XWPFHyperlinkDecorator.java | 6 +- .../poi/xwpf/usermodel/AbstractXWPFSDT.java | 13 +- .../poi/xwpf/usermodel/XWPFComment.java | 3 +- .../poi/xwpf/usermodel/XWPFDocument.java | 24 ++-- .../poi/xwpf/usermodel/XWPFFootnote.java | 7 +- .../poi/xwpf/usermodel/XWPFFootnotes.java | 4 +- .../poi/xwpf/usermodel/XWPFHeaderFooter.java | 7 +- .../poi/xwpf/usermodel/XWPFLatentStyles.java | 3 +- .../poi/xwpf/usermodel/XWPFNumbering.java | 7 +- .../poi/xwpf/usermodel/XWPFParagraph.java | 22 +-- .../apache/poi/xwpf/usermodel/XWPFRun.java | 27 ++-- .../poi/xwpf/usermodel/XWPFSDTContent.java | 4 +- .../apache/poi/xwpf/usermodel/XWPFStyles.java | 6 +- .../apache/poi/xwpf/usermodel/XWPFTable.java | 9 +- .../poi/xwpf/usermodel/XWPFTableCell.java | 21 +-- .../poi/xwpf/usermodel/XWPFTableRow.java | 7 +- .../apache/poi/xslf/TestXSLFSlideShow.java | 18 +-- .../poi/xslf/usermodel/TestXMLSlideShow.java | 10 +- .../xslf/usermodel/TestXSLFSimpleShape.java | 16 ++- .../poi/xssf/model/TestCalculationChain.java | 4 +- .../apache/poi/xssf/model/TestMapInfo.java | 2 +- .../poi/xssf/usermodel/TestXSSFBugs.java | 4 +- .../xssf/usermodel/TestXSSFColGrouping.java | 6 +- .../poi/xssf/usermodel/TestXSSFFont.java | 10 +- .../usermodel/TestXSSFRichTextString.java | 26 ++-- .../poi/xssf/usermodel/TestXSSFSheet.java | 92 ++++++------- .../poi/xssf/usermodel/TestXSSFTable.java | 25 ++-- .../poi/xssf/usermodel/TestXSSFWorkbook.java | 2 +- .../usermodel/helpers/TestColumnHelper.java | 2 +- .../poi/xssf/util/TestCTColComparator.java | 12 +- .../poi/xwpf/usermodel/TestXWPFDocument.java | 6 +- .../poi/xwpf/usermodel/TestXWPFParagraph.java | 11 +- .../poi/xwpf/usermodel/TestXWPFRun.java | 6 +- 67 files changed, 515 insertions(+), 472 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/POIXMLProperties.java b/src/ooxml/java/org/apache/poi/POIXMLProperties.java index d7a1719123..be23210174 100644 --- a/src/ooxml/java/org/apache/poi/POIXMLProperties.java +++ b/src/ooxml/java/org/apache/poi/POIXMLProperties.java @@ -371,9 +371,10 @@ public class POIXMLProperties { * * @return next property id starting with 2 */ - protected int nextPid(){ + @SuppressWarnings("deprecation") + protected int nextPid(){ int propid = 1; - for(CTProperty p : props.getProperties().getPropertyList()){ + for(CTProperty p : props.getProperties().getPropertyArray()){ if(p.getPid() > propid) propid = p.getPid(); } return propid + 1; @@ -385,8 +386,9 @@ public class POIXMLProperties { * @param name the name to check * @return whether a property with the given name exists in the custom properties */ + @SuppressWarnings("deprecation") public boolean contains(String name){ - for(CTProperty p : props.getProperties().getPropertyList()){ + for(CTProperty p : props.getProperties().getPropertyArray()){ if(p.getName().equals(name)) return true; } return false; diff --git a/src/ooxml/java/org/apache/poi/POIXMLPropertiesTextExtractor.java b/src/ooxml/java/org/apache/poi/POIXMLPropertiesTextExtractor.java index 51a4399f3f..ce576439f2 100644 --- a/src/ooxml/java/org/apache/poi/POIXMLPropertiesTextExtractor.java +++ b/src/ooxml/java/org/apache/poi/POIXMLPropertiesTextExtractor.java @@ -19,7 +19,6 @@ package org.apache.poi; import java.math.BigDecimal; import java.util.Date; -import java.util.List; import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart; import org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty; @@ -126,13 +125,13 @@ public class POIXMLPropertiesTextExtractor extends POIXMLTextExtractor { * Returns the custom document properties, if * there are any */ + @SuppressWarnings("deprecation") public String getCustomPropertiesText() { - StringBuffer text = new StringBuffer(); + StringBuilder text = new StringBuilder(); org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties props = getDocument().getProperties().getCustomProperties().getUnderlyingProperties(); - List properties = props.getPropertyList(); - for(CTProperty property : properties) { + for(CTProperty property : props.getPropertyArray()) { String val = "(not implemented!)"; if (property.isSetLpwstr()) { diff --git a/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java b/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java index b6523bedde..7f0f1b773c 100644 --- a/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java +++ b/src/ooxml/java/org/apache/poi/xslf/XSLFSlideShow.java @@ -31,7 +31,20 @@ import org.apache.poi.util.Internal; import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xslf.usermodel.XSLFRelation; import org.apache.xmlbeans.XmlException; -import org.openxmlformats.schemas.presentationml.x2006.main.*; +import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentList; +import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide; +import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation; +import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide; +import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdList; +import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry; +import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMaster; +import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdList; +import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry; +import org.openxmlformats.schemas.presentationml.x2006.main.CmLstDocument; +import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument; +import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument; +import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument; +import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument; /** * Experimental class to do low level processing of pptx files. @@ -53,6 +66,7 @@ public class XSLFSlideShow extends POIXMLDocument { */ private List embedds; + @SuppressWarnings("deprecation") public XSLFSlideShow(OPCPackage container) throws OpenXML4JException, IOException, XmlException { super(container); @@ -64,7 +78,7 @@ public class XSLFSlideShow extends POIXMLDocument { PresentationDocument.Factory.parse(getCorePart().getInputStream()); embedds = new LinkedList(); - for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdList()) { + for (CTSlideIdListEntry ctSlide : getSlideReferences().getSldIdArray()) { PackagePart corePart = getCorePart(); PackagePart slidePart = corePart.getRelatedPart( corePart.getRelationship(ctSlide.getId2())); diff --git a/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java b/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java index 4c3693d3e5..67f1067b71 100644 --- a/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java +++ b/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java @@ -118,6 +118,7 @@ public class XSLFPowerPointExtractor extends POIXMLTextExtractor { * @param notesText Should we retrieve text from notes? * @param masterText Should we retrieve text from master slides? */ + @SuppressWarnings("deprecation") public String getText(boolean slideText, boolean notesText, boolean masterText) { StringBuffer text = new StringBuffer(); @@ -150,7 +151,7 @@ public class XSLFPowerPointExtractor extends POIXMLTextExtractor { // If the slide has comments, do those too if (comments != null) { - for (CTComment comment : comments.getCTCommentsList().getCmList()) { + for (CTComment comment : comments.getCTCommentsList().getCmArray()) { // Do the author if we can if (commentAuthors != null) { CTCommentAuthor author = commentAuthors.getAuthorById(comment.getAuthorId()); diff --git a/src/ooxml/java/org/apache/poi/xslf/model/geom/CustomGeometry.java b/src/ooxml/java/org/apache/poi/xslf/model/geom/CustomGeometry.java index 5a81c307a5..4e30ac90d9 100644 --- a/src/ooxml/java/org/apache/poi/xslf/model/geom/CustomGeometry.java +++ b/src/ooxml/java/org/apache/poi/xslf/model/geom/CustomGeometry.java @@ -19,12 +19,17 @@ package org.apache.poi.xslf.model.geom; -import org.openxmlformats.schemas.drawingml.x2006.main.*; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.openxmlformats.schemas.drawingml.x2006.main.CTCustomGeometry2D; +import org.openxmlformats.schemas.drawingml.x2006.main.CTGeomGuide; +import org.openxmlformats.schemas.drawingml.x2006.main.CTGeomGuideList; +import org.openxmlformats.schemas.drawingml.x2006.main.CTGeomRect; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPath2D; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPath2DList; + /** * Definition of a custom geometric shape * @@ -36,19 +41,20 @@ public class CustomGeometry implements Iterable{ List paths = new ArrayList(); Path textBounds; + @SuppressWarnings("deprecation") public CustomGeometry(CTCustomGeometry2D geom) { CTGeomGuideList avLst = geom.getAvLst(); - if(avLst != null) for(CTGeomGuide gd : avLst.getGdList()){ + if(avLst != null) for(CTGeomGuide gd : avLst.getGdArray()){ adjusts.add(new AdjustValue(gd)); } CTGeomGuideList gdLst = geom.getGdLst(); - if(gdLst != null) for(CTGeomGuide gd : gdLst.getGdList()){ + if(gdLst != null) for(CTGeomGuide gd : gdLst.getGdArray()){ guides.add(new Guide(gd)); } CTPath2DList pathLst = geom.getPathLst(); - if(pathLst != null) for(CTPath2D spPath : pathLst.getPathList()){ + if(pathLst != null) for(CTPath2D spPath : pathLst.getPathArray()){ paths.add(new Path(spPath)); } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingTable.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingTable.java index c6d7da9f2b..2cc7724c79 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingTable.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingTable.java @@ -20,8 +20,6 @@ package org.apache.poi.xslf.usermodel; import org.openxmlformats.schemas.drawingml.x2006.main.CTTable; import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow; -import java.util.List; - public class DrawingTable { private final CTTable table; @@ -29,12 +27,13 @@ public class DrawingTable { this.table = table; } + @SuppressWarnings("deprecation") public DrawingTableRow[] getRows() { - List ctTableRows = table.getTrList(); - DrawingTableRow[] o = new DrawingTableRow[ctTableRows.size()]; + CTTableRow[] ctTableRows = table.getTrArray(); + DrawingTableRow[] o = new DrawingTableRow[ctTableRows.length]; for (int i=0; i ctTableCells = row.getTcList(); - DrawingTableCell[] o = new DrawingTableCell[ctTableCells.size()]; + CTTableCell[] ctTableCells = row.getTcArray(); + DrawingTableCell[] o = new DrawingTableCell[ctTableCells.length]; for (int i=0; i paragraphs = textBody.getPList(); - DrawingParagraph[] o = new DrawingParagraph[paragraphs.size()]; + CTTextParagraph[] paragraphs = textBody.getPArray(); + DrawingParagraph[] o = new DrawingParagraph[paragraphs.length]; for (int i=0; i computeOutlines(Graphics2D graphics) { Collection lst = new ArrayList(); @@ -576,7 +577,7 @@ class RenderableShape { public Guide getAdjustValue(String name) { CTPresetGeometry2D prst = _shape.getSpPr().getPrstGeom(); if (prst.isSetAvLst()) { - for (CTGeomGuide g : prst.getAvLst().getGdList()) { + for (CTGeomGuide g : prst.getAvLst().getGdArray()) { if (g.getName().equals(name)) { return new Guide(g); } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java index de31fb2fd6..69dc029523 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java @@ -115,6 +115,7 @@ public class XMLSlideShow extends POIXMLDocument { } @Override + @SuppressWarnings("deprecation") protected void onDocumentRead() throws IOException { try { PresentationDocument doc = @@ -140,8 +141,7 @@ public class XMLSlideShow extends POIXMLDocument { _slides = new ArrayList(); if (_presentation.isSetSldIdLst()) { - List slideIds = _presentation.getSldIdLst().getSldIdList(); - for (CTSlideIdListEntry slId : slideIds) { + for (CTSlideIdListEntry slId : _presentation.getSldIdLst().getSldIdArray()) { XSLFSlide sh = shIdMap.get(slId.getId2()); if (sh == null) { _logger.log(POILogger.WARN, "Slide with r:id " + slId.getId() + " was defined, but didn't exist in package, skipping"); @@ -201,13 +201,14 @@ public class XMLSlideShow extends POIXMLDocument { * @param layout * @return created slide */ + @SuppressWarnings("deprecation") public XSLFSlide createSlide(XSLFSlideLayout layout) { int slideNumber = 256, cnt = 1; CTSlideIdList slideList; if (!_presentation.isSetSldIdLst()) slideList = _presentation.addNewSldIdLst(); else { slideList = _presentation.getSldIdLst(); - for(CTSlideIdListEntry slideId : slideList.getSldIdList()){ + for(CTSlideIdListEntry slideId : slideList.getSldIdArray()){ slideNumber = (int)Math.max(slideId.getId() + 1, slideNumber); cnt++; } @@ -283,16 +284,16 @@ public class XMLSlideShow extends POIXMLDocument { _slides.add(newIndex, _slides.remove(oldIndex)); // fix ordering in the low-level xml - List slideIds = _presentation.getSldIdLst().getSldIdList(); - CTSlideIdListEntry oldEntry = slideIds.get(oldIndex); - slideIds.add(newIndex, oldEntry); - slideIds.remove(oldEntry); + CTSlideIdList sldIdLst = _presentation.getSldIdLst(); + CTSlideIdListEntry oldEntry = sldIdLst.getSldIdArray(oldIndex); + sldIdLst.insertNewSldId(newIndex).set(oldEntry); + sldIdLst.removeSldId(oldIndex); } public XSLFSlide removeSlide(int index){ XSLFSlide slide = _slides.remove(index); removeRelation(slide); - _presentation.getSldIdLst().getSldIdList().remove(index); + _presentation.getSldIdLst().removeSldId(index); return slide; } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java index 23ddb4d534..e52b9ec651 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java @@ -17,6 +17,8 @@ package org.apache.poi.xslf.usermodel; +import java.io.IOException; + import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; @@ -26,8 +28,6 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentAuthor; import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentAuthorList; import org.openxmlformats.schemas.presentationml.x2006.main.CmAuthorLstDocument; -import java.io.IOException; - @Beta public class XSLFCommentAuthors extends POIXMLDocumentPart { private final CTCommentAuthorList _authors; @@ -61,9 +61,10 @@ public class XSLFCommentAuthors extends POIXMLDocumentPart { return _authors; } + @SuppressWarnings("deprecation") public CTCommentAuthor getAuthorById(long id) { // TODO Have a map - for (CTCommentAuthor author : _authors.getCmAuthorList()) { + for (CTCommentAuthor author : _authors.getCmAuthorArray()) { if (author.getId() == id) { return author; } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java index 9eed7ec7e0..df3ca7ad05 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java @@ -66,6 +66,6 @@ public class XSLFComments extends POIXMLDocumentPart { } public CTComment getCommentAt(int pos) { - return _comments.getCmList().get(pos); + return _comments.getCmArray(pos); } } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java index b099b64571..0033665aa5 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommonSlideData.java @@ -17,6 +17,10 @@ package org.apache.poi.xslf.usermodel; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import org.apache.poi.POIXMLException; import org.apache.poi.util.Beta; import org.apache.xmlbeans.XmlCursor; @@ -32,10 +36,6 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFra import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape; import org.openxmlformats.schemas.presentationml.x2006.main.CTShape; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - @Beta public class XSLFCommonSlideData { private final CTCommonSlideData data; @@ -44,6 +44,7 @@ public class XSLFCommonSlideData { this.data = data; } + @SuppressWarnings("deprecation") public List getDrawingText() { CTGroupShape gs = data.getSpTree(); @@ -51,11 +52,11 @@ public class XSLFCommonSlideData { processShape(gs, out); - for (CTGroupShape shape : gs.getGrpSpList()) { + for (CTGroupShape shape : gs.getGrpSpArray()) { processShape(shape, out); } - for (CTGraphicalObjectFrame frame: gs.getGraphicFrameList()) { + for (CTGraphicalObjectFrame frame: gs.getGraphicFrameArray()) { CTGraphicalObjectData data = frame.getGraphic().getGraphicData(); XmlCursor c = data.newCursor(); c.selectPath("declare namespace pic='"+CTTable.type.getName().getNamespaceURI()+"' .//pic:tbl"); @@ -97,9 +98,9 @@ public class XSLFCommonSlideData { return paragraphs; } + @SuppressWarnings("deprecation") private void processShape(CTGroupShape gs, List out) { - List shapes = gs.getSpList(); - for (CTShape shape : shapes) { + for (CTShape shape : gs.getSpArray()) { CTTextBody ctTextBody = shape.getTxBody(); if (ctTextBody==null) { continue; diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java index 36afac5f8c..a95e0bbb92 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java @@ -19,6 +19,11 @@ package org.apache.poi.xslf.usermodel; +import java.awt.geom.AffineTransform; +import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; +import java.awt.geom.Rectangle2D; + import org.apache.poi.util.Beta; import org.apache.poi.util.Units; import org.apache.xmlbeans.XmlObject; @@ -35,11 +40,6 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; import org.openxmlformats.schemas.presentationml.x2006.main.CTShape; import org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual; -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.PathIterator; -import java.awt.geom.Rectangle2D; - /** * Represents a custom geometric shape. * This shape will consist of a series of lines and curves described within a creation path. @@ -120,12 +120,13 @@ public class XSLFFreeformShape extends XSLFAutoShape { * * @return the path */ + @SuppressWarnings("deprecation") public GeneralPath getPath() { GeneralPath path = new GeneralPath(); Rectangle2D bounds = getAnchor(); CTCustomGeometry2D geom = getSpPr().getCustGeom(); - for(CTPath2D spPath : geom.getPathLst().getPathList()){ + for(CTPath2D spPath : geom.getPathLst().getPathArray()){ double scaleW = bounds.getWidth() / Units.toPoints(spPath.getW()); double scaleH = bounds.getHeight() / Units.toPoints(spPath.getH()); for(XmlObject ch : spPath.selectPath("*")){ diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java index 6d6e631b52..43d151c66d 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java @@ -213,7 +213,7 @@ public class XSLFPictureShape extends XSLFSimpleShape { if(blip.isSetExtLst()) { CTOfficeArtExtensionList extLst = blip.getExtLst(); - for(CTOfficeArtExtension ext : extLst.getExtList()){ + for(CTOfficeArtExtension ext : extLst.getExtArray()){ String xpath = "declare namespace a14='http://schemas.microsoft.com/office/drawing/2010/main' $this//a14:imgProps/a14:imgLayer"; XmlObject[] obj = ext.selectPath(xpath); if(obj != null && obj.length == 1){ diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java index b8b2690509..a6ec8bcfe7 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java @@ -51,6 +51,7 @@ public class XSLFTable extends XSLFGraphicFrame implements Iterable _rows; + @SuppressWarnings("deprecation") /*package*/ XSLFTable(CTGraphicalObjectFrame shape, XSLFSheet sheet){ super(shape, sheet); @@ -71,8 +72,9 @@ public class XSLFTable extends XSLFGraphicFrame implements Iterable(_table.sizeOfTrArray()); - for(CTTableRow row : _table.getTrList()) _rows.add(new XSLFTableRow(row, this)); + CTTableRow[] trArray = _table.getTrArray(); + _rows = new ArrayList(trArray.length); + for(CTTableRow row : trArray) _rows.add(new XSLFTableRow(row, this)); } @Internal diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableRow.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableRow.java index c0067e9c75..04e9742aa3 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableRow.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableRow.java @@ -19,15 +19,15 @@ package org.apache.poi.xslf.usermodel; -import org.apache.poi.util.Units; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow; - import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; +import org.apache.poi.util.Units; +import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell; +import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow; + /** * Represents a table in a .pptx presentation * @@ -38,11 +38,13 @@ public class XSLFTableRow implements Iterable { private List _cells; private XSLFTable _table; + @SuppressWarnings("deprecation") /*package*/ XSLFTableRow(CTTableRow row, XSLFTable table){ _row = row; _table = table; - _cells = new ArrayList(_row.sizeOfTcArray()); - for(CTTableCell cell : _row.getTcList()) { + CTTableCell[] tcArray = _row.getTcArray(); + _cells = new ArrayList(tcArray.length); + for(CTTableCell cell : tcArray) { _cells.add(new XSLFTableCell(cell, table.getSheet())); } } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableStyles.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableStyles.java index 4ab67e2de5..245bbaae9d 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableStyles.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableStyles.java @@ -16,6 +16,12 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; @@ -24,12 +30,6 @@ import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyle; import org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyleList; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - @Beta public class XSLFTableStyles extends POIXMLDocumentPart implements Iterable{ private CTTableStyleList _tblStyleLst; @@ -39,12 +39,14 @@ public class XSLFTableStyles extends POIXMLDocumentPart implements Iterable(_tblStyleLst.sizeOfTblStyleArray()); - for(CTTableStyle c : _tblStyleLst.getTblStyleList()){ + CTTableStyle[] tblStyleArray = _tblStyleLst.getTblStyleArray(); + _styles = new ArrayList(tblStyleArray.length); + for(CTTableStyle c : tblStyleArray){ _styles.add(new XSLFTableStyle(c)); } } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java index af1c174c6a..d5ae1a2527 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java @@ -19,6 +19,14 @@ package org.apache.poi.xslf.usermodel; +import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + import org.apache.poi.POIXMLException; import org.apache.poi.util.Beta; import org.apache.poi.util.Units; @@ -36,14 +44,6 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder; import org.openxmlformats.schemas.presentationml.x2006.main.CTShape; import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType; -import java.awt.Graphics2D; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - /** * Represents a shape that can hold text. * @@ -58,13 +58,14 @@ public abstract class XSLFTextShape extends XSLFSimpleShape implements Iterable< */ private boolean _isTextBroken; + @SuppressWarnings("deprecation") /*package*/ XSLFTextShape(XmlObject shape, XSLFSheet sheet) { super(shape, sheet); _paragraphs = new ArrayList(); CTTextBody txBody = getTextBody(false); if (txBody != null) { - for (CTTextParagraph p : txBody.getPList()) { + for (CTTextParagraph p : txBody.getPArray()) { _paragraphs.add(new XSLFTextParagraph(p, this)); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java index baaac30406..7677426876 100644 --- a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java +++ b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java @@ -18,7 +18,6 @@ package org.apache.poi.xssf.eventusermodel; import java.util.Comparator; import java.util.LinkedList; -import java.util.List; import java.util.Queue; import org.apache.poi.ss.usermodel.BuiltinFormats; @@ -159,11 +158,11 @@ public class XSSFSheetXMLHandler extends DefaultHandler { this(styles, strings, sheetContentsHandler, new DataFormatter(), formulasNotResults); } + @SuppressWarnings("deprecation") private void init() { if (commentsTable != null) { commentCellRefs = new LinkedList(); - List commentList = commentsTable.getCTComments().getCommentList().getCommentList(); - for (CTComment comment : commentList) { + for (CTComment comment : commentsTable.getCTComments().getCommentList().getCommentArray()) { commentCellRefs.add(new CellReference(comment.getRef())); } } @@ -187,6 +186,7 @@ public class XSSFSheetXMLHandler extends DefaultHandler { } @Override + @SuppressWarnings("unused") public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { diff --git a/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java b/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java index f3799ab24e..b76e31fac5 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java @@ -149,15 +149,18 @@ public class CommentsTable extends POIXMLDocumentPart { public boolean removeComment(String cellRef) { CTCommentList lst = comments.getCommentList(); - if(lst != null) for(int i=0; i < lst.sizeOfCommentArray(); i++) { - CTComment comment = lst.getCommentArray(i); - if (cellRef.equals(comment.getRef())) { - lst.removeComment(i); - - if(commentRefs != null) { - commentRefs.remove(cellRef); + if(lst != null) { + int commentCount = lst.sizeOfCommentArray(); + for(int i=0; i < commentCount; i++) { + CTComment comment = lst.getCommentArray(i); + if (cellRef.equals(comment.getRef())) { + lst.removeComment(i); + + if(commentRefs != null) { + commentRefs.remove(cellRef); + } + return true; } - return true; } } return false; diff --git a/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java b/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java index f664f6bbc0..33c161b4c3 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/MapInfo.java @@ -24,7 +24,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; - import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; @@ -66,13 +65,14 @@ public class MapInfo extends POIXMLDocumentPart { readFrom(part.getInputStream()); } + @SuppressWarnings("deprecation") public void readFrom(InputStream is) throws IOException { try { MapInfoDocument doc = MapInfoDocument.Factory.parse(is); mapInfo = doc.getMapInfo(); maps= new HashMap(); - for(CTMap map :mapInfo.getMapList()){ + for(CTMap map :mapInfo.getMapArray()){ maps.put((int)map.getID(), new XSSFMap(map,this)); } @@ -104,10 +104,11 @@ public class MapInfo extends POIXMLDocumentPart { * @param schemaId the schema ID * @return CTSchema by it's ID */ + @SuppressWarnings("deprecation") public CTSchema getCTSchemaById(String schemaId){ CTSchema xmlSchema = null; - for(CTSchema schema: mapInfo.getSchemaList()){ + for(CTSchema schema: mapInfo.getSchemaArray()){ if(schema.getID().equals(schemaId)){ xmlSchema = schema; break; diff --git a/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java b/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java index 63c514b130..cb1542e87b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/SingleXmlCells.java @@ -94,10 +94,11 @@ public class SingleXmlCells extends POIXMLDocumentPart { * * @return all the SimpleXmlCell contained in this SingleXmlCells element */ + @SuppressWarnings("deprecation") public List getAllSimpleXmlCell(){ List list = new Vector(); - for(CTSingleXmlCell singleXmlCell: singleXMLCells.getSingleXmlCellList()){ + for(CTSingleXmlCell singleXmlCell: singleXMLCells.getSingleXmlCellArray()){ list.add(new XSSFSingleXmlCell(singleXmlCell,this)); } return list; diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java index bc5c6707dd..41038114f6 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java @@ -19,40 +19,40 @@ package org.apache.poi.xssf.usermodel; import java.io.IOException; import java.io.OutputStream; +import java.util.ArrayList; import java.util.HashMap; -import java.util.Map; import java.util.List; -import java.util.ArrayList; +import java.util.Map; import javax.xml.namespace.QName; import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; -import org.apache.poi.util.Internal; import org.apache.poi.ss.usermodel.Chart; +import org.apache.poi.ss.usermodel.charts.AxisPosition; import org.apache.poi.ss.usermodel.charts.ChartAxis; import org.apache.poi.ss.usermodel.charts.ChartAxisFactory; +import org.apache.poi.ss.usermodel.charts.ChartData; +import org.apache.poi.util.Internal; import org.apache.poi.xssf.usermodel.charts.XSSFCategoryAxis; -import org.apache.poi.xssf.usermodel.charts.XSSFChartDataFactory; import org.apache.poi.xssf.usermodel.charts.XSSFChartAxis; -import org.apache.poi.xssf.usermodel.charts.XSSFValueAxis; -import org.apache.poi.xssf.usermodel.charts.XSSFManualLayout; +import org.apache.poi.xssf.usermodel.charts.XSSFChartDataFactory; import org.apache.poi.xssf.usermodel.charts.XSSFChartLegend; -import org.apache.poi.ss.usermodel.charts.ChartData; -import org.apache.poi.ss.usermodel.charts.AxisPosition; +import org.apache.poi.xssf.usermodel.charts.XSSFManualLayout; +import org.apache.poi.xssf.usermodel.charts.XSSFValueAxis; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlOptions; import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx; import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart; import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartSpace; -import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle; -import org.openxmlformats.schemas.drawingml.x2006.chart.ChartSpaceDocument; +import org.openxmlformats.schemas.drawingml.x2006.chart.CTPageMargins; import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea; -import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx; import org.openxmlformats.schemas.drawingml.x2006.chart.CTPrintSettings; -import org.openxmlformats.schemas.drawingml.x2006.chart.CTPageMargins; +import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle; +import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx; +import org.openxmlformats.schemas.drawingml.x2006.chart.ChartSpaceDocument; import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId; import org.w3c.dom.NodeList; import org.w3c.dom.Text; @@ -306,14 +306,16 @@ public final class XSSFChart extends POIXMLDocumentPart implements Chart, ChartA parseValueAxis(); } + @SuppressWarnings("deprecation") private void parseCategoryAxis() { - for (CTCatAx catAx : chart.getPlotArea().getCatAxList()) { + for (CTCatAx catAx : chart.getPlotArea().getCatAxArray()) { axis.add(new XSSFCategoryAxis(this, catAx)); } } + @SuppressWarnings("deprecation") private void parseValueAxis() { - for (CTValAx valAx : chart.getPlotArea().getValAxList()) { + for (CTValAx valAx : chart.getPlotArea().getValAxArray()) { axis.add(new XSSFValueAxis(this, valAx)); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java index e80dc7ee6d..d63a18588d 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java @@ -127,7 +127,7 @@ public class XSSFPivotCacheDefinition extends POIXMLDocumentPart{ for(int i=columnStart; i<=columnEnd; i++) { CTCacheField cf = cFields.addNewCacheField(); if(i==columnEnd){ - cFields.setCount(cFields.getCacheFieldList().size()); + cFields.setCount(cFields.sizeOfCacheFieldArray()); } //General number format cf.setNumFmtId(0); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java index d31ae3f68a..278e66e3d3 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java @@ -240,7 +240,6 @@ public class XSSFPivotTable extends POIXMLDocumentPart { } CTPivotFields pivotFields = pivotTableDefinition.getPivotFields(); - List pivotFieldList = pivotTableDefinition.getPivotFields().getPivotFieldList(); CTPivotField pivotField = CTPivotField.Factory.newInstance(); CTItems items = pivotField.addNewItems(); @@ -249,10 +248,8 @@ public class XSSFPivotTable extends POIXMLDocumentPart { for(int i = 0; i <= lastRowIndex; i++) { items.addNewItem().setT(STItemType.DEFAULT); } - items.setCount(items.getItemList().size()); - pivotFieldList.set(columnIndex, pivotField); - - pivotFields.setPivotFieldArray(pivotFieldList.toArray(new CTPivotField[pivotFieldList.size()])); + items.setCount(items.sizeOfItemArray()); + pivotFields.setPivotFieldArray(columnIndex, pivotField); CTRowFields rowFields; if(pivotTableDefinition.getRowFields() != null) { @@ -262,7 +259,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart { } rowFields.addNewField().setX(columnIndex); - rowFields.setCount(rowFields.getFieldList().size()); + rowFields.setCount(rowFields.sizeOfFieldArray()); } @Beta @@ -307,7 +304,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart { colFields = pivotTableDefinition.addNewColFields(); } colFields.addNewField().setX(-2); - colFields.setCount(colFields.getFieldList().size()); + colFields.setCount(colFields.sizeOfFieldArray()); } } @@ -338,7 +335,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart { cell.setCellType(Cell.CELL_TYPE_STRING); dataField.setName(function.getName()); dataField.setFld(columnIndex); - dataFields.setCount(dataFields.getDataFieldList().size()); + dataFields.setCount(dataFields.sizeOfDataFieldArray()); } /** @@ -354,13 +351,11 @@ public class XSSFPivotTable extends POIXMLDocumentPart { throw new IndexOutOfBoundsException(); } CTPivotFields pivotFields = pivotTableDefinition.getPivotFields(); - List pivotFieldList = pivotFields.getPivotFieldList(); CTPivotField pivotField = CTPivotField.Factory.newInstance(); pivotField.setDataField(isDataField); pivotField.setShowAll(false); - pivotFieldList.set(columnIndex, pivotField); - pivotFields.setPivotFieldArray(pivotFieldList.toArray(new CTPivotField[pivotFieldList.size()])); + pivotFields.setPivotFieldArray(columnIndex, pivotField); } /** @@ -378,7 +373,6 @@ public class XSSFPivotTable extends POIXMLDocumentPart { } CTPivotFields pivotFields = pivotTableDefinition.getPivotFields(); - List pivotFieldList = pivotTableDefinition.getPivotFields().getPivotFieldList(); CTPivotField pivotField = CTPivotField.Factory.newInstance(); CTItems items = pivotField.addNewItems(); @@ -387,8 +381,8 @@ public class XSSFPivotTable extends POIXMLDocumentPart { for(int i = 0; i <= lastRowIndex; i++) { items.addNewItem().setT(STItemType.DEFAULT); } - items.setCount(items.getItemList().size()); - pivotFieldList.set(columnIndex, pivotField); + items.setCount(items.sizeOfItemArray()); + pivotFields.setPivotFieldArray(columnIndex, pivotField); CTPageFields pageFields; if (pivotTableDefinition.getPageFields()!= null) { @@ -402,7 +396,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart { pageField.setHier(-1); pageField.setFld(columnIndex); - pageFields.setCount(pageFields.getPageFieldList().size()); + pageFields.setCount(pageFields.sizeOfPageFieldArray()); pivotTableDefinition.getLocation().setColPageCount(pageFields.getCount()); } @@ -459,6 +453,6 @@ public class XSSFPivotTable extends POIXMLDocumentPart { pivotField.setDataField(false); pivotField.setShowAll(false); } - pivotFields.setCount(pivotFields.getPivotFieldList().size()); + pivotFields.setCount(pivotFields.sizeOfPivotFieldArray()); } } 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 fb5c6ef601..29c391ee6d 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -1342,8 +1342,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { /** * Do not leave the width attribute undefined (see #52186). */ + @SuppressWarnings("deprecation") private void setColWidthAttribute(CTCols ctCols) { - for (CTCol col : ctCols.getColList()) { + for (CTCol col : ctCols.getColArray()) { if (!col.isSetWidth()) { col.setWidth(getDefaultColumnWidth()); col.setCustomWidth(false); @@ -1380,10 +1381,11 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { } + @SuppressWarnings("deprecation") private short getMaxOutlineLevelCols() { CTCols ctCols = worksheet.getColsArray(0); short outlineLevel = 0; - for (CTCol col : ctCols.getColList()) { + for (CTCol col : ctCols.getColArray()) { outlineLevel = col.getOutlineLevel() > outlineLevel ? col.getOutlineLevel() : outlineLevel; } return outlineLevel; @@ -3543,7 +3545,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { + ":$" + rowRef2.getCellRefParts()[1]; } - StringBuffer rng = new StringBuffer(); + StringBuilder rng = new StringBuilder(); rng.append(c); if(rng.length() > 0 && r.length() > 0) { rng.append(','); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheetConditionalFormatting.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheetConditionalFormatting.java index be812c3dbf..a9be492c4c 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheetConditionalFormatting.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheetConditionalFormatting.java @@ -19,21 +19,21 @@ package org.apache.poi.xssf.usermodel; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.hssf.record.cf.CellRangeUtil; +import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.ComparisonOperator; import org.apache.poi.ss.usermodel.ConditionalFormatting; import org.apache.poi.ss.usermodel.ConditionalFormattingRule; import org.apache.poi.ss.usermodel.SheetConditionalFormatting; -import org.apache.poi.ss.usermodel.ComparisonOperator; import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.ss.SpreadsheetVersion; -import org.apache.poi.hssf.record.cf.CellRangeUtil; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCfRule; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCfType; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTConditionalFormatting; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.STConditionalFormattingOperator; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet; - -import java.util.List; -import java.util.ArrayList; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCfType; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.STConditionalFormattingOperator; /** * @author Yegor Kozlov @@ -115,6 +115,7 @@ public class XSSFSheetConditionalFormatting implements SheetConditionalFormattin return rule; } + @SuppressWarnings("deprecation") public int addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule[] cfRules) { if (regions == null) { throw new IllegalArgumentException("regions must not be null"); @@ -144,7 +145,7 @@ public class XSSFSheetConditionalFormatting implements SheetConditionalFormattin int priority = 1; - for(CTConditionalFormatting c : _sheet.getCTWorksheet().getConditionalFormattingList()){ + for(CTConditionalFormatting c : _sheet.getCTWorksheet().getConditionalFormattingArray()){ priority += c.sizeOfCfRuleArray(); } @@ -220,7 +221,7 @@ public class XSSFSheetConditionalFormatting implements SheetConditionalFormattin */ public void removeConditionalFormatting(int index) { checkIndex(index); - _sheet.getCTWorksheet().getConditionalFormattingList().remove(index); + _sheet.getCTWorksheet().removeConditionalFormatting(index); } private void checkIndex(int index) { diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java index ed1d9a27c5..d228cf9519 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java @@ -128,13 +128,14 @@ public class XSSFTable extends POIXMLDocumentPart { * * @return the xpath of the table's root element */ + @SuppressWarnings("deprecation") public String getCommonXpath() { if(commonXPath == null){ String[] commonTokens ={}; - for(CTTableColumn column :ctTable.getTableColumns().getTableColumnList()){ + for(CTTableColumn column :ctTable.getTableColumns().getTableColumnArray()){ if(column.getXmlColumnPr()!=null){ String xpath = column.getXmlColumnPr().getXpath(); String[] tokens = xpath.split("/"); @@ -173,11 +174,12 @@ public class XSSFTable extends POIXMLDocumentPart { } + @SuppressWarnings("deprecation") public List getXmlColumnPrs() { if(xmlColumnPr==null){ xmlColumnPr = new ArrayList(); - for (CTTableColumn column:ctTable.getTableColumns().getTableColumnList()){ + for (CTTableColumn column:ctTable.getTableColumns().getTableColumnArray()){ if (column.getXmlColumnPr()!=null){ XSSFXmlColumnPr columnPr = new XSSFXmlColumnPr(this,column,column.getXmlColumnPr()); xmlColumnPr.add(columnPr); @@ -285,6 +287,7 @@ public class XSSFTable extends POIXMLDocumentPart { * Headers must be in sync, otherwise Excel will display a * "Found unreadable content" message on startup. */ + @SuppressWarnings("deprecation") public void updateHeaders(){ XSSFSheet sheet = (XSSFSheet)getParent(); CellReference ref = getStartCellReference(); @@ -296,7 +299,7 @@ public class XSSFTable extends POIXMLDocumentPart { if (row != null && row.getCTRow().validate()) { int cellnum = firstHeaderColumn; - for (CTTableColumn col : getCTTable().getTableColumns().getTableColumnList()) { + for (CTTableColumn col : getCTTable().getTableColumns().getTableColumnArray()) { XSSFCell cell = row.getCell(cellnum); if (cell != null) { col.setName(cell.getStringCellValue()); 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 60e1ea415e..f5dc36b336 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -1410,10 +1410,11 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable(); if(workbook.isSetDefinedNames()) { - for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameList()) { + for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameArray()) { namedRanges.add(new XSSFName(ctName, this)); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java index 41beb6f259..74d9ef3994 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java @@ -19,7 +19,6 @@ package org.apache.poi.xssf.usermodel.helpers; import java.util.ArrayList; import java.util.Arrays; -import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -50,52 +49,39 @@ public class ColumnHelper { cleanColumns(); } + @SuppressWarnings("deprecation") public void cleanColumns() { this.newCols = CTCols.Factory.newInstance(); CTCols aggregateCols = CTCols.Factory.newInstance(); - List colsList = worksheet.getColsList(); - assert(colsList != null); + CTCols[] colsArray = worksheet.getColsArray(); + assert(colsArray != null); - for (CTCols cols : colsList) { - for (CTCol col : cols.getColList()) { + for (CTCols cols : colsArray) { + for (CTCol col : cols.getColArray()) { cloneCol(aggregateCols, col); } } sortColumns(aggregateCols); - CTCol[] colArray = new CTCol[aggregateCols.getColList().size()]; - aggregateCols.getColList().toArray(colArray); + CTCol[] colArray = aggregateCols.getColArray(); sweepCleanColumns(newCols, colArray, null); - int i = colsList.size(); + int i = colsArray.length; for (int y = i - 1; y >= 0; y--) { worksheet.removeCols(y); } worksheet.addNewCols(); worksheet.setColsArray(0, newCols); } - - private static class CTColByMaxComparator implements Comparator { - - public int compare(CTCol arg0, CTCol arg1) { - if (arg0.getMax() < arg1.getMax()) { - return -1; - } else { - if (arg0.getMax() > arg1.getMax()) return 1; - else return 0; - } - } - - } /** * @see Sweep line algorithm */ private void sweepCleanColumns(CTCols cols, CTCol[] flattenedColsArray, CTCol overrideColumn) { List flattenedCols = new ArrayList(Arrays.asList(flattenedColsArray)); - TreeSet currentElements = new TreeSet(new CTColByMaxComparator()); + TreeSet currentElements = new TreeSet(CTColComparator.BY_MAX); ListIterator flIter = flattenedCols.listIterator(); CTCol haveOverrideColumn = null; long lastMaxIndex = 0; @@ -103,7 +89,8 @@ public class ColumnHelper { while (flIter.hasNext()) { CTCol col = flIter.next(); long currentIndex = col.getMin(); - long nextIndex = (col.getMax() > currentMax) ? col.getMax() : currentMax; + long colMax = col.getMax(); + long nextIndex = (colMax > currentMax) ? colMax : currentMax; if (flIter.hasNext()) { nextIndex = flIter.next().getMin(); flIter.previous(); @@ -116,10 +103,10 @@ public class ColumnHelper { } if (!currentElements.isEmpty() && lastMaxIndex < currentIndex) { // we need to process previous elements first - insertCol(cols, lastMaxIndex, currentIndex - 1, currentElements.toArray(new CTCol[]{}), true, haveOverrideColumn); + insertCol(cols, lastMaxIndex, currentIndex - 1, currentElements.toArray(new CTCol[currentElements.size()]), true, haveOverrideColumn); } currentElements.add(col); - if (col.getMax() > currentMax) currentMax = col.getMax(); + if (colMax > currentMax) currentMax = colMax; if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn; while (currentIndex <= nextIndex && !currentElements.isEmpty()) { Set currentIndexElements = new HashSet(); @@ -130,26 +117,21 @@ public class ColumnHelper { CTCol currentElem = currentElements.first(); currentElemIndex = currentElem.getMax(); currentIndexElements.add(currentElem); - - for (CTCol cc : currentElements.tailSet(currentElem)) { - if (cc == null || cc.getMax() == currentElemIndex) break; - currentIndexElements.add(cc); - if (col.getMax() > currentMax) currentMax = col.getMax(); + + while (true) { + CTCol higherElem = currentElements.higher(currentElem); + if (higherElem == null || higherElem.getMax() != currentElemIndex) + break; + currentElem = higherElem; + currentIndexElements.add(currentElem); + if (colMax > currentMax) currentMax = colMax; if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn; } - - // JDK 6 code - // while (currentElements.higher(currentElem) != null && currentElements.higher(currentElem).getMax() == currentElemIndex) { - // currentElem = currentElements.higher(currentElem); - // currentIndexElements.add(currentElem); - // if (col.getMax() > currentMax) currentMax = col.getMax(); - // if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn; - // } } if (currentElemIndex < nextIndex || !flIter.hasNext()) { - insertCol(cols, currentIndex, currentElemIndex, currentElements.toArray(new CTCol[]{}), true, haveOverrideColumn); + insertCol(cols, currentIndex, currentElemIndex, currentElements.toArray(new CTCol[currentElements.size()]), true, haveOverrideColumn); if (flIter.hasNext()) { if (nextIndex > currentElemIndex) { currentElements.removeAll(currentIndexElements); @@ -170,10 +152,10 @@ public class ColumnHelper { sortColumns(cols); } + @SuppressWarnings("deprecation") public static void sortColumns(CTCols newCols) { - CTCol[] colArray = new CTCol[newCols.getColList().size()]; - newCols.getColList().toArray(colArray); - Arrays.sort(colArray, new CTColComparator()); + CTCol[] colArray = newCols.getColArray(); + Arrays.sort(colArray, CTColComparator.BY_MIN_MAX); newCols.setColArray(colArray); } @@ -198,46 +180,46 @@ public class ColumnHelper { * as 1 based. */ public CTCol getColumn1Based(long index1, boolean splitColumns) { - CTCols colsArray = worksheet.getColsArray(0); + CTCols cols = worksheet.getColsArray(0); // Fetching the array is quicker than working on the new style // list, assuming we need to read many of them (which we often do), // and assuming we're not making many changes (which we're not) @SuppressWarnings("deprecation") - CTCol[] cols = colsArray.getColArray(); - - for (int i = 0; i < cols.length; i++) { - CTCol colArray = cols[i]; - if (colArray.getMin() <= index1 && colArray.getMax() >= index1) { + CTCol[] colArray = cols.getColArray(); + + for (CTCol col : colArray) { + long colMin = col.getMin(); + long colMax = col.getMax(); + if (colMin <= index1 && colMax >= index1) { if (splitColumns) { - if (colArray.getMin() < index1) { - insertCol(colsArray, colArray.getMin(), (index1 - 1), new CTCol[]{colArray}); + if (colMin < index1) { + insertCol(cols, colMin, (index1 - 1), new CTCol[]{col}); } - if (colArray.getMax() > index1) { - insertCol(colsArray, (index1 + 1), colArray.getMax(), new CTCol[]{colArray}); + if (colMax > index1) { + insertCol(cols, (index1 + 1), colMax, new CTCol[]{col}); } - colArray.setMin(index1); - colArray.setMax(index1); + col.setMin(index1); + col.setMax(index1); } - return colArray; + return col; } } return null; } - + + @SuppressWarnings("deprecation") public CTCols addCleanColIntoCols(CTCols cols, CTCol col) { CTCols newCols = CTCols.Factory.newInstance(); - for (CTCol c : cols.getColList()) { + for (CTCol c : cols.getColArray()) { cloneCol(newCols, c); } cloneCol(newCols, col); sortColumns(newCols); - CTCol[] colArray = new CTCol[newCols.getColList().size()]; - newCols.getColList().toArray(colArray); + CTCol[] colArray = newCols.getColArray(); CTCols returnCols = CTCols.Factory.newInstance(); sweepCleanColumns(returnCols, colArray, col); - colArray = new CTCol[returnCols.getColList().size()]; - returnCols.getColList().toArray(colArray); + colArray = returnCols.getColArray(); cols.setColArray(colArray); return returnCols; } @@ -272,9 +254,11 @@ public class ColumnHelper { public boolean columnExists(CTCols cols, long index) { return columnExists1Based(cols, index+1); } + + @SuppressWarnings("deprecation") private boolean columnExists1Based(CTCols cols, long index1) { - for (int i = 0; i < cols.sizeOfColArray(); i++) { - if (cols.getColArray(i).getMin() == index1) { + for (CTCol col : cols.getColArray()) { + if (col.getMin() == index1) { return true; } } @@ -343,20 +327,24 @@ public class ColumnHelper { return -1; } + @SuppressWarnings("deprecation") private boolean columnExists(CTCols cols, long min, long max) { - for (int i = 0; i < cols.sizeOfColArray(); i++) { - if (cols.getColArray(i).getMin() == min && cols.getColArray(i).getMax() == max) { + for (CTCol col : cols.getColArray()) { + if (col.getMin() == min && col.getMax() == max) { return true; } } return false; } - - public int getIndexOfColumn(CTCols cols, CTCol col) { - for (int i = 0; i < cols.sizeOfColArray(); i++) { - if (cols.getColArray(i).getMin() == col.getMin() && cols.getColArray(i).getMax() == col.getMax()) { + + @SuppressWarnings("deprecation") + public int getIndexOfColumn(CTCols cols, CTCol searchCol) { + int i = 0; + for (CTCol col : cols.getColArray()) { + if (col.getMin() == searchCol.getMin() && col.getMax() == searchCol.getMax()) { return i; } + i++; } return -1; } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java index 1b51568867..b5614082e2 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java @@ -43,6 +43,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCfRule; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTConditionalFormatting; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType; /** @@ -213,28 +214,29 @@ public final class XSSFRowShifter { } } + @SuppressWarnings("deprecation") public void updateConditionalFormatting(FormulaShifter shifter) { XSSFWorkbook wb = sheet.getWorkbook(); int sheetIndex = wb.getSheetIndex(sheet); XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb); - List cfList = sheet.getCTWorksheet().getConditionalFormattingList(); - for(int j = 0; j< cfList.size(); j++){ - CTConditionalFormatting cf = cfList.get(j); + CTWorksheet ctWorksheet = sheet.getCTWorksheet(); + int cfCount = ctWorksheet.sizeOfConditionalFormattingArray(); + for(int j = 0; j< cfCount; j++){ + CTConditionalFormatting cf = ctWorksheet.getConditionalFormattingArray(j); ArrayList cellRanges = new ArrayList(); for (Object stRef : cf.getSqref()) { String[] regions = stRef.toString().split(" "); - for (int i = 0; i < regions.length; i++) { - cellRanges.add(CellRangeAddress.valueOf(regions[i])); + for (String region : regions) { + cellRanges.add(CellRangeAddress.valueOf(region)); } } boolean changed = false; List temp = new ArrayList(); - for (int i = 0; i < cellRanges.size(); i++) { - CellRangeAddress craOld = cellRanges.get(i); + for (CellRangeAddress craOld : cellRanges) { CellRangeAddress craNew = shiftRange(shifter, craOld, sheetIndex); if (craNew == null) { changed = true; @@ -249,7 +251,7 @@ public final class XSSFRowShifter { if (changed) { int nRanges = temp.size(); if (nRanges == 0) { - cfList.remove(j); + ctWorksheet.removeConditionalFormatting(j); continue; } List refs = new ArrayList(); @@ -257,14 +259,14 @@ public final class XSSFRowShifter { cf.setSqref(refs); } - for(CTCfRule cfRule : cf.getCfRuleList()){ - List formulas = cfRule.getFormulaList(); - for (int i = 0; i < formulas.size(); i++) { - String formula = formulas.get(i); + for(CTCfRule cfRule : cf.getCfRuleArray()){ + int formulaCount = cfRule.sizeOfFormulaArray(); + for (int i = 0; i < formulaCount; i++) { + String formula = cfRule.getFormulaArray(i); Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.CELL, sheetIndex); if (shifter.adjustFormula(ptgs, sheetIndex)) { String shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs); - formulas.set(i, shiftedFmla); + cfRule.setFormulaArray(i, shiftedFmla); } } } diff --git a/src/ooxml/java/org/apache/poi/xssf/util/CTColComparator.java b/src/ooxml/java/org/apache/poi/xssf/util/CTColComparator.java index 50d5c8f9f7..5368eb0e6e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/util/CTColComparator.java +++ b/src/ooxml/java/org/apache/poi/xssf/util/CTColComparator.java @@ -21,26 +21,26 @@ import java.util.Comparator; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol; -public class CTColComparator implements Comparator{ +public class CTColComparator { - public int compare(CTCol o1, CTCol o2) { - if (o1.getMin() < o2.getMin()) { - return -1; - } - else if (o1.getMin() > o2.getMin()) { - return 1; + private CTColComparator() {} + + public static final Comparator BY_MAX = new Comparator() { + @Override + public int compare(CTCol col1, CTCol col2) { + long col1max = col1.getMax(); + long col2max = col2.getMax(); + return col1max < col2max ? -1 : col1max > col2max ? 1 : 0; } - else { - if (o1.getMax() < o2.getMax()) { - return -1; - } - if (o1.getMax() > o2.getMax()) { - return 1; - } - return 0; + }; + + public static final Comparator BY_MIN_MAX = new Comparator() { + @Override + public int compare(CTCol col1, CTCol col2) { + long col11min = col1.getMin(); + long col2min = col2.getMin(); + return col11min < col2min ? -1 : col11min > col2min ? 1 : BY_MAX.compare(col1, col2); } - } - - - + }; + } diff --git a/src/ooxml/java/org/apache/poi/xwpf/model/XWPFCommentsDecorator.java b/src/ooxml/java/org/apache/poi/xwpf/model/XWPFCommentsDecorator.java index be7bf0408e..502a3b7861 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/model/XWPFCommentsDecorator.java +++ b/src/ooxml/java/org/apache/poi/xwpf/model/XWPFCommentsDecorator.java @@ -33,13 +33,15 @@ public class XWPFCommentsDecorator extends XWPFParagraphDecorator { public XWPFCommentsDecorator(XWPFParagraphDecorator nextDecorator) { this(nextDecorator.paragraph, nextDecorator); } + + @SuppressWarnings("deprecation") public XWPFCommentsDecorator(XWPFParagraph paragraph, XWPFParagraphDecorator nextDecorator) { super(paragraph, nextDecorator); XWPFComment comment; commentText = new StringBuffer(); - for(CTMarkupRange anchor : paragraph.getCTP().getCommentRangeStartList()) + for(CTMarkupRange anchor : paragraph.getCTP().getCommentRangeStartArray()) { if((comment = paragraph.getDocument().getCommentByID(anchor.getId().toString())) != null) commentText.append("\tComment by " + comment.getAuthor()+": "+comment.getText()); diff --git a/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHyperlinkDecorator.java b/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHyperlinkDecorator.java index 628ff37c94..d8120340f5 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHyperlinkDecorator.java +++ b/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHyperlinkDecorator.java @@ -52,10 +52,10 @@ public class XWPFHyperlinkDecorator extends XWPFParagraphDecorator { hyperlinkText = new StringBuffer(); // loop over hyperlink anchors - for(CTHyperlink link : paragraph.getCTP().getHyperlinkList()){ - for (CTR r : link.getRList()) { + for(CTHyperlink link : paragraph.getCTP().getHyperlinkArray()){ + for (CTR r : link.getRArray()) { // Loop over text runs - for (CTText text : r.getTList()){ + for (CTText text : r.getTArray()){ hyperlinkText.append(text.getStringValue()); } } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java index 9c668e8453..e69b0244e7 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java @@ -35,17 +35,18 @@ public abstract class AbstractXWPFSDT implements ISDTContents { private final String tag; private final IBody part; + @SuppressWarnings("deprecation") public AbstractXWPFSDT(CTSdtPr pr, IBody part){ - List aliases = pr.getAliasList(); - if (aliases != null && aliases.size() > 0){ - title = aliases.get(0).getVal(); + CTString[] aliases = pr.getAliasArray(); + if (aliases != null && aliases.length > 0){ + title = aliases[0].getVal(); } else { title = ""; } - List tags = pr.getTagList(); - if (tags != null && tags.size() > 0){ - tag = tags.get(0).getVal(); + CTString[] tags = pr.getTagArray(); + if (tags != null && tags.length > 0){ + tag = tags[0].getVal(); } else { tag = ""; } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java index d193983c79..84ebc36bb1 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java @@ -31,13 +31,14 @@ public class XWPFComment protected String author; protected StringBuffer text; + @SuppressWarnings("deprecation") public XWPFComment(CTComment comment, XWPFDocument document) { text = new StringBuffer(); id = comment.getId().toString(); author = comment.getAuthor(); - for(CTP ctp : comment.getPList()) + for(CTP ctp : comment.getPArray()) { XWPFParagraph p = new XWPFParagraph(ctp, document); text.append(p.getText()); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java index 568681dee4..9adc397048 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -184,7 +184,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { } else if (relation.equals(XWPFRelation.COMMENT.getRelation())) { // TODO Create according XWPFComment class, extending POIXMLDocumentPart CommentsDocument cmntdoc = CommentsDocument.Factory.parse(p.getPackagePart().getInputStream()); - for (CTComment ctcomment : cmntdoc.getComments().getCommentList()) { + for (CTComment ctcomment : cmntdoc.getComments().getCommentArray()) { comments.add(new XWPFComment(ctcomment, this)); } } else if (relation.equals(XWPFRelation.SETTINGS.getRelation())) { @@ -232,6 +232,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { } } + @SuppressWarnings("deprecation") private void initFootnotes() throws XmlException, IOException { for(POIXMLDocumentPart p : getRelations()){ String relation = p.getPackageRelationship().getRelationshipType(); @@ -241,7 +242,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){ EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream()); - for(CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteList()) { + for(CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteArray()) { endnotes.put(ctFtnEdn.getId().intValue(), new XWPFFootnote(this, ctFtnEdn)); } } @@ -364,10 +365,8 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { } public XWPFHyperlink getHyperlinkByID(String id) { - Iterator iter = hyperlinks.iterator(); - while (iter.hasNext()) { - XWPFHyperlink link = iter.next(); - if(link.getId().equals(id)) + for (XWPFHyperlink link : hyperlinks) { + if (link.getId().equals(id)) return link; } @@ -396,10 +395,8 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { } public XWPFComment getCommentByID(String id) { - Iterator iter = comments.iterator(); - while (iter.hasNext()) { - XWPFComment comment = iter.next(); - if(comment.getId().equals(id)) + for (XWPFComment comment : comments) { + if (comment.getId().equals(id)) return comment; } @@ -1187,14 +1184,15 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { * @param table */ @Override + @SuppressWarnings("deprecation") public void insertTable(int pos, XWPFTable table) { bodyElements.add(pos, table); - int i; - for (i = 0; i < ctDocument.getBody().getTblList().size(); i++) { - CTTbl tbl = ctDocument.getBody().getTblArray(i); + int i = 0; + for (CTTbl tbl : ctDocument.getBody().getTblArray()) { if (tbl == table.getCTTbl()) { break; } + i++; } tables.add(i, table); } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java index 7ecb4d77cd..5f0367d6bf 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java @@ -123,14 +123,15 @@ public class XWPFFootnote implements Iterable,IBody { * @param table * @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int pos, XWPFTable table) */ + @SuppressWarnings("deprecation") public void insertTable(int pos, XWPFTable table) { bodyElements.add(pos, table); - int i; - for (i = 0; i < ctFtnEdn.getTblList().size(); i++) { - CTTbl tbl = ctFtnEdn.getTblArray(i); + int i = 0; + for (CTTbl tbl : ctFtnEdn.getTblArray()) { if(tbl == table.getCTTbl()){ break; } + i++; } tables.add(i, table); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java index 74dd12613d..8647454f28 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java @@ -34,7 +34,6 @@ import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; - import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFootnotes; import org.openxmlformats.schemas.wordprocessingml.x2006.main.FootnotesDocument; @@ -68,6 +67,7 @@ public class XWPFFootnotes extends POIXMLDocumentPart { * Read document */ @Override + @SuppressWarnings("deprecation") protected void onDocumentRead () throws IOException { FootnotesDocument notesDoc; try { @@ -79,7 +79,7 @@ public class XWPFFootnotes extends POIXMLDocumentPart { } // Find our footnotes - for(CTFtnEdn note : ctFootnotes.getFootnoteList()) { + for(CTFtnEdn note : ctFootnotes.getFootnoteArray()) { listFootnote.add(new XWPFFootnote(note, this)); } } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java index 5fc2fdcd07..e6dee2fef3 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java @@ -436,14 +436,15 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo * @param pos * @param table */ + @SuppressWarnings("deprecation") public void insertTable(int pos, XWPFTable table) { bodyElements.add(pos, table); - int i; - for (i = 0; i < headerFooter.getTblList().size(); i++) { - CTTbl tbl = headerFooter.getTblArray(i); + int i = 0; + for (CTTbl tbl : headerFooter.getTblArray()) { if(tbl == table.getCTTbl()){ break; } + i++; } tables.add(i, table); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFLatentStyles.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFLatentStyles.java index a0a586313b..85bf7f6b6c 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFLatentStyles.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFLatentStyles.java @@ -38,8 +38,9 @@ public class XWPFLatentStyles { /** * checks wheter specific LatentStyleID is a latentStyle */ + @SuppressWarnings("deprecation") protected boolean isLatentStyle(String latentStyleID){ - for ( CTLsdException lsd: latentStyles.getLsdExceptionList()) { + for ( CTLsdException lsd: latentStyles.getLsdExceptionArray()) { if(lsd.getName().equals(latentStyleID)); return true; } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java index 2b4ca7049a..1bc8af5aed 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java @@ -71,6 +71,7 @@ public class XWPFNumbering extends POIXMLDocumentPart { * read numbering form an existing package */ @Override + @SuppressWarnings("deprecation") protected void onDocumentRead() throws IOException{ NumberingDocument numberingDoc = null; InputStream is; @@ -79,10 +80,10 @@ public class XWPFNumbering extends POIXMLDocumentPart { numberingDoc = NumberingDocument.Factory.parse(is); ctNumbering = numberingDoc.getNumbering(); //get any Nums - for(CTNum ctNum : ctNumbering.getNumList()) { + for(CTNum ctNum : ctNumbering.getNumArray()) { nums.add(new XWPFNum(ctNum, this)); } - for(CTAbstractNum ctAbstractNum : ctNumbering.getAbstractNumList()){ + for(CTAbstractNum ctAbstractNum : ctNumbering.getAbstractNumArray()){ abstractNums.add(new XWPFAbstractNum(ctAbstractNum, this)); } isNew = false; @@ -144,7 +145,7 @@ public class XWPFNumbering extends POIXMLDocumentPart { */ public BigInteger addNum(XWPFNum num){ ctNumbering.addNewNum(); - int pos = (ctNumbering.getNumList().size()) - 1; + int pos = ctNumbering.sizeOfNumArray() - 1; ctNumbering.setNumArray(pos, num.getCTNum()); nums.add(num); return num.getCTNum().getNumId(); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java index 98b9dccc46..5a4d7b33b7 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java @@ -137,7 +137,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents { } if (o instanceof CTHyperlink) { CTHyperlink link = (CTHyperlink) o; - for (CTR r : link.getRList()) { + for (CTR r : link.getRArray()) { XWPFHyperlinkRun hr = new XWPFHyperlinkRun(link, r, this); runs.add(hr); iruns.add(hr); @@ -152,14 +152,14 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents { iruns.add(cc); } if (o instanceof CTRunTrackChange) { - for (CTR r : ((CTRunTrackChange) o).getRList()) { + for (CTR r : ((CTRunTrackChange) o).getRArray()) { XWPFRun cr = new XWPFRun(r, this); runs.add(cr); iruns.add(cr); } } if (o instanceof CTSimpleField) { - for (CTR r : ((CTSimpleField) o).getRList()) { + for (CTR r : ((CTSimpleField) o).getRArray()) { XWPFRun cr = new XWPFRun(r, this); runs.add(cr); iruns.add(cr); @@ -1170,7 +1170,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents { */ protected void addRun(CTR run){ int pos; - pos = paragraph.getRList().size(); + pos = paragraph.sizeOfRArray(); paragraph.addNewR(); paragraph.setRArray(pos, run); } @@ -1230,9 +1230,10 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents { startChar = startPos.getChar(); int beginRunPos = 0, candCharPos = 0; boolean newList = false; - for (int runPos=startRun; runPos drawingList = r.getDrawingList(); - for (CTDrawing ctDrawing : drawingList) { - List anchorList = ctDrawing.getAnchorList(); - for (CTAnchor anchor : anchorList) { + for (CTDrawing ctDrawing : r.getDrawingArray()) { + for (CTAnchor anchor : ctDrawing.getAnchorArray()) { if (anchor.getDocPr() != null) { getDocument().getDrawingIdManager().reserve(anchor.getDocPr().getId()); } } - List inlineList = ctDrawing.getInlineList(); - for (CTInline inline : inlineList) { + for (CTInline inline : ctDrawing.getInlineArray()) { if (inline.getDocPr() != null) { getDocument().getDrawingIdManager().reserve(inline.getDocPr().getId()); } @@ -120,17 +119,17 @@ public class XWPFRun implements ISDTContents, IRunElement{ } // Look for any text in any of our pictures or drawings - StringBuffer text = new StringBuffer(); + StringBuilder text = new StringBuilder(); List pictTextObjs = new ArrayList(); - pictTextObjs.addAll(r.getPictList()); - pictTextObjs.addAll(drawingList); + pictTextObjs.addAll(Arrays.asList(r.getPictArray())); + pictTextObjs.addAll(Arrays.asList(r.getDrawingArray())); for(XmlObject o : pictTextObjs) { - XmlObject[] t = o.selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' .//w:t"); - for (int m = 0; m < t.length; m++) { - NodeList kids = t[m].getDomNode().getChildNodes(); + XmlObject[] ts = o.selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' .//w:t"); + for (XmlObject t : ts) { + NodeList kids = t.getDomNode().getChildNodes(); for (int n = 0; n < kids.getLength(); n++) { if (kids.item(n) instanceof Text) { - if(text.length() > 0) + if (text.length() > 0) text.append("\n"); text.append(kids.item(n).getNodeValue()); } @@ -317,7 +316,7 @@ public class XWPFRun implements ISDTContents, IRunElement{ * @param value the literal text which shall be displayed in the document */ public void setText(String value) { - setText(value,run.getTList().size()); + setText(value,run.sizeOfTArray()); } /** diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java index 59a0abba9f..42c56b3773 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java @@ -50,8 +50,8 @@ public class XWPFSDTContent implements ISDTContent { private List bodyElements = new ArrayList(); public XWPFSDTContent(CTSdtContentRun sdtRun, IBody part, IRunBody parent){ - for (CTR ctr : sdtRun.getRList()){ - XWPFRun run = new XWPFRun((CTR) ctr, parent); + for (CTR ctr : sdtRun.getRArray()){ + XWPFRun run = new XWPFRun(ctr, parent); runs.add(run); bodyElements.add(run); } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java index 35a0c6027e..359f4ece24 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java @@ -37,7 +37,6 @@ import org.apache.xmlbeans.XmlOptions; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles; import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument; - import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPrDefault; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage; @@ -74,6 +73,7 @@ public class XWPFStyles extends POIXMLDocumentPart{ * Read document */ @Override + @SuppressWarnings("deprecation") protected void onDocumentRead() throws IOException{ StylesDocument stylesDoc; try { @@ -86,7 +86,7 @@ public class XWPFStyles extends POIXMLDocumentPart{ } // Build up all the style objects - for(CTStyle style : ctStyles.getStyleList()) { + for(CTStyle style : ctStyles.getStyleArray()) { listStyle.add(new XWPFStyle(style, this)); } } @@ -137,7 +137,7 @@ public class XWPFStyles extends POIXMLDocumentPart{ public void addStyle(XWPFStyle style){ listStyle.add(style); ctStyles.addNewStyle(); - int pos = (ctStyles.getStyleList().size()) - 1; + int pos = ctStyles.sizeOfStyleArray() - 1; ctStyles.setStyleArray(pos, style.getCTStyle()); } /** diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java index 554e7bef2c..643d28ffa9 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java @@ -93,6 +93,7 @@ public class XWPFTable implements IBodyElement, ISDTContents { } } + @SuppressWarnings("deprecation") public XWPFTable(CTTbl table, IBody part){ this.part = part; this.ctTbl = table; @@ -103,12 +104,12 @@ public class XWPFTable implements IBodyElement, ISDTContents { if (table.sizeOfTrArray() == 0) createEmptyTable(table); - for (CTRow row : table.getTrList()) { - StringBuffer rowText = new StringBuffer(); + for (CTRow row : table.getTrArray()) { + StringBuilder rowText = new StringBuilder(); XWPFTableRow tabRow = new XWPFTableRow(row, this); tableRows.add(tabRow); - for (CTTc cell : row.getTcList()) { - for (CTP ctp : cell.getPList()) { + for (CTTc cell : row.getTcArray()) { + for (CTP ctp : cell.getPArray()) { XWPFParagraph p = new XWPFParagraph(ctp, part); if (rowText.length() > 0) { rowText.append('\t'); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java index e1b46fecd2..c1f0d4f447 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java @@ -79,7 +79,7 @@ public class XWPFTableCell implements IBody, ICell { this.part = part; this.tableRow = tableRow; // NB: If a table cell does not include at least one block-level element, then this document shall be considered corrupt. - if(cell.getPList().size()<1) + if(cell.sizeOfPArray()<1) cell.addNewP(); bodyElements = new ArrayList(); paragraphs = new ArrayList(); @@ -398,16 +398,17 @@ public class XWPFTableCell implements IBody, ICell { * inserts an existing XWPFTable to the arrays bodyElements and tables * @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int, org.apache.poi.xwpf.usermodel.XWPFTable) */ + @SuppressWarnings("deprecation") public void insertTable(int pos, XWPFTable table) { - bodyElements.add(pos, table); - int i; - for (i = 0; i < ctTc.getTblList().size(); i++) { - CTTbl tbl = ctTc.getTblArray(i); - if(tbl == table.getCTTbl()){ - break; - } - } - tables.add(i, table); + bodyElements.add(pos, table); + int i = 0; + for (CTTbl tbl : ctTc.getTblArray()) { + if (tbl == table.getCTTbl()) { + break; + } + i++; + } + tables.add(i, table); } public String getText(){ diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java index 56ea38745f..627ee3c8d3 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java @@ -152,10 +152,11 @@ public class XWPFTableRow { * who belongs to this row * @return a list of {@link XWPFTableCell} */ + @SuppressWarnings("deprecation") public List getTableCells(){ if(tableCells == null){ List cells = new ArrayList(); - for (CTTc tableCell : ctRow.getTcList()) { + for (CTTc tableCell : ctRow.getTcArray()) { cells.add(new XWPFTableCell(tableCell, this, table.getBody())); } //TODO: it is possible to have an SDT that contains a cell in within a row @@ -201,7 +202,7 @@ public class XWPFTableRow { boolean isCant = false; CTTrPr trpr = getTrPr(); if (trpr.sizeOfCantSplitArray() > 0) { - CTOnOff onoff = trpr.getCantSplitList().get(0); + CTOnOff onoff = trpr.getCantSplitArray(0); isCant = onoff.getVal().equals(STOnOff.ON); } return isCant; @@ -229,7 +230,7 @@ public class XWPFTableRow { boolean repeat = false; CTTrPr trpr = getTrPr(); if (trpr.sizeOfTblHeaderArray() > 0) { - CTOnOff rpt = trpr.getTblHeaderList().get(0); + CTOnOff rpt = trpr.getTblHeaderArray(0); repeat = rpt.getVal().equals(STOnOff.ON); } return repeat; diff --git a/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFSlideShow.java b/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFSlideShow.java index f82ed00ce0..b34a0d1c4e 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFSlideShow.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFSlideShow.java @@ -17,6 +17,7 @@ package org.apache.poi.xslf; import junit.framework.TestCase; + import org.apache.poi.POIDataSamples; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackagePart; @@ -61,22 +62,19 @@ public class TestXSLFSlideShow extends TestCase { ); } + @SuppressWarnings("deprecation") public void testSlideBasics() throws Exception { XSLFSlideShow xml = new XSLFSlideShow(pack); // Should have 1 master assertEquals(1, xml.getSlideMasterReferences().sizeOfSldMasterIdArray()); - assertEquals(1, xml.getSlideMasterReferences().getSldMasterIdList().size()); - + // Should have three sheets assertEquals(2, xml.getSlideReferences().sizeOfSldIdArray()); - assertEquals(2, xml.getSlideReferences().getSldIdList().size()); - + // Check they're as expected - CTSlideIdListEntry[] slides = new CTSlideIdListEntry[ - xml.getSlideReferences().getSldIdList().size()]; - xml.getSlideReferences().getSldIdList().toArray(slides); - + CTSlideIdListEntry[] slides = xml.getSlideReferences().getSldIdArray(); + assertEquals(256, slides[0].getId()); assertEquals(257, slides[1].getId()); assertEquals("rId2", slides[0].getId2()); @@ -91,9 +89,7 @@ public class TestXSLFSlideShow extends TestCase { assertNotNull(xml.getNotes(slides[1])); // And again for the master - CTSlideMasterIdListEntry[] masters = new CTSlideMasterIdListEntry[ - xml.getSlideMasterReferences().getSldMasterIdList().size()]; - xml.getSlideMasterReferences().getSldMasterIdList().toArray(masters); + CTSlideMasterIdListEntry[] masters = xml.getSlideMasterReferences().getSldMasterIdArray(); assertEquals(2147483648l, masters[0].getId()); assertEquals("rId1", masters[0].getId2()); diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java index 0fc4b20aaa..604f68fffb 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java @@ -17,6 +17,7 @@ package org.apache.poi.xslf.usermodel; import junit.framework.TestCase; + import org.apache.poi.POIDataSamples; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackagePart; @@ -58,6 +59,7 @@ public class TestXMLSlideShow extends TestCase { assertTrue(xml.getSlideMasters().length > 0); } + @SuppressWarnings("deprecation") public void testSlideBasics() throws Exception { XMLSlideShow xml = new XMLSlideShow(pack); @@ -68,9 +70,7 @@ public class TestXMLSlideShow extends TestCase { assertEquals(2, xml.getSlides().length); // Check they're as expected - CTSlideIdListEntry[] slides = new CTSlideIdListEntry[ - xml.getCTPresentation().getSldIdLst().getSldIdList().size()]; - xml.getCTPresentation().getSldIdLst().getSldIdList().toArray(slides); + CTSlideIdListEntry[] slides = xml.getCTPresentation().getSldIdLst().getSldIdArray(); assertEquals(256, slides[0].getId()); assertEquals(257, slides[1].getId()); @@ -86,9 +86,7 @@ public class TestXMLSlideShow extends TestCase { assertNotNull(xml.getSlides()[1].getNotes()); // Next up look for the slide master - CTSlideMasterIdListEntry[] masters = new CTSlideMasterIdListEntry[ - xml.getCTPresentation().getSldMasterIdLst().getSldMasterIdList().size()]; - xml.getCTPresentation().getSldMasterIdLst().getSldMasterIdList().toArray(masters); + CTSlideMasterIdListEntry[] masters = xml.getCTPresentation().getSldMasterIdLst().getSldMasterIdArray(); assertEquals(2147483648l, masters[0].getId()); assertEquals("rId1", masters[0].getId2()); diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java index f0d57241db..838db8137b 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java @@ -16,12 +16,19 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; +import java.awt.Color; + import junit.framework.TestCase; + import org.apache.poi.util.Units; import org.apache.poi.xslf.XSLFTestDataSamples; -import org.openxmlformats.schemas.drawingml.x2006.main.*; - -import java.awt.Color; +import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem; +import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleList; +import org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix; +import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap; +import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal; /** * @author Yegor Kozlov @@ -243,13 +250,14 @@ public class TestXSLFSimpleShape extends TestCase { } + @SuppressWarnings({ "deprecation", "unused" }) public void testShadowEffects(){ XMLSlideShow ppt = new XMLSlideShow(); XSLFSlide slide = ppt.createSlide(); CTStyleMatrix styleMatrix = slide.getTheme().getXmlObject().getThemeElements().getFmtScheme(); CTEffectStyleList lst = styleMatrix.getEffectStyleLst(); assertNotNull(lst); - for(CTEffectStyleItem ef : lst.getEffectStyleList()){ + for(CTEffectStyleItem ef : lst.getEffectStyleArray()){ CTOuterShadowEffect obj = ef.getEffectLst().getOuterShdw(); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java index 80e5f52510..0932177e00 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java @@ -32,7 +32,7 @@ public final class TestCalculationChain extends TestCase { CalculationChain chain = wb.getCalculationChain(); //the bean holding the reference to the formula to be deleted CTCalcCell c = chain.getCTCalcChain().getCArray(0); - int cnt = chain.getCTCalcChain().getCList().size(); + int cnt = chain.getCTCalcChain().sizeOfCArray(); assertEquals(10, c.getI()); assertEquals("E1", c.getR()); @@ -44,7 +44,7 @@ public final class TestCalculationChain extends TestCase { //the count of items is less by one c = chain.getCTCalcChain().getCArray(0); - int cnt2 = chain.getCTCalcChain().getCList().size(); + int cnt2 = chain.getCTCalcChain().sizeOfCArray(); assertEquals(cnt - 1, cnt2); //the first item in the calculation chain is the former second one assertEquals(10, c.getI()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestMapInfo.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestMapInfo.java index 7a4e98320f..33e91e8d3f 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestMapInfo.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestMapInfo.java @@ -50,7 +50,7 @@ public final class TestMapInfo extends TestCase { assertNotNull(ctMapInfo); - assertEquals(1, ctMapInfo.getSchemaList().size()); + assertEquals(1, ctMapInfo.sizeOfSchemaArray()); for (XSSFMap map : mapInfo.getAllXSSFMaps()) { Node xmlSchema = map.getSchema(); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index a08dffd2d1..79bbc4ea6d 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -964,9 +964,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { assertEquals(text, cell.getStringCellValue()); assertEquals(4, cell.getRichStringCellValue().numFormattingRuns()); - assertEquals("Use", cell.getRichStringCellValue().getCTRst().getRList().get(0).getT()); + assertEquals("Use", cell.getRichStringCellValue().getCTRst().getRArray(0).getT()); - String r3 = cell.getRichStringCellValue().getCTRst().getRList().get(2).getT(); + String r3 = cell.getRichStringCellValue().getCTRst().getRArray(2).getT(); assertEquals("line.\n", r3.substring(r3.length()-6)); // Save and re-check diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java index f99d007090..92fc298ab5 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java @@ -45,6 +45,7 @@ public class TestXSSFColGrouping extends TestCase { * Tests that POI doesn't produce "col" elements without "width" attribute. * POI-52186 */ + @SuppressWarnings("deprecation") public void testNoColsWithoutWidthWhenGrouping() { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet("test"); @@ -60,7 +61,7 @@ public class TestXSSFColGrouping extends TestCase { CTCols cols = sheet.getCTWorksheet().getColsArray(0); logger.log(POILogger.DEBUG, "test52186/cols:" + cols); - for (CTCol col : cols.getColList()) { + for (CTCol col : cols.getColArray()) { assertTrue("Col width attribute is unset: " + col.toString(), col.isSetWidth()); } } @@ -69,6 +70,7 @@ public class TestXSSFColGrouping extends TestCase { * Tests that POI doesn't produce "col" elements without "width" attribute. * POI-52186 */ + @SuppressWarnings("deprecation") public void testNoColsWithoutWidthWhenGroupingAndCollapsing() { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet("test"); @@ -90,7 +92,7 @@ public class TestXSSFColGrouping extends TestCase { assertEquals("Unexpected width of column "+ i, 5000, sheet.getColumnWidth(i)); } cols = sheet.getCTWorksheet().getColsArray(0); - for (CTCol col : cols.getColList()) { + for (CTCol col : cols.getColArray()) { assertTrue("Col width attribute is unset: " + col.toString(), col.isSetWidth()); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java index 5d93fa1215..3bbe6f2788 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java @@ -65,7 +65,7 @@ public final class TestXSSFFont extends BaseTestFont{ xssfFont.setBold(true); - assertEquals(ctFont.getBList().size(),1); + assertEquals(ctFont.sizeOfBArray(),1); assertEquals(true, ctFont.getBArray(0).getVal()); } @@ -135,7 +135,7 @@ public final class TestXSSFFont extends BaseTestFont{ assertEquals(false, xssfFont.getItalic()); xssfFont.setItalic(true); - assertEquals(ctFont.getIList().size(),1); + assertEquals(ctFont.sizeOfIArray(),1); assertEquals(true, ctFont.getIArray(0).getVal()); assertEquals(true,ctFont.getIArray(0).getVal()); } @@ -150,7 +150,7 @@ public final class TestXSSFFont extends BaseTestFont{ assertEquals(false, xssfFont.getStrikeout()); xssfFont.setStrikeout(true); - assertEquals(ctFont.getStrikeList().size(),1); + assertEquals(ctFont.sizeOfStrikeArray(),1); assertEquals(true, ctFont.getStrikeArray(0).getVal()); assertEquals(true,ctFont.getStrikeArray(0).getVal()); } @@ -191,11 +191,11 @@ public final class TestXSSFFont extends BaseTestFont{ assertEquals(Font.U_SINGLE, xssfFont.getUnderline()); xssfFont.setUnderline(Font.U_DOUBLE); - assertEquals(ctFont.getUList().size(),1); + assertEquals(ctFont.sizeOfUArray(),1); assertEquals(STUnderlineValues.DOUBLE,ctFont.getUArray(0).getVal()); xssfFont.setUnderline(FontUnderline.DOUBLE_ACCOUNTING); - assertEquals(ctFont.getUList().size(),1); + assertEquals(ctFont.sizeOfUArray(),1); assertEquals(STUnderlineValues.DOUBLE_ACCOUNTING,ctFont.getUArray(0).getVal()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java index 40f8b065ad..5a45219ac3 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java @@ -308,22 +308,22 @@ public final class TestXSSFRichTextString extends TestCase { str = new XSSFRichTextString("Incorrect\nLine-Breaking"); str.applyFont(0, 8, font); - t1 = str.getCTRst().getRList().get(0).xgetT(); - t2 = str.getCTRst().getRList().get(1).xgetT(); + t1 = str.getCTRst().getRArray(0).xgetT(); + t2 = str.getCTRst().getRArray(1).xgetT(); assertEquals("Incorrec", t1.xmlText()); assertEquals("t\nLine-Breaking", t2.xmlText()); str = new XSSFRichTextString("Incorrect\nLine-Breaking"); str.applyFont(0, 9, font); - t1 = str.getCTRst().getRList().get(0).xgetT(); - t2 = str.getCTRst().getRList().get(1).xgetT(); + t1 = str.getCTRst().getRArray(0).xgetT(); + t2 = str.getCTRst().getRArray(1).xgetT(); assertEquals("Incorrect", t1.xmlText()); assertEquals("\nLine-Breaking", t2.xmlText()); str = new XSSFRichTextString("Incorrect\n Line-Breaking"); str.applyFont(0, 9, font); - t1 = str.getCTRst().getRList().get(0).xgetT(); - t2 = str.getCTRst().getRList().get(1).xgetT(); + t1 = str.getCTRst().getRArray(0).xgetT(); + t2 = str.getCTRst().getRArray(1).xgetT(); assertEquals("Incorrect", t1.xmlText()); assertEquals("\n Line-Breaking", t2.xmlText()); @@ -333,15 +333,15 @@ public final class TestXSSFRichTextString extends TestCase { assertEquals("Tab\tseparated\n", t1.xmlText()); str.applyFont(0, 3, font); - t1 = str.getCTRst().getRList().get(0).xgetT(); - t2 = str.getCTRst().getRList().get(1).xgetT(); + t1 = str.getCTRst().getRArray(0).xgetT(); + t2 = str.getCTRst().getRArray(1).xgetT(); assertEquals("Tab", t1.xmlText()); assertEquals("\tseparated\n", t2.xmlText()); str = new XSSFRichTextString("Tab\tseparated\n"); str.applyFont(0, 4, font); - t1 = str.getCTRst().getRList().get(0).xgetT(); - t2 = str.getCTRst().getRList().get(1).xgetT(); + t1 = str.getCTRst().getRArray(0).xgetT(); + t2 = str.getCTRst().getRArray(1).xgetT(); // YK: don't know why, but XmlBeans converts leading tab characters to spaces //assertEquals("Tab\t", t1.xmlText()); assertEquals("separated\n", t2.xmlText()); @@ -349,9 +349,9 @@ public final class TestXSSFRichTextString extends TestCase { str = new XSSFRichTextString("\n\n\nNew Line\n\n"); str.applyFont(0, 3, font); str.applyFont(11, 13, font); - t1 = str.getCTRst().getRList().get(0).xgetT(); - t2 = str.getCTRst().getRList().get(1).xgetT(); - t3 = str.getCTRst().getRList().get(2).xgetT(); + t1 = str.getCTRst().getRArray(0).xgetT(); + t2 = str.getCTRst().getRArray(1).xgetT(); + t3 = str.getCTRst().getRArray(2).xgetT(); // YK: don't know why, but XmlBeans converts leading tab characters to spaces assertEquals("\n\n\n", t1.xmlText()); assertEquals("New Line", t2.xmlText()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java index 44342781a8..6da347671c 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -335,6 +335,7 @@ public final class TestXSSFSheet extends BaseTestSheet { @Test + @SuppressWarnings("deprecation") public void groupUngroupColumn() { XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet sheet = workbook.createSheet(); @@ -344,36 +345,36 @@ public final class TestXSSFSheet extends BaseTestSheet { sheet.groupColumn(10, 11); CTCols cols = sheet.getCTWorksheet().getColsArray(0); assertEquals(2, cols.sizeOfColArray()); - List colArray = cols.getColList(); + CTCol[] colArray = cols.getColArray(); assertNotNull(colArray); - assertEquals(2 + 1, colArray.get(0).getMin()); // 1 based - assertEquals(7 + 1, colArray.get(0).getMax()); // 1 based - assertEquals(1, colArray.get(0).getOutlineLevel()); + assertEquals(2 + 1, colArray[0].getMin()); // 1 based + assertEquals(7 + 1, colArray[0].getMax()); // 1 based + assertEquals(1, colArray[0].getOutlineLevel()); //two level sheet.groupColumn(1, 2); cols = sheet.getCTWorksheet().getColsArray(0); assertEquals(4, cols.sizeOfColArray()); - colArray = cols.getColList(); - assertEquals(2, colArray.get(1).getOutlineLevel()); + colArray = cols.getColArray(); + assertEquals(2, colArray[1].getOutlineLevel()); //three level sheet.groupColumn(6, 8); sheet.groupColumn(2, 3); cols = sheet.getCTWorksheet().getColsArray(0); assertEquals(7, cols.sizeOfColArray()); - colArray = cols.getColList(); - assertEquals(3, colArray.get(1).getOutlineLevel()); + colArray = cols.getColArray(); + assertEquals(3, colArray[1].getOutlineLevel()); assertEquals(3, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol()); sheet.ungroupColumn(8, 10); - colArray = cols.getColList(); + colArray = cols.getColArray(); //assertEquals(3, colArray[1].getOutlineLevel()); sheet.ungroupColumn(4, 6); sheet.ungroupColumn(2, 2); - colArray = cols.getColList(); - assertEquals(4, colArray.size()); + colArray = cols.getColArray(); + assertEquals(4, colArray.length); assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol()); } @@ -758,9 +759,8 @@ public final class TestXSSFSheet extends BaseTestSheet { XSSFSheet xs = sheet; CTWorksheet cts = xs.getCTWorksheet(); - List cols_s = cts.getColsList(); - assertEquals(1, cols_s.size()); - CTCols cols = cols_s.get(0); + assertEquals(1, cts.sizeOfColsArray()); + CTCols cols = cts.getColsArray(0); assertEquals(1, cols.sizeOfColArray()); CTCol col = cols.getColArray(0); @@ -773,9 +773,8 @@ public final class TestXSSFSheet extends BaseTestSheet { // Now set another sheet.setColumnWidth(3, 33 * 256); - cols_s = cts.getColsList(); - assertEquals(1, cols_s.size()); - cols = cols_s.get(0); + assertEquals(1, cts.sizeOfColsArray()); + cols = cts.getColsArray(0); assertEquals(2, cols.sizeOfColArray()); col = cols.getColArray(0); @@ -960,6 +959,7 @@ public final class TestXSSFSheet extends BaseTestSheet { * but CTRows are kept in ascending order */ @Test + @SuppressWarnings("deprecation") public void createRow() { XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet sheet = workbook.createSheet(); @@ -983,27 +983,27 @@ public final class TestXSSFSheet extends BaseTestSheet { row3.createCell(5); - List xrow = sheetData.getRowList(); - assertEquals(3, xrow.size()); + CTRow[] xrow = sheetData.getRowArray(); + assertEquals(3, xrow.length); //rows are sorted: {0, 1, 2} - assertEquals(4, xrow.get(0).sizeOfCArray()); - assertEquals(1, xrow.get(0).getR()); - assertTrue(xrow.get(0).equals(row3.getCTRow())); + assertEquals(4, xrow[0].sizeOfCArray()); + assertEquals(1, xrow[0].getR()); + assertTrue(xrow[0].equals(row3.getCTRow())); - assertEquals(3, xrow.get(1).sizeOfCArray()); - assertEquals(2, xrow.get(1).getR()); - assertTrue(xrow.get(1).equals(row2.getCTRow())); + assertEquals(3, xrow[1].sizeOfCArray()); + assertEquals(2, xrow[1].getR()); + assertTrue(xrow[1].equals(row2.getCTRow())); - assertEquals(2, xrow.get(2).sizeOfCArray()); - assertEquals(3, xrow.get(2).getR()); - assertTrue(xrow.get(2).equals(row1.getCTRow())); + assertEquals(2, xrow[2].sizeOfCArray()); + assertEquals(3, xrow[2].getR()); + assertTrue(xrow[2].equals(row1.getCTRow())); - List xcell = xrow.get(0).getCList(); - assertEquals("D1", xcell.get(0).getR()); - assertEquals("A1", xcell.get(1).getR()); - assertEquals("C1", xcell.get(2).getR()); - assertEquals("F1", xcell.get(3).getR()); + CTCell[] xcell = xrow[0].getCArray(); + assertEquals("D1", xcell[0].getR()); + assertEquals("A1", xcell[1].getR()); + assertEquals("C1", xcell[2].getR()); + assertEquals("F1", xcell[3].getR()); //re-creating a row does NOT add extra data to the parent row2 = sheet.createRow(1); @@ -1015,25 +1015,25 @@ public final class TestXSSFSheet extends BaseTestSheet { workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook); sheet = workbook.getSheetAt(0); wsh = sheet.getCTWorksheet(); - xrow = sheetData.getRowList(); - assertEquals(3, xrow.size()); + xrow = sheetData.getRowArray(); + assertEquals(3, xrow.length); //rows are sorted: {0, 1, 2} - assertEquals(4, xrow.get(0).sizeOfCArray()); - assertEquals(1, xrow.get(0).getR()); + assertEquals(4, xrow[0].sizeOfCArray()); + assertEquals(1, xrow[0].getR()); //cells are now sorted - xcell = xrow.get(0).getCList(); - assertEquals("A1", xcell.get(0).getR()); - assertEquals("C1", xcell.get(1).getR()); - assertEquals("D1", xcell.get(2).getR()); - assertEquals("F1", xcell.get(3).getR()); + xcell = xrow[0].getCArray(); + assertEquals("A1", xcell[0].getR()); + assertEquals("C1", xcell[1].getR()); + assertEquals("D1", xcell[2].getR()); + assertEquals("F1", xcell[3].getR()); - assertEquals(0, xrow.get(1).sizeOfCArray()); - assertEquals(2, xrow.get(1).getR()); + assertEquals(0, xrow[1].sizeOfCArray()); + assertEquals(2, xrow[1].getR()); - assertEquals(2, xrow.get(2).sizeOfCArray()); - assertEquals(3, xrow.get(2).getR()); + assertEquals(2, xrow[2].sizeOfCArray()); + assertEquals(3, xrow[2].getR()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java index de7eff6be7..ccde542245 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java @@ -17,13 +17,8 @@ package org.apache.poi.xssf.usermodel; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.xssf.XSSFTestDataSamples; -import org.apache.poi.xssf.streaming.SXSSFWorkbook; -import org.apache.poi.util.TempFile; -import org.junit.Test; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileInputStream; @@ -32,8 +27,13 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.util.TempFile; +import org.apache.poi.xssf.XSSFTestDataSamples; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; +import org.junit.Test; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn; public final class TestXSSFTable { @@ -41,6 +41,7 @@ public final class TestXSSFTable { } @Test + @SuppressWarnings("deprecation") public void bug56274() throws IOException { // read sample file XSSFWorkbook inputWorkbook = XSSFTestDataSamples.openSampleWorkbook("56274.xlsx"); @@ -60,13 +61,13 @@ public final class TestXSSFTable { // re-read the saved file and make sure headers in the xml are in the original order inputWorkbook = new org.apache.poi.xssf.usermodel.XSSFWorkbook(new FileInputStream(outputFile)); CTTable ctTable = inputWorkbook.getSheetAt(0).getTables().get(0).getCTTable(); - List ctTableColumnList = ctTable.getTableColumns().getTableColumnList(); + CTTableColumn[] ctTableColumnArray = ctTable.getTableColumns().getTableColumnArray(); assertEquals("number of headers in xml table should match number of header cells in worksheet", - headers.size(), ctTableColumnList.size()); + headers.size(), ctTableColumnArray.length); for (int i = 0; i < headers.size(); i++) { assertEquals("header name in xml table should match number of header cells in worksheet", - headers.get(i), ctTableColumnList.get(i).getName()); + headers.get(i), ctTableColumnArray[i].getName()); } assertTrue(outputFile.delete()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java index f50fb5dfa5..fd41ac6721 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java @@ -704,7 +704,7 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook { CTPivotCache pivotCache = wb.addPivotCache("0"); //Ensures that pivotCaches is initiated assertTrue(ctWb.isSetPivotCaches()); - assertSame(pivotCache, ctWb.getPivotCaches().getPivotCacheList().get(0)); + assertSame(pivotCache, ctWb.getPivotCaches().getPivotCacheArray(0)); assertEquals("0", pivotCache.getId()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java index 8ca6fc6f9b..a99e0f75eb 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java @@ -186,7 +186,7 @@ public final class TestColumnHelper extends TestCase { helper.addCleanColIntoCols(cols1, col9); // TODO - assert something interesting - assertEquals(12, cols1.getColList().size()); + assertEquals(12, cols1.sizeOfColArray()); assertEquals(1, cols1.getColArray(0).getMin()); assertEquals(16750, cols1.getColArray(11).getMax()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java b/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java index 64f43c4a75..9fa8320bba 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java @@ -27,39 +27,37 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol; public final class TestCTColComparator extends TestCase { public void testCompare() { - CTColComparator comparator = new CTColComparator(); CTCol o1 = CTCol.Factory.newInstance(); o1.setMin(1); o1.setMax(10); CTCol o2 = CTCol.Factory.newInstance(); o2.setMin(11); o2.setMax(12); - assertEquals(-1, comparator.compare(o1, o2)); + assertEquals(-1, CTColComparator.BY_MIN_MAX.compare(o1, o2)); CTCol o3 = CTCol.Factory.newInstance(); o3.setMin(5); o3.setMax(8); CTCol o4 = CTCol.Factory.newInstance(); o4.setMin(5); o4.setMax(80); - assertEquals(-1, comparator.compare(o3, o4)); + assertEquals(-1, CTColComparator.BY_MIN_MAX.compare(o3, o4)); } public void testArraysSort() { - CTColComparator comparator = new CTColComparator(); CTCol o1 = CTCol.Factory.newInstance(); o1.setMin(1); o1.setMax(10); CTCol o2 = CTCol.Factory.newInstance(); o2.setMin(11); o2.setMax(12); - assertEquals(-1, comparator.compare(o1, o2)); + assertEquals(-1, CTColComparator.BY_MIN_MAX.compare(o1, o2)); CTCol o3 = CTCol.Factory.newInstance(); o3.setMin(5); o3.setMax(80); CTCol o4 = CTCol.Factory.newInstance(); o4.setMin(5); o4.setMax(8); - assertEquals(1, comparator.compare(o3, o4)); + assertEquals(1, CTColComparator.BY_MIN_MAX.compare(o3, o4)); CTCol[] cols = new CTCol[4]; cols[0] = o1; cols[1] = o2; @@ -67,7 +65,7 @@ public final class TestCTColComparator extends TestCase { cols[3] = o4; assertEquals(80, cols[2].getMax()); assertEquals(8, cols[3].getMax()); - Arrays.sort(cols, comparator); + Arrays.sort(cols, CTColComparator.BY_MIN_MAX); assertEquals(12, cols[3].getMax()); assertEquals(8, cols[1].getMax()); assertEquals(80, cols[2].getMax()); diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java index 09c1c1636f..546299e3ec 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java @@ -234,7 +234,7 @@ public final class TestXWPFDocument extends TestCase { OutputStream os = newImagePart.getOutputStream(); os.write(nature1); os.close(); - XWPFHeader xwpfHeader = doc.getHeaderList().get(0); + XWPFHeader xwpfHeader = doc.getHeaderArray(0); PackageRelationship relationship = xwpfHeader.getPackagePart().addRelationship(partName, TargetMode.INTERNAL, jpgRelation.getRelation()); XWPFPictureData newPicData = new XWPFPictureData(newImagePart,relationship); /* new part is now ready to rumble */ @@ -317,13 +317,13 @@ public final class TestXWPFDocument extends TestCase { XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("issue_51265_2.docx"); assertEquals(1,doc.getAllPictures().size()); assertEquals(1,doc.getAllPackagePictures().size()); - assertEquals(1,doc.getHeaderList().get(0).getAllPictures().size()); + assertEquals(1,doc.getHeaderArray(0).getAllPictures().size()); doc.getPackage().revert(); } public void testPictureHandlingComplex() throws IOException, InvalidFormatException { XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("issue_51265_3.docx"); - XWPFHeader xwpfHeader = doc.getHeaderList().get(0); + XWPFHeader xwpfHeader = doc.getHeaderArray(0); assertEquals(3,doc.getAllPictures().size()); assertEquals(3,xwpfHeader.getAllPictures().size()); diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java index 7d6e83c303..c8f179680f 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java @@ -24,6 +24,9 @@ import java.util.List; import junit.framework.TestCase; import org.apache.poi.xwpf.XWPFTestDataSamples; +import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture; +import org.openxmlformats.schemas.drawingml.x2006.picture.PicDocument; +import org.openxmlformats.schemas.drawingml.x2006.picture.impl.PicDocumentImpl; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd; @@ -39,9 +42,6 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STLineSpacingRule; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment; -import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture; -import org.openxmlformats.schemas.drawingml.x2006.picture.PicDocument; -import org.openxmlformats.schemas.drawingml.x2006.picture.impl.PicDocumentImpl; /** * Tests for XWPF Paragraphs @@ -62,7 +62,7 @@ public final class TestXWPFParagraph extends TestCase { assertEquals(1, ps.size()); XWPFParagraph p = ps.get(0); - assertEquals(5, p.getCTP().getRList().size()); + assertEquals(5, p.getCTP().sizeOfRArray()); assertEquals("First header column!\tMid header\tRight header!", p .getText()); } @@ -234,6 +234,7 @@ public final class TestXWPFParagraph extends TestCase { assertEquals(STOnOff.TRUE, ppr.getPageBreakBefore().getVal()); } + @SuppressWarnings("deprecation") public void testBookmarks() throws IOException { XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("bookmarks.docx"); XWPFParagraph paragraph = doc.getParagraphs().get(0); @@ -242,7 +243,7 @@ public final class TestXWPFParagraph extends TestCase { assertEquals(0, paragraph.getCTP().sizeOfBookmarkEndArray()); CTBookmark ctBookmark = paragraph.getCTP().getBookmarkStartArray(0); assertEquals("poi", ctBookmark.getName()); - for(CTBookmark bookmark : paragraph.getCTP().getBookmarkStartList()) { + for(CTBookmark bookmark : paragraph.getCTP().getBookmarkStartArray()) { assertEquals("poi", bookmark.getName()); } } diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java index d3c42e912f..618618f92c 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java @@ -180,7 +180,7 @@ public class TestXWPFRun extends TestCase { run.addCarriageReturn(); run.setText("T2"); run.addCarriageReturn(); - assertEquals(3, run.getCTR().getCrList().size()); + assertEquals(3, run.getCTR().sizeOfCrArray()); assertEquals("T1\n\nT2\n", run.toString()); } @@ -200,8 +200,8 @@ public class TestXWPFRun extends TestCase { run.setText("T2"); run.addTab(); run.setText("T3"); - assertEquals(1, run.getCTR().getCrList().size()); - assertEquals(1, run.getCTR().getTabList().size()); + assertEquals(1, run.getCTR().sizeOfCrArray()); + assertEquals(1, run.getCTR().sizeOfTabArray()); assertEquals("T1\nT2\tT3", run.toString()); } -- 2.39.5